[Uml-devel] KDE/kdesdk/umbrello/umbrello

Ralf Habacker ralf.habacker at gmail.com
Wed Dec 14 15:38:34 UTC 2011


SVN commit 1268743 by habacker:

merged in QGraphicsSceneMouseEvent related changes from the soc-umbrello branch for ToolBarStateOneWidget

This is done by implementing a real QMouseEvent wrapper class UMLSceneMouseEvent
containing the required methods.

 M  +1 -4      toolbarstateassociation.cpp  
 M  +1 -1      toolbarstateassociation.h  
 M  +1 -1      toolbarstatemessages.cpp  
 M  +1 -1      toolbarstatemessages.h  
 M  +16 -1     umlscene.h  
 M  +4 -4      umlview.cpp  
 M  +18 -20    widgets/toolbarstateonewidget.cpp  
 M  +5 -12     widgets/toolbarstateonewidget.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/toolbarstateassociation.cpp #1268742:1268743
@@ -30,9 +30,6 @@
 #include <klocale.h>
 #include <kmessagebox.h>
 
-// qt includes
-#include <QtGui/QGraphicsSceneMouseEvent>
-
 /**
  * Creates a new ToolBarStateAssociation.
  *
@@ -78,7 +75,7 @@
  * It executes the base method and then updates the position of the
  * association line, if any.
  */
-void ToolBarStateAssociation::mouseMove(QMouseEvent* ome)
+void ToolBarStateAssociation::mouseMove(UMLSceneMouseEvent* ome)
 {
     ToolBarStatePool::mouseMove(ome);
 
--- trunk/KDE/kdesdk/umbrello/umbrello/toolbarstateassociation.h #1268742:1268743
@@ -45,7 +45,7 @@
 
     virtual void cleanBeforeChange();
 
-    virtual void mouseMove(QMouseEvent* ome);
+    virtual void mouseMove(UMLSceneMouseEvent* ome);
 
 public slots:
 
--- trunk/KDE/kdesdk/umbrello/umbrello/toolbarstatemessages.cpp #1268742:1268743
@@ -73,7 +73,7 @@
  * It executes the base method and then updates the position of the
  * message line, if any.
  */
-void ToolBarStateMessages::mouseMove(QMouseEvent* ome)
+void ToolBarStateMessages::mouseMove(UMLSceneMouseEvent* ome)
 {
     ToolBarStatePool::mouseMove(ome);
 
--- trunk/KDE/kdesdk/umbrello/umbrello/toolbarstatemessages.h #1268742:1268743
@@ -57,7 +57,7 @@
 
     virtual void cleanBeforeChange();
 
-    virtual void mouseMove(QMouseEvent* ome);
+    virtual void mouseMove(UMLSceneMouseEvent* ome);
 
 public slots:
 
--- trunk/KDE/kdesdk/umbrello/umbrello/umlscene.h #1268742:1268743
@@ -27,8 +27,9 @@
 };
 
 /// uml related types - makes it easier to switch to QGraphicsScene types
+// base types
+typedef QPoint UMLScenePoint;
 // event types
-typedef QMouseEvent UMLSceneMouseEvent;
 typedef QKeyEvent UMLSceneKeyEvent;
 typedef QKeyEvent UMLSceneKeyEvent;
 typedef QHoverEvent UMLSceneHoverEvent;
@@ -42,4 +43,18 @@
 typedef Q3CanvasEllipse UMLSceneEllipse;
 typedef Q3CanvasItemList UMLSceneItemList;
 
+/**
+  qt3 migration wrapper for QMouseEvent
+*/ 
+class  UMLSceneMouseEvent : public QMouseEvent 
+{
+public:
+    UMLSceneMouseEvent(Type type, const QPoint & position, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) 
+     : QMouseEvent(type, position, button, buttons, modifiers)
+    {
+    }
+
+    UMLScenePoint scenePos() { return pos(); }
+};
+
 #endif
--- trunk/KDE/kdesdk/umbrello/umbrello/umlview.cpp #1268742:1268743
@@ -419,7 +419,7 @@
 
 void UMLView::contentsMouseReleaseEvent(QMouseEvent* ome)
 {
-    m_pToolBarState->mouseRelease(ome);
+    m_pToolBarState->mouseRelease(static_cast<UMLSceneMouseEvent*>(ome));
 }
 
 void UMLView::slotToolBarChanged(int c)
@@ -798,7 +798,7 @@
 
 void UMLView::contentsMouseMoveEvent(QMouseEvent* ome)
 {
-    m_pToolBarState->mouseMove(ome);
+    m_pToolBarState->mouseMove(static_cast<UMLSceneMouseEvent*>(ome));
 }
 
 // search both our UMLWidget AND MessageWidget lists
@@ -940,7 +940,7 @@
 
 void UMLView::contentsMouseDoubleClickEvent(QMouseEvent* ome)
 {
-    m_pToolBarState->mouseDoubleClick(ome);
+    m_pToolBarState->mouseDoubleClick(static_cast<UMLSceneMouseEvent*>(ome));
 }
 
 QRect UMLView::getDiagramRect()
@@ -1240,7 +1240,7 @@
 
 void UMLView::contentsMousePressEvent(QMouseEvent* ome)
 {
-    m_pToolBarState->mousePress(ome);
+    m_pToolBarState->mousePress(static_cast<UMLSceneMouseEvent*>(ome));
     //TODO should be managed by widgets when are selected. Right now also has some
     //problems, such as clicking on a widget, and clicking to move that widget shows
     //documentation of the diagram instead of keeping the widget documentation.
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/toolbarstateonewidget.cpp #1268742:1268743
@@ -14,18 +14,16 @@
 
 // app includes
 #include "activitywidget.h"
-#include "debug_utils.h"
 #include "dialog_utils.h"
 #include "floatingtextwidget.h"
-#include "pinwidget.h"
-#include "preconditionwidget.h"
 #include "messagewidget.h"
 #include "objectwidget.h"
+#include "pinwidget.h"
+#include "preconditionwidget.h"
 #include "regionwidget.h"
 #include "uml.h"
 #include "umldoc.h"
 #include "umlscene.h"
-#include "umlview.h"
 #include "umlwidget.h"
 
 // kde includes
@@ -40,10 +38,10 @@
  * @param umlView The UMLView to use.
  */
 ToolBarStateOneWidget::ToolBarStateOneWidget(UMLScene *umlScene)
-  : ToolBarStatePool(umlScene)
+  : ToolBarStatePool(umlScene),
+    m_firstObject(0),
+    m_isObjectWidgetLine(false)
 {
-    m_pUMLScene = umlScene;
-    m_firstObject = 0;
 }
 
 /**
@@ -67,7 +65,7 @@
  * It executes the base method and then updates the position of the
  * message line, if any.
  */
-void ToolBarStateOneWidget::mouseMove(QMouseEvent* ome)
+void ToolBarStateOneWidget::mouseMove(UMLSceneMouseEvent* ome)
 {
     ToolBarStatePool::mouseMove(ome);
 }
@@ -93,14 +91,14 @@
 void ToolBarStateOneWidget::setCurrentElement()
 {
     m_isObjectWidgetLine = false;
-    ObjectWidget* objectWidgetLine = m_pUMLScene->onWidgetLine(m_pMouseEvent->pos());
+    ObjectWidget* objectWidgetLine = m_pUMLScene->onWidgetLine(m_pMouseEvent->scenePos());
     if (objectWidgetLine) {
         setCurrentWidget(objectWidgetLine);
         m_isObjectWidgetLine = true;
         return;
     }
 
-    UMLWidget *widget = m_pUMLScene->widgetAt(m_pMouseEvent->pos());
+    UMLWidget *widget = m_pUMLScene->widgetAt(m_pMouseEvent->scenePos());
     if (widget) {
         setCurrentWidget(widget);
         return;
@@ -120,12 +118,12 @@
  */
 void ToolBarStateOneWidget::mouseReleaseWidget()
 {
-    WidgetBase::WidgetType widgetType = getWidgetType();
+    WidgetBase::WidgetType type = widgetType();
 
-    if (widgetType == WidgetBase::wt_Precondition) {
+    if (type == WidgetBase::wt_Precondition) {
         m_firstObject = 0;
     }
-    if (widgetType == WidgetBase::wt_Pin) {
+    if (type == WidgetBase::wt_Pin) {
         m_firstObject = 0;
     }
 
@@ -136,7 +134,7 @@
         return;
     }
 
-    if (!m_firstObject && widgetType == WidgetBase::wt_Pin) {
+    if (!m_firstObject && type == WidgetBase::wt_Pin) {
         setWidget(getCurrentWidget());
         return ;
     }
@@ -171,21 +169,21 @@
 {
     m_firstObject = firstObject;
 
-    UMLWidget * umlwidget = NULL;
-    //m_pUMLView->viewport()->setMouseTracking(true);
-    if (getWidgetType() == WidgetBase::wt_Precondition) {
+    UMLWidget * umlwidget = 0;
+    //m_pUMLScene->viewport()->setMouseTracking(true);
+    if (widgetType() == WidgetBase::wt_Precondition) {
         umlwidget = new PreconditionWidget(m_pUMLScene, static_cast<ObjectWidget*>(m_firstObject));
 
         Dialog_Utils::askNameForWidget(umlwidget, i18n("Enter Precondition Name"), i18n("Enter the precondition"), i18n("new precondition"));
             // Create the widget. Some setup functions can remove the widget.
     }
 
-    if (getWidgetType() == WidgetBase::wt_Pin) {
+    if (widgetType() == WidgetBase::wt_Pin) {
         umlwidget = new PinWidget(m_pUMLScene, m_firstObject);
             // Create the widget. Some setup functions can remove the widget.
     }
 
-    if (umlwidget != NULL) {
+    if (umlwidget) {
             m_pUMLScene->setupNewWidget(umlwidget);
     }
 
@@ -196,7 +194,7 @@
  *
  * @return The widget type of this tool.
  */
-WidgetBase::WidgetType ToolBarStateOneWidget::getWidgetType()
+WidgetBase::WidgetType ToolBarStateOneWidget::widgetType()
 {
     if (getButton() == WorkToolBar::tbb_Seq_Precondition) {
         return WidgetBase::wt_Precondition;
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/toolbarstateonewidget.h #1268742:1268743
@@ -15,10 +15,6 @@
 #include "toolbarstatepool.h"
 #include "widgetbase.h"
 
-class ObjectWidget;
-class QMouseEvent;
-class UMLWidget;
-
 /**
  * Sequence tool to create components linked with one object in sequence diagram
  * like precondition.
@@ -30,12 +26,12 @@
     Q_OBJECT
 public:
     ToolBarStateOneWidget(UMLScene *umlScene);
-
     virtual ~ToolBarStateOneWidget();
 
     virtual void cleanBeforeChange();
 
-    virtual void mouseMove(QMouseEvent* ome);
+	// FIXME: obsolate
+    virtual void mouseMove(UMLSceneMouseEvent* ome);
 
 public Q_SLOTS:
     virtual void slotWidgetRemoved(UMLWidget* widget);  
@@ -47,13 +43,11 @@
     virtual void mouseReleaseEmpty();
 
     void setWidget(UMLWidget* firstObject);
-    WidgetBase::WidgetType getWidgetType();
+    WidgetBase::WidgetType widgetType();
 
+    UMLWidget* m_firstObject;  ///< The first object in the message.
+
     /**
-     * The first object in the message.
-     */
-    UMLWidget* m_firstObject;
-    /**
      * If there is a current widget, it is true if the press event happened on
      * the line of an object, or false if it happened on a normal UMLWidget.
      */
@@ -61,7 +55,6 @@
 
 private: 
     virtual void init();
-       
 };
 
 #endif //TOOLBARSTATEONEWIDGET_H




More information about the umbrello-devel mailing list