From 65ce182131727603e99e1659a86a3e90b41dcab4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 2 Nov 2007 20:26:28 +0000 Subject: [PATCH] I wonder why boost::tuple is preferable over a simple struct. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21388 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/KeyMap.cpp | 13 ++++++------- src/KeyMap.h | 15 ++++++++------- src/frontends/qt4/GuiPrefs.cpp | 7 ++++--- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/KeyMap.cpp b/src/KeyMap.cpp index 04a3bbcb33..89e1f48837 100644 --- a/src/KeyMap.cpp +++ b/src/KeyMap.cpp @@ -31,7 +31,6 @@ using std::endl; using std::ios; using std::ofstream; using std::string; -using boost::make_tuple; namespace lyx { @@ -270,11 +269,11 @@ void KeyMap::write(string const & bind_file, bool append, bool unbind) const BindingList::const_iterator it = list.begin(); BindingList::const_iterator it_end = list.end(); for (; it != it_end; ++it) { - kb_action action = it->get<0>().action; - string arg = to_utf8(it->get<0>().argument()); + kb_action action = it->request.action; + string arg = to_utf8(it->request.argument()); os << tag << " \"" - << to_utf8(it->get<1>().print(KeySequence::BindFile)) + << to_utf8(it->sequence.print(KeySequence::BindFile)) << "\" \"" << lyxaction.getActionName(action) << (arg.empty() ? "" : " ") << arg @@ -493,12 +492,12 @@ KeyMap::BindingList KeyMap::listBindings(bool unbound, int tag) const BindingList::const_iterator it = list.begin(); BindingList::const_iterator it_end = list.end(); for (; it != it_end; ++it) - if (it->get<0>().action == action) { + if (it->request.action == action) { has_action = true; break; } if (!has_action) - list.push_back(make_tuple(action, KeySequence(0, 0), tag)); + list.push_back(Binding(FuncRequest(action), KeySequence(0, 0), tag)); } } return list; @@ -519,7 +518,7 @@ void KeyMap::listBindings(BindingList & list, } else { KeySequence seq = prefix; seq.addkey(it->code, it->mod.first); - list.push_back(make_tuple(it->func, seq, tag)); + list.push_back(Binding(it->func, seq, tag)); } } } diff --git a/src/KeyMap.h b/src/KeyMap.h index f52fabb425..b9f8b28641 100644 --- a/src/KeyMap.h +++ b/src/KeyMap.h @@ -15,14 +15,11 @@ #define KEYMAP_H #include "FuncRequest.h" - -#include "frontends/KeyModifier.h" -#include "frontends/KeySymbol.h" +#include "KeySequence.h" #include "support/strfwd.h" #include -#include #include #include @@ -30,8 +27,6 @@ namespace lyx { -class KeySequence; - /// Defines key maps and actions for key sequences class KeyMap { public: @@ -104,7 +99,13 @@ public: /// Given an action, print the keybindings. docstring const printbindings(FuncRequest const & func) const; - typedef boost::tuple Binding; + struct Binding { + Binding(FuncRequest const & r, KeySequence const & s, int t) + : request(r), sequence(s), tag(t) {} + FuncRequest request; + KeySequence sequence; + int tag; + }; typedef std::vector BindingList; /** * Return all lfun and their associated bindings. diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 7ebc2b381a..5d09c1fa4f 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -61,6 +61,8 @@ #include #include +#include + #include #include #include @@ -1831,8 +1833,7 @@ void PrefShortcuts::updateShortcutsTW() KeyMap::BindingList::const_iterator it = bindinglist.begin(); KeyMap::BindingList::const_iterator it_end = bindinglist.end(); for (; it != it_end; ++it) - insertShortcutItem(it->get<0>(), it->get<1>(), - static_cast(it->get<2>())); + insertShortcutItem(it->request, it->sequence, item_type(it->tag)); shortcutsTW->sortItems(0, Qt::AscendingOrder); QList items = shortcutsTW->selectedItems(); @@ -1920,7 +1921,7 @@ QTreeWidgetItem * PrefShortcuts::insertShortcutItem(FuncRequest const & lfun, newItem->setText(0, lfun_name); newItem->setText(1, shortcut); // record BindFile representation to recover KeySequence when needed. - newItem->setData(1, Qt::UserRole, QVariant(toqstr(seq.print(KeySequence::BindFile)))); + newItem->setData(1, Qt::UserRole, toqstr(seq.print(KeySequence::BindFile))); setItemType(newItem, item_tag); return newItem; } -- 2.39.2