Bulk metadata edit: option to not refresh after edit

Bulk metadata edit: Add a checkbox to prevent the refreshing of the book
list after the bulk edit. This means that the book list will not be
resorted and any existing search/virtual library will not be refreshed.
Useful if you have a large library as the refresh can be slow.
This commit is contained in:
Kovid Goyal 2013-07-11 15:08:20 +05:30
parent b18b6e98b9
commit 278a13abc3
4 changed files with 38 additions and 14 deletions

View File

@ -110,6 +110,7 @@ defs['bd_overlay_cover_size'] = False
defs['tags_browser_category_icons'] = {}
defs['cover_browser_reflections'] = True
defs['extra_row_spacing'] = 0
defs['refresh_book_list_on_bulk_edit'] = True
del defs
# }}}

View File

@ -10,7 +10,7 @@ from functools import partial
from PyQt4.Qt import QMenu, QModelIndex, QTimer, QIcon
from calibre.gui2 import error_dialog, Dispatcher, question_dialog
from calibre.gui2 import error_dialog, Dispatcher, question_dialog, gprefs
from calibre.gui2.dialogs.metadata_bulk import MetadataBulkDialog
from calibre.gui2.dialogs.confirm_delete import confirm
from calibre.gui2.dialogs.device_category_editor import DeviceCategoryEditor
@ -366,8 +366,11 @@ class EditMetadataAction(InterfaceAction):
self.gui.tags_view.blockSignals(False)
if changed:
m = self.gui.library_view.model()
m.refresh(reset=False)
m.research()
if gprefs['refresh_book_list_on_bulk_edit']:
m.refresh(reset=False)
m.research()
else:
m.refresh_ids(book_ids)
self.gui.tags_view.recount()
if self.gui.cover_flow:
self.gui.cover_flow.dataChanged()

View File

@ -317,6 +317,8 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
Ui_MetadataBulkDialog.__init__(self)
self.model = model
self.db = model.db
self.refresh_book_list.setChecked(gprefs['refresh_book_list_on_bulk_edit'])
self.refresh_book_list.toggled.connect(self.save_refresh_booklist)
self.ids = [self.db.id(r) for r in rows]
self.box_title.setText('<p>' +
_('Editing meta information for <b>%d books</b>') %
@ -380,6 +382,9 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
self.authors.setFocus(Qt.OtherFocusReason)
self.exec_()
def save_refresh_booklist(self, *args):
gprefs['refresh_book_list_on_bulk_edit'] = bool(self.refresh_book_list.isChecked())
def save_state(self, *args):
gprefs['bulk_metadata_window_geometry'] = \
bytearray(self.saveGeometry())

View File

@ -45,7 +45,7 @@
<x>0</x>
<y>0</y>
<width>950</width>
<height>576</height>
<height>577</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -1113,7 +1113,7 @@ not multiple and the destination field is multiple</string>
<x>0</x>
<y>0</y>
<width>934</width>
<height>213</height>
<height>256</height>
</rect>
</property>
<layout class="QGridLayout" name="testgrid">
@ -1170,14 +1170,30 @@ not multiple and the destination field is multiple</string>
</widget>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="button_box">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QCheckBox" name="refresh_book_list">
<property name="toolTip">
<string>If enabled, the book list will be re-sorted and any existing
search or Virtual LIbrary will be refreshed after the edit
is completed. This can be slow on large libraries.</string>
</property>
<property name="text">
<string>&amp;Refresh book list after edit</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="button_box">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
@ -1241,7 +1257,6 @@ not multiple and the destination field is multiple</string>
<tabstop>scrollArea</tabstop>
<tabstop>central_widget</tabstop>
<tabstop>query_field</tabstop>
<tabstop>button_box</tabstop>
<tabstop>save_button</tabstop>
<tabstop>remove_button</tabstop>
<tabstop>search_field</tabstop>