]> git.lyx.org Git - features.git/commitdiff
rename LyXKeySym into KeySymbol
authorAndré Pönitz <poenitz@gmx.net>
Fri, 27 Apr 2007 08:43:38 +0000 (08:43 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 27 Apr 2007 08:43:38 +0000 (08:43 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18059 a592a061-630c-0410-9148-cb99ea01b6c8

21 files changed:
src/KeyMap.cpp
src/KeyMap.h
src/KeySequence.cpp
src/KeySequence.h
src/LyXFunc.cpp
src/LyXFunc.h
src/frontends/KeySymbol.h [new file with mode: 0644]
src/frontends/LyXKeySym.h [deleted file]
src/frontends/LyXKeySymFactory.h [deleted file]
src/frontends/Makefile.am
src/frontends/WorkArea.cpp
src/frontends/WorkArea.h
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/KeySymbol.cpp [new file with mode: 0644]
src/frontends/qt4/LyXKeySymFactory.cpp [deleted file]
src/frontends/qt4/Makefile.am
src/frontends/qt4/QKeySymbol.cpp [new file with mode: 0644]
src/frontends/qt4/QKeySymbol.h [new file with mode: 0644]
src/frontends/qt4/QLyXKeySym.cpp [deleted file]
src/frontends/qt4/QLyXKeySym.h [deleted file]

index bef688fe54eb3d383119304944a05cd4ec62e89a..a9bcb596227c1540154b0cb744ad25dfdc44d4ea 100644 (file)
@@ -20,7 +20,7 @@
 #include "LyXAction.h"
 #include "Lexer.h"
 
-#include "frontends/LyXKeySym.h"
+#include "frontends/KeySymbol.h"
 
 #include "support/filetools.h"
 
@@ -36,7 +36,7 @@ using std::endl;
 using std::string;
 
 
-string const KeyMap::printKeySym(LyXKeySym const & key,
+string const KeyMap::printKeySym(KeySymbol const & key,
                                    key_modifier::state mod)
 {
        string buf;
@@ -171,7 +171,7 @@ bool KeyMap::read(string const & bind_file)
 
 
 FuncRequest const &
-KeyMap::lookup(LyXKeySymPtr key,
+KeyMap::lookup(KeySymbolPtr key,
                  key_modifier::state mod, KeySequence * seq) const
 {
        static FuncRequest const unknown(LFUN_UNKNOWN_ACTION);
@@ -226,7 +226,7 @@ docstring const KeyMap::print(bool forgui) const
 
 void KeyMap::defkey(KeySequence * seq, FuncRequest const & func, unsigned int r)
 {
-       LyXKeySymPtr code = seq->sequence[r];
+       KeySymbolPtr code = seq->sequence[r];
        if (!code->isOK())
                return;
 
@@ -322,7 +322,7 @@ KeyMap::Bindings KeyMap::findbindings(FuncRequest const & func,
 }
 
 
-std::pair<LyXKeySym const *, key_modifier::state>
+std::pair<KeySymbol const *, key_modifier::state>
 KeyMap::find1keybinding(FuncRequest const & func) const
 {
        Table::const_iterator end = table.end();
@@ -332,7 +332,7 @@ KeyMap::find1keybinding(FuncRequest const & func) const
                        return std::make_pair(cit->code.get(), cit->mod.first);
        }
 
-       return std::make_pair<LyXKeySym const *, key_modifier::state>(0, key_modifier::none);
+       return std::make_pair<KeySymbol const *, key_modifier::state>(0, key_modifier::none);
 }
 
 
index eaf1006e40819d06f0eabbe0d03743cbd2874d0a..8cd372881e390200e6fa2579f07cc8e2f1d02bf0 100644 (file)
@@ -17,7 +17,7 @@
 #include "FuncRequest.h"
 
 #include "frontends/key_state.h"
-#include "frontends/LyXKeySym.h"
+#include "frontends/KeySymbol.h"
 
 #include "support/docstream.h"
 
@@ -60,7 +60,7 @@ public:
         * @return the action / LFUN_COMMAND_PREFIX / LFUN_UNKNOWN_ACTION
         */
        FuncRequest const &
-       lookup(LyXKeySymPtr key,
+       lookup(KeySymbolPtr key,
               key_modifier::state mod, KeySequence * seq) const;
 
        ///
@@ -74,10 +74,10 @@ public:
 
        /**
         *  Given an action, find the first 1-key binding (if it exists).
-        *  The LyXKeySym pointer is 0 is no key is found.
+        *  The KeySymbol pointer is 0 is no key is found.
         *  [only used by the Qt/Mac frontend]
         */
-       std::pair<LyXKeySym const *, key_modifier::state>
+       std::pair<KeySymbol const *, key_modifier::state>
        find1keybinding(FuncRequest const & func) const;
 
 
@@ -86,7 +86,7 @@ public:
         * @param key the key as a keysym
         * @param mod the modifiers
         */
-       static std::string const printKeySym(LyXKeySym const & key,
+       static std::string const printKeySym(KeySymbol const & key,
                                             key_modifier::state mod);
 
        typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
@@ -95,7 +95,7 @@ private:
        ///
        struct Key {
                /// Keysym
-               LyXKeySymPtr code;
+               KeySymbolPtr code;
 
                /// Modifier masks
                modifier_pair mod;
index c13c41ecdfaf08c81665fafd7323111db7236864..9f25e9b0ab89e7615b4854d4f11670605e87d4ba 100644 (file)
@@ -18,8 +18,7 @@
 #include "KeyMap.h"
 #include "lfuns.h"
 
-#include "frontends/LyXKeySym.h"
-#include "frontends/LyXKeySymFactory.h"
+#include "frontends/KeySymbol.h"
 
 
 namespace lyx {
@@ -29,7 +28,7 @@ using std::string;
 
 
 FuncRequest const &
-KeySequence::addkey(LyXKeySymPtr key,
+KeySequence::addkey(KeySymbolPtr key,
                    key_modifier::state mod, key_modifier::state nmod)
 {
        // adding a key to a deleted sequence
@@ -108,7 +107,7 @@ size_t KeySequence::parse(string const & s)
                        for (; j < s.length() && s[j] != ' '; ++j)
                                tbuf += s[j];    // (!!!check bounds :-)
 
-                       LyXKeySymPtr key(LyXKeySymFactory::create());
+                       KeySymbolPtr key(createKeySymbol());
                        key->init(tbuf);
 
                        if (!key->isOK())
index 3aead2826c1cd0ad7d38b6771381e9e77aa5e8cd..7774f0a0ab6140233fd41f01de1ba70078266eae 100644 (file)
@@ -14,7 +14,7 @@
 #define KB_SEQUENCE_H
 
 #include "frontends/key_state.h"
-#include "frontends/LyXKeySym.h"
+#include "frontends/KeySymbol.h"
 
 #include <string>
 #include <vector>
@@ -28,7 +28,7 @@ class FuncRequest;
 /// Holds a key sequence and the current and standard keymaps
 class KeySequence {
 public:
-       typedef std::vector<LyXKeySymPtr> Sequence;
+       typedef std::vector<KeySymbolPtr> Sequence;
 
        friend class KeyMap;
 
@@ -45,7 +45,7 @@ public:
         * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
         */
        FuncRequest const &
-       addkey(LyXKeySymPtr keysym, key_modifier::state mod,
+       addkey(KeySymbolPtr keysym, key_modifier::state mod,
               key_modifier::state nmod = key_modifier::none);
 
        /**
index cf78d142342b17b48bf96f315934f5bc5edf72a5..1ea7b4acfc9d4d6f74ef30c90023339e392b79fa 100644 (file)
@@ -80,7 +80,7 @@
 #include "frontends/FileDialog.h"
 #include "frontends/FontLoader.h"
 #include "frontends/Gui.h"
-#include "frontends/LyXKeySym.h"
+#include "frontends/KeySymbol.h"
 #include "frontends/LyXView.h"
 #include "frontends/Menubar.h"
 #include "frontends/Toolbars.h"
@@ -275,7 +275,7 @@ void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
 }
 
 
-void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
+void LyXFunc::processKeySym(KeySymbolPtr keysym, key_modifier::state state)
 {
        LYXERR(Debug::KEY) << "KeySym is " << keysym->getSymbolName() << endl;
 
index 12e9ce3e0406e72c412b880880a06d12f89dcf7a..f532cc1073d936772e1a8c483818a783167a9dd9 100644 (file)
@@ -28,7 +28,7 @@ namespace lyx {
 class BufferView;
 class FuncRequest;
 class FuncStatus;
-class LyXKeySym;
+class KeySymbol;
 class LyXText;
 class LyXView;
 
@@ -57,7 +57,7 @@ public:
        docstring const viewStatusMessage();
 
        ///
-       void processKeySym(LyXKeySymPtr key, key_modifier::state state);
+       void processKeySym(KeySymbolPtr key, key_modifier::state state);
 
        ///
        FuncStatus getStatus(FuncRequest const & action) const;
diff --git a/src/frontends/KeySymbol.h b/src/frontends/KeySymbol.h
new file mode 100644 (file)
index 0000000..359ef3d
--- /dev/null
@@ -0,0 +1,82 @@
+// -*- C++ -*-
+/**
+ * \file KeySymbol.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Asger and Jürgen
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef KEYSYMBOL_H
+#define KEYSYMBOL_H
+
+#include <string>
+
+#include "key_state.h"
+
+#include "support/docstring.h"
+
+#include <boost/shared_ptr.hpp>
+
+
+namespace lyx {
+
+/**
+ * This is a base class for representing a keypress.
+ * Each frontend has to implement this to provide
+ * the functionality that LyX needs in regards to
+ * key presses.
+ */
+class KeySymbol {
+public:
+       KeySymbol() {}
+
+       virtual ~KeySymbol() {}
+
+       ///
+       virtual bool operator==(KeySymbol const& ks) const = 0;
+
+       /// Initialize with the name of a key. F. ex. "space" or "a"
+       virtual void init(std::string const & symbolname) = 0;
+
+       /// Is this a valid key?
+       virtual bool isOK() const = 0;
+
+       /// Is this a modifier key only?
+       virtual bool isModifier() const = 0;
+
+       /// Is this normal insertable text ? (last ditch attempt only)
+       virtual bool isText() const = 0;
+
+       /// What is the symbolic name of this key? F.ex. "Return" or "c"
+       virtual std::string getSymbolName() const = 0;
+
+       /**
+        * Return the value of the keysym into the UCS-4 encoding.
+        * This converts the KeySymbol to a 32-bit encoded character.
+        */
+       virtual char_type getUCSEncoded() const = 0;
+
+       /**
+        * Return a string describing the KeySym with modifier mod.
+        * Use the native UI format when \c forgui is true.
+        */
+       virtual docstring const print(key_modifier::state mod, bool forgui) const = 0;
+};
+
+
+typedef boost::shared_ptr<KeySymbol> KeySymbolPtr;
+
+
+/**
+ * Make a KeySymbol. Used because we want to
+ * generate a toolkit-specific instance.
+ */
+KeySymbol * createKeySymbol();
+
+
+} // namespace lyx
+
+#endif
diff --git a/src/frontends/LyXKeySym.h b/src/frontends/LyXKeySym.h
deleted file mode 100644 (file)
index 23ab01b..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-// -*- C++ -*-
-/**
- * \file LyXKeySym.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Asger and Jürgen
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef LYXKEYSYM_H
-#define LYXKEYSYM_H
-
-#include <string>
-
-#include "key_state.h"
-
-#include "support/docstring.h"
-
-#include <boost/shared_ptr.hpp>
-
-
-namespace lyx {
-
-/**
- * This is a base class for representing a keypress.
- * Each frontend has to implement this to provide
- * the functionality that LyX needs in regards to
- * key presses.
- */
-class LyXKeySym {
-public:
-       LyXKeySym() {}
-
-       virtual ~LyXKeySym() {}
-
-       ///
-       virtual bool operator==(LyXKeySym const& ks) const = 0;
-
-       /// Initialize with the name of a key. F. ex. "space" or "a"
-       virtual void init(std::string const & symbolname) = 0;
-
-       /// Is this a valid key?
-       virtual bool isOK() const = 0;
-
-       /// Is this a modifier key only?
-       virtual bool isModifier() const = 0;
-
-       /// Is this normal insertable text ? (last ditch attempt only)
-       virtual bool isText() const = 0;
-
-       /// What is the symbolic name of this key? F.ex. "Return" or "c"
-       virtual std::string getSymbolName() const = 0;
-
-       /**
-        * Return the value of the keysym into the UCS-4 encoding.
-        * This converts the LyXKeySym to a 32-bit encoded character.
-        */
-       virtual char_type getUCSEncoded() const = 0;
-
-       /**
-        * Return a string describing the KeySym with modifier mod.
-        * Use the native UI format when \c forgui is true.
-        */
-       virtual docstring const print(key_modifier::state mod, bool forgui) const = 0;
-};
-
-
-typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
-
-
-} // namespace lyx
-
-#endif
diff --git a/src/frontends/LyXKeySymFactory.h b/src/frontends/LyXKeySymFactory.h
deleted file mode 100644 (file)
index 585a8a5..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// -*- C++ -*-
-/**
- * \file LyXKeySymFactory.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Asger & Jürgen
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef LYXKEYSYMFACTORY_H
-#define LYXKEYSYMFACTORY_H
-
-namespace lyx {
-
-class LyXKeySym;
-
-namespace LyXKeySymFactory {
-       /**
-        * Make a LyXKeySym. Used because we want to
-        * generate a toolkit-specific instance.
-        */
-       LyXKeySym * create();
-}
-
-} // namespace lyx
-
-#endif // LYXKEYSYM_FACTORY_H
index 791c4545f1d8b6f60f12a61baf4604dfe1298c01..a8b4a6024ac473ffa214c4bab7f72054aa531e49 100644 (file)
@@ -25,8 +25,8 @@ libfrontends_la_SOURCES = \
        FileDialog.h \
        FontLoader.h \
        FontMetrics.h \
-       LyXKeySym.h \
-       LyXKeySymFactory.h \
+       KeySymbol.h \
+       KeySymbolFactory.h \
        LyXView.cpp \
        LyXView.h \
        Menubar.h \
index c428821135b785f5fb565e2ff9675d32d39a826b..191a2179dc27dacd96d5ec74a09ae5d64c1a8eee 100644 (file)
@@ -165,7 +165,7 @@ void WorkArea::redraw()
 }
 
 
-void WorkArea::processKeySym(LyXKeySymPtr key, key_modifier::state state)
+void WorkArea::processKeySym(KeySymbolPtr key, key_modifier::state state)
 {
        // In order to avoid bad surprise in the middle of an operation, we better stop
        // the blinking cursor.
index 12baf4321722eeee7fedf2ec3081abe2f9e37314..8b4ced60527bf89897c85b51315ae9e172b0ca8e 100644 (file)
@@ -15,7 +15,7 @@
 #define BASE_WORKAREA_H
 
 #include "frontends/key_state.h"
-#include "frontends/LyXKeySym.h"
+#include "frontends/KeySymbol.h"
 #include "frontends/Timeout.h"
 
 #include "support/docstring.h"
@@ -93,7 +93,7 @@ public:
 
        /// Process Key pressed event.
        /// This needs to be public because it is accessed externally by GuiView.
-       void processKeySym(LyXKeySymPtr key, key_modifier::state state);
+       void processKeySym(KeySymbolPtr key, key_modifier::state state);
 protected:
        /// cause the display of the given area of the work area
        virtual void expose(int x, int y, int w, int h) = 0;
index b28860bbc7638fcfcd145d121f7d61e86f6b4810..d0b6771b343102913c528803735e78a49b57ed91 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "GuiImplementation.h"
 #include "GuiWorkArea.h"
-#include "QLyXKeySym.h"
+#include "QKeySymbol.h"
 #include "QLMenubar.h"
 #include "QLToolbar.h"
 #include "QCommandBuffer.h"
@@ -650,7 +650,7 @@ bool GuiView::event(QEvent * e)
        if (e->type() == QEvent::ShortcutOverride) {
                QKeyEvent * ke = static_cast<QKeyEvent*>(e);
                if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
-                       boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
+                       boost::shared_ptr<QKeySymbol> sym(new QKeySymbol);
                        sym->set(ke);
                        BOOST_ASSERT(work_area_);
                        work_area_->processKeySym(sym, key_modifier::none);
index ff6764ec603163af1e8e44ab3e6cae9e24944dfb..f63d44c64bb4bbfdc612e825b2ce82a0377ecf75 100644 (file)
@@ -15,7 +15,7 @@
 
 #include "GuiApplication.h"
 #include "QLPainter.h"
-#include "QLyXKeySym.h"
+#include "QKeySymbol.h"
 #include "qt_helpers.h"
 
 #include "LyXView.h"
@@ -421,7 +421,7 @@ void GuiWorkArea::keyPressEvent(QKeyEvent * e)
                << " key=" << e->key()
                << endl;
 
-       boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
+       boost::shared_ptr<QKeySymbol> sym(new QKeySymbol);
        sym->set(e);
        processKeySym(sym, q_key_state(e->modifiers()));
 }
diff --git a/src/frontends/qt4/KeySymbol.cpp b/src/frontends/qt4/KeySymbol.cpp
new file mode 100644 (file)
index 0000000..b98b37a
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * \file qt4/KeySymbolFactory.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Asger & Jürgen
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "frontends/KeySymbol.h"
+
+#include "QKeySymbol.h"
+
+namespace lyx {
+
+KeySymbol * createKeySymbol()
+{
+       return new QKeySymbol;
+}
+
+} // namespace lyx
diff --git a/src/frontends/qt4/LyXKeySymFactory.cpp b/src/frontends/qt4/LyXKeySymFactory.cpp
deleted file mode 100644 (file)
index abff60d..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * \file qt4/LyXKeySymFactory.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Asger & Jürgen
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "frontends/LyXKeySymFactory.h"
-
-#include "QLyXKeySym.h"
-
-
-namespace lyx {
-
-namespace LyXKeySymFactory {
-
-LyXKeySym * create()
-{
-       return new QLyXKeySym;
-}
-
-} // namespace LyXKeySymFactory
-
-
-} // namespace lyx
index 62dae0778ea9ddecb7e05d05a07bd5b214a0a881..092d2968fbbdd5e1d6afca057a9d7e252cd62d49 100644 (file)
@@ -39,7 +39,7 @@ libqt4_la_SOURCES = \
        GuiFontLoader.h GuiFontLoader.cpp \
        GuiFontMetrics.h GuiFontMetrics.cpp \
        GuiSelection.h GuiSelection.cpp \
-       LyXKeySymFactory.cpp \
+       KeySymbol.cpp \
        QLMenubar.cpp QLMenubar.h \
        QBox.cpp QBox.h \
        QBranches.cpp QBranches.h \
@@ -50,7 +50,7 @@ libqt4_la_SOURCES = \
        QLImage.cpp QLImage.h \
        QViewSource.cpp QViewSource.h \
        QLPainter.cpp QLPainter.h \
-       QLyXKeySym.cpp QLyXKeySym.h \
+       QKeySymbol.cpp QKeySymbol.h \
        QPrint.cpp QPrint.h \
        Qt2BC.cpp       Qt2BC.h \
        CheckedLineEdit.cpp CheckedLineEdit.h \
diff --git a/src/frontends/qt4/QKeySymbol.cpp b/src/frontends/qt4/QKeySymbol.cpp
new file mode 100644 (file)
index 0000000..366b48e
--- /dev/null
@@ -0,0 +1,202 @@
+/**
+ * \file QKeySymbol.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Asger and Jürgen
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "QKeySymbol.h"
+#include "qlkey.h"
+#include "qt_helpers.h"
+
+
+#include "debug.h"
+
+#include <QKeyEvent>
+#include <QKeySequence>
+#include <QEvent>
+#include <QTextCodec>
+
+#include <map>
+#include "support/lstrings.h"
+#include "support/environment.h"
+#include "support/unicode.h"
+
+#include "Encoding.h"
+#include "Language.h"
+
+
+namespace lyx {
+
+using std::endl;
+using std::string;
+using std::map;
+using lyx::support::contains;
+using lyx::support::getEnv;
+
+
+namespace {
+
+typedef map<string, QTextCodec *> EncodingMap;
+EncodingMap encoding_map;
+
+char const encode(string const & encoding, QString const & str)
+{
+       QTextCodec * codec = 0;
+
+       EncodingMap::const_iterator cit = encoding_map.find(encoding);
+       if (cit == encoding_map.end()) {
+               LYXERR(Debug::KEY) << "Unrecognised encoding '" << encoding
+                                  << "'." << endl;
+               codec = encoding_map.find("")->second;
+       } else {
+               codec = cit->second;
+       }
+
+       if (!codec) {
+               LYXERR(Debug::KEY) << "No codec for encoding '" << encoding
+                                  << "' found." << endl;
+               return 0;
+       }
+
+       LYXERR(Debug::KEY) << "Using codec " << fromqstr(codec->name()) << endl;
+
+       if (!codec->canEncode(str)) {
+               LYXERR(Debug::KEY) << "Oof. Can't encode the text !" << endl;
+               return 0;
+       }
+
+       return codec->fromUnicode(str).data()[0];
+}
+
+}
+
+
+QKeySymbol::QKeySymbol()
+       : KeySymbol(), key_(0)
+{
+}
+
+
+void QKeySymbol::set(QKeyEvent * ev)
+{
+       key_ = ev->key();
+       if (ev->text().isNull()) {
+               LYXERR(Debug::KEY) << "keyevent has isNull() text !" << endl;
+               text_ = "";
+               return;
+       }
+       text_ = ev->text();
+       LYXERR(Debug::KEY) << "Setting key to " << key_ << ", " <<  fromqstr(text_) << endl;
+}
+
+
+void QKeySymbol::init(string const & symbolname)
+{
+       key_ = string_to_qkey(symbolname);
+       text_ = toqstr(symbolname);
+       LYXERR(Debug::KEY) << "Init key to " << key_ << ", " << fromqstr(text_) << endl;
+}
+
+
+bool QKeySymbol::isOK() const
+{
+       bool const ok(!(text_.isEmpty() && key_ == Qt::Key_unknown));
+       LYXERR(Debug::KEY) << "isOK is " << ok << endl;
+       return ok;
+}
+
+
+bool QKeySymbol::isModifier() const
+{
+       bool const mod(q_is_modifier(key_));
+       LYXERR(Debug::KEY) << "isMod is " << mod << endl;
+       return mod;
+}
+
+
+string QKeySymbol::getSymbolName() const
+{
+       string sym(qkey_to_string(key_));
+
+       // e.g. A-Za-z, and others
+       if (sym.empty())
+               sym = fromqstr(text_);
+
+       return sym;
+}
+
+
+char_type QKeySymbol::getUCSEncoded() const
+{
+       if (text_.isEmpty())
+               return 0;
+
+       // UTF16 has a maximum of two characters.
+       BOOST_ASSERT(text_.size() <= 2);
+
+       if (lyxerr.debugging() && text_.size() > 1) {
+               // We don't know yet how well support the full ucs4 range.
+               LYXERR(Debug::KEY) << "QKeySymbol::getUCSEncoded()" << endl;
+               for (int i = 0; i < text_.size(); ++i) {
+                       LYXERR(Debug::KEY) << "char " << i << ": "
+                               << text_[i].unicode() << endl;
+               }
+       }
+       
+       // Only one UCS4 character at the end.
+       docstring ucs4_text = qstring_to_ucs4(text_);
+       return ucs4_text[0];
+}
+
+
+docstring const QKeySymbol::print(key_modifier::state mod, bool forgui) const
+{
+       int tmpkey = key_;
+
+       if (mod & key_modifier::shift)
+               tmpkey += Qt::SHIFT;
+       if (mod & key_modifier::ctrl)
+               tmpkey += Qt::CTRL;
+       if (mod & key_modifier::alt)
+               tmpkey += Qt::ALT;
+       
+       QKeySequence seq(tmpkey);
+
+       return qstring_to_ucs4(seq.toString(forgui ? QKeySequence::NativeText 
+                                           : QKeySequence::PortableText));
+}
+
+
+bool QKeySymbol::isText() const
+{
+       if (text_.isEmpty()) {
+               LYXERR(Debug::KEY) << "text_ empty, isText() == false" << endl;
+               return false;
+       }
+
+       return true;
+}
+
+
+bool QKeySymbol::operator==(KeySymbol const & ks) const
+{
+       QKeySymbol const & qks = static_cast<QKeySymbol const &>(ks);
+
+       // we do not have enough info for a fair comparison, so return
+       // false. This works out OK because unknown text from Qt will
+       // get inserted anyway after the isText() check
+       if (key_ == Qt::Key_unknown || qks.key_ == Qt::Key_unknown)
+               return false;
+
+       return key_ == qks.key_;
+}
+
+
+} // namespace lyx
diff --git a/src/frontends/qt4/QKeySymbol.h b/src/frontends/qt4/QKeySymbol.h
new file mode 100644 (file)
index 0000000..edeff27
--- /dev/null
@@ -0,0 +1,87 @@
+// -*- C++ -*-
+/**
+ * \file QKeySymbol.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Asger and Jürgen
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QLYXKEYSYM_H
+#define QLYXKEYSYM_H
+
+#include "frontends/KeySymbol.h"
+
+#include <QString>
+#include <QKeyEvent>
+
+
+class QKeyEvent;
+
+namespace lyx {
+
+/**
+ * Qt-specific key press.
+ *
+ * This is some really sick stuff.
+ */
+class QKeySymbol : public KeySymbol {
+public:
+       QKeySymbol();
+
+       virtual ~QKeySymbol() {}
+
+       /// .
+       /// inlined out because of profiling results under linux when
+       /// opening a document.
+       inline bool operator==(KeySymbol const& ks) const;
+
+       /// delayed constructor
+       void set(QKeyEvent * ev);
+
+       /// set from a LyX symbolic name
+       virtual void init(std::string const & symbolname);
+
+       /// Is this a valid key?
+       virtual bool isOK() const;
+
+       /// Is this a modifier key only?
+       virtual bool isModifier() const;
+
+       /// return the LyX symbolic name
+       virtual std::string getSymbolName() const;
+
+       /// Is this normal insertable text ? (last ditch attempt only)
+       virtual bool isText() const;
+
+       /**
+        * Return the value of the keysym into the UCS-4 encoding.
+        * This converts the KeySymbol to a 32-bit encoded character.
+        */
+       virtual char_type getUCSEncoded() const;
+
+       /**
+        * Return a human-readable version of a key+modifier pair.
+        * This will be the GUI version (translated and with special
+        * characters for Mac OS X) when \c forgui is true.
+        */
+       virtual docstring const print(key_modifier::state mod, bool forgui) const;
+
+       ///
+       int key() const {
+               return key_;
+       }
+private:
+       /// the Qt sym value
+       int key_;
+       /// the event string value
+       QString text_;
+};
+
+
+} // namespace lyx
+
+#endif // QLYXKEYSYM_H
diff --git a/src/frontends/qt4/QLyXKeySym.cpp b/src/frontends/qt4/QLyXKeySym.cpp
deleted file mode 100644 (file)
index 3d61f9d..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/**
- * \file QLyXKeySym.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Asger and Jürgen
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "QLyXKeySym.h"
-#include "qlkey.h"
-#include "qt_helpers.h"
-
-
-#include "debug.h"
-
-#include <QKeyEvent>
-#include <QKeySequence>
-#include <QEvent>
-#include <QTextCodec>
-
-#include <map>
-#include "support/lstrings.h"
-#include "support/environment.h"
-#include "support/unicode.h"
-
-#include "Encoding.h"
-#include "Language.h"
-
-
-namespace lyx {
-
-using std::endl;
-using std::string;
-using std::map;
-using lyx::support::contains;
-using lyx::support::getEnv;
-
-
-namespace {
-
-typedef map<string, QTextCodec *> EncodingMap;
-EncodingMap encoding_map;
-
-char const encode(string const & encoding, QString const & str)
-{
-       QTextCodec * codec = 0;
-
-       EncodingMap::const_iterator cit = encoding_map.find(encoding);
-       if (cit == encoding_map.end()) {
-               LYXERR(Debug::KEY) << "Unrecognised encoding '" << encoding
-                                  << "'." << endl;
-               codec = encoding_map.find("")->second;
-       } else {
-               codec = cit->second;
-       }
-
-       if (!codec) {
-               LYXERR(Debug::KEY) << "No codec for encoding '" << encoding
-                                  << "' found." << endl;
-               return 0;
-       }
-
-       LYXERR(Debug::KEY) << "Using codec " << fromqstr(codec->name()) << endl;
-
-       if (!codec->canEncode(str)) {
-               LYXERR(Debug::KEY) << "Oof. Can't encode the text !" << endl;
-               return 0;
-       }
-
-       return codec->fromUnicode(str).data()[0];
-}
-
-}
-
-
-QLyXKeySym::QLyXKeySym()
-       : LyXKeySym(), key_(0)
-{
-}
-
-
-void QLyXKeySym::set(QKeyEvent * ev)
-{
-       key_ = ev->key();
-       if (ev->text().isNull()) {
-               LYXERR(Debug::KEY) << "keyevent has isNull() text !" << endl;
-               text_ = "";
-               return;
-       }
-       text_ = ev->text();
-       LYXERR(Debug::KEY) << "Setting key to " << key_ << ", " <<  fromqstr(text_) << endl;
-}
-
-
-void QLyXKeySym::init(string const & symbolname)
-{
-       key_ = string_to_qkey(symbolname);
-       text_ = toqstr(symbolname);
-       LYXERR(Debug::KEY) << "Init key to " << key_ << ", " << fromqstr(text_) << endl;
-}
-
-
-bool QLyXKeySym::isOK() const
-{
-       bool const ok(!(text_.isEmpty() && key_ == Qt::Key_unknown));
-       LYXERR(Debug::KEY) << "isOK is " << ok << endl;
-       return ok;
-}
-
-
-bool QLyXKeySym::isModifier() const
-{
-       bool const mod(q_is_modifier(key_));
-       LYXERR(Debug::KEY) << "isMod is " << mod << endl;
-       return mod;
-}
-
-
-string QLyXKeySym::getSymbolName() const
-{
-       string sym(qkey_to_string(key_));
-
-       // e.g. A-Za-z, and others
-       if (sym.empty())
-               sym = fromqstr(text_);
-
-       return sym;
-}
-
-
-char_type QLyXKeySym::getUCSEncoded() const
-{
-       if (text_.isEmpty())
-               return 0;
-
-       // UTF16 has a maximum of two characters.
-       BOOST_ASSERT(text_.size() <= 2);
-
-       if (lyxerr.debugging() && text_.size() > 1) {
-               // We don't know yet how well support the full ucs4 range.
-               LYXERR(Debug::KEY) << "QLyXKeySym::getUCSEncoded()" << endl;
-               for (int i = 0; i < text_.size(); ++i) {
-                       LYXERR(Debug::KEY) << "char " << i << ": "
-                               << text_[i].unicode() << endl;
-               }
-       }
-       
-       // Only one UCS4 character at the end.
-       docstring ucs4_text = qstring_to_ucs4(text_);
-       return ucs4_text[0];
-}
-
-
-docstring const QLyXKeySym::print(key_modifier::state mod, bool forgui) const
-{
-       int tmpkey = key_;
-
-       if (mod & key_modifier::shift)
-               tmpkey += Qt::SHIFT;
-       if (mod & key_modifier::ctrl)
-               tmpkey += Qt::CTRL;
-       if (mod & key_modifier::alt)
-               tmpkey += Qt::ALT;
-       
-       QKeySequence seq(tmpkey);
-
-       return qstring_to_ucs4(seq.toString(forgui ? QKeySequence::NativeText 
-                                           : QKeySequence::PortableText));
-}
-
-
-bool QLyXKeySym::isText() const
-{
-       if (text_.isEmpty()) {
-               LYXERR(Debug::KEY) << "text_ empty, isText() == false" << endl;
-               return false;
-       }
-
-       return true;
-}
-
-
-bool QLyXKeySym::operator==(LyXKeySym const & ks) const
-{
-       QLyXKeySym const & qks = static_cast<QLyXKeySym const &>(ks);
-
-       // we do not have enough info for a fair comparison, so return
-       // false. This works out OK because unknown text from Qt will
-       // get inserted anyway after the isText() check
-       if (key_ == Qt::Key_unknown || qks.key_ == Qt::Key_unknown)
-               return false;
-
-       return key_ == qks.key_;
-}
-
-
-} // namespace lyx
diff --git a/src/frontends/qt4/QLyXKeySym.h b/src/frontends/qt4/QLyXKeySym.h
deleted file mode 100644 (file)
index 69d6001..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-// -*- C++ -*-
-/**
- * \file QLyXKeySym.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Asger and Jürgen
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QLYXKEYSYM_H
-#define QLYXKEYSYM_H
-
-#include "frontends/LyXKeySym.h"
-
-#include <QString>
-#include <QKeyEvent>
-
-
-class QKeyEvent;
-
-namespace lyx {
-
-/**
- * Qt-specific key press.
- *
- * This is some really sick stuff.
- */
-class QLyXKeySym : public LyXKeySym {
-public:
-       QLyXKeySym();
-
-       virtual ~QLyXKeySym() {}
-
-       /// .
-       /// inlined out because of profiling results under linux when
-       /// opening a document.
-       inline bool operator==(LyXKeySym const& ks) const;
-
-       /// delayed constructor
-       void set(QKeyEvent * ev);
-
-       /// set from a LyX symbolic name
-       virtual void init(std::string const & symbolname);
-
-       /// Is this a valid key?
-       virtual bool isOK() const;
-
-       /// Is this a modifier key only?
-       virtual bool isModifier() const;
-
-       /// return the LyX symbolic name
-       virtual std::string getSymbolName() const;
-
-       /// Is this normal insertable text ? (last ditch attempt only)
-       virtual bool isText() const;
-
-       /**
-        * Return the value of the keysym into the UCS-4 encoding.
-        * This converts the LyXKeySym to a 32-bit encoded character.
-        */
-       virtual char_type getUCSEncoded() const;
-
-       /**
-        * Return a human-readable version of a key+modifier pair.
-        * This will be the GUI version (translated and with special
-        * characters for Mac OS X) when \c forgui is true.
-        */
-       virtual docstring const print(key_modifier::state mod, bool forgui) const;
-
-       ///
-       int key() const {
-               return key_;
-       }
-private:
-       /// the Qt sym value
-       int key_;
-       /// the event string value
-       QString text_;
-};
-
-
-} // namespace lyx
-
-#endif // QLYXKEYSYM_H