Index: trunk/BNC/qwt/qwt_event_pattern.cpp
===================================================================
--- trunk/BNC/qwt/qwt_event_pattern.cpp	(revision 4271)
+++ trunk/BNC/qwt/qwt_event_pattern.cpp	(revision 8127)
@@ -38,8 +38,4 @@
 void QwtEventPattern::initMousePattern( int numButtons )
 {
-    const int altButton = Qt::AltModifier;
-    const int controlButton = Qt::ControlModifier;
-    const int shiftButton = Qt::ShiftModifier;
-
     d_mousePattern.resize( MousePatternCount );
 
@@ -49,6 +45,6 @@
         {
             setMousePattern( MouseSelect1, Qt::LeftButton );
-            setMousePattern( MouseSelect2, Qt::LeftButton, controlButton );
-            setMousePattern( MouseSelect3, Qt::LeftButton, altButton );
+            setMousePattern( MouseSelect2, Qt::LeftButton, Qt::ControlModifier );
+            setMousePattern( MouseSelect3, Qt::LeftButton, Qt::AltModifier );
             break;
         }
@@ -57,5 +53,5 @@
             setMousePattern( MouseSelect1, Qt::LeftButton );
             setMousePattern( MouseSelect2, Qt::RightButton );
-            setMousePattern( MouseSelect3, Qt::LeftButton, altButton );
+            setMousePattern( MouseSelect3, Qt::LeftButton, Qt::AltModifier );
             break;
         }
@@ -67,10 +63,13 @@
         }
     }
-    for ( int i = 0; i < 3; i++ )
-    {
-        setMousePattern( MouseSelect4 + i,
-                         d_mousePattern[MouseSelect1 + i].button,
-                         d_mousePattern[MouseSelect1 + i].state | shiftButton );
-    }
+
+    setMousePattern( MouseSelect4, d_mousePattern[MouseSelect1].button,
+        d_mousePattern[MouseSelect1].modifiers | Qt::ShiftModifier );
+
+    setMousePattern( MouseSelect5, d_mousePattern[MouseSelect2].button,
+        d_mousePattern[MouseSelect2].modifiers | Qt::ShiftModifier );
+
+    setMousePattern( MouseSelect6, d_mousePattern[MouseSelect3].button,
+        d_mousePattern[MouseSelect3].modifiers | Qt::ShiftModifier );
 }
 
@@ -103,14 +102,15 @@
   \param pattern Index of the pattern
   \param button Button
-  \param state State
+  \param modifiers Keyboard modifiers
 
   \sa QMouseEvent
 */
-void QwtEventPattern::setMousePattern( uint pattern, int button, int state )
-{
-    if ( pattern < ( uint )d_mousePattern.count() )
+void QwtEventPattern::setMousePattern( MousePatternCode pattern, 
+    Qt::MouseButton button, Qt::KeyboardModifiers modifiers )
+{
+    if ( pattern >= 0 && pattern < MousePatternCount )
     {
-        d_mousePattern[int( pattern )].button = button;
-        d_mousePattern[int( pattern )].state = state;
+        d_mousePattern[ pattern ].button = button;
+        d_mousePattern[ pattern ].modifiers = modifiers;
     }
 }
@@ -121,14 +121,15 @@
   \param pattern Index of the pattern
   \param key Key
-  \param state State
+  \param modifiers Keyboard modifiers
 
   \sa QKeyEvent
 */
-void QwtEventPattern::setKeyPattern( uint pattern, int key, int state )
-{
-    if ( pattern < ( uint )d_keyPattern.count() )
+void QwtEventPattern::setKeyPattern( KeyPatternCode pattern, 
+    int key, Qt::KeyboardModifiers modifiers )
+{
+    if ( pattern >= 0 && pattern < KeyPatternCount )
     {
-        d_keyPattern[int( pattern )].key = key;
-        d_keyPattern[int( pattern )].state = state;
+        d_keyPattern[ pattern ].key = key;
+        d_keyPattern[ pattern ].modifiers = modifiers;
     }
 }
@@ -146,5 +147,5 @@
 }
 
-//! Return mouse patterns
+//! \return Mouse pattern
 const QVector<QwtEventPattern::MousePattern> &
 QwtEventPattern::mousePattern() const
@@ -153,5 +154,5 @@
 }
 
-//! Return key patterns
+//! \return Key pattern
 const QVector<QwtEventPattern::KeyPattern> &
 QwtEventPattern::keyPattern() const
@@ -160,5 +161,5 @@
 }
 
-//! Return ,ouse patterns
+//! \return Mouse pattern
 QVector<QwtEventPattern::MousePattern> &QwtEventPattern::mousePattern()
 {
@@ -166,5 +167,5 @@
 }
 
-//! Return Key patterns
+//! \return Key pattern
 QVector<QwtEventPattern::KeyPattern> &QwtEventPattern::keyPattern()
 {
@@ -179,5 +180,5 @@
   are set.
 
-  \param pattern Index of the event pattern
+  \param code Index of the event pattern
   \param event Mouse event
   \return true if matches
@@ -185,13 +186,11 @@
   \sa keyMatch()
 */
-bool QwtEventPattern::mouseMatch( uint pattern, 
+bool QwtEventPattern::mouseMatch( MousePatternCode code, 
     const QMouseEvent *event ) const
 {
-    bool ok = false;
-
-    if ( event && pattern < ( uint )d_mousePattern.count() )
-        ok = mouseMatch( d_mousePattern[int( pattern )], event );
-
-    return ok;
+    if ( code >= 0 && code < MousePatternCount )
+        return mouseMatch( d_mousePattern[ code ], event );
+
+    return false;
 }
 
@@ -213,12 +212,9 @@
     const QMouseEvent *event ) const
 {
-    if ( event->button() != pattern.button )
+    if ( event == NULL )
         return false;
 
-    const bool matched =
-        ( event->modifiers() & Qt::KeyboardModifierMask ) ==
-            ( int )( pattern.state & Qt::KeyboardModifierMask );
-
-    return matched;
+    const MousePattern mousePattern( event->button(), event->modifiers() );
+    return mousePattern == pattern;
 }
 
@@ -230,5 +226,5 @@
   are set.
 
-  \param pattern Index of the event pattern
+  \param code Index of the event pattern
   \param event Key event
   \return true if matches
@@ -236,13 +232,11 @@
   \sa mouseMatch()
 */
-bool QwtEventPattern::keyMatch( uint pattern, 
+bool QwtEventPattern::keyMatch( KeyPatternCode code, 
     const QKeyEvent *event ) const
 {
-    bool ok = false;
-
-    if ( event && pattern < ( uint )d_keyPattern.count() )
-        ok = keyMatch( d_keyPattern[int( pattern )], event );
-
-    return ok;
+    if ( code >= 0 && code < KeyPatternCount )
+        return keyMatch( d_keyPattern[ code ], event );
+
+    return false;
 }
 
@@ -264,11 +258,8 @@
     const KeyPattern &pattern, const QKeyEvent *event ) const
 {
-    if ( event->key() != pattern.key )
+    if ( event == NULL )
         return false;
 
-    const bool matched =
-        ( event->modifiers() & Qt::KeyboardModifierMask ) ==
-            ( int )( pattern.state & Qt::KeyboardModifierMask );
-
-    return matched;
-}
+    const KeyPattern keyPattern( event->key(), event->modifiers() );
+    return keyPattern == pattern;
+}
