]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QLyXKeySym.C
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / QLyXKeySym.C
1 /**
2  * \file QLyXKeySym.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Asger and Juergen
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #include <config.h>
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include "QLyXKeySym.h"
19 #include "qlkey.h"
20 #include "debug.h"
21
22 #include <qevent.h>
23
24 using std::endl;
25
26
27 QLyXKeySym::QLyXKeySym()
28         : LyXKeySym(), key_(0)
29 {
30 }
31
32
33 void QLyXKeySym::set(QKeyEvent * ev)
34 {
35         key_ = ev->key();
36         text_ = ev->text();
37 }
38
39
40 void QLyXKeySym::init(string const & symbolname)
41 {
42         key_ = string_to_qkey(symbolname);
43         text_ = symbolname.c_str();
44         lyxerr[Debug::KEY] << "Init key to " << key_ << ", " << text_ << endl;
45 }
46
47
48 bool QLyXKeySym::isOK() const
49 {
50         return ! key_ == 0;
51 }
52
53
54 bool QLyXKeySym::isModifier() const
55 {
56         return q_is_modifier(key_);
57 }
58
59
60 string QLyXKeySym::getSymbolName() const
61 {
62         string sym(qkey_to_string(key_));
63
64         if (sym.empty()) {
65                 lyxerr[Debug::KEY] << "sym empty in getSymbolName()" << endl;
66                 sym = text_.latin1();
67         }
68         lyxerr[Debug::KEY] << "getSymbolName() -> " << sym << endl;
69         return sym;
70 }
71
72
73 char QLyXKeySym::getISOEncoded() const
74 {
75         lyxerr[Debug::KEY] << "getISO returning " << text_.latin1()[0] << endl;
76         return text_.latin1()[0];
77 }
78
79
80 bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
81 {
82         // note we ignore text_ here (non-strict ==), because
83         // text_ is not filled out by keymap initialisation
84
85         return static_cast<QLyXKeySym const &>(k1).key()
86                 == static_cast<QLyXKeySym const &>(k2).key();
87
88 }