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

Oliver Kellogg okellogg at users.sourceforge.net
Mon Jul 16 20:57:12 UTC 2007


SVN commit 688793 by okellogg:

UMLObject::set{Name,Visibility}: Make virtual.
UMLAttribute::attributeChanged(): New signal.
UMLAttribute::set{Name,Visibility}: New.  Reimplement methods from UMLObject
 in order to emit extra signal attributeChanged().
AssociationWidget::slotAttributeChanged(): New slot. Connects to UMLAttribute::
 attributeChanged() when the AssociationWidget represents an UMLAttribute.

The extra signal is necessary because the attribute name must already have
been updated at the AssociationWidget by the time UMLObject::emitModified()
is called else UMLView::createAutoAttributeAssociations() will think it needs
to create a new attribute association.

BUG:147919


 M  +1 -0      ChangeLog  
 M  +14 -0     umbrello/associationwidget.cpp  
 M  +8 -0      umbrello/associationwidget.h  
 M  +13 -1     umbrello/attribute.cpp  
 M  +20 -0     umbrello/attribute.h  
 M  +2 -2      umbrello/umlobject.h  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #688792:688793
@@ -8,6 +8,7 @@
 * The size of a fork/join is not restored (147069)
 * Crash when changing the association type to containment (147202)
 * Moving component on diagram results in absurd shape of self-association (147810)
+* Crash when changing the attribute name (147919)
 
 Version 1.5.71
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/associationwidget.cpp #688792:688793
@@ -3110,6 +3110,7 @@
     if (obj == NULL)
         return;
     UMLClassifier *klass = NULL;
+    UMLAttribute *attr = NULL;
     UMLEntity *ent = NULL;
     const Uml::Object_Type ot = obj->getBaseType();
     switch (ot) {
@@ -3123,6 +3124,8 @@
             klass = static_cast<UMLClassifier*>(obj->parent());
             connect(klass, SIGNAL(attributeRemoved(UMLClassifierListItem*)),
                     this, SLOT(slotAttributeRemoved(UMLClassifierListItem*)));
+            attr = static_cast<UMLAttribute*>(obj);
+            connect(attr, SIGNAL(attributeChanged()), this, SLOT(slotAttributeChanged()));
             break;
         case Uml::ot_EntityAttribute:
             ent = static_cast<UMLEntity*>(obj->parent());
@@ -3143,6 +3146,17 @@
     m_pView->removeAssoc(this);
 }
 
+void AssociationWidget::slotAttributeChanged() {
+    UMLAttribute *attr = getAttribute();
+    if (attr == NULL) {
+        kError() << "AssociationWidget::slotAttributeChanged: getAttribute returns NULL"
+            << endl;
+        return;
+    }
+    setVisibility(attr->getVisibility(), B);
+    setRoleName(attr->getName(), B);
+}
+
 void AssociationWidget::init (UMLView *view)
 {
     WidgetBase::init(view, wt_Association);
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/associationwidget.h #688792:688793
@@ -1030,6 +1030,14 @@
     void slotAttributeRemoved(UMLClassifierListItem* obj);
 
     /**
+     * Connected to UMLObject::modified() in case this
+     * AssociationWidget is linked to a classifer's attribute type.
+     *
+     * @param obj               The UMLAttribute removed.
+     */
+    void slotAttributeChanged();
+
+    /**
      * Synchronize this widget from the UMLAssociation.
      */
     void syncToModel();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/attribute.cpp #688792:688793
@@ -48,6 +48,18 @@
 
 UMLAttribute::~UMLAttribute() { }
 
+void UMLAttribute::setName(const QString &name) {
+    m_Name = name;
+    emit attributeChanged();
+    UMLObject::emitModified();
+}
+
+void UMLAttribute::setVisibility(Uml::Visibility s) {
+    m_Vis = s;
+    emit attributeChanged();
+    UMLObject::emitModified();
+}
+
 QString UMLAttribute::getInitialValue() {
     return m_InitialValue;
 }
@@ -312,4 +324,4 @@
 }
 
 
-
+#include "attribute.moc"
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/attribute.h #688792:688793
@@ -26,6 +26,7 @@
  * Bugs and comments to uml-devel at lists.sf.net or http://bugs.kde.org
  */
 class UMLAttribute : public UMLClassifierListItem {
+    Q_OBJECT
 public:
     /**
      * Sets up an attribute.
@@ -66,6 +67,18 @@
     virtual void copyInto(UMLAttribute *rhs) const;
 
     /**
+     * Reimplementation of method from UMLObject is required as
+     * an extra signal, attributeChanged(), is emitted.
+     */
+    void setName(const QString &name);
+
+    /**
+     * Reimplementation of method from UMLObject is required as
+     * an extra signal, attributeChanged(), is emitted.
+     */
+    void setVisibility(Uml::Visibility s);
+
+    /**
      * Make a clone of the UMLAttribute.
      */
     virtual UMLObject* clone() const;
@@ -117,6 +130,13 @@
      */
     virtual UMLClassifierList getTemplateParams();
 
+signals:
+    /**
+     * Required for informing AssociationWidgets representing this attribute
+     * that the attribute name or visibility has changed.
+     */
+    void attributeChanged();
+
 protected:
     /**
      * Loads the <UML:Attribute> XMI element.
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.h #688792:688793
@@ -131,7 +131,7 @@
      *
      * @param s The visibility of the object.
      */
-    void setVisibility(Uml::Visibility s);
+    virtual void setVisibility(Uml::Visibility s);
 
     /**
      * Sets the classes stereotype name.
@@ -229,7 +229,7 @@
     /**
      * Set the UMLObject's name
      */
-    void setName(const QString &strName);
+    virtual void setName(const QString &strName);
 
     /**
      * Returns the fully qualified name, i.e. all package prefixes and then m_Name.




More information about the umbrello-devel mailing list