]> git.lyx.org Git - features.git/commitdiff
I wonder why boost::tuple is preferable over a simple struct.
authorAndré Pönitz <poenitz@gmx.net>
Fri, 2 Nov 2007 20:26:28 +0000 (20:26 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 2 Nov 2007 20:26:28 +0000 (20:26 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21388 a592a061-630c-0410-9148-cb99ea01b6c8

src/KeyMap.cpp
src/KeyMap.h
src/frontends/qt4/GuiPrefs.cpp

index 04a3bbcb338c4a615a81859b1565beb17a899023..89e1f488374fb752e7db489572ec611159ece6ed 100644 (file)
@@ -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));
                }
        }
 }
index f52fabb425d9bbeeb831cea8bf172745bb3b3856..b9f8b28641b4a4c184a140d4ca935f2b8bfbf849 100644 (file)
 #define KEYMAP_H
 
 #include "FuncRequest.h"
-
-#include "frontends/KeyModifier.h"
-#include "frontends/KeySymbol.h"
+#include "KeySequence.h"
 
 #include "support/strfwd.h"
 
 #include <boost/shared_ptr.hpp>
-#include <boost/tuple/tuple.hpp>
 
 #include <vector>
 #include <deque>
@@ -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<FuncRequest, KeySequence, int> 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<Binding> BindingList;
        /**
         * Return all lfun and their associated bindings.
index 7ebc2b381a63adeed47f5286d2a6711ea352224b..5d09c1fa4f7248b2c2394cbdc8a0e4072a1e9657 100644 (file)
@@ -61,6 +61,8 @@
 #include <QValidator>
 #include <QCloseEvent>
 
+#include <boost/tuple/tuple.hpp>
+
 #include <iomanip>
 #include <sstream>
 #include <algorithm>
@@ -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<item_type>(it->get<2>()));
+               insertShortcutItem(it->request, it->sequence, item_type(it->tag));
 
        shortcutsTW->sortItems(0, Qt::AscendingOrder);
        QList<QTreeWidgetItem*> 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;
 }