From 6de8e3510cc563d0991f6a52ee60183c46114336 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 20 Aug 2010 12:50:14 -0600 Subject: [PATCH] ... --- src/calibre/gui2/dialogs/config/toolbar.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/calibre/gui2/dialogs/config/toolbar.py b/src/calibre/gui2/dialogs/config/toolbar.py index 355a35ee99..1a31eac6fb 100644 --- a/src/calibre/gui2/dialogs/config/toolbar.py +++ b/src/calibre/gui2/dialogs/config/toolbar.py @@ -5,6 +5,8 @@ __license__ = 'GPL v3' __copyright__ = '2010, Kovid Goyal ' __docformat__ = 'restructuredtext en' +from functools import partial + from PyQt4.Qt import QWidget, QAbstractListModel, Qt, QIcon, \ QVariant, QItemSelectionModel @@ -132,8 +134,8 @@ class ToolbarLayout(QWidget, Ui_Form): self.add_action_button.clicked.connect(self.add_action) self.remove_action_button.clicked.connect(self.remove_action) - self.action_up_button.clicked.connect(self.action_up) - self.action_down_button.clicked.connect(self.action_down) + self.action_up_button.clicked.connect(partial(self.move, -1)) + self.action_down_button.clicked.connect(partial(self.move, 1)) def what_changed(self, idx): key = unicode(self.what.itemData(idx).toString()) @@ -146,21 +148,11 @@ class ToolbarLayout(QWidget, Ui_Form): def remove_action(self, *args): pass - def action_up(self, *args): + def move(self, delta, *args): ci = self.current_actions.currentIndex() m = self.current_actions.model() if ci.isValid(): - ni = m.move(ci, -1) - if ni is not None: - self.current_actions.setCurrentIndex(ni) - self.current_actions.selectionModel().select(ni, - QItemSelectionModel.ClearAndSelect) - - def action_down(self, *args): - ci = self.current_actions.currentIndex() - m = self.current_actions.model() - if ci.isValid(): - ni = m.move(ci, 1) + ni = m.move(ci, delta) if ni is not None: self.current_actions.setCurrentIndex(ni) self.current_actions.selectionModel().select(ni,