]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QLyXKeySym.C
Compilation fix.
[lyx.git] / src / frontends / qt2 / QLyXKeySym.C
1 /**
2  * \file QLyXKeySym.C
3  * Copyright 2002 the LyX Team
4  * Read the file COPYING
5  *
6  * \author Asger and Juergen
7  * \author John Levon <moz@compsoc.man.ac.uk>
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "QLyXKeySym.h"
17 #include "qlkey.h"
18 #include "debug.h"
19  
20 #include <qevent.h>
21
22 using std::endl;
23
24 QLyXKeySym::QLyXKeySym()
25         : LyXKeySym(), key_(0)
26 {
27 }
28  
29  
30 void QLyXKeySym::set(QKeyEvent * ev)
31 {
32         key_ = ev->key();
33         text_ = ev->text(); 
34 }
35  
36
37 void QLyXKeySym::init(string const & symbolname)
38 {
39         key_ = string_to_qkey(symbolname);
40         text_ = symbolname.c_str();
41         lyxerr[Debug::KEY] << "Init key to " << key_ << ", " << text_ << endl;
42 }
43
44  
45 bool QLyXKeySym::isOK() const
46 {
47         return ! key_ == 0;
48 }
49  
50
51 bool QLyXKeySym::isModifier() const
52 {
53         return q_is_modifier(key_);
54 }
55
56
57 string QLyXKeySym::getSymbolName() const
58 {
59         string sym(qkey_to_string(key_));
60
61         if (sym.empty()) {
62                 lyxerr[Debug::KEY] << "sym empty in getSymbolName()" << endl;
63                 sym = text_.latin1();
64         }
65         lyxerr[Debug::KEY] << "getSymbolName() -> " << sym << endl;
66         return sym;
67 }
68
69  
70 char QLyXKeySym::getISOEncoded() const
71 {
72         lyxerr[Debug::KEY] << "getISO returning " << text_.latin1()[0] << endl;
73         return text_.latin1()[0]; 
74 }
75  
76
77 bool QLyXKeySym::operator==(LyXKeySym const & k) const
78 {
79         QLyXKeySym const & o = static_cast<QLyXKeySym const &>(k);
80         // ignore text_ ! 
81         return o.key_ == key_;
82 }