mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
Fix #1866405 [[Enhancement] Filter available tags in User categories editor](https://bugs.launchpad.net/calibre/+bug/1866405) Fix #1866400 [[Enhancement] Add languages to the Category filter](https://bugs.launchpad.net/calibre/+bug/1866400)
This commit is contained in:
commit
b14e6c9a1f
@ -10,7 +10,7 @@ from calibre.gui2.dialogs.tag_categories_ui import Ui_TagCategories
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.gui2 import error_dialog
|
||||
from calibre.constants import islinux
|
||||
from calibre.utils.icu import sort_key, strcmp
|
||||
from calibre.utils.icu import sort_key, strcmp, primary_contains
|
||||
from polyglot.builtins import iteritems, unicode_type
|
||||
|
||||
|
||||
@ -72,9 +72,11 @@ class TagCategories(QDialog, Ui_TagCategories):
|
||||
lambda: [t.original_name.replace('|', ',') for t in self.db_categories['authors']],
|
||||
lambda: [t.original_name for t in self.db_categories['series']],
|
||||
lambda: [t.original_name for t in self.db_categories['publisher']],
|
||||
lambda: [t.original_name for t in self.db_categories['tags']]
|
||||
lambda: [t.original_name for t in self.db_categories['tags']],
|
||||
lambda: [t.original_name for t in self.db_categories['languages']]
|
||||
]
|
||||
category_names = ['', _('Authors'), ngettext('Series', 'Series', 2), _('Publishers'), _('Tags')]
|
||||
category_names = ['', _('Authors'), ngettext('Series', 'Series', 2),
|
||||
_('Publishers'), _('Tags'), _('Languages')]
|
||||
|
||||
for key,cc in iteritems(self.db.custom_field_metadata()):
|
||||
if cc['datatype'] in ['text', 'series', 'enumeration']:
|
||||
@ -106,6 +108,7 @@ class TagCategories(QDialog, Ui_TagCategories):
|
||||
self.category_box.currentIndexChanged[int].connect(self.select_category)
|
||||
self.category_filter_box.currentIndexChanged[int].connect(
|
||||
self.display_filtered_categories)
|
||||
self.item_filter_box.textEdited.connect(self.display_filtered_items)
|
||||
self.delete_category_button.clicked.connect(self.del_category)
|
||||
if islinux:
|
||||
self.available_items_box.itemDoubleClicked.connect(self.apply_tags)
|
||||
@ -168,13 +171,18 @@ class TagCategories(QDialog, Ui_TagCategories):
|
||||
w.setToolTip(_('Category lookup name: ') + item.label)
|
||||
return w
|
||||
|
||||
def display_filtered_items(self, text):
|
||||
self.display_filtered_categories(None)
|
||||
|
||||
def display_filtered_categories(self, idx):
|
||||
idx = idx if idx is not None else self.category_filter_box.currentIndex()
|
||||
self.available_items_box.clear()
|
||||
self.applied_items_box.clear()
|
||||
item_filter = self.item_filter_box.text()
|
||||
for item in self.all_items_sorted:
|
||||
if idx == 0 or item.label == self.category_labels[idx]:
|
||||
if item.index not in self.applied_items and item.exists:
|
||||
if primary_contains(item_filter, item.name):
|
||||
self.available_items_box.addItem(self.make_list_widget(item))
|
||||
for index in self.applied_items:
|
||||
self.applied_items_box.addItem(self.make_list_widget(self.all_items[index]))
|
||||
|
@ -64,6 +64,26 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_filt">
|
||||
<property name="text">
|
||||
<string>Item &filter: </string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>item_filter_box</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="item_filter_box">
|
||||
<property name="toolTip">
|
||||
<string>Enter text to filter the available items. Case and accents are ignored.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="3">
|
||||
@ -136,6 +156,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="blank">
|
||||
<property name="text">
|
||||
<string> </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@ -152,7 +179,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QListWidget" name="available_items_box">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
@ -165,7 +192,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QToolButton" name="apply_button">
|
||||
<property name="toolTip">
|
||||
<string>Apply tags to current tag category</string>
|
||||
@ -189,7 +216,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<item row="3" column="2">
|
||||
<widget class="QListWidget" name="applied_items_box">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
@ -199,7 +226,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<item row="3" column="3">
|
||||
<widget class="QToolButton" name="unapply_button">
|
||||
<property name="toolTip">
|
||||
<string>Unapply (remove) tag from current tag category</string>
|
||||
@ -213,7 +240,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="4">
|
||||
<item row="4" column="0" colspan="4">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
Loading…
x
Reference in New Issue
Block a user