Modification of single metadata_single.py interface to add columns saying if there is a summary and a cover, add an option to automatically download a cover

This commit is contained in:
Sengian 2010-11-21 20:09:42 +01:00
parent fc524ee7d4
commit 9f34a0c270
4 changed files with 198 additions and 173 deletions

View File

@ -123,6 +123,8 @@ def _config():
help=_('Download social metadata (tags/rating/etc.)')) help=_('Download social metadata (tags/rating/etc.)'))
c.add_opt('overwrite_author_title_metadata', default=True, c.add_opt('overwrite_author_title_metadata', default=True,
help=_('Overwrite author and title with new metadata')) help=_('Overwrite author and title with new metadata'))
c.add_opt('overwrite_cover_image', default=False,
help=_('Overwrite cover with new new cover if existing'))
c.add_opt('enforce_cpu_limit', default=True, c.add_opt('enforce_cpu_limit', default=True,
help=_('Limit max simultaneous jobs to number of CPUs')) help=_('Limit max simultaneous jobs to number of CPUs'))
c.add_opt('tag_browser_hidden_categories', default=set(), c.add_opt('tag_browser_hidden_categories', default=set(),

View File

@ -48,7 +48,7 @@ class Matches(QAbstractTableModel):
return len(self.matches) return len(self.matches)
def columnCount(self, *args): def columnCount(self, *args):
return 6 return 8
def headerData(self, section, orientation, role): def headerData(self, section, orientation, role):
if role != Qt.DisplayRole: if role != Qt.DisplayRole:
@ -61,6 +61,8 @@ class Matches(QAbstractTableModel):
elif section == 3: text = _("Publisher") elif section == 3: text = _("Publisher")
elif section == 4: text = _("ISBN") elif section == 4: text = _("ISBN")
elif section == 5: text = _("Published") elif section == 5: text = _("Published")
elif section == 6: text = _("Cover?")
elif section == 7: text = _("Summary?")
return QVariant(text) return QVariant(text)
else: else:
@ -87,6 +89,10 @@ class Matches(QAbstractTableModel):
elif col == 5: elif col == 5:
if hasattr(book.pubdate, 'timetuple'): if hasattr(book.pubdate, 'timetuple'):
res = strftime('%b %Y', book.pubdate.timetuple()) res = strftime('%b %Y', book.pubdate.timetuple())
elif col == 6 and book.has_cover:
res = 'OK'
elif col == 7 and book.comments:
res = 'OK'
if not res: if not res:
return NONE return NONE
return QVariant(res) return QVariant(res)
@ -131,6 +137,7 @@ class FetchMetadata(QDialog, Ui_FetchMetadata):
self.fetch_metadata() self.fetch_metadata()
self.opt_get_social_metadata.setChecked(config['get_social_metadata']) self.opt_get_social_metadata.setChecked(config['get_social_metadata'])
self.opt_overwrite_author_title_metadata.setChecked(config['overwrite_author_title_metadata']) self.opt_overwrite_author_title_metadata.setChecked(config['overwrite_author_title_metadata'])
self.opt_overwrite_cover_image.setChecked(config['overwrite_cover_image'])
def show_summary(self, current, *args): def show_summary(self, current, *args):
@ -213,6 +220,13 @@ class FetchMetadata(QDialog, Ui_FetchMetadata):
_hung_fetchers.add(self.fetcher) _hung_fetchers.add(self.fetcher)
if hasattr(self, '_hangcheck') and self._hangcheck.isActive(): if hasattr(self, '_hangcheck') and self._hangcheck.isActive():
self._hangcheck.stop() self._hangcheck.stop()
#option configure
if self.opt_get_social_metadata.isChecked() != config['get_social_metadata']:
config.set('get_social_metadata', self.opt_get_social_metadata.isChecked())
if self.opt_overwrite_author_title_metadata.isChecked() != config['overwrite_author_title_metadata']:
config.set('overwrite_author_title_metadata', self.opt_overwrite_author_title_metadata.isChecked())
if self.opt_overwrite_cover_image.isChecked() != config['overwrite_cover_image']:
config.set('overwrite_cover_image', self.opt_overwrite_cover_image.isChecked())
def __enter__(self, *args): def __enter__(self, *args):
return self return self

View File

@ -1,172 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>FetchMetadata</class> <class>FetchMetadata</class>
<widget class="QDialog" name="FetchMetadata"> <widget class="QDialog" name="FetchMetadata">
<property name="windowModality"> <property name="windowModality">
<enum>Qt::WindowModal</enum> <enum>Qt::WindowModal</enum>
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>830</width> <width>890</width>
<height>642</height> <height>642</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Fetch metadata</string> <string>Fetch metadata</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="../../../../resources/images.qrc"> <iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/metadata.png</normaloff>:/images/metadata.png</iconset> <normaloff>:/images/metadata.png</normaloff>:/images/metadata.png</iconset>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout">
<item> <item>
<widget class="QLabel" name="tlabel"> <widget class="QLabel" name="tlabel">
<property name="text"> <property name="text">
<string>&lt;p&gt;calibre can find metadata for your books from two locations: &lt;b&gt;Google Books&lt;/b&gt; and &lt;b&gt;isbndb.com&lt;/b&gt;. &lt;p&gt;To use isbndb.com you must sign up for a &lt;a href=&quot;http://www.isbndb.com&quot;&gt;free account&lt;/a&gt; and enter your access key below.</string> <string>&lt;p&gt;calibre can find metadata for your books from two locations: &lt;b&gt;Google Books&lt;/b&gt; and &lt;b&gt;isbndb.com&lt;/b&gt;. &lt;p&gt;To use isbndb.com you must sign up for a &lt;a href=&quot;http://www.isbndb.com&quot;&gt;free account&lt;/a&gt; and enter your access key below.</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="openExternalLinks"> <property name="openExternalLinks">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>&amp;Access Key:</string> <string>&amp;Access Key:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>key</cstring> <cstring>key</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="key"/> <widget class="QLineEdit" name="key"/>
</item> </item>
<item> <item>
<widget class="QPushButton" name="fetch"> <widget class="QPushButton" name="fetch">
<property name="text"> <property name="text">
<string>Fetch</string> <string>Fetch</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QLabel" name="warning"> <widget class="QLabel" name="warning">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>Matches</string> <string>Matches</string>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout">
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Select the book that most closely matches your copy from the list below</string> <string>Select the book that most closely matches your copy from the list below</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTableView" name="matches"> <widget class="QTableView" name="matches">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>1</verstretch> <verstretch>1</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="alternatingRowColors"> <property name="alternatingRowColors">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="selectionMode"> <property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum> <enum>QAbstractItemView::SingleSelection</enum>
</property> </property>
<property name="selectionBehavior"> <property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum> <enum>QAbstractItemView::SelectRows</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTextBrowser" name="summary"/> <widget class="QTextBrowser" name="summary"/>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="opt_get_social_metadata"> <widget class="QCheckBox" name="opt_overwrite_author_title_metadata">
<property name="text"> <property name="text">
<string>Download &amp;social metadata (tags/rating/etc.) for the selected book</string> <string>Overwrite author and title with author and title of selected book</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="opt_overwrite_author_title_metadata"> <widget class="QCheckBox" name="opt_get_social_metadata">
<property name="text"> <property name="text">
<string>Overwrite author and title with author and title of selected book</string> <string>Download &amp;social metadata (tags/rating/etc.) for the selected book</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QCheckBox" name="opt_overwrite_cover_image">
<property name="standardButtons"> <property name="text">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <string>Overwrite cover image with downloaded cover if available for the selected book</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item>
</widget> <widget class="QDialogButtonBox" name="buttonBox">
<resources> <property name="standardButtons">
<include location="../../../../resources/images.qrc"/> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</resources> </property>
<connections> </widget>
<connection> </item>
<sender>buttonBox</sender> </layout>
<signal>accepted()</signal> </widget>
<receiver>FetchMetadata</receiver> <resources>
<slot>accept()</slot> <include location="../../../../resources/images.qrc"/>
<hints> </resources>
<hint type="sourcelabel"> <connections>
<x>460</x> <connection>
<y>599</y> <sender>buttonBox</sender>
</hint> <signal>accepted()</signal>
<hint type="destinationlabel"> <receiver>FetchMetadata</receiver>
<x>657</x> <slot>accept()</slot>
<y>530</y> <hints>
</hint> <hint type="sourcelabel">
</hints> <x>460</x>
</connection> <y>599</y>
<connection> </hint>
<sender>buttonBox</sender> <hint type="destinationlabel">
<signal>rejected()</signal> <x>657</x>
<receiver>FetchMetadata</receiver> <y>530</y>
<slot>reject()</slot> </hint>
<hints> </hints>
<hint type="sourcelabel"> </connection>
<x>417</x> <connection>
<y>599</y> <sender>buttonBox</sender>
</hint> <signal>rejected()</signal>
<hint type="destinationlabel"> <receiver>FetchMetadata</receiver>
<x>0</x> <slot>reject()</slot>
<y>491</y> <hints>
</hint> <hint type="sourcelabel">
</hints> <x>417</x>
</connection> <y>599</y>
</connections> </hint>
</ui> <hint type="destinationlabel">
<x>0</x>
<y>491</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -718,6 +718,8 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
if book.author_sort: self.author_sort.setText(book.author_sort) if book.author_sort: self.author_sort.setText(book.author_sort)
if book.publisher: self.publisher.setEditText(book.publisher) if book.publisher: self.publisher.setEditText(book.publisher)
if book.isbn: self.isbn.setText(book.isbn) if book.isbn: self.isbn.setText(book.isbn)
if d.opt_overwrite_cover_image.isChecked() and book.has_cover:
self.fetch_cover()
if book.pubdate: if book.pubdate:
d = book.pubdate d = book.pubdate
self.pubdate.setDate(QDate(d.year, d.month, d.day)) self.pubdate.setDate(QDate(d.year, d.month, d.day))