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

List:       kde-commits
Subject:    [umbrello] umbrello: Revert "Fetch list of associations from QGraphicsScene."
From:       Ralf Habacker <ralf.habacker () freenet ! de>
Date:       2013-11-30 19:07:21
Message-ID: E1Vmpsv-0001T2-MT () scm ! kde ! org
[Download RAW message or body]

Git commit a9d547fe7a09ca18f34bc1a97bd43656ed3cd807 by Ralf Habacker.
Committed on 30/11/2013 at 19:07.
Pushed by habacker into branch 'master'.

Revert "Fetch list of associations from QGraphicsScene."

This reverts commit 276db0de86ae117b4938c39bfa2fdc328d4ecca2.

M  +29   -36   umbrello/umlscene.cpp
M  +2    -1    umbrello/umlscene.h

http://commits.kde.org/umbrello/a9d547fe7a09ca18f34bc1a97bd43656ed3cd807

diff --git a/umbrello/umlscene.cpp b/umbrello/umlscene.cpp
index b07217f..053399a 100644
--- a/umbrello/umlscene.cpp
+++ b/umbrello/umlscene.cpp
@@ -413,15 +413,9 @@ void UMLScene::setOptionState(const Settings::OptionState& \
options)  /**
  * Returns a reference to the association list.
  */
-AssociationWidgetList UMLScene::associationList()
+AssociationWidgetList& UMLScene::associationList()
 {
-    AssociationWidgetList list;
-    foreach(QGraphicsItem* a, items()) {
-        AssociationWidget* assocwidget = dynamic_cast<AssociationWidget*>(a);
-        if (assocwidget)
-            list.append(assocwidget);
-    }
-    return list;
+    return m_AssociationList;
 }
 
 /**
@@ -1099,7 +1093,7 @@ UMLWidget * UMLScene::findWidget(Uml::ID::Type id)
  */
 AssociationWidget * UMLScene::findAssocWidget(Uml::ID::Type id)
 {
-    foreach(AssociationWidget* obj, associationList()) {
+    foreach(AssociationWidget* obj, m_AssociationList) {
         UMLAssociation* umlassoc = obj->association();
         if (umlassoc && umlassoc->id() == id) {
             return obj;
@@ -1123,7 +1117,7 @@ AssociationWidget * UMLScene::findAssocWidget(Uml::ID::Type id)
 AssociationWidget * UMLScene::findAssocWidget(UMLWidget *pWidgetA,
                                               UMLWidget *pWidgetB, const QString& \
roleNameB)  {
-    foreach(AssociationWidget* assoc, associationList()) {
+    foreach(AssociationWidget* assoc, m_AssociationList) {
         const Uml::AssociationType::Enum testType = assoc->associationType();
         if (testType != Uml::AssociationType::Association &&
                 testType != Uml::AssociationType::UniAssociation &&
@@ -1154,7 +1148,7 @@ AssociationWidget * UMLScene::findAssocWidget(UMLWidget \
*pWidgetA,  AssociationWidget * UMLScene::findAssocWidget(AssociationType::Enum at,
                                               UMLWidget *pWidgetA, UMLWidget \
*pWidgetB)  {
-    foreach(AssociationWidget* assoc, associationList()) {
+    foreach(AssociationWidget* assoc, m_AssociationList) {
         Uml::AssociationType::Enum testType = assoc->associationType();
         if (testType != at) {
             continue;
@@ -1430,7 +1424,7 @@ void UMLScene::deleteSelection()
     }
 
     // Delete any selected associations.
-    foreach(AssociationWidget* assocwidget, associationList()) {
+    foreach(AssociationWidget* assocwidget, m_AssociationList) {
         if (assocwidget->isSelected()) {
             removeAssoc(assocwidget);
         }
@@ -1781,7 +1775,7 @@ void UMLScene::activate()
 
     // Activate all association widgets
 
-    foreach(AssociationWidget* aw, associationList()) {
+    foreach(AssociationWidget* aw, m_AssociationList) {
         if (aw->activate()) {
             if (m_PastePoint.x() != 0) {
                 int x = m_PastePoint.x() - m_Pos.x();
@@ -1789,7 +1783,7 @@ void UMLScene::activate()
                 aw->moveEntireAssoc(x, y);
             }
         } else {
-            associationList().removeAll(aw);
+            m_AssociationList.removeAll(aw);
             delete aw;
         }
     }
@@ -1849,14 +1843,13 @@ UMLWidgetList UMLScene::selectedWidgetsExt(bool filterText \
                /*= true*/)
  */
 AssociationWidgetList UMLScene::selectedAssocs()
 {
-    AssociationWidgetList list;
+    AssociationWidgetList assocWidgetList;
 
-    foreach(QGraphicsItem* a, selectedItems()) {
-        AssociationWidget* assocwidget = dynamic_cast<AssociationWidget*>(a);
-        if (assocwidget)
-            list.append(assocwidget);
+    foreach(AssociationWidget* assocwidget, m_AssociationList) {
+        if (assocwidget->isSelected())
+            assocWidgetList.append(assocwidget);
     }
-    return list;
+    return assocWidgetList;
 }
 
 /**
@@ -2154,14 +2147,14 @@ bool UMLScene::addAssociation(AssociationWidget* pAssoc, bool \
isPasteOperation)  
     //make sure there isn't already the same assoc
 
-    foreach(AssociationWidget* assocwidget, associationList()) {
+    foreach(AssociationWidget* assocwidget, m_AssociationList) {
         if (*pAssoc == *assocwidget)
             // this is nuts. Paste operation wants to know if 'true'
             // for duplicate, but loadFromXMI needs 'false' value
             return (isPasteOperation ? true : false);
     }
 
-    associationList().append(pAssoc);
+    m_AssociationList.append(pAssoc);
 
     FloatingTextWidget *ft[5] = { pAssoc->nameWidget(),
                                   pAssoc->roleWidget(Uml::RoleType::A),
@@ -2233,7 +2226,7 @@ void UMLScene::removeAssoc(AssociationWidget* pAssoc)
     emit sigAssociationRemoved(pAssoc);
 
     pAssoc->cleanup();
-    associationList().removeAll(pAssoc);
+    m_AssociationList.removeAll(pAssoc);
     pAssoc->deleteLater();
     m_doc->setModified();
 }
@@ -2278,7 +2271,7 @@ void UMLScene::removeAssocInViewAndDoc(AssociationWidget* a)
  */
 void UMLScene::removeAssociations(UMLWidget* widget)
 {
-    foreach(AssociationWidget* assocwidget, associationList()) {
+    foreach(AssociationWidget* assocwidget, m_AssociationList) {
         if (assocwidget->containsAsEndpoint(widget)) {
             removeAssoc(assocwidget);
         }
@@ -2292,7 +2285,7 @@ void UMLScene::removeAssociations(UMLWidget* widget)
  */
 void UMLScene::selectAssociations(bool bSelect)
 {
-    foreach(AssociationWidget* assocwidget, associationList()) {
+    foreach(AssociationWidget* assocwidget, m_AssociationList) {
         UMLWidget *widA = assocwidget->widgetForRole(Uml::RoleType::A);
         UMLWidget *widB = assocwidget->widgetForRole(Uml::RoleType::B);
         if (bSelect &&
@@ -2313,7 +2306,7 @@ void UMLScene::getWidgetAssocs(UMLObject* Obj, \
AssociationWidgetList & Associati  if (! Obj)
         return;
 
-    foreach(AssociationWidget* assocwidget, associationList()) {
+    foreach(AssociationWidget* assocwidget, m_AssociationList) {
         if (assocwidget->widgetForRole(Uml::RoleType::A)->umlObject() == Obj ||
             assocwidget->widgetForRole(Uml::RoleType::B)->umlObject() == Obj)
             Associations.append(assocwidget);
@@ -2327,12 +2320,12 @@ void UMLScene::getWidgetAssocs(UMLObject* Obj, \
AssociationWidgetList & Associati  void UMLScene::removeAllAssociations()
 {
     //Remove All association widgets
-    foreach(AssociationWidget* assocwidget, associationList()) {
+    foreach(AssociationWidget* assocwidget, m_AssociationList) {
         removeAssoc(assocwidget);
     }
 
-    qDeleteAll(associationList());
-    associationList().clear();
+    qDeleteAll(m_AssociationList);
+    m_AssociationList.clear();
 }
 
 /**
@@ -2380,7 +2373,7 @@ void UMLScene::updateContainment(UMLCanvasObject *self)
     if (selfWidget == NULL)
         return;
     // Remove possibly obsoleted containment association.
-    foreach(AssociationWidget* a, associationList()) {
+    foreach(AssociationWidget* a, m_AssociationList) {
         if (a->associationType() != Uml::AssociationType::Containment)
             continue;
         // Container is at role A, containee at B.
@@ -2406,7 +2399,7 @@ void UMLScene::updateContainment(UMLCanvasObject *self)
     AssociationWidget *a = AssociationWidget::create
                              (this, newParentWidget,
                               Uml::AssociationType::Containment, selfWidget);
-    associationList().append(a);
+    m_AssociationList.append(a);
 }
 
 /**
@@ -2887,7 +2880,7 @@ void UMLScene::copyAsImage(QPixmap*& pix)
     //get each type of associations
     //This needs to be reimplemented to increase the rectangle
     //if a part of any association is not included
-    foreach(AssociationWidget *a, associationList()) {
+    foreach(AssociationWidget *a, m_AssociationList) {
         if (! a->isSelected())
             continue;
         const FloatingTextWidget* multiA = a->multiplicityWidget(Uml::RoleType::A);
@@ -3417,7 +3410,7 @@ void UMLScene::checkSelections()
     }//end for
     //check Associations
 
-    foreach(AssociationWidget *pAssoc, associationList()) {
+    foreach(AssociationWidget *pAssoc, m_AssociationList) {
         if (pAssoc->isSelected()) {
             pWA = pAssoc->widgetForRole(Uml::RoleType::A);
             pWB = pAssoc->widgetForRole(Uml::RoleType::B);
@@ -3754,7 +3747,7 @@ void UMLScene::saveToXMI(QDomDocument & qDoc, QDomElement & \
qElement)  viewElement.appendChild(messageElement);
     //now save the associations
     QDomElement assocElement = qDoc.createElement("associations");
-    if (associationList().count()) {
+    if (m_AssociationList.count()) {
         // We guard against (m_AssociationList.count() == 0) because
         // this code could be reached as follows:
         //  ^  UMLScene::saveToXMI()
@@ -3767,7 +3760,7 @@ void UMLScene::saveToXMI(QDomDocument & qDoc, QDomElement & \
qElement)  //  ^  main()
         //
         AssociationWidget * assoc = 0;
-        foreach(assoc, associationList()) {
+        foreach(assoc, m_AssociationList) {
             assoc->saveToXMI(qDoc, assocElement);
         }
     }
@@ -4070,7 +4063,7 @@ bool UMLScene::loadUisDiagramPresentation(QDomElement & \
qElement)  AssociationWidget *aw =
                         AssociationWidget::create(this, wA, at, wB, umla);
                     aw->syncToModel();
-                    associationList().append(aw);
+                    m_AssociationList.append(aw);
                 } else {
                     uError() << "cannot create assocwidget from (" ; //<< wA << ", " \
<< wB << ")";  }
diff --git a/umbrello/umlscene.h b/umbrello/umlscene.h
index 93f41dc..db620f6 100644
--- a/umbrello/umlscene.h
+++ b/umbrello/umlscene.h
@@ -149,7 +149,7 @@ public:
     const Settings::OptionState& optionState() const;
     void setOptionState(const Settings::OptionState& options);
 
-    AssociationWidgetList associationList();
+    AssociationWidgetList& associationList();
     UMLWidgetList& widgetList();
     MessageWidgetList& messageList();
     UMLObjectList umlObjects();
@@ -326,6 +326,7 @@ protected:
 
     MessageWidgetList      m_MessageList;      ///< All the message widgets on the \
                diagram.
     UMLWidgetList          m_WidgetList;       ///< All the UMLWidgets on the \
diagram. +    AssociationWidgetList  m_AssociationList;  ///< All the \
AssociationWidgets on the diagram.  
     bool m_bUseSnapToGrid;  ///< Flag to use snap to grid. The default is off.
     bool m_bUseSnapComponentSizeToGrid;  ///< Flag to use snap to grid for component \
size. The default is off.


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

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