/**
* \file QLyXKeySym.C
- * Copyright 2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
* \author Asger and Juergen
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
*/
#include <config.h>
#include "QLyXKeySym.h"
#include "qlkey.h"
#include "debug.h"
-
+
+#include <qevent.h>
+
+using std::endl;
+
+
QLyXKeySym::QLyXKeySym()
- : LyXKeySym(), key_(0), shift_(false)
+ : LyXKeySym(), key_(0)
{
}
-
-
-void QLyXKeySym::set(int key, bool shift)
+
+
+void QLyXKeySym::set(QKeyEvent * ev)
{
- key_ = key;
- shift_ = shift;
+ key_ = ev->key();
+ text_ = ev->text();
}
-
+
void QLyXKeySym::init(string const & symbolname)
{
key_ = string_to_qkey(symbolname);
+ text_ = symbolname.c_str();
+ lyxerr[Debug::KEY] << "Init key to " << key_ << ", " << text_ << endl;
}
-
+
bool QLyXKeySym::isOK() const
{
- // FIXME
- return key_ != 0;
+ return ! key_ == 0;
}
-
+
bool QLyXKeySym::isModifier() const
{
return q_is_modifier(key_);
}
-
+
string QLyXKeySym::getSymbolName() const
{
- return qkey_to_string(key_, shift_);
+ string sym(qkey_to_string(key_));
+
+ if (sym.empty()) {
+ lyxerr[Debug::KEY] << "sym empty in getSymbolName()" << endl;
+ sym = text_.latin1();
+ }
+ lyxerr[Debug::KEY] << "getSymbolName() -> " << sym << endl;
+ return sym;
}
-
+
char QLyXKeySym::getISOEncoded() const
{
- /* Even though we could try to use QKeyEvent->text(),
- * it won't work, because it returns something other
- * than 'Z' for things like C-S-z. Do not ask me why,
- * just more Qt bullshit.
- */
- return qkey_to_char(key_, shift_);
+ lyxerr[Debug::KEY] << "getISO returning " << text_.latin1()[0] << endl;
+ return text_.latin1()[0];
}
-
-bool QLyXKeySym::operator==(LyXKeySym const & k) const
+
+bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
{
- QLyXKeySym const & o = static_cast<QLyXKeySym const &>(k);
- return o.key_ == key_;
+ // note we ignore text_ here (non-strict ==), because
+ // text_ is not filled out by keymap initialisation
+
+ return static_cast<QLyXKeySym const &>(k1).key()
+ == static_cast<QLyXKeySym const &>(k2).key();
+
}