[Uml-devel] branches/work/soc-umbrello/umbrello

Andi Fischer andi.fischer at hispeed.ch
Thu Sep 24 21:41:18 UTC 2009


SVN commit 1027843 by fischer:

Removing some dependencies.

 M  +1 -5      classifier.cpp  
 M  +2 -5      codeimport/import_utils.cpp  
 M  +4 -8      folder.cpp  
 M  +41 -0     model_utils.cpp  
 M  +5 -0      model_utils.h  
 M  +1 -2      widgets/classifierwidget.cpp  
 M  +2 -2      widgets/classifierwidget.h  


--- branches/work/soc-umbrello/umbrello/classifier.cpp #1027842:1027843
@@ -27,7 +27,6 @@
 #include "stereotype.h"
 #include "umldoc.h"
 #include "uml.h"
-#include "umllistview.h"
 #include "uniqueid.h"
 #include "object_factory.h"
 #include "model_utils.h"
@@ -93,10 +92,7 @@
             uError() << "cannot set to type " << ot;
             return;
     }
-    // @todo get rid of direct dependencies to UMLListView
-    //  (e.g. move utility methods to Model_Utils and/or use signals)
-    UMLListView *listView = UMLApp::app()->getListView();
-    listView->changeIconOf(this, newIcon);
+    Model_Utils::treeViewChangeIcon(this, newIcon);
 }
 
 /**
--- branches/work/soc-umbrello/umbrello/codeimport/import_utils.cpp #1027842:1027843
@@ -14,8 +14,6 @@
 // app includes
 #include "uml.h"
 #include "umldoc.h"
-#include "umllistview.h"
-#include "umllistviewitem.h"
 #include "umlobject.h"
 #include "package.h"
 #include "folder.h"
@@ -26,6 +24,7 @@
 #include "template.h"
 #include "association.h"
 #include "object_factory.h"
+#include "model_utils.h"
 
 // kde includes
 #include <kmessagebox.h>
@@ -221,9 +220,7 @@
                     Uml::Object_Type ot = (wantNamespace == KMessageBox::Yes ? Uml::ot_Package : Uml::ot_Class);
                     o = Object_Factory::createUMLObject(ot, scopeName, parentPkg);
                     parentPkg = static_cast<UMLPackage*>(o);
-                    UMLListView *listView = UMLApp::app()->getListView();
-                    UMLListViewItem *lvitem = listView->findUMLObject(o);
-                    listView->setCurrentItem(lvitem);
+                    Model_Utils::treeViewSetCurrentItem(o);
                 }
                 // All scope qualified datatypes live in the global scope.
                 bPutAtGlobalScope = true;
--- branches/work/soc-umbrello/umbrello/folder.cpp #1027842:1027843
@@ -15,7 +15,6 @@
 #include "uml.h"
 #include "umldoc.h"
 #include "umlview.h"
-#include "umllistview.h"
 #include "optionstate.h"
 #include "object_factory.h"
 #include "model_utils.h"
@@ -145,19 +144,16 @@
         }
     }
 
-    foreach (UMLView* v, m_diagrams)
+    foreach (UMLView* v, m_diagrams) {
         v->umlScene()->activateAfterLoad();
+    }
     // Make sure we have a treeview item for each diagram.
     // It may happen that we are missing them after switching off tabbed widgets.
     Settings::OptionState optionState = Settings::getOptionState();
-    if (optionState.generalState.tabdiagrams)
+    if (optionState.generalState.tabdiagrams) {
         return;
-    UMLListView *lv = UMLApp::app()->getListView();
-    foreach (UMLView* v,  m_diagrams ) {
-        if (lv->findItem(v->umlScene()->getID()) != NULL)
-            continue;
-        lv->createDiagramItem(v);
     }
+    Model_Utils::treeViewAddViews(m_diagrams);
 }
 
 /**
--- branches/work/soc-umbrello/umbrello/model_utils.cpp #1027842:1027843
@@ -27,6 +27,10 @@
 #include "umlrole.h"
 #include "umldoc.h"
 #include "uml.h"
+#include "umllistview.h"
+#include "umllistviewitem.h"
+#include "umlscene.h"
+#include "umlview.h"
 #include "codegenerator.h"
 
 // kde includes
@@ -269,6 +273,43 @@
 }
 
 /**
+ * Add the given list of views to the tree view.
+ * @param viewList   the list of views to add
+ */
+void treeViewAddViews(const UMLViewList& viewList)
+{
+    UMLListView* tree = UMLApp::app()->getListView();
+    foreach (UMLView* v,  viewList) {
+        if (tree->findItem(v->umlScene()->getID()) != NULL) {
+            continue;
+        }
+        tree->createDiagramItem(v);
+    }
+}
+
+/**
+ * Change an icon of an object in the tree view.
+ * @param object   the object in the treeViewAddViews
+ * @param to       the new icon type for the given object
+ */
+void treeViewChangeIcon(UMLObject* object, Icon_Utils::Icon_Type to)
+{
+    UMLListView* tree = UMLApp::app()->getListView();
+    tree->changeIconOf(object, to);
+}
+
+/**
+ * Set the given object to the current item in the tree view.
+ * @param object   the object which will be the current item
+ */
+void treeViewSetCurrentItem(UMLObject* object)
+{
+    UMLListView* tree = UMLApp::app()->getListView();
+    UMLListViewItem* item = tree->findUMLObject(object);
+    tree->setCurrentItem(item);
+}
+
+/**
  * Returns a name for the new object, appended with a number
  * if the default name is taken e.g. new_actor, new_actor_1
  * etc.
--- branches/work/soc-umbrello/umbrello/model_utils.h #1027842:1027843
@@ -16,6 +16,7 @@
 
 #include "umlnamespace.h"
 #include "umlobjectlist.h"
+#include "umlviewlist.h"
 #include "foreignkeyconstraint.h"
 #include "icon_utils.h"
 
@@ -41,6 +42,10 @@
                           Uml::Object_Type type = Uml::ot_UMLObject,
                           UMLObject *currentObj = NULL);
 
+void treeViewAddViews(const UMLViewList& viewList);
+void treeViewChangeIcon(UMLObject* object, Icon_Utils::Icon_Type to);
+void treeViewSetCurrentItem(UMLObject* object);
+
 QString uniqObjectName(Uml::Object_Type type,
                        UMLPackage *parentPkg,
                        QString prefix = QString());
--- branches/work/soc-umbrello/umbrello/widgets/classifierwidget.cpp #1027842:1027843
@@ -52,8 +52,7 @@
  */
 ClassifierWidget::ClassifierWidget(UMLClassifier *c)
     : UMLWidget(c),
-    m_classAssociationWidget(0)
-
+      m_classAssociationWidget(0)
 {
     createTextItemGroup(); // For header (name, stereotype..)
     createTextItemGroup(); // For attributes and operations.
--- branches/work/soc-umbrello/umbrello/widgets/classifierwidget.h #1027842:1027843
@@ -44,9 +44,9 @@
         ShowOperations = 0x2,
         ShowPublicOnly = 0x4,
         ShowVisibility = 0x8,
-        ShowPackage = 0x10,
+        ShowPackage    = 0x10,
         ShowAttributes = 0x20,
-        DrawAsCircle = 0x40,
+        DrawAsCircle   = 0x40,
 
         // These two are effective only in setters.
         ShowOperationSignature = 0x60,




More information about the umbrello-devel mailing list