Enhancement #1886347: Apply virtual libraries in quickview" toggle button in QV panel

This commit is contained in:
Charles Haley 2020-07-06 11:11:51 +01:00
parent 40f17e4b0d
commit 34cbfad9a8
2 changed files with 22 additions and 3 deletions

View File

@ -174,6 +174,10 @@ class Quickview(QDialog, Ui_Quickview):
self.last_search = None
self.no_valid_items = False
self.apply_vls.setCheckState(Qt.Checked if gprefs['qv_respects_vls']
else Qt.Unchecked)
self.apply_vls.stateChanged.connect(self.vl_box_changed)
self.fm = self.db.field_metadata
self.items.setSelectionMode(QAbstractItemView.SingleSelection)
@ -428,6 +432,10 @@ class Quickview(QDialog, Ui_Quickview):
self.fill_in_books_box(unicode_type(txt))
self.set_search_text(self.current_key + ':"=' + txt.replace('"', '\\"') + '"')
def vl_box_changed(self):
gprefs['qv_respects_vls'] = self.apply_vls.isChecked()
self._refresh(self.current_book_id, self.current_key)
def refresh(self, idx):
'''
Given a cell in the library view, display the information. This method
@ -534,7 +542,7 @@ class Quickview(QDialog, Ui_Quickview):
else:
sv = selected_item
sv = self.current_key + ':"=' + sv.replace('"', r'\"') + '"'
if gprefs['qv_respects_vls']:
if self.apply_vls.isChecked():
books = self.db.search(sv, return_matches=True, sort_results=False)
else:
books = self.db.new_api.search(sv)
@ -588,8 +596,8 @@ class Quickview(QDialog, Ui_Quickview):
a = TableItem(v, timestampfromdt(d))
elif self.fm[col]['datatype'] in ('float', 'int'):
v = mi.format_field(col)[1]
sv = mi.get(col)
a = TableItem(v, sv)
sort_val = mi.get(col)
a = TableItem(v, sort_val)
else:
v = mi.format_field(col)[1]
a = TableItem(v, v)

View File

@ -75,6 +75,17 @@
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="apply_vls">
<property name="text">
<string>&amp;Apply virtual libraries</string>
</property>
<property name="toolTip">
<string>&lt;p&gt;Select to make Quickview show only books in the current
virtual library&lt;/p&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="lock_qv">
<property name="text">