commit b53d07897b3e8f1e89e8d12005508b23921042b8 Author: Guillaume Munch <g...@lyx.org> Date: Sun May 29 20:58:33 2016 +0100
ShortcutPrefs: clean-up diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 98dbd8c..91f8720 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -2822,6 +2822,13 @@ void PrefShortcuts::updateShortcutsTW() } +//static +KeyMap::ItemType PrefShortcuts::itemType(QTreeWidgetItem & item) +{ + return static_cast<KeyMap::ItemType>(item.data(0, Qt::UserRole).toInt()); +} + + void PrefShortcuts::setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag) { item->setData(0, Qt::UserRole, QVariant(tag)); @@ -2915,9 +2922,7 @@ void PrefShortcuts::on_shortcutsTW_itemSelectionChanged() if (items.isEmpty()) return; - KeyMap::ItemType tag = - static_cast<KeyMap::ItemType>(items[0]->data(0, Qt::UserRole).toInt()); - if (tag == KeyMap::UserUnbind) + if (itemType(*items[0]) == KeyMap::UserUnbind) removePB->setText(qt_("Res&tore")); else removePB->setText(qt_("Remo&ve")); @@ -2955,10 +2960,8 @@ void PrefShortcuts::removeShortcut() string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString()); string lfun = fromqstr(items[i]->text(0)); FuncRequest func = lyxaction.lookupFunc(lfun); - KeyMap::ItemType tag = - static_cast<KeyMap::ItemType>(items[i]->data(0, Qt::UserRole).toInt()); - switch (tag) { + switch (itemType(*items[i])) { case KeyMap::System: { // for system bind, we do not touch the item // but add an user unbind item @@ -3010,10 +3013,8 @@ void PrefShortcuts::deactivateShortcuts(QList<QTreeWidgetItem*> const & items) string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString()); string lfun = fromqstr(items[i]->text(0)); FuncRequest func = lyxaction.lookupFunc(lfun); - KeyMap::ItemType tag = - static_cast<KeyMap::ItemType>(items[i]->data(0, Qt::UserRole).toInt()); - switch (tag) { + switch (itemType(*items[i])) { case KeyMap::System: // for system bind, we do not touch the item // but add an user unbind item diff --git a/src/frontends/qt4/GuiPrefs.h b/src/frontends/qt4/GuiPrefs.h index c2c4576..9f6c35e 100644 --- a/src/frontends/qt4/GuiPrefs.h +++ b/src/frontends/qt4/GuiPrefs.h @@ -456,6 +456,23 @@ public: void applyRC(LyXRC & rc) const; void updateRC(LyXRC const & rc); void updateShortcutsTW(); + +public Q_SLOTS: + void selectBind(); + void on_modifyPB_pressed(); + void on_newPB_pressed(); + void on_removePB_pressed(); + void on_searchLE_textEdited(); + /// + void on_shortcutsTW_itemSelectionChanged(); + void on_shortcutsTW_itemDoubleClicked(); + /// + void shortcutOkPressed(); + void shortcutCancelPressed(); + void shortcutClearPressed(); + void shortcutRemovePressed(); + +private: void modifyShortcut(); /// remove selected binding, restore default value void removeShortcut(); @@ -472,25 +489,11 @@ public: FuncRequest currentBinding(KeySequence const & k); /// void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag); - QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun, - KeySequence const & shortcut, KeyMap::ItemType tag); - -public Q_SLOTS: - void selectBind(); - void on_modifyPB_pressed(); - void on_newPB_pressed(); - void on_removePB_pressed(); - void on_searchLE_textEdited(); /// - void on_shortcutsTW_itemSelectionChanged(); - void on_shortcutsTW_itemDoubleClicked(); + static KeyMap::ItemType itemType(QTreeWidgetItem & item); /// - void shortcutOkPressed(); - void shortcutCancelPressed(); - void shortcutClearPressed(); - void shortcutRemovePressed(); - -private: + QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun, + KeySequence const & shortcut, KeyMap::ItemType tag); /// GuiShortcutDialog * shortcut_; ///