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

Andi Fischer andi.fischer at hispeed.ch
Thu Dec 13 09:10:44 UTC 2007


SVN commit 747977 by fischer:

Some code and documentation format changes.

 M  +31 -57    codegenobjectwithtextblocks.cpp  
 M  +45 -39    codegenobjectwithtextblocks.h  
 M  +1 -1      hierarchicalcodeblock.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/codegenobjectwithtextblocks.cpp #747976:747977
@@ -29,8 +29,6 @@
 #include "hierarchicalcodeblock.h"
 #include "uml.h"
 
-// Constructors/Destructors
-//
 
 CodeGenObjectWithTextBlocks::CodeGenObjectWithTextBlocks ( CodeDocument *parent )
   : m_pCodeDoc(parent)
@@ -38,58 +36,47 @@
     initFields();
 }
 
-CodeGenObjectWithTextBlocks::~CodeGenObjectWithTextBlocks ( ) {
+CodeGenObjectWithTextBlocks::~CodeGenObjectWithTextBlocks ( )
+{
     resetTextBlocks();
 }
 
-//
-// Methods
-//
-
-
-// Accessor methods
-//
-
 /**
  * Get the list of TextBlock objects held by m_textblockVector
  * @return QPtrList<TextBlock *> list of TextBlock objects held by
  * m_textblockVector
  */
-TextBlockList * CodeGenObjectWithTextBlocks::getTextBlockList ( ) {
+TextBlockList * CodeGenObjectWithTextBlocks::getTextBlockList ( )
+{
     return &m_textblockVector;
 }
 
-// Other methods
-//
-
 /**
  * Add a TextBlock object to the m_textblockVector List
  */
-bool CodeGenObjectWithTextBlocks::addTextBlock(TextBlock* add_object ) {
-
+bool CodeGenObjectWithTextBlocks::addTextBlock(TextBlock* add_object )
+{
     QString tag = add_object->getTag();
 
     // assign a tag if one doesn't already exist
-    if(tag.isEmpty())
+    if (tag.isEmpty())
     {
         tag = getUniqueTag();
         add_object->setTag(tag);
     }
     else
     {
-
         // if it has a tag, check to see that its not in some other parent object
         // IF it is then we will need to remove it FIRST before adding to new parent
         CodeDocument * parentDoc = add_object->getParentDocument();
-        if(parentDoc) {
-
+        if (parentDoc) {
             CodeGenObjectWithTextBlocks * oldParent = parentDoc->findParentObjectForTaggedTextBlock (tag);
-            if(oldParent && oldParent != this)
+            if (oldParent && oldParent != this)
                 oldParent->removeTextBlock(add_object);
         }
     }
 
-    if(m_textBlockTagMap.contains(tag))
+    if (m_textBlockTagMap.contains(tag))
         return false; // return false, we already have some object with this tag in the list
 
     // if we get here, then the object is a "fresh" one, we havent
@@ -103,24 +90,24 @@
 /**
  * Remove a TextBlock object from m_textblockVector List
  */
-bool CodeGenObjectWithTextBlocks::removeTextBlock ( TextBlock * remove_object ) {
-
+bool CodeGenObjectWithTextBlocks::removeTextBlock ( TextBlock * remove_object )
+{
     // check if we can remove it from our local list
-    if(!m_textblockVector.removeRef(remove_object))
+    if (!m_textblockVector.removeRef(remove_object))
     {
         // may be hiding in child hierarchical codeblock
         TextBlock * tb;
         for(TextBlockListIt it(m_textblockVector); (tb = it.current()) != NULL; ++it)
         {
             HierarchicalCodeBlock * hb = dynamic_cast<HierarchicalCodeBlock*>(tb);
-            if(hb && hb->removeTextBlock(remove_object))
+            if (hb && hb->removeTextBlock(remove_object))
                 return true;
         }
     }
 
     // if we get here.. it was in this object so remove from our map
     QString tag = remove_object->getTag();
-    if(!tag.isEmpty())
+    if (!tag.isEmpty())
         m_textBlockTagMap.remove(tag);
 
     return true;
@@ -139,8 +126,8 @@
 // and down into its Hierarchical codeblocks. This means you should start any
 // search from the parent document of the text block. This method NOT meant for
 // casual usage.
-CodeGenObjectWithTextBlocks * CodeGenObjectWithTextBlocks::findParentObjectForTaggedTextBlock (const QString & tag) {
-
+CodeGenObjectWithTextBlocks * CodeGenObjectWithTextBlocks::findParentObjectForTaggedTextBlock (const QString & tag)
+{
     // what??!? no tag, then CANT be here
     if(tag.isEmpty())
         return (CodeGenObjectWithTextBlocks*) NULL;
@@ -174,8 +161,8 @@
  * @param       comment
  * @param       indentLevel
  */
-HierarchicalCodeBlock * CodeGenObjectWithTextBlocks::getHierarchicalCodeBlock ( const QString &tag, const QString &comment, int indentLevel ) {
-
+HierarchicalCodeBlock * CodeGenObjectWithTextBlocks::getHierarchicalCodeBlock ( const QString &tag, const QString &comment, int indentLevel )
+{
     // now actually declare the fields
     HierarchicalCodeBlock * codeBlock = dynamic_cast<HierarchicalCodeBlock*>(findTextBlockByTag(tag));
     if (!codeBlock) {
@@ -199,15 +186,14 @@
     return codeBlock;
 }
 
-
 /**
  * @return      CodeBlockWithComments
  * @param       tag
  * @param       comment
  * @param       indentLevel
  */
-CodeBlockWithComments * CodeGenObjectWithTextBlocks::getCodeBlockWithComments ( const QString &tag, const QString &comment, int indentLevel ) {
-
+CodeBlockWithComments * CodeGenObjectWithTextBlocks::getCodeBlockWithComments ( const QString &tag, const QString &comment, int indentLevel )
+{
     // now actually declare the fields
     CodeBlockWithComments * codeBlock = dynamic_cast<CodeBlockWithComments*>(findTextBlockByTag(tag));
     if (!codeBlock) {
@@ -224,10 +210,8 @@
     codeBlock->getComment()->setText(comment);
 
     return codeBlock;
-
 }
 
-
 /**
  * @return      CodeComment
  * @param       tag
@@ -236,7 +220,6 @@
  */
 CodeComment * CodeGenObjectWithTextBlocks::addOrUpdateTaggedCodeComment ( const QString &tag, const QString &text, int indentationLevel)
 {
-
     TextBlock * tBlock = findTextBlockByTag(tag);
     CodeComment * codeComment = dynamic_cast<CodeComment*>(tBlock);
     bool createdCodeComment = false;
@@ -265,7 +248,6 @@
     return codeComment;
 }
 
-
 /**
  * @return      CodeBlockWithComments
  * @param       tag
@@ -276,12 +258,11 @@
  */
 CodeBlockWithComments * CodeGenObjectWithTextBlocks::addOrUpdateTaggedCodeBlockWithComments (const QString &tag, const QString &text, const QString &ctext, int indentLevel, bool forceUserBlockUpdate )
 {
-
     TextBlock * tBlock = findTextBlockByTag(tag);
     CodeBlockWithComments * codeBlock = dynamic_cast<CodeBlockWithComments*>(tBlock);
     bool createdCodeBlock = false;
 
-    if(!codeBlock) {
+    if (!codeBlock) {
         createdCodeBlock = true;
         codeBlock = newCodeBlockWithComments();
         codeBlock->setTag(tag);
@@ -293,21 +274,20 @@
     }
 
     // ONLY update IF we are forcing the update of user blocks OR its an "AutoGenerated" Block
-    if(forceUserBlockUpdate || codeBlock->getContentType() == CodeBlock::AutoGenerated)
+    if (forceUserBlockUpdate || codeBlock->getContentType() == CodeBlock::AutoGenerated)
     {
-
         codeBlock->setText(text);
         codeBlock->getComment()->setText(ctext);
 
         // if we created this from scratch, make it write out only when the block isnt empty
         if (createdCodeBlock)
         {
-            if(!ctext.isEmpty())
+            if (!ctext.isEmpty())
                 codeBlock->getComment()->setWriteOutText(true);
             else
                 codeBlock->getComment()->setWriteOutText(false);
 
-            if(!text.isEmpty())
+            if (!text.isEmpty())
                 codeBlock->setWriteOutText(true);
             else
                 codeBlock->setWriteOutText(false);
@@ -318,10 +298,10 @@
     }
 
     return codeBlock;
-
 }
 
-void CodeGenObjectWithTextBlocks::resetTextBlocks() {
+void CodeGenObjectWithTextBlocks::resetTextBlocks()
+{
     /**************  @todo I had to deactivate this code:
     TextBlock *tb;
     for (TextBlockListIt it(m_textblockVector); (tb = it.current()) != NULL; ++it)
@@ -385,8 +365,8 @@
     }
 }
 
-void CodeGenObjectWithTextBlocks::setAttributesOnNode (QDomDocument & doc, QDomElement & root) {
-
+void CodeGenObjectWithTextBlocks::setAttributesOnNode (QDomDocument & doc, QDomElement & root)
+{
     // set a section to hold document content
     QDomElement tblockElement = doc.createElement( "textblocks" );
 
@@ -396,7 +376,6 @@
         block->saveToXMI(doc, tblockElement);
 
     root.appendChild( tblockElement);
-
 }
 
 /** set the class attributes of this object from
@@ -404,13 +383,10 @@
  */
 void CodeGenObjectWithTextBlocks::setAttributesFromNode ( QDomElement & root)
 {
-
     // clear existing codeblocks
     resetTextBlocks();
-
     // now load em back in
     loadChildTextBlocksFromNode(root);
-
 }
 
 // load text blocks
@@ -421,7 +397,6 @@
 // derived from codeblock/codecomment
 void CodeGenObjectWithTextBlocks::loadChildTextBlocksFromNode ( QDomElement & root)
 {
-
     QDomNode tnode = root.firstChild();
     QDomElement telement = tnode.toElement();
     bool loadCheckForChildrenOK = false;
@@ -535,9 +510,8 @@
 
 }
 
-void CodeGenObjectWithTextBlocks::initFields ( ) {
-
+void CodeGenObjectWithTextBlocks::initFields ( )
+{
     m_textblockVector.setAutoDelete(false);
-
 }
 
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenobjectwithtextblocks.h #747976:747977
@@ -17,7 +17,7 @@
 #ifndef CODEGENOBJECTWITHTEXTBLOCKS_H
 #define CODEGENOBJECTWITHTEXTBLOCKS_H
 
-#include <qmap.h>
+#include <QtCore/QMap>
 #include "codeaccessormethod.h"
 #include "textblocklist.h"
 
@@ -31,7 +31,6 @@
 
 
 /**
-  * class CodeGenObjectWithTextBlocks
   * This abstract class is for code generator objects which 'own' text blocks.
   */
 
@@ -39,9 +38,6 @@
 {
 public:
 
-    // Constructors/Destructors
-    //
-
     /**
      * Constructor
      */
@@ -88,9 +84,9 @@
     virtual HierarchicalCodeBlock * getHierarchicalCodeBlock ( const QString &tag, const QString &comment, int indentLevel );
 
     /**
-            * Will get a codeblockwithcomments from the document with given tag. IF the codeblock
-            * doesn't exist, then it will create it at the end of the document textBlock
-            * list and pass back a reference.
+     * Will get a codeblockwithcomments from the document with given tag. IF the codeblock
+     * doesn't exist, then it will create it at the end of the document textBlock
+     * list and pass back a reference.
      * @return  CodeBlockWithComments
      * @param   tag
      * @param   comment
@@ -98,28 +94,30 @@
      */
     virtual CodeBlockWithComments * getCodeBlockWithComments ( const QString &tag, const QString &comment, int indentLevel );
 
-    /** allows the user to add a code comment to the end of the list
+     /**
+      * Allows the user to add a code comment to the end of the list
+      * of text blocks in this document OR, if a text block already exists
+      * with that tag, it will update it with the passed text as appropriate.
+      * @return codeblock/comment pointer to the object which was created/updated.
+      * @return   CodeComment
+      * @param    tag
+      * @param    text
+      * @param    indentationLevel
+      */
+     CodeComment * addOrUpdateTaggedCodeComment (const QString &tag = "", const QString &text = "", int indentationLevel = 0 );
+
+    /**
+     * Allows the user to either add a code block with comments to the end of the list
      * of text blocks in this document OR, if a text block already exists
      * with that tag, it will update it with the passed text as appropriate.
      * @return codeblock/comment pointer to the object which was created/updated.
-     * @return   CodeComment
+     * @return   CodeBlockWithComments
      * @param    tag
      * @param    text
-     * @param    indentationLevel
+     * @param    comment
+     * @param    indentLevel
+     * @param    forceUserBlockUpdate
      */
-     CodeComment * addOrUpdateTaggedCodeComment (const QString &tag = "", const QString &text = "", int indentationLevel = 0 );
-
-   /** allows the user to either add a code block with comments to the end of the list
-    * of text blocks in this document OR, if a text block already exists
-    * with that tag, it will update it with the passed text as appropriate.
-    * @return codeblock/comment pointer to the object which was created/updated.
-    * @return   CodeBlockWithComments
-    * @param    tag
-    * @param    text
-    * @param    comment
-    * @param    indentLevel
-    * @param    forceUserBlockUpdate
-    */
     CodeBlockWithComments * addOrUpdateTaggedCodeBlockWithComments (const QString &tag, const QString &text, const QString &comment, int indentLevel, bool forceUserBlockUpdate );
 
     /**
@@ -134,13 +132,15 @@
      */
     virtual QString getUniqueTag (const QString& prefix = "" ) = 0;
 
-    /** Virtual methods that return a new code document objects.
+    /**
+     * Virtual methods that return a new code document objects.
      */
     virtual CodeBlock * newCodeBlock() = 0;
     virtual CodeBlockWithComments * newCodeBlockWithComments() = 0;
     virtual HierarchicalCodeBlock * newHierarchicalCodeBlock() = 0;
 
-    /** Find the direct parent for a given textblock. This
+    /**
+     * Find the direct parent for a given textblock. This
      * may be any object which holds text blocks, e.g. a CodeGenObjectWithTextBlocks.
      * @return parent object. Could return null if the textblock is missing from the
      * branch of the document tree being examined.
@@ -149,12 +149,14 @@
 
 protected:
 
-    /** set attributes of the node that represents this class
+    /**
+     * Set attributes of the node that represents this class
      * in the XMI document.
      */
     virtual void setAttributesOnNode (QDomDocument & doc, QDomElement & elem );
 
-    /** set the class attributes of this object from
+    /**
+     * Set the class attributes of this object from
      * the passed element node.
      */
     virtual void setAttributesFromNode ( QDomElement & element);
@@ -162,24 +164,28 @@
     virtual void setAttributesFromObject (CodeGenObjectWithTextBlocks * obj);
 
     /**
-      * in this vanilla version, we only load comments and codeblocks
-      * as they are the only instanciatable (vanilla) things
-      * this method should be overridden if this class is inherited
-      * by some other class that is concrete and takes children
-      * derived from codeblock/codecomment/hierarchicalcb/ownedhiercodeblock
-      */
+     * In this vanilla version, we only load comments and codeblocks
+     * as they are the only instanciatable (vanilla) things
+     * this method should be overridden if this class is inherited
+     * by some other class that is concrete and takes children
+     * derived from codeblock/codecomment/hierarchicalcb/ownedhiercodeblock
+     */
     virtual void loadChildTextBlocksFromNode ( QDomElement & root);
 
-    // reset/clear the inventory text blocks held by this object
+    /**
+     * Reset/clear the inventory text blocks held by this object.
+     */
     virtual void resetTextBlocks();
 
+    /**
+     * Find specific text block belonging to code classfields.
+     * Block may not presently be alocated t othe textblock list.
+     */
+    virtual TextBlock * findCodeClassFieldTextBlockByTag( const QString &tag) = 0;
+
     QMap<QString, TextBlock *> m_textBlockTagMap;
     TextBlockList m_textblockVector;
 
-    // find specific text block belonging to code classfields.
-    // block may not presently be alocated t othe textblock list.
-    virtual TextBlock * findCodeClassFieldTextBlockByTag( const QString &tag) = 0;
-
 private:
 
     void initFields ();
--- trunk/KDE/kdesdk/umbrello/umbrello/hierarchicalcodeblock.cpp #747976:747977
@@ -320,7 +320,7 @@
 
 void HierarchicalCodeBlock::initAttributes()
 {
-    m_canDelete = false;
+    setCanDelete(false);
     m_startText = "";
     m_endText = "";
 }




More information about the umbrello-devel mailing list