Add search to the Manage tags/series/etc. dialogs

This commit is contained in:
Kovid Goyal 2012-06-24 15:19:22 +05:30
commit c7ad62e03c
2 changed files with 109 additions and 66 deletions

View File

@ -5,7 +5,7 @@ from PyQt4.Qt import (Qt, QDialog, QTableWidgetItem, QIcon, QByteArray,
QString, QSize)
from calibre.gui2.dialogs.tag_list_editor_ui import Ui_TagListEditor
from calibre.gui2 import question_dialog, error_dialog, gprefs
from calibre.gui2 import question_dialog, error_dialog, info_dialog, gprefs
from calibre.utils.icu import sort_key
class NameTableWidgetItem(QTableWidgetItem):
@ -149,6 +149,9 @@ class TagListEditor(QDialog, Ui_TagListEditor):
self.table.itemChanged.connect(self.finish_editing)
self.buttonBox.accepted.connect(self.accepted)
self.search_box.initialize('tag_list_search_box_' + cat_name)
self.search_button.clicked.connect(self.search_clicked)
try:
geom = gprefs.get('tag_list_editor_dialog_geometry', None)
if geom is not None:
@ -158,6 +161,26 @@ class TagListEditor(QDialog, Ui_TagListEditor):
except:
pass
def search_clicked(self):
search_for = unicode(self.search_box.text())
if not search_for:
error_dialog(self, _('Find'), _('You must enter some text to search for'),
show=True, show_copy_button=False)
return
row = self.table.currentRow()
if row < 0:
row = 0
rows = self.table.rowCount()
for i in range(0, rows):
row += 1
if row >= rows:
row = 0
item = self.table.item(row, 0)
if search_for in unicode(item.text()):
self.table.setCurrentItem(item)
return
info_dialog(self, _('Find'), _('No tag found'), show=True, show_copy_button=False)
def table_column_resized(self, col, old, new):
self.table_column_widths = []
for c in range(0, self.table.columnCount()):

View File

@ -18,75 +18,88 @@
<normaloff>:/images/chapters.png</normaloff>:/images/chapters.png</iconset>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout">
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<layout class="QHBoxLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QToolButton" name="delete_button">
<property name="toolTip">
<string>Delete item from database. This will unapply the item from all books and then remove it from the database.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/trash.png</normaloff>:/images/trash.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="rename_button">
<property name="toolTip">
<string>Rename the item in every book where it is used.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/edit_input.png</normaloff>:/images/edit_input.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTableWidget" name="table">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item>
</layout>
<widget class="HistoryLineEdit" name="search_box">
<property name="toolTip">
<string>Search for an item in the Tag column</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="search_button">
<property name="text">
<string>Find</string>
</property>
<property name="toolTip">
<string>Copy the selected color name to the clipboard</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QToolButton" name="delete_button">
<property name="toolTip">
<string>Delete item from database. This will unapply the item from all books and then remove it from the database.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/trash.png</normaloff>:/images/trash.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="rename_button">
<property name="toolTip">
<string>Rename the item in every book where it is used.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/edit_input.png</normaloff>:/images/edit_input.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QTableWidget" name="table">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -101,6 +114,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HistoryLineEdit</class>
<extends>QLineEdit</extends>
<header>widgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>