]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QLyXKeySym.C
Lots and lots of little trivial bits.
[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 QLyXKeySym::QLyXKeySym()
27         : LyXKeySym(), key_(0)
28 {
29 }
30  
31  
32 void QLyXKeySym::set(QKeyEvent * ev)
33 {
34         key_ = ev->key();
35         text_ = ev->text(); 
36 }
37  
38
39 void QLyXKeySym::init(string const & symbolname)
40 {
41         key_ = string_to_qkey(symbolname);
42         text_ = symbolname.c_str();
43         lyxerr[Debug::KEY] << "Init key to " << key_ << ", " << text_ << endl;
44 }
45
46  
47 bool QLyXKeySym::isOK() const
48 {
49         return ! key_ == 0;
50 }
51  
52
53 bool QLyXKeySym::isModifier() const
54 {
55         return q_is_modifier(key_);
56 }
57
58
59 string QLyXKeySym::getSymbolName() const
60 {
61         string sym(qkey_to_string(key_));
62
63         if (sym.empty()) {
64                 lyxerr[Debug::KEY] << "sym empty in getSymbolName()" << endl;
65                 sym = text_.latin1();
66         }
67         lyxerr[Debug::KEY] << "getSymbolName() -> " << sym << endl;
68         return sym;
69 }
70
71  
72 char QLyXKeySym::getISOEncoded() const
73 {
74         lyxerr[Debug::KEY] << "getISO returning " << text_.latin1()[0] << endl;
75         return text_.latin1()[0]; 
76 }
77  
78
79 bool QLyXKeySym::operator==(LyXKeySym const & k) const
80 {
81         QLyXKeySym const & o = static_cast<QLyXKeySym const &>(k);
82         // ignore text_ ! 
83         return o.key_ == key_;
84 }