mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #836
This commit is contained in:
parent
ffc6d51e1d
commit
09b8ba77d2
@ -8,6 +8,7 @@ from PyQt4.QtGui import QDialog
|
|||||||
|
|
||||||
from calibre.gui2 import qstring_to_unicode
|
from calibre.gui2 import qstring_to_unicode
|
||||||
from calibre.gui2.dialogs.metadata_bulk_ui import Ui_MetadataBulkDialog
|
from calibre.gui2.dialogs.metadata_bulk_ui import Ui_MetadataBulkDialog
|
||||||
|
from calibre.gui2.dialogs.tag_editor import TagEditor
|
||||||
|
|
||||||
class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
||||||
def __init__(self, window, rows, db):
|
def __init__(self, window, rows, db):
|
||||||
@ -20,8 +21,6 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
|||||||
self.write_rating = False
|
self.write_rating = False
|
||||||
self.changed = False
|
self.changed = False
|
||||||
QObject.connect(self.button_box, SIGNAL("accepted()"), self.sync)
|
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)
|
QObject.connect(self.rating, SIGNAL('valueChanged(int)'), self.rating_changed)
|
||||||
|
|
||||||
all_series = self.db.all_series()
|
all_series = self.db.all_series()
|
||||||
@ -31,9 +30,17 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
|||||||
self.series.addItem(name)
|
self.series.addItem(name)
|
||||||
|
|
||||||
self.series.lineEdit().setText('')
|
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_()
|
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):
|
def sync(self):
|
||||||
for id in self.ids:
|
for id in self.ids:
|
||||||
@ -51,7 +58,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
|||||||
self.db.set_publisher(id, pub)
|
self.db.set_publisher(id, pub)
|
||||||
tags = qstring_to_unicode(self.tags.text()).strip()
|
tags = qstring_to_unicode(self.tags.text()).strip()
|
||||||
if tags:
|
if tags:
|
||||||
tags = tags.split(',')
|
tags = map(lambda x: x.strip(), tags.split(','))
|
||||||
self.db.set_tags(id, tags, append=True)
|
self.db.set_tags(id, tags, append=True)
|
||||||
remove_tags = qstring_to_unicode(self.remove_tags.text()).strip()
|
remove_tags = qstring_to_unicode(self.remove_tags.text()).strip()
|
||||||
if remove_tags:
|
if remove_tags:
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
<string>Edit Meta information</string>
|
<string>Edit Meta information</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon" >
|
<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>
|
</property>
|
||||||
<layout class="QGridLayout" >
|
<layout class="QGridLayout" name="gridLayout_2" >
|
||||||
<item row="0" column="0" >
|
<item row="0" column="0" >
|
||||||
<widget class="QSplitter" name="splitter" >
|
<widget class="QSplitter" name="splitter" >
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
@ -26,16 +27,7 @@
|
|||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin" >
|
<property name="margin" >
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@ -43,7 +35,7 @@
|
|||||||
<property name="title" >
|
<property name="title" >
|
||||||
<string>Meta information</string>
|
<string>Meta information</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" >
|
<layout class="QGridLayout" name="gridLayout" >
|
||||||
<item row="0" column="0" >
|
<item row="0" column="0" >
|
||||||
<widget class="QLabel" name="label_2" >
|
<widget class="QLabel" name="label_2" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
@ -57,7 +49,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" >
|
<item row="0" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="authors" >
|
<widget class="QLineEdit" name="authors" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Change the author(s) of this book. Multiple authors should be separated by a comma</string>
|
<string>Change the author(s) of this book. Multiple authors should be separated by a comma</string>
|
||||||
@ -77,7 +69,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" >
|
<item row="1" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="author_sort" >
|
<widget class="QLineEdit" name="author_sort" >
|
||||||
<property name="toolTip" >
|
<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>
|
<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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" >
|
<item row="2" column="1" colspan="2" >
|
||||||
<widget class="QSpinBox" name="rating" >
|
<widget class="QSpinBox" name="rating" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Rating of this book. 0-5 stars</string>
|
<string>Rating of this book. 0-5 stars</string>
|
||||||
@ -126,7 +118,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1" >
|
<item row="3" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="publisher" >
|
<widget class="QLineEdit" name="publisher" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Change the publisher of this book</string>
|
<string>Change the publisher of this book</string>
|
||||||
@ -153,6 +145,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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" >
|
<item row="5" column="0" >
|
||||||
<widget class="QLabel" name="label" >
|
<widget class="QLabel" name="label" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
@ -163,7 +169,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1" >
|
<item row="5" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="remove_tags" >
|
<widget class="QLineEdit" name="remove_tags" >
|
||||||
<property name="toolTip" >
|
<property name="toolTip" >
|
||||||
<string>Comma separated list of tags to remove from the books. </string>
|
<string>Comma separated list of tags to remove from the books. </string>
|
||||||
@ -218,7 +224,7 @@
|
|||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons" >
|
<property name="standardButtons" >
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -9,14 +9,17 @@ from calibre.gui2 import question_dialog, error_dialog
|
|||||||
|
|
||||||
class TagEditor(QDialog, Ui_TagEditor):
|
class TagEditor(QDialog, Ui_TagEditor):
|
||||||
|
|
||||||
def __init__(self, window, db, index):
|
def __init__(self, window, db, index=None):
|
||||||
QDialog.__init__(self, window)
|
QDialog.__init__(self, window)
|
||||||
Ui_TagEditor.__init__(self)
|
Ui_TagEditor.__init__(self)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
self.db = db
|
self.db = db
|
||||||
self.index = index
|
self.index = index
|
||||||
|
if self.index is not None:
|
||||||
tags = self.db.tags(self.index)
|
tags = self.db.tags(self.index)
|
||||||
|
else:
|
||||||
|
tags = []
|
||||||
if tags:
|
if tags:
|
||||||
tags = [tag.lower().strip() for tag in tags.split(',') if tag.strip()]
|
tags = [tag.lower().strip() for tag in tags.split(',') if tag.strip()]
|
||||||
tags.sort()
|
tags.sort()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user