Fix Get Books result list and jobs list not being populated on Qt 5.8

Apparently Qt 5.8 broke the layoutChanged() signal for models. Replace it
with modelReset()
This commit is contained in:
Kovid Goyal 2017-02-09 15:19:32 +05:30
parent 82b97f2b0e
commit e863f7227d
2 changed files with 13 additions and 11 deletions

View File

@ -191,9 +191,9 @@ class JobManager(QAbstractTableModel, AdaptSQP): # {{{
if job.is_finished:
self.job_done.emit(len(self.unfinished_jobs()))
if needs_reset:
self.layoutAboutToBeChanged.emit()
self.modelAboutToBeReset.emit()
self.jobs.sort()
self.layoutChanged.emit()
self.modelReset.emit()
else:
for job in jobs:
idx = self.jobs.index(job)
@ -216,11 +216,11 @@ class JobManager(QAbstractTableModel, AdaptSQP): # {{{
self.server.kill_job(job)
def _add_job(self, job):
self.layoutAboutToBeChanged.emit()
self.modelAboutToBeReset.emit()
self.jobs.append(job)
self.jobs.sort()
self.job_added.emit(len(self.unfinished_jobs()))
self.layoutChanged.emit()
self.modelReset.emit()
def done_jobs(self):
return [j for j in self.jobs if j.is_finished]

View File

@ -87,7 +87,7 @@ class Matches(QAbstractItemModel):
def add_result(self, result, store_plugin):
if result not in self.all_matches:
self.layoutAboutToBeChanged.emit()
self.modelAboutToBeReset.emit()
self.all_matches.append(result)
self.search_filter.add_search_result(result)
if result.cover_url:
@ -96,8 +96,8 @@ class Matches(QAbstractItemModel):
else:
result.cover_queued = False
self.details_pool.add_task(result, store_plugin, self.got_result_details_dispatcher)
self.filter_results()
self.layoutChanged.emit()
self._filter_results()
self.modelReset.emit()
def get_result(self, index):
row = index.row()
@ -109,8 +109,7 @@ class Matches(QAbstractItemModel):
def has_results(self):
return len(self.matches) > 0
def filter_results(self):
self.layoutAboutToBeChanged.emit()
def _filter_results(self):
# Only use the search filter's filtered results when there is a query
# and it is a filterable query. This allows for the stores best guess
# matches to come though.
@ -120,7 +119,11 @@ class Matches(QAbstractItemModel):
self.matches = list(self.search_filter.universal_set())
self.total_changed.emit(self.rowCount())
self.sort(self.sort_col, self.sort_order, False)
self.layoutChanged.emit()
def filter_results(self):
self.modelAboutToBeReset.emit()
self._filter_results()
self.modelReset.emit()
def got_result_details(self, result):
if not result.cover_queued and result.cover_url:
@ -470,4 +473,3 @@ class SearchFilter(SearchQueryParser):
punctuation is removed first, so that a.and.b becomes a b '''
field = force_unicode(field)
return self.joiner_pat.sub(' ', field.translate(self.punctuation_table))