mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Sync to trunk.
This commit is contained in:
commit
755c2226f7
@ -8,8 +8,6 @@ import os
|
|||||||
|
|
||||||
from calibre.customize.conversion import OutputFormatPlugin, \
|
from calibre.customize.conversion import OutputFormatPlugin, \
|
||||||
OptionRecommendation
|
OptionRecommendation
|
||||||
from calibre.ebooks.txt.markdownml import MarkdownMLizer
|
|
||||||
from calibre.ebooks.txt.textileml import TextileMLizer
|
|
||||||
from calibre.ebooks.txt.txtml import TXTMLizer
|
from calibre.ebooks.txt.txtml import TXTMLizer
|
||||||
from calibre.ebooks.txt.newlines import TxtNewlines, specified_newlines
|
from calibre.ebooks.txt.newlines import TxtNewlines, specified_newlines
|
||||||
|
|
||||||
@ -66,8 +64,10 @@ class TXTOutput(OutputFormatPlugin):
|
|||||||
|
|
||||||
def convert(self, oeb_book, output_path, input_plugin, opts, log):
|
def convert(self, oeb_book, output_path, input_plugin, opts, log):
|
||||||
if opts.txt_output_formatting.lower() == 'markdown':
|
if opts.txt_output_formatting.lower() == 'markdown':
|
||||||
|
from calibre.ebooks.txt.markdownml import MarkdownMLizer
|
||||||
writer = MarkdownMLizer(log)
|
writer = MarkdownMLizer(log)
|
||||||
elif opts.txt_output_formatting.lower() == 'textile':
|
elif opts.txt_output_formatting.lower() == 'textile':
|
||||||
|
from calibre.ebooks.txt.textileml import TextileMLizer
|
||||||
writer = TextileMLizer(log)
|
writer = TextileMLizer(log)
|
||||||
else:
|
else:
|
||||||
writer = TXTMLizer(log)
|
writer = TXTMLizer(log)
|
||||||
|
@ -29,21 +29,21 @@ class TextileMLizer(object):
|
|||||||
|
|
||||||
def mlize_spine(self):
|
def mlize_spine(self):
|
||||||
output = [u'']
|
output = [u'']
|
||||||
|
|
||||||
for item in self.oeb_book.spine:
|
for item in self.oeb_book.spine:
|
||||||
self.log.debug('Converting %s to Textile formatted TXT...' % item.href)
|
self.log.debug('Converting %s to Textile formatted TXT...' % item.href)
|
||||||
|
|
||||||
html = unicode(etree.tostring(item.data.find(XHTML('body')), encoding=unicode))
|
html = unicode(etree.tostring(item.data.find(XHTML('body')), encoding=unicode))
|
||||||
|
|
||||||
if not self.opts.keep_links:
|
if not self.opts.keep_links:
|
||||||
html = re.sub(r'<\s*a[^>]*>', '', html)
|
html = re.sub(r'<\s*a[^>]*>', '', html)
|
||||||
html = re.sub(r'<\s*/\s*a\s*>', '', html)
|
html = re.sub(r'<\s*/\s*a\s*>', '', html)
|
||||||
if not self.opts.keep_image_references:
|
if not self.opts.keep_image_references:
|
||||||
html = re.sub(r'<\s*img[^>]*>', '', html)
|
html = re.sub(r'<\s*img[^>]*>', '', html)
|
||||||
html = re.sub(r'<\s*img\s*>', '', html)
|
html = re.sub(r'<\s*img\s*>', '', html)
|
||||||
|
|
||||||
text = html2textile(html)
|
text = html2textile(html)
|
||||||
|
|
||||||
# Ensure the section ends with at least two new line characters.
|
# Ensure the section ends with at least two new line characters.
|
||||||
# This is to prevent the last paragraph from a section being
|
# This is to prevent the last paragraph from a section being
|
||||||
# combined into the fist paragraph of the next.
|
# combined into the fist paragraph of the next.
|
||||||
@ -56,9 +56,9 @@ class TextileMLizer(object):
|
|||||||
text += '\n\n'
|
text += '\n\n'
|
||||||
if end_chars[1] == '\n' and not end_chars[0] == '\n':
|
if end_chars[1] == '\n' and not end_chars[0] == '\n':
|
||||||
text += '\n'
|
text += '\n'
|
||||||
|
|
||||||
output += text
|
output += text
|
||||||
|
|
||||||
output = u''.join(output)
|
output = u''.join(output)
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
@ -120,6 +120,8 @@ def _config():
|
|||||||
help='Search history for the LRF viewer')
|
help='Search history for the LRF viewer')
|
||||||
c.add_opt('scheduler_search_history', default=[],
|
c.add_opt('scheduler_search_history', default=[],
|
||||||
help='Search history for the recipe scheduler')
|
help='Search history for the recipe scheduler')
|
||||||
|
c.add_opt('plugin_search_history', default=[],
|
||||||
|
help='Search history for the recipe scheduler')
|
||||||
c.add_opt('worker_limit', default=6,
|
c.add_opt('worker_limit', default=6,
|
||||||
help=_('Maximum number of waiting worker processes'))
|
help=_('Maximum number of waiting worker processes'))
|
||||||
c.add_opt('get_social_metadata', default=True,
|
c.add_opt('get_social_metadata', default=True,
|
||||||
@ -138,6 +140,7 @@ def _config():
|
|||||||
help=_('Show the average rating per item indication in the tag browser'))
|
help=_('Show the average rating per item indication in the tag browser'))
|
||||||
c.add_opt('disable_animations', default=False,
|
c.add_opt('disable_animations', default=False,
|
||||||
help=_('Disable UI animations'))
|
help=_('Disable UI animations'))
|
||||||
|
c.add_opt
|
||||||
return ConfigProxy(c)
|
return ConfigProxy(c)
|
||||||
|
|
||||||
config = _config()
|
config = _config()
|
||||||
|
@ -16,7 +16,6 @@ from calibre.utils.config import prefs
|
|||||||
from calibre.gui2 import gprefs, warning_dialog, Dispatcher, error_dialog, \
|
from calibre.gui2 import gprefs, warning_dialog, Dispatcher, error_dialog, \
|
||||||
question_dialog, info_dialog
|
question_dialog, info_dialog
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.gui2.dialogs.check_library import CheckLibraryDialog, DBCheck
|
|
||||||
|
|
||||||
class LibraryUsageStats(object): # {{{
|
class LibraryUsageStats(object): # {{{
|
||||||
|
|
||||||
@ -139,6 +138,12 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
None, None), attr='action_check_library')
|
None, None), attr='action_check_library')
|
||||||
ac.triggered.connect(self.check_library, type=Qt.QueuedConnection)
|
ac.triggered.connect(self.check_library, type=Qt.QueuedConnection)
|
||||||
self.maintenance_menu.addAction(ac)
|
self.maintenance_menu.addAction(ac)
|
||||||
|
ac = self.create_action(spec=(_('Restore database'), 'lt.png',
|
||||||
|
None, None),
|
||||||
|
attr='action_restore_database')
|
||||||
|
ac.triggered.connect(self.restore_database, type=Qt.QueuedConnection)
|
||||||
|
self.maintenance_menu.addAction(ac)
|
||||||
|
|
||||||
self.choose_menu.addMenu(self.maintenance_menu)
|
self.choose_menu.addMenu(self.maintenance_menu)
|
||||||
|
|
||||||
def pick_random(self, *args):
|
def pick_random(self, *args):
|
||||||
@ -267,7 +272,17 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
_('Metadata will be backed up while calibre is running, at the '
|
_('Metadata will be backed up while calibre is running, at the '
|
||||||
'rate of approximately 1 book every three seconds.'), show=True)
|
'rate of approximately 1 book every three seconds.'), show=True)
|
||||||
|
|
||||||
|
def restore_database(self):
|
||||||
|
from calibre.gui2.dialogs.restore_library import restore_database
|
||||||
|
m = self.gui.library_view.model()
|
||||||
|
m.stop_metadata_backup()
|
||||||
|
db = m.db
|
||||||
|
db.prefs.disable_setting = True
|
||||||
|
if restore_database(db, self.gui):
|
||||||
|
self.gui.library_moved(db.library_path, call_close=False)
|
||||||
|
|
||||||
def check_library(self):
|
def check_library(self):
|
||||||
|
from calibre.gui2.dialogs.check_library import CheckLibraryDialog, DBCheck
|
||||||
self.gui.library_view.save_state()
|
self.gui.library_view.save_state()
|
||||||
m = self.gui.library_view.model()
|
m = self.gui.library_view.model()
|
||||||
m.stop_metadata_backup()
|
m.stop_metadata_backup()
|
||||||
|
@ -4,7 +4,6 @@ __license__ = 'GPL 3'
|
|||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
from PyQt4.Qt import Qt
|
|
||||||
|
|
||||||
from calibre.gui2.convert.txt_output_ui import Ui_Form
|
from calibre.gui2.convert.txt_output_ui import Ui_Form
|
||||||
from calibre.gui2.convert import Widget
|
from calibre.gui2.convert import Widget
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>392</width>
|
<width>392</width>
|
||||||
<height>343</height>
|
<height>346</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -23,7 +23,10 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Output Encoding:</string>
|
<string>Output &Encoding:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>opt_txt_output_encoding</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -50,7 +53,10 @@
|
|||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Formatting</string>
|
<string>&Formatting:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>opt_txt_output_formatting</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
115
src/calibre/gui2/dialogs/restore_library.py
Normal file
115
src/calibre/gui2/dialogs/restore_library.py
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
|
||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
from PyQt4.Qt import QDialog, QLabel, QVBoxLayout, QDialogButtonBox, \
|
||||||
|
QProgressBar, QSize, QTimer, pyqtSignal, Qt
|
||||||
|
|
||||||
|
from calibre.library.restore import Restore
|
||||||
|
from calibre.gui2 import error_dialog, question_dialog, warning_dialog, \
|
||||||
|
info_dialog
|
||||||
|
|
||||||
|
class DBRestore(QDialog):
|
||||||
|
|
||||||
|
update_signal = pyqtSignal(object, object)
|
||||||
|
|
||||||
|
def __init__(self, parent, library_path):
|
||||||
|
QDialog.__init__(self, parent)
|
||||||
|
self.l = QVBoxLayout()
|
||||||
|
self.setLayout(self.l)
|
||||||
|
self.l1 = QLabel('<b>'+_('Restoring database from backups, do not'
|
||||||
|
' interrupt, this will happen in two stages')+'...')
|
||||||
|
self.setWindowTitle(_('Restoring database'))
|
||||||
|
self.l.addWidget(self.l1)
|
||||||
|
self.pb = QProgressBar(self)
|
||||||
|
self.l.addWidget(self.pb)
|
||||||
|
self.pb.setMaximum(0)
|
||||||
|
self.pb.setMinimum(0)
|
||||||
|
self.msg = QLabel('')
|
||||||
|
self.l.addWidget(self.msg)
|
||||||
|
self.msg.setWordWrap(True)
|
||||||
|
self.bb = QDialogButtonBox(QDialogButtonBox.Cancel)
|
||||||
|
self.l.addWidget(self.bb)
|
||||||
|
self.bb.rejected.connect(self.reject)
|
||||||
|
self.resize(self.sizeHint() + QSize(100, 50))
|
||||||
|
self.error = None
|
||||||
|
self.rejected = False
|
||||||
|
self.library_path = library_path
|
||||||
|
self.update_signal.connect(self.do_update, type=Qt.QueuedConnection)
|
||||||
|
|
||||||
|
self.restorer = Restore(library_path, self)
|
||||||
|
self.restorer.daemon = True
|
||||||
|
|
||||||
|
# Give the metadata backup thread time to stop
|
||||||
|
QTimer.singleShot(2000, self.start)
|
||||||
|
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
self.restorer.start()
|
||||||
|
QTimer.singleShot(10, self.update)
|
||||||
|
|
||||||
|
def reject(self):
|
||||||
|
self.rejected = True
|
||||||
|
self.restorer.progress_callback = lambda x, y: x
|
||||||
|
QDialog.rejecet(self)
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
if self.restorer.is_alive():
|
||||||
|
QTimer.singleShot(10, self.update)
|
||||||
|
else:
|
||||||
|
self.restorer.progress_callback = lambda x, y: x
|
||||||
|
self.accept()
|
||||||
|
|
||||||
|
def __call__(self, msg, step):
|
||||||
|
self.update_signal.emit(msg, step)
|
||||||
|
|
||||||
|
def do_update(self, msg, step):
|
||||||
|
if msg is None:
|
||||||
|
self.pb.setMaximum(step)
|
||||||
|
else:
|
||||||
|
self.msg.setText(msg)
|
||||||
|
self.pb.setValue(step)
|
||||||
|
|
||||||
|
|
||||||
|
def restore_database(db, parent=None):
|
||||||
|
if not question_dialog(parent, _('Are you sure?'), '<p>'+
|
||||||
|
_('Your list of books, with all their metadata is '
|
||||||
|
'stored in a single file, called a database. '
|
||||||
|
'In addition, metadata for each individual '
|
||||||
|
'book is stored in that books\' folder, as '
|
||||||
|
'a backup.'
|
||||||
|
'<p>This operation will rebuild '
|
||||||
|
'the database from the individual book '
|
||||||
|
'metadata. This is useful if the '
|
||||||
|
'database has been corrupted and you get a '
|
||||||
|
'blank list of books. Note that restoring only '
|
||||||
|
'restores books, not any settings stored in the '
|
||||||
|
'database, or any custom recipes.'
|
||||||
|
'<p>Do you want to restore the database?')):
|
||||||
|
return False
|
||||||
|
db.conn.close()
|
||||||
|
d = DBRestore(parent, db.library_path)
|
||||||
|
d.exec_()
|
||||||
|
r = d.restorer
|
||||||
|
d.restorer = None
|
||||||
|
if d.rejected:
|
||||||
|
return True
|
||||||
|
if r.tb is not None:
|
||||||
|
error_dialog(parent, _('Failed'),
|
||||||
|
_('Restoring database failed, click Show details to see details'),
|
||||||
|
det_msg=r.tb, show=True)
|
||||||
|
else:
|
||||||
|
if r.errors_occurred:
|
||||||
|
warning_dialog(parent, _('Success'),
|
||||||
|
_('Restoring the database succeeded with some warnings',
|
||||||
|
' click Show details to see the details.'),
|
||||||
|
det_msg=r.report, show=True)
|
||||||
|
else:
|
||||||
|
info_dialog(parent, _('Success'),
|
||||||
|
_('Restoring database was successful'), show=True,
|
||||||
|
show_copy_button=False)
|
||||||
|
return True
|
||||||
|
|
@ -17,11 +17,14 @@ from calibre.customize.ui import initialized_plugins, is_disabled, enable_plugin
|
|||||||
remove_plugin
|
remove_plugin
|
||||||
from calibre.gui2 import NONE, error_dialog, info_dialog, choose_files, \
|
from calibre.gui2 import NONE, error_dialog, info_dialog, choose_files, \
|
||||||
question_dialog
|
question_dialog
|
||||||
|
from calibre.utils.search_query_parser import SearchQueryParser
|
||||||
|
from calibre.utils.icu import lower
|
||||||
|
|
||||||
class PluginModel(QAbstractItemModel): # {{{
|
class PluginModel(QAbstractItemModel, SearchQueryParser): # {{{
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
QAbstractItemModel.__init__(self, *args)
|
QAbstractItemModel.__init__(self, *args)
|
||||||
|
SearchQueryParser.__init__(self, ['all'])
|
||||||
self.icon = QVariant(QIcon(I('plugins.png')))
|
self.icon = QVariant(QIcon(I('plugins.png')))
|
||||||
p = QIcon(self.icon).pixmap(32, 32, QIcon.Disabled, QIcon.On)
|
p = QIcon(self.icon).pixmap(32, 32, QIcon.Disabled, QIcon.On)
|
||||||
self.disabled_icon = QVariant(QIcon(p))
|
self.disabled_icon = QVariant(QIcon(p))
|
||||||
@ -40,6 +43,72 @@ class PluginModel(QAbstractItemModel): # {{{
|
|||||||
for plugins in self._data.values():
|
for plugins in self._data.values():
|
||||||
plugins.sort(cmp=lambda x, y: cmp(x.name.lower(), y.name.lower()))
|
plugins.sort(cmp=lambda x, y: cmp(x.name.lower(), y.name.lower()))
|
||||||
|
|
||||||
|
def universal_set(self):
|
||||||
|
ans = set([])
|
||||||
|
for c, category in enumerate(self.categories):
|
||||||
|
ans.add((c, -1))
|
||||||
|
for p, plugin in enumerate(self._data[category]):
|
||||||
|
ans.add((c, p))
|
||||||
|
return ans
|
||||||
|
|
||||||
|
def get_matches(self, location, query, candidates=None):
|
||||||
|
if candidates is None:
|
||||||
|
candidates = self.universal_set()
|
||||||
|
ans = set([])
|
||||||
|
if not query:
|
||||||
|
return ans
|
||||||
|
query = lower(query)
|
||||||
|
for c, p in candidates:
|
||||||
|
if p < 0:
|
||||||
|
if query in lower(self.categories[c]):
|
||||||
|
ans.add((c, p))
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
plugin = self._data[self.categories[c]][p]
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
if query in lower(plugin.name) or query in lower(plugin.author) or \
|
||||||
|
query in lower(plugin.description):
|
||||||
|
ans.add((c, p))
|
||||||
|
return ans
|
||||||
|
|
||||||
|
def find(self, query):
|
||||||
|
query = query.strip()
|
||||||
|
matches = self.parse(query)
|
||||||
|
if not matches:
|
||||||
|
return QModelIndex()
|
||||||
|
matches = list(sorted(matches))
|
||||||
|
c, p = matches[0]
|
||||||
|
cat_idx = self.index(c, 0, QModelIndex())
|
||||||
|
if p == -1:
|
||||||
|
return cat_idx
|
||||||
|
return self.index(p, 0, cat_idx)
|
||||||
|
|
||||||
|
def find_next(self, idx, query, backwards=False):
|
||||||
|
query = query.strip()
|
||||||
|
matches = self.parse(query)
|
||||||
|
if not matches:
|
||||||
|
return idx
|
||||||
|
if idx.parent().isValid():
|
||||||
|
loc = (idx.parent().row(), idx.row())
|
||||||
|
else:
|
||||||
|
loc = (idx.row(), -1)
|
||||||
|
if loc not in matches:
|
||||||
|
return self.find(query)
|
||||||
|
if len(matches) == 1:
|
||||||
|
return QModelIndex()
|
||||||
|
matches = list(sorted(matches))
|
||||||
|
i = matches.index(loc)
|
||||||
|
if backwards:
|
||||||
|
ans = i - 1 if i - 1 >= 0 else len(matches)-1
|
||||||
|
else:
|
||||||
|
ans = i + 1 if i + 1 < len(matches) else 0
|
||||||
|
|
||||||
|
ans = matches[ans]
|
||||||
|
|
||||||
|
return self.index(ans[0], 0, QModelIndex()) if ans[1] < 0 else \
|
||||||
|
self.index(ans[1], 0, self.index(ans[0], 0, QModelIndex()))
|
||||||
|
|
||||||
def index(self, row, column, parent):
|
def index(self, row, column, parent):
|
||||||
if not self.hasIndex(row, column, parent):
|
if not self.hasIndex(row, column, parent):
|
||||||
return QModelIndex()
|
return QModelIndex()
|
||||||
@ -127,6 +196,7 @@ class PluginModel(QAbstractItemModel): # {{{
|
|||||||
return plugin
|
return plugin
|
||||||
return NONE
|
return NONE
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||||
@ -144,6 +214,42 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.customize_plugin_button.clicked.connect(self.customize_plugin)
|
self.customize_plugin_button.clicked.connect(self.customize_plugin)
|
||||||
self.remove_plugin_button.clicked.connect(self.remove_plugin)
|
self.remove_plugin_button.clicked.connect(self.remove_plugin)
|
||||||
self.button_plugin_add.clicked.connect(self.add_plugin)
|
self.button_plugin_add.clicked.connect(self.add_plugin)
|
||||||
|
self.search.initialize('plugin_search_history',
|
||||||
|
help_text=_('Search for plugin'))
|
||||||
|
self.search.search.connect(self.find)
|
||||||
|
self.next_button.clicked.connect(self.find_next)
|
||||||
|
self.previous_button.clicked.connect(self.find_previous)
|
||||||
|
|
||||||
|
def find(self, query):
|
||||||
|
idx = self._plugin_model.find(query)
|
||||||
|
if not idx.isValid():
|
||||||
|
return info_dialog(self, _('No matches'),
|
||||||
|
_('Could not find any matching plugins'), show=True,
|
||||||
|
show_copy_button=False)
|
||||||
|
self.highlight_index(idx)
|
||||||
|
|
||||||
|
def highlight_index(self, idx):
|
||||||
|
self.plugin_view.scrollTo(idx)
|
||||||
|
self.plugin_view.selectionModel().select(idx,
|
||||||
|
self.plugin_view.selectionModel().ClearAndSelect)
|
||||||
|
self.plugin_view.setCurrentIndex(idx)
|
||||||
|
|
||||||
|
def find_next(self, *args):
|
||||||
|
idx = self.plugin_view.currentIndex()
|
||||||
|
if not idx.isValid():
|
||||||
|
idx = self._plugin_model.index(0, 0)
|
||||||
|
idx = self._plugin_model.find_next(idx,
|
||||||
|
unicode(self.search.currentText()))
|
||||||
|
self.highlight_index(idx)
|
||||||
|
|
||||||
|
def find_previous(self, *args):
|
||||||
|
idx = self.plugin_view.currentIndex()
|
||||||
|
if not idx.isValid():
|
||||||
|
idx = self._plugin_model.index(0, 0)
|
||||||
|
idx = self._plugin_model.find_next(idx,
|
||||||
|
unicode(self.search.currentText()), backwards=True)
|
||||||
|
self.highlight_index(idx)
|
||||||
|
|
||||||
|
|
||||||
def toggle_plugin(self, *args):
|
def toggle_plugin(self, *args):
|
||||||
self.modify_plugin(op='toggle')
|
self.modify_plugin(op='toggle')
|
||||||
@ -184,13 +290,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
show=True, show_copy_button=False)
|
show=True, show_copy_button=False)
|
||||||
idx = self._plugin_model.plugin_to_index_by_properties(plugin)
|
idx = self._plugin_model.plugin_to_index_by_properties(plugin)
|
||||||
if idx.isValid():
|
if idx.isValid():
|
||||||
self.plugin_view.scrollTo(idx,
|
self.highlight_index(idx)
|
||||||
self.plugin_view.PositionAtCenter)
|
|
||||||
self.plugin_view.scrollTo(idx,
|
|
||||||
self.plugin_view.PositionAtCenter)
|
|
||||||
self.plugin_view.selectionModel().select(idx,
|
|
||||||
self.plugin_view.selectionModel().ClearAndSelect)
|
|
||||||
self.plugin_view.setCurrentIndex(idx)
|
|
||||||
else:
|
else:
|
||||||
error_dialog(self, _('No valid plugin path'),
|
error_dialog(self, _('No valid plugin path'),
|
||||||
_('%s is not a valid plugin path')%path).exec_()
|
_('%s is not a valid plugin path')%path).exec_()
|
||||||
|
@ -24,6 +24,47 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="SearchBox2" name="search"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="next_button">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Next</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../../../resources/images.qrc">
|
||||||
|
<normaloff>:/images/arrow-down.png</normaloff>:/images/arrow-down.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="previous_button">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Previous</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../../../resources/images.qrc">
|
||||||
|
<normaloff>:/images/arrow-up.png</normaloff>:/images/arrow-up.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="plugin_view">
|
<widget class="QTreeView" name="plugin_view">
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
@ -84,6 +125,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>SearchBox2</class>
|
||||||
|
<extends>QComboBox</extends>
|
||||||
|
<header>calibre/gui2/search_box.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../../resources/images.qrc"/>
|
<include location="../../../../resources/images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -356,9 +356,9 @@ class BrowseServer(object):
|
|||||||
if category in category_icon_map:
|
if category in category_icon_map:
|
||||||
icon = category_icon_map[category]
|
icon = category_icon_map[category]
|
||||||
elif meta['is_custom']:
|
elif meta['is_custom']:
|
||||||
icon = category_icon_map[':custom']
|
icon = category_icon_map['custom:']
|
||||||
elif meta['kind'] == 'user':
|
elif meta['kind'] == 'user':
|
||||||
icon = category_icon_map[':user']
|
icon = category_icon_map['user:']
|
||||||
else:
|
else:
|
||||||
icon = 'blank.png'
|
icon = 'blank.png'
|
||||||
cats.append((meta['name'], category, icon))
|
cats.append((meta['name'], category, icon))
|
||||||
|
@ -30,7 +30,7 @@ from lxml import etree
|
|||||||
from calibre.ebooks.oeb.base import barename
|
from calibre.ebooks.oeb.base import barename
|
||||||
|
|
||||||
class EchoTarget:
|
class EchoTarget:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.final_output = []
|
self.final_output = []
|
||||||
self.block = False
|
self.block = False
|
||||||
@ -38,14 +38,14 @@ class EchoTarget:
|
|||||||
self.ul_ident = 0
|
self.ul_ident = 0
|
||||||
self.list_types = []
|
self.list_types = []
|
||||||
self.haystack = []
|
self.haystack = []
|
||||||
|
|
||||||
def start(self, tag, attrib):
|
def start(self, tag, attrib):
|
||||||
tag = barename(tag)
|
tag = barename(tag)
|
||||||
|
|
||||||
newline = '\n'
|
newline = '\n'
|
||||||
dot = ''
|
dot = ''
|
||||||
new_tag = ''
|
new_tag = ''
|
||||||
|
|
||||||
if tag in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6'):
|
if tag in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6'):
|
||||||
new_tag = tag
|
new_tag = tag
|
||||||
dot = '. '
|
dot = '. '
|
||||||
@ -86,35 +86,35 @@ class EchoTarget:
|
|||||||
'href':attrib.get('href', '')}
|
'href':attrib.get('href', '')}
|
||||||
else:
|
else:
|
||||||
self.a_part = {'title':None, 'href':attrib.get('href', '')}
|
self.a_part = {'title':None, 'href':attrib.get('href', '')}
|
||||||
new_tag = ''
|
new_tag = ''
|
||||||
newline = ''
|
newline = ''
|
||||||
|
|
||||||
elif tag == 'img':
|
elif tag == 'img':
|
||||||
if 'alt' in attrib:
|
if 'alt' in attrib:
|
||||||
new_tag = ' !%s(%s)' % (attrib.get('src'), attrib.get('title'),)
|
new_tag = ' !%s(%s)' % (attrib.get('src'), attrib.get('title'),)
|
||||||
else:
|
else:
|
||||||
new_tag = ' !%s' % attrib.get('src')
|
new_tag = ' !%s' % attrib.get('src')
|
||||||
newline = ''
|
newline = ''
|
||||||
|
|
||||||
elif tag in ('ul', 'ol'):
|
elif tag in ('ul', 'ol'):
|
||||||
new_tag = ''
|
new_tag = ''
|
||||||
newline = ''
|
newline = ''
|
||||||
self.list_types.append(tag)
|
self.list_types.append(tag)
|
||||||
if tag == 'ul':
|
if tag == 'ul':
|
||||||
self.ul_ident += 1
|
self.ul_ident += 1
|
||||||
else:
|
else:
|
||||||
self.ol_ident += 1
|
self.ol_ident += 1
|
||||||
|
|
||||||
elif tag == 'li':
|
elif tag == 'li':
|
||||||
indent = self.ul_ident + self.ol_ident
|
indent = self.ul_ident + self.ol_ident
|
||||||
if self.list_types[-1] == 'ul':
|
if self.list_types[-1] == 'ul':
|
||||||
new_tag = '*' * indent + ' '
|
new_tag = '*' * indent + ' '
|
||||||
newline = '\n'
|
newline = '\n'
|
||||||
else:
|
else:
|
||||||
new_tag = '#' * indent + ' '
|
new_tag = '#' * indent + ' '
|
||||||
newline = '\n'
|
newline = '\n'
|
||||||
|
|
||||||
|
|
||||||
if tag not in ('ul', 'ol'):
|
if tag not in ('ul', 'ol'):
|
||||||
textile = '%(newline)s%(tag)s%(dot)s' % \
|
textile = '%(newline)s%(tag)s%(dot)s' % \
|
||||||
{
|
{
|
||||||
@ -126,10 +126,10 @@ class EchoTarget:
|
|||||||
self.final_output.append(textile)
|
self.final_output.append(textile)
|
||||||
else:
|
else:
|
||||||
self.haystack.append(textile)
|
self.haystack.append(textile)
|
||||||
|
|
||||||
def end(self, tag):
|
def end(self, tag):
|
||||||
tag = barename(tag)
|
tag = barename(tag)
|
||||||
|
|
||||||
if tag in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'):
|
if tag in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'):
|
||||||
self.final_output.append('\n')
|
self.final_output.append('\n')
|
||||||
elif tag in ('b', 'strong'):
|
elif tag in ('b', 'strong'):
|
||||||
@ -161,7 +161,7 @@ class EchoTarget:
|
|||||||
''.join(self.haystack),
|
''.join(self.haystack),
|
||||||
self.a_part.get('href'),
|
self.a_part.get('href'),
|
||||||
)
|
)
|
||||||
self.haystack = []
|
self.haystack = []
|
||||||
self.final_output.append(textilized)
|
self.final_output.append(textilized)
|
||||||
self.block = False
|
self.block = False
|
||||||
elif tag == 'img':
|
elif tag == 'img':
|
||||||
@ -176,7 +176,7 @@ class EchoTarget:
|
|||||||
self.list_types.pop()
|
self.list_types.pop()
|
||||||
if len(self.list_types) == 0:
|
if len(self.list_types) == 0:
|
||||||
self.final_output.append('\n')
|
self.final_output.append('\n')
|
||||||
|
|
||||||
def data(self, data):
|
def data(self, data):
|
||||||
#we dont want any linebreaks inside our tags
|
#we dont want any linebreaks inside our tags
|
||||||
node_data = data.replace('\n','')
|
node_data = data.replace('\n','')
|
||||||
@ -191,7 +191,7 @@ class EchoTarget:
|
|||||||
def close(self):
|
def close(self):
|
||||||
return "closed!"
|
return "closed!"
|
||||||
|
|
||||||
|
|
||||||
def html2textile(html):
|
def html2textile(html):
|
||||||
#1st pass
|
#1st pass
|
||||||
#clean the whitespace and convert html to xhtml
|
#clean the whitespace and convert html to xhtml
|
||||||
|
@ -260,12 +260,12 @@ class SearchQueryParser(object):
|
|||||||
'''
|
'''
|
||||||
Should return the set of matches for :param:'location` and :param:`query`.
|
Should return the set of matches for :param:'location` and :param:`query`.
|
||||||
|
|
||||||
The search must be performed over all entries is :param:`candidates` is
|
The search must be performed over all entries if :param:`candidates` is
|
||||||
None otherwise only over the items in candidates.
|
None otherwise only over the items in candidates.
|
||||||
|
|
||||||
:param:`location` is one of the items in :member:`SearchQueryParser.DEFAULT_LOCATIONS`.
|
:param:`location` is one of the items in :member:`SearchQueryParser.DEFAULT_LOCATIONS`.
|
||||||
:param:`query` is a string literal.
|
:param:`query` is a string literal.
|
||||||
:param: None or a subset of the set returned by :meth:`universal_set`.
|
:return: None or a subset of the set returned by :meth:`universal_set`.
|
||||||
'''
|
'''
|
||||||
return set([])
|
return set([])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user