Merge from trunk

This commit is contained in:
Charles Haley 2011-01-11 18:09:59 +00:00
commit 91d2e1e282
4 changed files with 30 additions and 8 deletions

View File

@ -269,10 +269,14 @@ def question_dialog(parent, title, msg, det_msg='', show_copy_button=True,
return d.exec_() == yes_button 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, d = MessageBox(QMessageBox.Information, title, msg, QMessageBox.Ok,
parent, det_msg) parent, det_msg)
d.setIconPixmap(QPixmap(I('dialog_information.png'))) d.setIconPixmap(QPixmap(I('dialog_information.png')))
if not show_copy_button:
d.cb.setVisible(False)
if show: if show:
return d.exec_() return d.exec_()
return d return d

View File

@ -77,6 +77,16 @@ class PluginModel(QAbstractItemModel): # {{{
return self.index(j, 0, parent) return self.index(j, 0, parent)
return QModelIndex() 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): def refresh_plugin(self, plugin, rescan=False):
if rescan: if rescan:
self.populate() self.populate()
@ -171,7 +181,13 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
_('Plugin <b>{0}</b> successfully installed under <b>' _('Plugin <b>{0}</b> successfully installed under <b>'
' {1} plugins</b>. You may have to restart calibre ' ' {1} plugins</b>. You may have to restart calibre '
'for the plugin to take effect.').format(plugin.name, plugin.type), '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: 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_()
@ -201,10 +217,13 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
if plugin.do_user_config(): if plugin.do_user_config():
self._plugin_model.refresh_plugin(plugin) self._plugin_model.refresh_plugin(plugin)
elif op == 'remove': elif op == 'remove':
msg = _('Plugin {0} successfully removed').format(plugin.name)
if remove_plugin(plugin): if remove_plugin(plugin):
self._plugin_model.populate() self._plugin_model.populate()
self._plugin_model.reset() self._plugin_model.reset()
self.changed_signal.emit() self.changed_signal.emit()
info_dialog(self, _('Success'), msg, show=True,
show_copy_button=False)
else: else:
error_dialog(self, _('Cannot remove builtin plugin'), error_dialog(self, _('Cannot remove builtin plugin'),
plugin.name + _(' cannot be removed. It is a ' plugin.name + _(' cannot be removed. It is a '

View File

@ -19,7 +19,7 @@ from PyQt4.Qt import Qt, SIGNAL, QTimer, \
QMessageBox, QHelpEvent QMessageBox, QHelpEvent
from calibre import prints from calibre import prints
from calibre.constants import __appname__, isosx, DEBUG from calibre.constants import __appname__, isosx
from calibre.ptempfile import PersistentTemporaryFile from calibre.ptempfile import PersistentTemporaryFile
from calibre.utils.config import prefs, dynamic from calibre.utils.config import prefs, dynamic
from calibre.utils.ipc.server import Server from calibre.utils.ipc.server import Server

View File

@ -298,8 +298,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
base, base,
prefer_custom=True) prefer_custom=True)
self.FIELD_MAP['ondevice'] = base+1 self.FIELD_MAP['ondevice'] = base = base+1
self.field_metadata.set_field_record_index('ondevice', base+1, prefer_custom=False) self.field_metadata.set_field_record_index('ondevice', base, prefer_custom=False)
script = ''' script = '''
DROP VIEW IF EXISTS meta2; DROP VIEW IF EXISTS meta2;
@ -1373,9 +1373,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
if r is not None: if r is not None:
if (now - r[self.FIELD_MAP['timestamp']]) > delta: if (now - r[self.FIELD_MAP['timestamp']]) > delta:
tags = r[self.FIELD_MAP['tags']] tags = r[self.FIELD_MAP['tags']]
tags = tags.lower().split(',') if tags else [] if tags and tag in [x.strip() for x in
tags = [tag.strip() for tag in tags if tag.strip()] tags.lower().split(',')]:
if tag in tags:
yield r[self.FIELD_MAP['id']] yield r[self.FIELD_MAP['id']]
def get_next_series_num_for(self, series): def get_next_series_num_for(self, series):