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