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

Sharan Rao sharanrao at gmail.com
Wed Aug 15 21:24:39 UTC 2007


SVN commit 700569 by sharan:

Patch by Andi Fischer. Porting to Qt4 and some other stuff :). Thanks a lot Andi :)
CCMAIL:andi.fischer at hispeed.ch

btw, I didn't apply your point 2 that you mentioned in your mail ( which was absolutely right in the context you 
specified, but I had already changed the for statements to Qt foreach )



 M  +35 -16    toolbarstatearrow.cpp  
 M  +3 -7      toolbarstatearrow.h  
 M  +31 -33    toolbarstatefactory.cpp  
 M  +3 -5      toolbarstatefactory.h  
 M  +3 -3      umlview.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/toolbarstatearrow.cpp #700568:700569
@@ -21,30 +21,38 @@
 #include "umlview.h"
 #include "umlwidget.h"
 
-ToolBarStateArrow::ToolBarStateArrow(UMLView *umlView): ToolBarState(umlView) {
-    m_selectionRect.setAutoDelete(true);
+#include <kdebug.h>
 
+ToolBarStateArrow::ToolBarStateArrow(UMLView *umlView): ToolBarState(umlView)
+{
     init();
 }
 
-ToolBarStateArrow::~ToolBarStateArrow() {
+ToolBarStateArrow::~ToolBarStateArrow() 
+{
 }
 
-void ToolBarStateArrow::init() {
+void ToolBarStateArrow::init()
+{
     ToolBarState::init();
 
+    while (!m_selectionRect.isEmpty())
+        delete m_selectionRect.takeFirst();
     m_selectionRect.clear();
 }
 
-void ToolBarStateArrow::mousePressAssociation() {
+void ToolBarStateArrow::mousePressAssociation()
+{
     getCurrentAssociation()->mousePressEvent(m_pMouseEvent);
 }
 
-void ToolBarStateArrow::mousePressWidget() {
+void ToolBarStateArrow::mousePressWidget()
+{
     getCurrentWidget()->mousePressEvent(m_pMouseEvent);
 }
 
-void ToolBarStateArrow::mousePressEmpty() {
+void ToolBarStateArrow::mousePressEmpty() 
+{
     if (m_pMouseEvent->button() != Qt::LeftButton) {
         // Leave widgets selected upon RMB press on empty diagram area.
         // The popup menu is activated upon RMB release.
@@ -68,7 +76,8 @@
     }
 }
 
-void ToolBarStateArrow::mouseReleaseAssociation() {
+void ToolBarStateArrow::mouseReleaseAssociation() 
+{
     getCurrentAssociation()->mouseReleaseEvent(m_pMouseEvent);
 }
 
@@ -76,31 +85,39 @@
     getCurrentWidget()->mouseReleaseEvent(m_pMouseEvent);
 }
 
-void ToolBarStateArrow::mouseReleaseEmpty() {
+void ToolBarStateArrow::mouseReleaseEmpty()
+{
     if (m_selectionRect.count() == 4) {
+        while (!m_selectionRect.isEmpty())
+            delete m_selectionRect.takeFirst();
         m_selectionRect.clear();
     } else if (m_pMouseEvent->button() == Qt::RightButton) {
         m_pUMLView->setMenu();
     }
 }
 
-void ToolBarStateArrow::mouseDoubleClickAssociation() {
+void ToolBarStateArrow::mouseDoubleClickAssociation() 
+{
     getCurrentAssociation()->mouseDoubleClickEvent(m_pMouseEvent);
 }
 
-void ToolBarStateArrow::mouseDoubleClickWidget() {
+void ToolBarStateArrow::mouseDoubleClickWidget()
+{
     getCurrentWidget()->mouseDoubleClickEvent(m_pMouseEvent);
 }
 
-void ToolBarStateArrow::mouseMoveAssociation() {
+void ToolBarStateArrow::mouseMoveAssociation()
+{
     getCurrentAssociation()->mouseMoveEvent(m_pMouseEvent);
 }
 
-void ToolBarStateArrow::mouseMoveWidget() {
+void ToolBarStateArrow::mouseMoveWidget()
+{
     getCurrentWidget()->mouseMoveEvent(m_pMouseEvent);
 }
 
-void ToolBarStateArrow::mouseMoveEmpty() {
+void ToolBarStateArrow::mouseMoveEmpty()
+{
     if (m_selectionRect.count() == 4) {
         Q3CanvasLine* line = m_selectionRect.at(0);
         line->setPoints(m_startPosition.x(), m_startPosition.y(),
@@ -123,10 +140,12 @@
     }
 }
 
-void ToolBarStateArrow::changeTool() {
+void ToolBarStateArrow::changeTool() 
+{
 }
 
-void ToolBarStateArrow::setCurrentWidget(UMLWidget* currentWidget) {
+void ToolBarStateArrow::setCurrentWidget(UMLWidget* currentWidget) 
+{
     if (currentWidget != 0 && getCurrentWidget() != 0) {
         return;
     }
--- trunk/KDE/kdesdk/umbrello/umbrello/toolbarstatearrow.h #700568:700569
@@ -12,17 +12,13 @@
 #ifndef TOOLBARSTATEARROW_H
 #define TOOLBARSTATEARROW_H
 
-
 #include "toolbarstate.h"
-
 #include "worktoolbar.h"
-//Added by qt3to4:
-#include <QMouseEvent>
-#include <Q3PtrList>
 
+#include <QList>
+
 class QMouseEvent;
 class UMLView;
-
 class Q3CanvasLine;
 
 /**
@@ -149,7 +145,7 @@
     /**
      * The selection rectangle that contains the four lines of its borders.
      */
-    Q3PtrList<Q3CanvasLine> m_selectionRect;
+    QList<Q3CanvasLine *> m_selectionRect;
 
     /**
      * The start position of the selection rectangle.
--- trunk/KDE/kdesdk/umbrello/umbrello/toolbarstatefactory.cpp #700568:700569
@@ -20,13 +20,11 @@
 
 #include "umlview.h"
 
-ToolBarStateFactory::ToolBarStateFactory(UMLView *umlView)
+ToolBarStateFactory::ToolBarStateFactory()
 {
-    m_pUMLView = umlView;
-
     for (int i = 0; i < NR_OF_TOOLBAR_STATES; i++)
     {
-        states[i] = NULL;
+        m_states[i] = NULL;
     }
 }
 
@@ -34,35 +32,35 @@
 {
     for (int i = 0; i < NR_OF_TOOLBAR_STATES; i++)
     {
-        if (states[i] != NULL) delete states[i];
+        if (m_states[i] != NULL) delete m_states[i];
     }
 }
 
 
-ToolBarState* ToolBarStateFactory::getState(const WorkToolBar::ToolBar_Buttons &toolbarButton)
+ToolBarState* ToolBarStateFactory::getState(const WorkToolBar::ToolBar_Buttons &toolbarButton, UMLView *umlView)
 {
     int key = getKey(toolbarButton);
 
-    if (states[key] == NULL)
+    if (m_states[key] == NULL)
     {
         switch (key)
         {
             // When you add a new state, make sure you also increase the
             // NR_OF_TOOLBAR_STATES
-        case 0: states[0] = new ToolBarStateOther(m_pUMLView); break;
-        case 1: states[1] = new ToolBarStateAssociation(m_pUMLView); break;
-        case 2: states[2] = new ToolBarStateMessages(m_pUMLView); break;
+        case 0: m_states[0] = new ToolBarStateOther(umlView); break;
+        case 1: m_states[1] = new ToolBarStateAssociation(umlView); break;
+        case 2: m_states[2] = new ToolBarStateMessages(umlView); break;
 
             // This case has no pool.
-        case 3: states[3] = new ToolBarStateArrow(m_pUMLView); break;
-        case 4: states[4] = new ToolBarStateOneWidget(m_pUMLView); break;
+        case 3: m_states[3] = new ToolBarStateArrow(umlView); break;
+        case 4: m_states[4] = new ToolBarStateOneWidget(umlView); break;
         }
     }
 
     // Make explicit the selected button. This is only necessary for states with a pool.
-    if (key != 3) ((ToolBarStatePool *) states[key])->setButton(toolbarButton);
+    if (key != 3) ((ToolBarStatePool *) m_states[key])->setButton(toolbarButton);
 
-    return states[key];
+    return m_states[key];
 }
 
 
@@ -71,21 +69,21 @@
     switch (toolbarButton)
     {
         // Associations
-    case WorkToolBar::tbb_Dependency:          return 1;
-    case WorkToolBar::tbb_Aggregation:         return 1;
-    case WorkToolBar::tbb_Relationship:        return 1;
-    case WorkToolBar::tbb_Generalization:      return 1;
-    case WorkToolBar::tbb_Association:         return 1;
-    case WorkToolBar::tbb_UniAssociation:      return 1;
-    case WorkToolBar::tbb_Composition:         return 1;
-    case WorkToolBar::tbb_Containment:         return 1;
-    case WorkToolBar::tbb_Anchor:              return 1;
-    case WorkToolBar::tbb_Coll_Message:        return 1;
-    case WorkToolBar::tbb_State_Transition:    return 1;
-    case WorkToolBar::tbb_Activity_Transition: return 1;
-    case WorkToolBar::tbb_Exception:           return 1;
-    case WorkToolBar::tbb_Category2Parent:     return 1;
-    case WorkToolBar::tbb_Child2Category:      return 1;
+    case WorkToolBar::tbb_Dependency:               return 1;
+    case WorkToolBar::tbb_Aggregation:              return 1;
+    case WorkToolBar::tbb_Relationship:             return 1;
+    case WorkToolBar::tbb_Generalization:           return 1;
+    case WorkToolBar::tbb_Association:              return 1;
+    case WorkToolBar::tbb_UniAssociation:           return 1;
+    case WorkToolBar::tbb_Composition:              return 1;
+    case WorkToolBar::tbb_Containment:              return 1;
+    case WorkToolBar::tbb_Anchor:                   return 1;
+    case WorkToolBar::tbb_Coll_Message:             return 1;
+    case WorkToolBar::tbb_State_Transition:         return 1;
+    case WorkToolBar::tbb_Activity_Transition:      return 1;
+    case WorkToolBar::tbb_Exception:                return 1;
+    case WorkToolBar::tbb_Category2Parent:          return 1;
+    case WorkToolBar::tbb_Child2Category:           return 1;
 
         // Messages
     case WorkToolBar::tbb_Seq_Message_Synchronous:  return 2;
@@ -93,14 +91,14 @@
     case WorkToolBar::tbb_Seq_Message_Found:        return 2;
     case WorkToolBar::tbb_Seq_Message_Lost:         return 2;
 
-    case WorkToolBar::tbb_Seq_Precondition: return 4;
-    case WorkToolBar::tbb_Pin: return 4;
+    case WorkToolBar::tbb_Seq_Precondition:         return 4;
+    case WorkToolBar::tbb_Pin:                      return 4;
 
         // Arrow pointer
-    case WorkToolBar::tbb_Arrow: return 3;
+    case WorkToolBar::tbb_Arrow:                    return 3;
 
         // Other.
-    default: return 0;
+    default:                                        return 0;
     }
 
 }
--- trunk/KDE/kdesdk/umbrello/umbrello/toolbarstatefactory.h #700568:700569
@@ -34,20 +34,18 @@
 {
 public:
     // constructor.
-    ToolBarStateFactory(UMLView* umlView);
+    ToolBarStateFactory();
 
     // Destructor
     virtual ~ToolBarStateFactory();
 
-    ToolBarState* getState(const WorkToolBar::ToolBar_Buttons &toolbarButton);
+    ToolBarState* getState(const WorkToolBar::ToolBar_Buttons &toolbarButton, UMLView* umlView);
 
 protected:
     int getKey(const WorkToolBar::ToolBar_Buttons &toolbarButton) const;
 
 protected:
-    ToolBarState* states[NR_OF_TOOLBAR_STATES];
-
-    UMLView* m_pUMLView;
+    ToolBarState* m_states[NR_OF_TOOLBAR_STATES];
 };
 
 #endif //TOOLBARSTATEFACTORY_H
--- trunk/KDE/kdesdk/umbrello/umbrello/umlview.cpp #700568:700569
@@ -189,8 +189,8 @@
 
     // Create the ToolBarState factory. This class is not a singleton, because it
     // needs a pointer to this object.
-    m_pToolBarStateFactory = new ToolBarStateFactory(this);
-    m_pToolBarState = m_pToolBarStateFactory->getState(WorkToolBar::tbb_Arrow);
+    m_pToolBarStateFactory = new ToolBarStateFactory();
+    m_pToolBarState = m_pToolBarStateFactory->getState(WorkToolBar::tbb_Arrow, this);
 
 }
 
@@ -421,7 +421,7 @@
 
 void UMLView::slotToolBarChanged(int c) {
     m_pToolBarState->cleanBeforeChange();
-    m_pToolBarState = m_pToolBarStateFactory->getState((WorkToolBar::ToolBar_Buttons)c);
+    m_pToolBarState = m_pToolBarStateFactory->getState((WorkToolBar::ToolBar_Buttons)c, this);
     m_pToolBarState->init();
 
     m_bPaste = false;




More information about the umbrello-devel mailing list