[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegraphics/okular/ui
From:       Albert Astals Cid <tsdgeos () terra ! es>
Date:       2010-08-18 19:14:55
Message-ID: 20100818191455.21F27AC855 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1165294 by aacid:

Factor out static methods for determining the event type and button when dealing with \
annotations Patch by Radu Voicilas


 M  +17 -0     annotationtools.cpp  
 M  +3 -0      annotationtools.h  
 M  +4 -13     pageviewannotator.cpp  
 M  +5 -12     presentationwidget.cpp  


--- trunk/KDE/kdegraphics/okular/ui/annotationtools.cpp #1165293:1165294
@@ -11,6 +11,7 @@
 
 // qt / kde includes
 #include <qcolor.h>
+#include <qevent.h>
 #include <qpainter.h>
 
 // local includes
@@ -29,6 +30,22 @@
         m_annotElement = annElement;
 }
 
+void AnnotatorEngine::decodeEvent( const QMouseEvent * mouseEvent, EventType * \
eventType, Button * button ) +{
+    *eventType = AnnotatorEngine::Press;
+    if ( mouseEvent->type() == QEvent::MouseMove )
+        *eventType = AnnotatorEngine::Move;
+    else if ( mouseEvent->type() == QEvent::MouseButtonRelease )
+        *eventType = AnnotatorEngine::Release;
+
+    *button = AnnotatorEngine::None;
+    const Qt::MouseButtons buttonState = ( *eventType == AnnotatorEngine::Move ) ? \
mouseEvent->buttons() : mouseEvent->button(); +    if ( buttonState == Qt::LeftButton \
) +        *button = AnnotatorEngine::Left;
+    else if ( buttonState == Qt::RightButton )
+        *button = AnnotatorEngine::Right;
+}
+
 AnnotatorEngine::~AnnotatorEngine()
 {
 }
--- trunk/KDE/kdegraphics/okular/ui/annotationtools.h #1165293:1165294
@@ -16,6 +16,7 @@
 
 #include "core/area.h"
 
+class QMouseEvent;
 class QPainter;
 class PageViewItem;
 namespace Okular {
@@ -47,6 +48,8 @@
 
         void setItem( PageViewItem * item ) { m_item = item; }
 
+        static void decodeEvent( const QMouseEvent * mouseEvent, EventType * \
eventType, Button * button ); +
     protected:
         PageViewItem * item() { return m_item; }
 
--- trunk/KDE/kdegraphics/okular/ui/pageviewannotator.cpp #1165293:1165294
@@ -711,20 +711,11 @@
 {
     if ( !item ) return QRect();
 
-    // find out mouse event type
-    AnnotatorEngine::EventType eventType = AnnotatorEngine::Press;
-    if ( e->type() == QEvent::MouseMove )
-        eventType = AnnotatorEngine::Move;
-    else if ( e->type() == QEvent::MouseButtonRelease )
-        eventType = AnnotatorEngine::Release;
+    AnnotatorEngine::EventType eventType;
+    AnnotatorEngine::Button button;
 
-    // find out the pressed button
-    AnnotatorEngine::Button button = AnnotatorEngine::None;
-    Qt::MouseButtons buttonState = ( eventType == AnnotatorEngine::Move ) ? \
                e->buttons() : e->button();
-    if ( buttonState == Qt::LeftButton )
-        button = AnnotatorEngine::Left;
-    else if ( buttonState == Qt::RightButton )
-        button = AnnotatorEngine::Right;
+    // figure out the event type and button
+    AnnotatorEngine::decodeEvent( e, &eventType, &button );
 
     // find out normalized mouse coords inside current item
     const QRect & itemRect = item->uncroppedGeometry();
--- trunk/KDE/kdegraphics/okular/ui/presentationwidget.cpp #1165293:1165294
@@ -1057,19 +1057,12 @@
     const QRect & geom = m_frames[ m_frameIndex ]->geometry;
     const Okular::Page * page = m_frames[ m_frameIndex ]->page;
 
-    AnnotatorEngine::EventType eventType = AnnotatorEngine::Press;
-    if ( e->type() == QEvent::MouseMove )
-        eventType = AnnotatorEngine::Move;
-    else if ( e->type() == QEvent::MouseButtonRelease )
-        eventType = AnnotatorEngine::Release;
+    AnnotatorEngine::EventType eventType;
+    AnnotatorEngine::Button button;
 
-    // find out the pressed button
-    AnnotatorEngine::Button button = AnnotatorEngine::None;
-    Qt::MouseButtons buttonState = ( eventType == AnnotatorEngine::Move ) ? \
                e->buttons() : e->button();
-    if ( buttonState == Qt::LeftButton )
-        button = AnnotatorEngine::Left;
-    else if ( buttonState == Qt::RightButton )
-        button = AnnotatorEngine::Right;
+    // figure out the event type and button
+    AnnotatorEngine::decodeEvent( e, &eventType, &button );
+
     static bool hasclicked = false;
     if ( eventType == AnnotatorEngine::Press )
         hasclicked = true;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic