This commit is contained in:
Kovid Goyal 2008-06-30 14:13:15 -07:00
parent ffc6d51e1d
commit 09b8ba77d2
3 changed files with 42 additions and 26 deletions

View File

@ -8,6 +8,7 @@ from PyQt4.QtGui import QDialog
from calibre.gui2 import qstring_to_unicode
from calibre.gui2.dialogs.metadata_bulk_ui import Ui_MetadataBulkDialog
from calibre.gui2.dialogs.tag_editor import TagEditor
class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
def __init__(self, window, rows, db):
@ -20,8 +21,6 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
self.write_rating = False
self.changed = False
QObject.connect(self.button_box, SIGNAL("accepted()"), self.sync)
QObject.connect(self.series, SIGNAL('currentIndexChanged(int)'), self.series_changed)
QObject.connect(self.series, SIGNAL('editTextChanged(QString)'), self.series_changed)
QObject.connect(self.rating, SIGNAL('valueChanged(int)'), self.rating_changed)
all_series = self.db.all_series()
@ -31,9 +30,17 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
self.series.addItem(name)
self.series.lineEdit().setText('')
QObject.connect(self.series, SIGNAL('currentIndexChanged(int)'), self.series_changed)
QObject.connect(self.series, SIGNAL('editTextChanged(QString)'), self.series_changed)
QObject.connect(self.tag_editor_button, SIGNAL('clicked()'), self.tag_editor)
self.exec_()
def tag_editor(self):
d = TagEditor(self, self.db, None)
d.exec_()
if d.result() == QDialog.Accepted:
tag_string = ', '.join(d.tags)
self.tags.setText(tag_string)
def sync(self):
for id in self.ids:
@ -51,7 +58,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
self.db.set_publisher(id, pub)
tags = qstring_to_unicode(self.tags.text()).strip()
if tags:
tags = tags.split(',')
tags = map(lambda x: x.strip(), tags.split(','))
self.db.set_tags(id, tags, append=True)
remove_tags = qstring_to_unicode(self.remove_tags.text()).strip()
if remove_tags:

View File

@ -13,9 +13,10 @@
<string>Edit Meta information</string>
</property>
<property name="windowIcon" >
<iconset resource="../images.qrc" >:/images/edit_input.svg</iconset>
<iconset resource="../images.qrc" >
<normaloff>:/images/edit_input.svg</normaloff>:/images/edit_input.svg</iconset>
</property>
<layout class="QGridLayout" >
<layout class="QGridLayout" name="gridLayout_2" >
<item row="0" column="0" >
<widget class="QSplitter" name="splitter" >
<property name="orientation" >
@ -26,16 +27,7 @@
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>0</number>
</property>
<item>
@ -43,7 +35,7 @@
<property name="title" >
<string>Meta information</string>
</property>
<layout class="QGridLayout" >
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
@ -57,7 +49,7 @@
</property>
</widget>
</item>
<item row="0" column="1" >
<item row="0" column="1" colspan="2" >
<widget class="QLineEdit" name="authors" >
<property name="toolTip" >
<string>Change the author(s) of this book. Multiple authors should be separated by a comma</string>
@ -77,7 +69,7 @@
</property>
</widget>
</item>
<item row="1" column="1" >
<item row="1" column="1" colspan="2" >
<widget class="QLineEdit" name="author_sort" >
<property name="toolTip" >
<string>Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles.</string>
@ -94,7 +86,7 @@
</property>
</widget>
</item>
<item row="2" column="1" >
<item row="2" column="1" colspan="2" >
<widget class="QSpinBox" name="rating" >
<property name="toolTip" >
<string>Rating of this book. 0-5 stars</string>
@ -126,7 +118,7 @@
</property>
</widget>
</item>
<item row="3" column="1" >
<item row="3" column="1" colspan="2" >
<widget class="QLineEdit" name="publisher" >
<property name="toolTip" >
<string>Change the publisher of this book</string>
@ -153,6 +145,20 @@
</property>
</widget>
</item>
<item row="4" column="2" >
<widget class="QToolButton" name="tag_editor_button" >
<property name="toolTip" >
<string>Open Tag Editor</string>
</property>
<property name="text" >
<string>Open Tag Editor</string>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >
<normaloff>:/images/chapters.svg</normaloff>:/images/chapters.svg</iconset>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
@ -163,7 +169,7 @@
</property>
</widget>
</item>
<item row="5" column="1" >
<item row="5" column="1" colspan="2" >
<widget class="QLineEdit" name="remove_tags" >
<property name="toolTip" >
<string>Comma separated list of tags to remove from the books. </string>
@ -218,7 +224,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>

View File

@ -9,14 +9,17 @@ from calibre.gui2 import question_dialog, error_dialog
class TagEditor(QDialog, Ui_TagEditor):
def __init__(self, window, db, index):
def __init__(self, window, db, index=None):
QDialog.__init__(self, window)
Ui_TagEditor.__init__(self)
self.setupUi(self)
self.db = db
self.index = index
tags = self.db.tags(self.index)
if self.index is not None:
tags = self.db.tags(self.index)
else:
tags = []
if tags:
tags = [tag.lower().strip() for tag in tags.split(',') if tag.strip()]
tags.sort()