3 * Copyright 2002 the LyX Team
4 * Read the file COPYING
6 * \author Asger and Juergen
7 * \author John Levon <moz@compsoc.man.ac.uk>
13 #pragma implementation
16 #include "QLyXKeySym.h"
22 QLyXKeySym::QLyXKeySym()
23 : LyXKeySym(), key_(0)
28 void QLyXKeySym::set(QKeyEvent * ev)
36 void QLyXKeySym::init(string const & symbolname)
38 key_ = string_to_qkey(symbolname);
39 text_ = symbolname.c_str();
41 lyxerr[Debug::KEY] << "Init key to " << key_ << ", " << text_ << endl;
45 bool QLyXKeySym::isOK() const
51 bool QLyXKeySym::isModifier() const
53 return q_is_modifier(key_);
57 // This is one ALMIGHTY hack. When you press C-S-z, you get
58 // "Press key 90 text "?", ascii "26"
59 // where text is meaningless. So we check specifically
60 // for this case ! (90 is 'Z')
61 // We also check against 0 for when we're comparing
62 // against a stored binding.
63 bool QLyXKeySym::is_qt_bogon() const
67 return (ascii_ < 27 && !text_.isEmpty());
71 char QLyXKeySym::debogonify() const
73 return 'A' + ascii_ - 1;
77 string QLyXKeySym::getSymbolName() const
79 string sym(qkey_to_string(key_));
81 // deal with "A", "a" properly
83 lyxerr[Debug::KEY] << "sym empty in getSymbolName()" << endl;
91 lyxerr[Debug::KEY] << "getSymbolName() -> " << sym << endl;
96 char QLyXKeySym::getISOEncoded() const
98 lyxerr[Debug::KEY] << "getISO returning " << text_.latin1()[0] << endl;
104 return text_.latin1()[0];
108 bool QLyXKeySym::operator==(LyXKeySym const & k) const
110 QLyXKeySym const & o = static_cast<QLyXKeySym const &>(k);
112 return o.key_ == key_;