Fix unused imports and removeRow override.
Override removeRows instead of removeRow. > removeRow is not virtual in C++, so if this gets called by Qt > internally for some reason, it wouldn't use the overloaded version - > so I think it'd be better to implement removeRows and then use > removeRow without overloading that - The-Compiler
This commit is contained in:
parent
00be9e3c7f
commit
ff9efe22ae
@ -25,7 +25,6 @@ from PyQt5.QtSql import QSqlQueryModel
|
||||
|
||||
from qutebrowser.misc import sql
|
||||
from qutebrowser.utils import debug
|
||||
from qutebrowser.commands import cmdexc
|
||||
from qutebrowser.config import config
|
||||
|
||||
|
||||
@ -90,9 +89,10 @@ class HistoryCategory(QSqlQueryModel):
|
||||
self._query.run(pat=pattern)
|
||||
self.setQuery(self._query)
|
||||
|
||||
def removeRow(self, _row, _col):
|
||||
"""Re-run sql query to respond to a row removal."""
|
||||
def removeRows(self, _row, _count, _parent=None):
|
||||
"""Override QAbstractItemModel::removeRows to re-run sql query."""
|
||||
# re-run query to reload updated table
|
||||
with debug.log_time('sql', 'Re-running completion query post-delete'):
|
||||
self._query.run()
|
||||
self.setQuery(self._query)
|
||||
return True
|
||||
|
@ -21,11 +21,10 @@
|
||||
|
||||
import re
|
||||
|
||||
from PyQt5.QtCore import Qt, QSortFilterProxyModel, QModelIndex, QRegExp
|
||||
from PyQt5.QtCore import Qt, QSortFilterProxyModel, QRegExp
|
||||
from PyQt5.QtGui import QStandardItem, QStandardItemModel
|
||||
|
||||
from qutebrowser.utils import qtutils
|
||||
from qutebrowser.commands import cmdexc
|
||||
|
||||
|
||||
class ListCategory(QSortFilterProxyModel):
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
"""Test the web history completion category."""
|
||||
|
||||
import unittest.mock
|
||||
import datetime
|
||||
|
||||
import pytest
|
||||
@ -27,7 +26,6 @@ from PyQt5.QtCore import QModelIndex
|
||||
|
||||
from qutebrowser.misc import sql
|
||||
from qutebrowser.completion.models import histcategory
|
||||
from qutebrowser.commands import cmdexc
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -141,7 +139,7 @@ def test_sorting(max_items, before, after, model_validator, hist, config_stub):
|
||||
model_validator.validate(after)
|
||||
|
||||
|
||||
def test_remove_row(hist, model_validator):
|
||||
def test_remove_rows(hist, model_validator):
|
||||
hist.insert({'url': 'foo', 'title': 'Foo'})
|
||||
hist.insert({'url': 'bar', 'title': 'Bar'})
|
||||
cat = histcategory.HistoryCategory()
|
||||
@ -149,5 +147,5 @@ def test_remove_row(hist, model_validator):
|
||||
cat.set_pattern('')
|
||||
hist.delete('url', 'foo')
|
||||
# histcategory does not care which index was removed, it just regenerates
|
||||
cat.removeRow(QModelIndex(), QModelIndex())
|
||||
cat.removeRows(QModelIndex(), 1)
|
||||
model_validator.validate([('bar', 'Bar', '')])
|
||||
|
@ -19,12 +19,9 @@
|
||||
|
||||
"""Tests for CompletionFilterModel."""
|
||||
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from qutebrowser.completion.models import listcategory
|
||||
from qutebrowser.commands import cmdexc
|
||||
|
||||
|
||||
@pytest.mark.parametrize('pattern, before, after', [
|
||||
|
Loading…
Reference in New Issue
Block a user