From f7ae68a8c97aa5448f7dbacc575582c1fbcb7030 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 11 Jan 2011 09:55:36 -0700 Subject: [PATCH 1/3] After adding plugin scroll to it in the plugins list --- src/calibre/gui2/__init__.py | 6 +++++- src/calibre/gui2/preferences/plugins.py | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index df6ac45e5b..e699551150 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -269,10 +269,14 @@ def question_dialog(parent, title, msg, det_msg='', show_copy_button=True, return d.exec_() == yes_button -def info_dialog(parent, title, msg, det_msg='', show=False): +def info_dialog(parent, title, msg, det_msg='', show=False, + show_copy_button=True): d = MessageBox(QMessageBox.Information, title, msg, QMessageBox.Ok, parent, det_msg) d.setIconPixmap(QPixmap(I('dialog_information.png'))) + if not show_copy_button: + d.cb.setVisible(False) + if show: return d.exec_() return d diff --git a/src/calibre/gui2/preferences/plugins.py b/src/calibre/gui2/preferences/plugins.py index 8b4a221f56..c53c634ab4 100644 --- a/src/calibre/gui2/preferences/plugins.py +++ b/src/calibre/gui2/preferences/plugins.py @@ -77,6 +77,16 @@ class PluginModel(QAbstractItemModel): # {{{ return self.index(j, 0, parent) return QModelIndex() + def plugin_to_index_by_properties(self, plugin): + for i, category in enumerate(self.categories): + parent = self.index(i, 0, QModelIndex()) + for j, p in enumerate(self._data[category]): + if plugin.name == p.name and plugin.type == p.type and \ + plugin.author == p.author and plugin.version == p.version: + return self.index(j, 0, parent) + return QModelIndex() + + def refresh_plugin(self, plugin, rescan=False): if rescan: self.populate() @@ -171,7 +181,13 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): _('Plugin {0} successfully installed under ' ' {1} plugins. You may have to restart calibre ' 'for the plugin to take effect.').format(plugin.name, plugin.type), - show=True) + show=True, show_copy_button=False) + idx = self._plugin_model.plugin_to_index_by_properties(plugin) + if idx.isValid(): + self.plugin_view.scrollTo(idx, + self.plugin_view.PositionAtCenter) + self.plugin_view.scrollTo(idx, + self.plugin_view.PositionAtCenter) else: error_dialog(self, _('No valid plugin path'), _('%s is not a valid plugin path')%path).exec_() @@ -201,10 +217,13 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): if plugin.do_user_config(): self._plugin_model.refresh_plugin(plugin) elif op == 'remove': + msg = _('Plugin {0} successfully removed').format(plugin.name) if remove_plugin(plugin): self._plugin_model.populate() self._plugin_model.reset() self.changed_signal.emit() + info_dialog(self, _('Success'), msg, show=True, + show_copy_button=False) else: error_dialog(self, _('Cannot remove builtin plugin'), plugin.name + _(' cannot be removed. It is a ' From 2ea905dffd76f31f860962982a76ca997d219745 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 11 Jan 2011 10:38:10 -0700 Subject: [PATCH 2/3] Fix bug that caused automatic news removal to remove any book that has a tag that contains the word 'news' instead of only books that have the tag News --- src/calibre/library/database2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 3b06064226..6ab003f2d5 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1373,7 +1373,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): if r is not None: if (now - r[self.FIELD_MAP['timestamp']]) > delta: tags = r[self.FIELD_MAP['tags']] - if tags and tag in tags.lower(): + if tags and tag in tags.lower().split(','): yield r[self.FIELD_MAP['id']] def get_next_series_num_for(self, series): From efda0e0275f2f3127a53dc619994dceba70dcc9d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 11 Jan 2011 10:55:03 -0700 Subject: [PATCH 3/3] ... --- src/calibre/library/database2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 6ab003f2d5..aa491aff28 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1373,7 +1373,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): if r is not None: if (now - r[self.FIELD_MAP['timestamp']]) > delta: tags = r[self.FIELD_MAP['tags']] - if tags and tag in tags.lower().split(','): + if tags and tag in [x.strip() for x in + tags.lower().split(',')]: yield r[self.FIELD_MAP['id']] def get_next_series_num_for(self, series):