mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow the metadata that is used to create collections on the reader to be customized by the user
This commit is contained in:
commit
2dc4e8db5b
@ -180,7 +180,7 @@ class BookList(_BookList):
|
||||
return child
|
||||
return None
|
||||
|
||||
def add_book(self, mi, name, size, ctime):
|
||||
def add_book(self, mi, name, collections, size, ctime):
|
||||
""" Add a node into the DOM tree, representing a book """
|
||||
book = self.book_by_path(name)
|
||||
if book is not None:
|
||||
@ -221,12 +221,18 @@ class BookList(_BookList):
|
||||
book = Book(node, self.mountpath, [], prefix=self.prefix)
|
||||
book.datetime = ctime
|
||||
self.append(book)
|
||||
|
||||
tags = []
|
||||
if mi.tags:
|
||||
tags.extend(mi.tags)
|
||||
if mi.series:
|
||||
tags.append(mi.series)
|
||||
for item in collections:
|
||||
item = item.strip()
|
||||
mitem = getattr(mi, item, None)
|
||||
if mitem:
|
||||
if isinstance(mitem, list):
|
||||
tags.extend(mitem)
|
||||
else:
|
||||
tags.append(mitem)
|
||||
if tags:
|
||||
tags = list(set(tags))
|
||||
if hasattr(mi, 'tag_order'):
|
||||
self.tag_order.update(mi.tag_order)
|
||||
self.set_tags(book, tags)
|
||||
|
@ -55,6 +55,11 @@ class PRS505(CLI, Device):
|
||||
MUST_READ_METADATA = True
|
||||
EBOOK_DIR_MAIN = 'database/media/books'
|
||||
|
||||
EXTRA_CUSTOMIZATION_MESSAGE = _('Comma separated list of metadata fields '
|
||||
'to turn into collections on the device. Posiibilities include: ')+\
|
||||
'series, tags, authors'
|
||||
EXTRA_CUSTOMIZATION_DEFAULT = ', '.join(['series', 'tags'])
|
||||
|
||||
def windows_filter_pnp_id(self, pnp_id):
|
||||
return '_LAUNCHER' in pnp_id
|
||||
|
||||
@ -159,7 +164,8 @@ class PRS505(CLI, Device):
|
||||
if name.startswith('/'):
|
||||
name = name[1:]
|
||||
|
||||
booklists[blist].add_book(info, name, *location[1:-1])
|
||||
opts = self.settings()
|
||||
booklists[blist].add_book(info, name, opts.extra_customization.split(','), *location[1:-1])
|
||||
fix_ids(*booklists)
|
||||
|
||||
def delete_books(self, paths, end_session=True):
|
||||
|
@ -47,8 +47,7 @@ class DeviceConfig(object):
|
||||
def config_widget(cls):
|
||||
from calibre.gui2.device_drivers.configwidget import ConfigWidget
|
||||
cw = ConfigWidget(cls.settings(), cls.FORMATS, cls.SUPPORTS_SUB_DIRS,
|
||||
cls.MUST_READ_METADATA, cls.EXTRA_CUSTOMIZATION_MESSAGE,
|
||||
cls.EXTRA_CUSTOMIZATION_DEFAULT)
|
||||
cls.MUST_READ_METADATA, cls.EXTRA_CUSTOMIZATION_MESSAGE)
|
||||
return cw
|
||||
|
||||
@classmethod
|
||||
|
@ -11,8 +11,7 @@ from calibre.gui2.device_drivers.configwidget_ui import Ui_ConfigWidget
|
||||
class ConfigWidget(QWidget, Ui_ConfigWidget):
|
||||
|
||||
def __init__(self, settings, all_formats, supports_subdirs,
|
||||
must_read_metadata, extra_customization_message,
|
||||
extra_customization_value):
|
||||
must_read_metadata, extra_customization_message):
|
||||
|
||||
QWidget.__init__(self)
|
||||
Ui_ConfigWidget.__init__(self)
|
||||
@ -41,8 +40,7 @@ class ConfigWidget(QWidget, Ui_ConfigWidget):
|
||||
self.opt_read_metadata.hide()
|
||||
if extra_customization_message:
|
||||
self.extra_customization_label.setText(extra_customization_message)
|
||||
if extra_customization_value:
|
||||
self.opt_extra_customization.setText(extra_customization_value)
|
||||
self.opt_extra_customization.setText(settings.extra_customization)
|
||||
else:
|
||||
self.extra_customization_label.setVisible(False)
|
||||
self.opt_extra_customization.setVisible(False)
|
||||
|
@ -177,7 +177,7 @@ class PluginModel(QAbstractItemModel):
|
||||
ans='%s (%s) %s %s\n%s'%(plugin.name, ver, _('by'), plugin.author, desc)
|
||||
c = plugin_customization(plugin)
|
||||
if c:
|
||||
ans += '\nCustomization: '+c
|
||||
ans += _('\nCustomization: ')+c
|
||||
return QVariant(ans)
|
||||
if role == Qt.DecorationRole:
|
||||
return self.disabled_icon if is_disabled(plugin) else self.icon
|
||||
|
@ -15,7 +15,7 @@
|
||||
<string>Preferences</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
<iconset resource="../../../../../resources/images.qrc">
|
||||
<normaloff>:/images/config.svg</normaloff>:/images/config.svg</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
@ -148,7 +148,7 @@
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="../../../../../resources/images.qrc">
|
||||
<normaloff>:/images/mimetypes/dir.svg</normaloff>:/images/mimetypes/dir.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@ -285,7 +285,7 @@
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="../../../../../resources/images.qrc">
|
||||
<normaloff>:/images/arrow-up.svg</normaloff>:/images/arrow-up.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@ -309,7 +309,7 @@
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="../../../../../resources/images.qrc">
|
||||
<normaloff>:/images/arrow-down.svg</normaloff>:/images/arrow-down.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@ -473,7 +473,7 @@
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="../../../../../resources/images.qrc">
|
||||
<normaloff>:/images/arrow-up.svg</normaloff>:/images/arrow-up.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@ -497,7 +497,7 @@
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="../../../../../resources/images.qrc">
|
||||
<normaloff>:/images/arrow-down.svg</normaloff>:/images/arrow-down.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@ -557,7 +557,7 @@
|
||||
<string>&Add email</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="../../../../../resources/images.qrc">
|
||||
<normaloff>:/images/plus.svg</normaloff>:/images/plus.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
@ -584,7 +584,7 @@
|
||||
<string>&Remove email</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="../../../../../resources/images.qrc">
|
||||
<normaloff>:/images/minus.svg</normaloff>:/images/minus.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
@ -907,6 +907,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="plugin_view">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
@ -916,6 +919,9 @@
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -973,7 +979,7 @@
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="../../../../../resources/images.qrc">
|
||||
<normaloff>:/images/document_open.svg</normaloff>:/images/document_open.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@ -1044,7 +1050,7 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../../work/calibre/resources/images.qrc"/>
|
||||
<include location="../../../../../resources/images.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
Loading…
x
Reference in New Issue
Block a user