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

Andi Fischer andi.fischer at hispeed.ch
Sun Oct 5 11:50:08 UTC 2008


SVN commit 868075 by fischer:

Suspicous code comments from Christoph Bartoscheck in kde-core-devel ML.

 M  +10 -13    codegenerators/textblock.cpp  
 M  +6 -2      dialogs/parmpropdlg.cpp  
 M  +8 -3      dialogs/umloperationdialog.cpp  
 M  +45 -48    foreignkeyconstraint.cpp  
 M  +1 -1      uml.cpp  
 M  +3 -7      uniqueconstraint.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/textblock.cpp #868074:868075
@@ -189,20 +189,17 @@
 {
     QString endLine = UMLApp::app()->getCommonPolicy()->getNewLineEndingChars();
 
-    if (&doc != 0 ) {
+    blockElement.setAttribute("tag",getTag());
 
-        blockElement.setAttribute("tag",getTag());
-
-        // only write these if different from defaults
-        if (getIndentationLevel())
-            blockElement.setAttribute("indentLevel", QString::number(getIndentationLevel()));
-        if (!m_text.isEmpty())
-            blockElement.setAttribute("text", encodeText(m_text, endLine));
-        if (!getWriteOutText())
-            blockElement.setAttribute("writeOutText", getWriteOutText()?"true":"false");
-        if (!canDelete())
-            blockElement.setAttribute("canDelete", canDelete()?"true":"false");
-    }
+    // only write these if different from defaults
+    if (getIndentationLevel())
+        blockElement.setAttribute("indentLevel", QString::number(getIndentationLevel()));
+    if (!m_text.isEmpty())
+        blockElement.setAttribute("text", encodeText(m_text, endLine));
+    if (!getWriteOutText())
+        blockElement.setAttribute("writeOutText", getWriteOutText()?"true":"false");
+    if (!canDelete())
+        blockElement.setAttribute("canDelete", canDelete()?"true":"false");
 }
 
 void TextBlock::setAttributesFromObject(TextBlock * obj)
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/parmpropdlg.cpp #868074:868075
@@ -132,12 +132,16 @@
     m_pTypeCB->setEditable(true);
     m_pTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
 //    m_pTypeCB->setCompleter(...);
-    insertTypesSorted(attr->getTypeName());
+    if (attr) {
+        insertTypesSorted(attr->getTypeName());
+    }
 
     // manage stereotypes
     m_pStereoTypeCB->setDuplicatesEnabled(false); //only allow one of each type in box
     m_pStereoTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
-    insertStereotypesSorted(m_pAtt->getStereotype());
+    if (m_pAtt) {
+        insertStereotypesSorted(m_pAtt->getStereotype());
+    }
 
     // set tab order
     setTabOrder(m_pKind, m_pTypeCB);
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/umloperationdialog.cpp #868074:868075
@@ -445,7 +445,7 @@
     }
 
     UMLClassifier *classifier = dynamic_cast<UMLClassifier*>( m_operation->parent() );
-    if( classifier != 0L &&
+    if( classifier != 0 &&
             classifier->checkOperationSignature(name, m_operation->getParmList(), m_operation) )
     {
         QString msg = i18n("An operation with that signature already exists in %1.\n", classifier->getName())
@@ -466,7 +466,10 @@
       m_operation -> setVisibility( Uml::Visibility::Implementation );
 
     QString typeName = m_pRtypeCB->currentText();
-    UMLTemplate *tmplParam = classifier->findTemplate(typeName);
+    UMLTemplate *tmplParam = 0;
+    if (classifier) {
+        tmplParam = classifier->findTemplate(typeName);
+    }
     if (tmplParam)
         m_operation->setType(tmplParam);
     else
@@ -482,7 +485,9 @@
            The inverse is not true: The fact that no operation is
            abstract does not mean that the class must be non-abstract.
          */
-        classifier->setAbstract(true);
+        if (classifier) {
+            classifier->setAbstract(true);
+        }
     }
     m_operation->setStatic( m_pStaticCB->isChecked() );
     m_operation->setConst( m_pQueryCB->isChecked() );
--- trunk/KDE/kdesdk/umbrello/umbrello/foreignkeyconstraint.cpp #868074:868075
@@ -1,11 +1,10 @@
 /***************************************************************************
- *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2002-2007                                               *
+ *   copyright (C) 2002-2008                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
@@ -24,16 +23,19 @@
 
 UMLForeignKeyConstraint::UMLForeignKeyConstraint(UMLObject *parent,
     const QString& name, Uml::IDType id)
-    : UMLEntityConstraint(parent, name, id) {
+    : UMLEntityConstraint(parent, name, id)
+{
     init();
 }
 
 UMLForeignKeyConstraint::UMLForeignKeyConstraint(UMLObject *parent)
-    : UMLEntityConstraint( parent ) {
+    : UMLEntityConstraint( parent )
+{
     init();
 }
 
-void UMLForeignKeyConstraint::init() {
+void UMLForeignKeyConstraint::init()
+{
     // initialise attributes
      m_BaseType = Uml::ot_ForeignKeyConstraint;
 
@@ -48,7 +50,8 @@
      connect( this,SIGNAL( sigReferencedEntityChanged() ),this,SLOT( slotReferencedEntityChanged() ) );
 }
 
-bool UMLForeignKeyConstraint::operator==( const UMLForeignKeyConstraint &rhs) {
+bool UMLForeignKeyConstraint::operator==( const UMLForeignKeyConstraint &rhs)
+{
     if( this == &rhs )
         return true;
 
@@ -56,12 +59,14 @@
         return false;
 
     return true;
+}
 
+UMLForeignKeyConstraint::~UMLForeignKeyConstraint()
+{
 }
 
-UMLForeignKeyConstraint::~UMLForeignKeyConstraint() {}
-
-void UMLForeignKeyConstraint::copyInto(UMLObject *lhs) const {
+void UMLForeignKeyConstraint::copyInto(UMLObject *lhs) const
+{
     UMLForeignKeyConstraint *target = static_cast<UMLForeignKeyConstraint*>(lhs);
 
     // call the parent first.
@@ -74,15 +79,16 @@
     target->m_UpdateAction = m_UpdateAction;
 }
 
-UMLObject* UMLForeignKeyConstraint::clone() const {
+UMLObject* UMLForeignKeyConstraint::clone() const
+{
     //FIXME: The new attribute should be slaved to the NEW parent not the old.
     UMLForeignKeyConstraint *clone = new UMLForeignKeyConstraint( static_cast<UMLObject*>(parent()) );
     copyInto(clone);
     return clone;
 }
 
-QString UMLForeignKeyConstraint::toString(Uml::Signature_Type sig ){
-
+QString UMLForeignKeyConstraint::toString(Uml::Signature_Type sig )
+{
     QString s;
 
     if(sig == Uml::st_ShowSig || sig == Uml::st_ShowSig || sig == Uml::st_SigNoVis) {
@@ -103,8 +109,8 @@
     return s;
 }
 
-
-void UMLForeignKeyConstraint::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
+void UMLForeignKeyConstraint::saveToXMI( QDomDocument & qDoc, QDomElement & qElement )
+{
     QDomElement foreignKeyConstraintElement = UMLObject::save( "UML:ForeignKeyConstraint", qDoc );
 
     foreignKeyConstraintElement.setAttribute( "referencedEntity", ID2STR( m_ReferencedEntity->getID() ) );
@@ -126,45 +132,41 @@
     qElement.appendChild(foreignKeyConstraintElement);
 }
 
-bool UMLForeignKeyConstraint::showPropertiesDialog(QWidget* parent) {
+bool UMLForeignKeyConstraint::showPropertiesDialog(QWidget* parent)
+{
     UMLForeignKeyConstraintDialog dialog(parent, this );
     return dialog.exec();
 }
 
-bool UMLForeignKeyConstraint::addEntityAttributePair(UMLEntityAttribute* pAttr, UMLEntityAttribute* rAttr) {
-
-
+bool UMLForeignKeyConstraint::addEntityAttributePair(UMLEntityAttribute* pAttr, UMLEntityAttribute* rAttr)
+{
     UMLEntity *owningParent = dynamic_cast<UMLEntity*>(parent());
 
     if ( pAttr == NULL || rAttr == NULL ) {
-        uError()<<"null values passed to function"<<endl;
+        uError() << "null values passed to function";
         return false;
     }
     // check for sanity of pAttr ( parent entity attribute )
     if (owningParent == NULL) {
-        uError() << m_Name
-        << "): parent " << owningParent->getName()
-        << " is not a UMLEntity" << endl;
+        uError() << m_Name << ": parent is not a UMLEntity";
         return false;
     }
 
     if ( owningParent->findChildObjectById( pAttr->getID() ) == NULL ) {
-        uError()
-        << " parent " << owningParent->getName()
-                 << " does not contain attribute " << pAttr->getName()<<endl;
+        uError() << " parent " << owningParent->getName()
+                 << " does not contain attribute " << pAttr->getName();
         return false;
     }
 
     //check for sanity of rAttr ( referenced entity attribute )
     if ( m_ReferencedEntity != NULL ) {
        if ( m_ReferencedEntity->findChildObjectById( rAttr->getID() ) == NULL ) {
-        uError()
-        << " parent " << m_ReferencedEntity->getName()
-                 << " does not contain attribute " << rAttr->getName()<<endl;
+        uError() << " parent " << m_ReferencedEntity->getName()
+                 << " does not contain attribute " << rAttr->getName();
         return false;
        }
     } else {
-        uError()<< "Referenced Table Not set. Not Adding Pair "<< endl;
+        uError() << "Referenced Table Not set. Not Adding Pair ";
         return false;
     }
 
@@ -190,16 +192,15 @@
      return true;
 }
 
-bool UMLForeignKeyConstraint::removeEntityAttributePair(UMLEntityAttribute* /*key*/ pAttr) {
-
+bool UMLForeignKeyConstraint::removeEntityAttributePair(UMLEntityAttribute* /*key*/ pAttr)
+{
     bool state = m_AttributeMap.remove( pAttr );
 
     return state;
-
 }
 
-bool UMLForeignKeyConstraint::hasEntityAttributePair(UMLEntityAttribute* pAttr,UMLEntityAttribute* rAttr) const {
-
+bool UMLForeignKeyConstraint::hasEntityAttributePair(UMLEntityAttribute* pAttr,UMLEntityAttribute* rAttr) const
+{
     if ( m_AttributeMap.contains( pAttr ) ) {
         if ( m_AttributeMap.value( pAttr ) == rAttr ) {
             return true;
@@ -209,7 +210,8 @@
     return false;
 }
 
-bool UMLForeignKeyConstraint::load( QDomElement & element ) {
+bool UMLForeignKeyConstraint::load( QDomElement & element )
+{
     UMLDoc* doc = UMLApp::app()->getDocument();
 
     Uml::IDType referencedEntityId = STR2ID( element.attribute("referencedEntity","" ) );
@@ -253,7 +255,6 @@
                value = static_cast<UMLEntityAttribute*>( valueObj );
             }
 
-
         } else {
             uWarning() << "unknown child type in UMLUniqueConstraint::load";
         }
@@ -264,30 +265,29 @@
     return true;
 }
 
-
-
-void UMLForeignKeyConstraint::setReferencedEntity(UMLEntity* ent){
+void UMLForeignKeyConstraint::setReferencedEntity(UMLEntity* ent)
+{
     if ( ent == m_ReferencedEntity )
         return;
 
     m_ReferencedEntity = ent;
 
     emit sigReferencedEntityChanged();
-
 }
 
-void UMLForeignKeyConstraint::slotReferencedEntityChanged(){
-
+void UMLForeignKeyConstraint::slotReferencedEntityChanged()
+{
     // clear all mappings
     m_AttributeMap.clear();
 }
 
-void UMLForeignKeyConstraint::clearMappings(){
+void UMLForeignKeyConstraint::clearMappings()
+{
     m_AttributeMap.clear();
-
 }
 
-bool UMLForeignKeyConstraint::resolveRef() {
+bool UMLForeignKeyConstraint::resolveRef()
+{
     // resolve referenced entity first
     UMLDoc* doc = UMLApp::app()->getDocument();
 
@@ -317,6 +317,3 @@
 }
 
 #include "foreignkeyconstraint.moc"
-
-
-
--- trunk/KDE/kdesdk/umbrello/umbrello/uml.cpp #868074:868075
@@ -2258,8 +2258,8 @@
 {
     if (cmd != NULL) {
         m_pUndoStack->push(cmd);
+        uDebug() << cmd->text() << " [" << m_pUndoStack->count() << "]";
     }
-    uDebug() << cmd->text() << " [" << m_pUndoStack->count() << "]";
 
     UMLApp::app()->enableUndo(true);
 }
--- trunk/KDE/kdesdk/umbrello/umbrello/uniqueconstraint.cpp #868074:868075
@@ -194,14 +194,12 @@
     UMLEntity *owningParent = dynamic_cast<UMLEntity*>(parent());
 
     if ( hasEntityAttribute( attr ) ) {
-        uDebug() << "Unique Constraint already contains"<<attr->getName();
+        uDebug() << "Unique Constraint already contains" << attr->getName();
         return false;
 
     }
     if (owningParent == NULL) {
-        uError() << m_Name
-            << "): parent " << owningParent->getName()
-            << " is not a UMLEntity";
+        uError() << m_Name << ": parent is not a UMLEntity";
         return false;
     }
 
@@ -223,9 +221,7 @@
     UMLEntity *owningParent = dynamic_cast<UMLEntity*>(parent());
 
     if (owningParent == NULL) {
-        uError() << m_Name
-            << "): parent " << owningParent->getName()
-            << " is not a UMLEntity";
+        uError() << m_Name << ": parent is not a UMLEntity";
         return false;
     }
 




More information about the umbrello-devel mailing list