On Thu, Nov 21, 2002 at 09:18:55PM +0100, Juergen Spitzmueller wrote:

> OK, shove it in QUICKLY.

I'm still compiling. It's attached

regards
john

-- 
Khendon's Law: If the same point is made twice by the same person,
the thread is over.
Index: QLyXKeySym.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLyXKeySym.h,v
retrieving revision 1.8
diff -u -r1.8 QLyXKeySym.h
--- QLyXKeySym.h        20 Oct 2002 01:48:27 -0000      1.8
+++ QLyXKeySym.h        21 Nov 2002 20:35:14 -0000
@@ -56,10 +56,17 @@
         * This relies on user to use the right encoding.
         */
        virtual char getISOEncoded() const;
-       ///
+ 
+       /// return the Qt key code
        int key() const {
                return key_;
        }
+
+       /// return the text (if any)
+       QString text() const {
+               return text_;
+       }
+ 
 private:
        /// the Qt sym value
        int key_;
Index: QLyXKeySym.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLyXKeySym.C,v
retrieving revision 1.10
diff -u -r1.10 QLyXKeySym.C
--- QLyXKeySym.C        20 Oct 2002 01:48:27 -0000      1.10
+++ QLyXKeySym.C        21 Nov 2002 20:35:14 -0000
@@ -53,7 +53,7 @@
 
 bool QLyXKeySym::isModifier() const
 {
-       return q_is_modifier(key_);
+       return !text_.length() && q_is_modifier(key_);
 }
 
 
@@ -79,10 +79,27 @@
 
 bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
 {
-       // 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();
+       QLyXKeySym const & q1(static_cast<QLyXKeySym const &>(k1)); 
+       QLyXKeySym const & q2(static_cast<QLyXKeySym const &>(k2)); 
 
+       // This is painfully subtle. First, we cannot just compare
+       // text()s, because our kbmap handling cannot fill out text_
+       // field. And we cannot compare just key(), as every
+       // Qt::Key_unknown key will match (in the test case, German
+       // � on some keyboards will match with shift-tab (ISO_Left_tab)
+       // because both are unknown to Qt. However, German � *does*
+       // have a correct text(). So ...
+
+       if (q1.key() != q2.key())
+               return false;
+ 
+       // non-unknown are OK, they're differentiated already
+       if (q1.key() != Qt::Key_unknown)
+               return true;
+
+       // right. Both are unknown. Here we could have ISO_Left_tab
+       // compared against � or similar (which will have text() == "�".
+       // One of them will be the stored kbmap entry, with text() == ""
+       // So just compare text()s
+       return q1.text() == q2.text();
 }

Reply via email to