mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add search to the Manage tags/series/etc. dialogs
This commit is contained in:
commit
c7ad62e03c
@ -5,7 +5,7 @@ from PyQt4.Qt import (Qt, QDialog, QTableWidgetItem, QIcon, QByteArray,
|
|||||||
QString, QSize)
|
QString, QSize)
|
||||||
|
|
||||||
from calibre.gui2.dialogs.tag_list_editor_ui import Ui_TagListEditor
|
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
|
from calibre.utils.icu import sort_key
|
||||||
|
|
||||||
class NameTableWidgetItem(QTableWidgetItem):
|
class NameTableWidgetItem(QTableWidgetItem):
|
||||||
@ -149,6 +149,9 @@ class TagListEditor(QDialog, Ui_TagListEditor):
|
|||||||
self.table.itemChanged.connect(self.finish_editing)
|
self.table.itemChanged.connect(self.finish_editing)
|
||||||
self.buttonBox.accepted.connect(self.accepted)
|
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:
|
try:
|
||||||
geom = gprefs.get('tag_list_editor_dialog_geometry', None)
|
geom = gprefs.get('tag_list_editor_dialog_geometry', None)
|
||||||
if geom is not None:
|
if geom is not None:
|
||||||
@ -158,6 +161,26 @@ class TagListEditor(QDialog, Ui_TagListEditor):
|
|||||||
except:
|
except:
|
||||||
pass
|
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):
|
def table_column_resized(self, col, old, new):
|
||||||
self.table_column_widths = []
|
self.table_column_widths = []
|
||||||
for c in range(0, self.table.columnCount()):
|
for c in range(0, self.table.columnCount()):
|
||||||
|
@ -18,11 +18,28 @@
|
|||||||
<normaloff>:/images/chapters.png</normaloff>:/images/chapters.png</iconset>
|
<normaloff>:/images/chapters.png</normaloff>:/images/chapters.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="1">
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout">
|
<widget class="HistoryLineEdit" name="search_box">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Search for an item in the Tag column</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<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">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="delete_button">
|
<widget class="QToolButton" name="delete_button">
|
||||||
@ -69,7 +86,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="1">
|
||||||
<widget class="QTableWidget" name="table">
|
<widget class="QTableWidget" name="table">
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -82,11 +99,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
<item row="3" column="0" colspan="2">
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" colspan="2">
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -101,6 +114,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>HistoryLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>widgets.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user