mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix reselect after bulk edit very slow
This commit is contained in:
parent
462e670727
commit
2f6fa5c8a8
@ -188,8 +188,9 @@ class EditMetadataAction(InterfaceAction):
|
|||||||
finally:
|
finally:
|
||||||
self.gui.tags_view.blockSignals(False)
|
self.gui.tags_view.blockSignals(False)
|
||||||
if changed:
|
if changed:
|
||||||
self.gui.library_view.model().resort(reset=False)
|
m = self.gui.library_view.model()
|
||||||
self.gui.library_view.model().research()
|
m.resort(reset=False)
|
||||||
|
m.research()
|
||||||
self.gui.tags_view.recount()
|
self.gui.tags_view.recount()
|
||||||
if self.gui.cover_flow:
|
if self.gui.cover_flow:
|
||||||
self.gui.cover_flow.dataChanged()
|
self.gui.cover_flow.dataChanged()
|
||||||
|
@ -9,7 +9,7 @@ import os
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt4.Qt import QTableView, Qt, QAbstractItemView, QMenu, pyqtSignal, \
|
from PyQt4.Qt import QTableView, Qt, QAbstractItemView, QMenu, pyqtSignal, \
|
||||||
QModelIndex, QIcon
|
QModelIndex, QIcon, QItemSelection
|
||||||
|
|
||||||
from calibre.gui2.library.delegates import RatingDelegate, PubDateDelegate, \
|
from calibre.gui2.library.delegates import RatingDelegate, PubDateDelegate, \
|
||||||
TextDelegate, DateDelegate, TagsDelegate, CcTextDelegate, \
|
TextDelegate, DateDelegate, TagsDelegate, CcTextDelegate, \
|
||||||
@ -488,29 +488,29 @@ class BooksView(QTableView): # {{{
|
|||||||
Select rows identified by identifiers. identifiers can be a set of ids,
|
Select rows identified by identifiers. identifiers can be a set of ids,
|
||||||
row numbers or QModelIndexes.
|
row numbers or QModelIndexes.
|
||||||
'''
|
'''
|
||||||
selmode = self.selectionMode()
|
rows = set([x.row() if hasattr(x, 'row') else x for x in
|
||||||
self.setSelectionMode(QAbstractItemView.MultiSelection)
|
identifiers])
|
||||||
try:
|
if using_ids:
|
||||||
rows = set([x.row() if hasattr(x, 'row') else x for x in
|
rows = set([])
|
||||||
identifiers])
|
identifiers = set(identifiers)
|
||||||
if using_ids:
|
m = self.model()
|
||||||
rows = set([])
|
for row in xrange(m.rowCount(QModelIndex())):
|
||||||
identifiers = set(identifiers)
|
if m.id(row) in identifiers:
|
||||||
m = self.model()
|
rows.add(row)
|
||||||
for row in range(m.rowCount(QModelIndex())):
|
rows = list(sorted(rows))
|
||||||
if m.id(row) in identifiers:
|
if rows:
|
||||||
rows.add(row)
|
row = rows[0]
|
||||||
if rows:
|
if change_current:
|
||||||
row = list(sorted(rows))[0]
|
self.set_current_row(row, select=False)
|
||||||
if change_current:
|
if scroll:
|
||||||
self.set_current_row(row, select=False)
|
self.scroll_to_row(row)
|
||||||
if scroll:
|
sm = self.selectionModel()
|
||||||
self.scroll_to_row(row)
|
sel = QItemSelection()
|
||||||
self.clearSelection()
|
m = self.model()
|
||||||
for r in rows:
|
max_col = m.columnCount(QModelIndex()) - 1
|
||||||
self.selectRow(r)
|
for row in rows:
|
||||||
finally:
|
sel.select(m.index(row, 0), m.index(row, max_col))
|
||||||
self.setSelectionMode(selmode)
|
sm.select(sel, sm.ClearAndSelect)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._model.close()
|
self._model.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user