diff --git a/src/calibre/gui2/dialogs/tag_editor.py b/src/calibre/gui2/dialogs/tag_editor.py
index 2a6529bb87..51bf292dd0 100644
--- a/src/calibre/gui2/dialogs/tag_editor.py
+++ b/src/calibre/gui2/dialogs/tag_editor.py
@@ -53,6 +53,13 @@ class TagEditor(QDialog, Ui_TagEditor):
self.connect(self.add_tag_button, SIGNAL('clicked()'), self.add_tag)
self.connect(self.delete_button, SIGNAL('clicked()'), self.delete_tags)
self.connect(self.add_tag_input, SIGNAL('returnPressed()'), self.add_tag)
+ # add the handlers for the filter input clear buttons
+ self.connect(self.available_filter_input_clear_btn, SIGNAL('clicked()'), self.clear_available_filter)
+ self.connect(self.applied_filter_input_clear_btn, SIGNAL('clicked()'), self.clear_applied_filter)
+ # add the handlers for the filter input fields
+ self.available_filter_input.textChanged.connect(self.filter_available)
+ self.applied_filter_input.textChanged.connect(self.filter_applied)
+
if islinux:
self.available_tags.itemDoubleClicked.connect(self.apply_tags)
else:
@@ -115,6 +122,9 @@ class TagEditor(QDialog, Ui_TagEditor):
if row > 2:
item = self.available_tags.item(row)
self.available_tags.scrollToItem(item)
+
+ # use the filter again when the applied tags were changed
+ self.filter_applied(self.applied_filter_input.text())
def unapply_tags(self, item=None):
items = self.applied_tags.selectedItems() if item is None else [item]
@@ -134,6 +144,10 @@ class TagEditor(QDialog, Ui_TagEditor):
self.available_tags.clear()
for item in items:
self.available_tags.addItem(item)
+
+ # use the filter again when the applied tags were changed
+ self.filter_applied(self.applied_filter_input.text())
+ self.filter_available(self.available_filter_input.text())
def add_tag(self):
tags = unicode(self.add_tag_input.text()).split(',')
@@ -151,7 +165,40 @@ class TagEditor(QDialog, Ui_TagEditor):
for tag in self.tags:
self.applied_tags.addItem(tag)
- self.add_tag_input.setText('')
+ self.add_tag_input.setText('')
+ # use the filter again when the applied tags were changed
+ self.filter_applied(self.applied_filter_input.text())
+
+
+ # do the filtering on the available tags
+ def filter_available(self, filter_value):
+ itemCount = self.available_tags.count()
+ for i in range(0, itemCount): # on every available tag
+ if str(filter_value).lower() in str(self.available_tags.item(i).text()).lower():
+ # if contains the filter text, then show it
+ self.available_tags.item(i).setHidden(False)
+ else:
+ # if not then hide it from the list
+ self.available_tags.item(i).setHidden(True)
+
+ # do the filtering on the applied tags
+ def filter_applied(self, filter_value):
+ itemCount = self.applied_tags.count()
+ for i in range(0, itemCount): # on every applied tag
+ if str(filter_value).lower() in str(self.applied_tags.item(i).text()).lower():
+ # if contains the filter text, then show it
+ self.applied_tags.item(i).setHidden(False)
+ else:
+ # if not then hide it from the list
+ self.applied_tags.item(i).setHidden(True)
+
+ # clears the available tags filter input
+ def clear_available_filter(self):
+ self.available_filter_input.setText('');
+
+ # clears the applied tags filter input
+ def clear_applied_filter(self):
+ self.applied_filter_input.setText('');
def accept(self):
self.save_state()
@@ -163,4 +210,3 @@ class TagEditor(QDialog, Ui_TagEditor):
def save_state(self):
gprefs['tag_editor_geometry'] = bytearray(self.saveGeometry())
-
diff --git a/src/calibre/gui2/dialogs/tag_editor.ui b/src/calibre/gui2/dialogs/tag_editor.ui
index c418b3ac87..bb9691db1f 100644
--- a/src/calibre/gui2/dialogs/tag_editor.ui
+++ b/src/calibre/gui2/dialogs/tag_editor.ui
@@ -6,213 +6,24 @@
0
0
- 588
- 335
+ 600
+ 360
Tag Editor
-
-
- :/images/chapters.png:/images/chapters.png
-
-
- -
-
+
+
-
+
+
+ 0
+
+
+ 0
+
-
-
-
-
-
-
- A&vailable tags
-
-
- available_tags
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
- -
-
-
-
-
-
- Delete tag from database. This will unapply the tag from all books and then remove it from the database.
-
-
- ...
-
-
-
- :/images/trash.png:/images/trash.png
-
-
-
- -
-
-
- true
-
-
- QAbstractItemView::MultiSelection
-
-
- QAbstractItemView::SelectRows
-
-
-
-
-
-
-
- -
-
-
-
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Apply tag to current book
-
-
- ...
-
-
-
- :/images/forward.png:/images/forward.png
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
- A&pplied tags
-
-
- applied_tags
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
- -
-
-
- true
-
-
- QAbstractItemView::MultiSelection
-
-
-
-
-
- -
-
-
-
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Unapply (remove) tag from current book
-
-
- ...
-
-
-
- :/images/list_remove.png:/images/list_remove.png
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
- -
-
-
-
-
+
Qt::Horizontal
@@ -256,7 +67,7 @@
-
-
+
Qt::Horizontal
@@ -270,11 +81,175 @@
- -
-
+
-
+
Qt::Horizontal
+
+
+ -
+
+
+ 8
+
+
-
+
+
-
+
+
+ A&vailable tags
+
+
+ available_tags
+
+
+
+ -
+
+
-
+
+
+ filter the available tags
+
+
+
+ -
+
+
+ Clear the available tags filter input field
+
+
+
+
+
+
+ :/images/clear_left.png:/images/clear_left.png
+
+
+
+
+
+ -
+
+
+ true
+
+
+ QAbstractItemView::MultiSelection
+
+
+ QAbstractItemView::SelectRows
+
+
+
+ -
+
+
+ Delete tag from database. This will unapply the tag from all books and then remove it from the database.
+
+
+ Delete tag
+
+
+
+ :/images/trash.png:/images/trash.png
+
+
+
+
+
+ -
+
+
+ Apply tag to current book
+
+
+ ...
+
+
+
+ :/images/forward.png:/images/forward.png
+
+
+
+ -
+
+
-
+
+
+ A&pplied tags
+
+
+ applied_tags
+
+
+
+ -
+
+
-
+
+
+ filter the applied tags
+
+
+
+ -
+
+
+ Clear the applied tags filter input field
+
+
+
+
+
+
+ :/images/clear_left.png:/images/clear_left.png
+
+
+
+
+
+ -
+
+
+ true
+
+
+ QAbstractItemView::MultiSelection
+
+
+ QAbstractItemView::SelectRows
+
+
+
+ -
+
+
+ Unapply (remove) tag from current book
+
+
+ Unapply tag
+
+
+
+ :/images/list_remove.png:/images/list_remove.png
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ -
+
QDialogButtonBox::Cancel|QDialogButtonBox::Ok
@@ -282,6 +257,7 @@
+
EnLineEdit
@@ -289,9 +265,8 @@
-
-
-
+
+
buttonBox