-----BEGIN PGP SIGNED MESSAGE-----

On Sonntag, 8. Dezember 2002 18:43, Lars Gullik Bj�nnes wrote:
> Kornel Benko <[EMAIL PROTECTED]> writes:
> | Index: QLyXKeySym.C
> | ===================================================================
> | RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/QLyXKeySym.C,v
> | retrieving revision 1.10
> | diff -u -r1.10 QLyXKeySym.C
> | --- QLyXKeySym.C    2002/10/20 01:48:27     1.10
> | +++ QLyXKeySym.C    2002/12/08 16:51:53
> | @@ -33,7 +33,29 @@
> |  void QLyXKeySym::set(QKeyEvent * ev)
> |  {
> |     key_ = ev->key();
> | -   text_ = ev->text();
> | +   {
>
> Why this extra block?

I was trying to make my changes visible to me, while testing.

>
> | +       QString s = ev->text();
> | +       lyxerr[Debug::KEY] << " unicode of key is";
> | +       for (int i = 0; i < s.length(); i++) {
>
> i++ -> ++i

Matter of taste here ...
OK.

> | +           QChar a = s.ref(i);
>
> const it?

OK

> | +           lyxerr[Debug::KEY] << " " << (int) a ;
>
> " " -> ' '
> (int)a -> int(a)

OK.

> | +       }
> | +       if (s.length() > 0) {
>
> if !s.empty()
> (I guess this is some isEmpty() in QT speach.)

Yes.

> | +           lyxerr[Debug::KEY] << " ascii == " << ev->ascii();
> | +       }
> | +       lyxerr[Debug::KEY] << endl;
> | +       if ((s.length() == 1) && ( key_ == 65535)) {
>
> Is it possible to use a symbolic name for 65535? Instead of this magic
> number?

I dont't have one. I observed this number for all latin-2 chars.
(maybe Key_unknown from qnamespace.h is related)

... Yes it is ...


> | +           if ((int) s.ref(0) == 0) {
>
> s.ref(0) == QChar(0)
> would look better to me.

Yes. But it doesn't work. (I tried!)

> | +               char xx[2];
> | +               xx[0] = ev->ascii();
> | +               xx[1] = '\0';
> | +               s = xx;
>
> Can't
>
> s = ev->ascii()
>
> be used?
> (why not?)


        int QKeyEvent::ascii() const
is not char. I was unsure. But your version seems to work.

...

So, next patch attached.

        Kornel

- -- 
Kornel Benko
[EMAIL PROTECTED]
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8

iQCVAwUBPfOXALewfbDGmeqhAQH3ngQA23w6sx3bK2dPhViZrZ/VtdzztyL3wcT2
hk1XGL02HprCuzuyCAdIthEWowj5x0RIRSrrrEWc4wm8P4IyWmfC8PcM+AJwcU3D
TmAydPi8Z5cCrnLRQh2uWGaAuWmoHfrxWgpEaeGwKnaEH+g2y0I7T+BdDFikGV3F
jzI7YCwWUEQ=
=nZie
-----END PGP SIGNATURE-----
Index: QLyXKeySym.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/QLyXKeySym.C,v
retrieving revision 1.10
diff -u -r1.10 QLyXKeySym.C
--- QLyXKeySym.C	2002/10/20 01:48:27	1.10
+++ QLyXKeySym.C	2002/12/08 18:55:24
@@ -33,7 +33,26 @@
 void QLyXKeySym::set(QKeyEvent * ev)
 {
 	key_ = ev->key();
-	text_ = ev->text();
+	{
+	    QString s = ev->text();
+	    lyxerr[Debug::KEY] << " unicode of key is";
+	    for (int i = 0; i < s.length(); ++i) {
+		QChar const a = s.ref(i);
+		lyxerr[Debug::KEY] << " " << int(a);
+	    }
+	    if (!s.isEmpty()) {
+	    	lyxerr[Debug::KEY] << " ascii == " << ev->ascii();
+	    }
+	    lyxerr[Debug::KEY] << endl;
+	    if ((s.length() == 1) && ( key_ == Qt::Key_unknown)) {
+		if ((int) s.ref(0) == 0) {
+		    s = ev->ascii();
+		    key_ = 0;
+		}
+	    }
+	    text_ = s;
+	}
+	lyxerr[Debug::KEY] << "Setting key to " << key_ << ", " <<  text_.latin1() << endl;
 }
 
 
@@ -41,19 +60,23 @@
 {
 	key_ = string_to_qkey(symbolname);
 	text_ = symbolname.c_str();
-	lyxerr[Debug::KEY] << "Init key to " << key_ << ", " << text_ << endl;
+	lyxerr[Debug::KEY] << "Init key to " << key_ << ", " << text_.latin1() << endl;
 }
 
 
 bool QLyXKeySym::isOK() const
 {
-	return ! key_ == 0;
+	bool const ok(!(text_.isEmpty() && key_ == Qt::Key_unknown));
+	lyxerr[Debug::KEY] << "isOK is " << ok << endl;
+	return ok;
 }
-
 
+ 
 bool QLyXKeySym::isModifier() const
 {
-	return q_is_modifier(key_);
+	bool const mod(q_is_modifier(key_));
+	lyxerr[Debug::KEY] << "isMod is " << mod << endl;
+	return mod;
 }
 
 
@@ -63,7 +86,10 @@
 
 	if (sym.empty()) {
 		lyxerr[Debug::KEY] << "sym empty in getSymbolName()" << endl;
-		sym = text_.latin1();
+		if (!text_.isEmpty())
+		    sym = text_.latin1();
+		else
+		    sym = "none";
 	}
 	lyxerr[Debug::KEY] << "getSymbolName() -> " << sym << endl;
 	return sym;
@@ -77,6 +103,20 @@
 }
 
 
+bool QLyXKeySym::isText() const
+{
+	if (text_.isEmpty()) {
+		lyxerr[Debug::KEY] << "text_ empty, isText() == false" << endl;
+		return false;
+	}
+
+	QChar const c(text_[0]);
+	lyxerr[Debug::KEY] << "isText for key " << key_ 
+		<< " isPrint is " << c.isPrint() << endl;
+	return c.isPrint();
+}
+
+ 
 bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
 {
 	// note we ignore text_ here (non-strict ==), because

Reply via email to