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

Andi Fischer andi.fischer at hispeed.ch
Thu Dec 13 08:53:09 UTC 2007


SVN commit 747972 by fischer:

Some code and documentation format changes.

 M  +21 -21    textblock.cpp  
 M  +46 -28    textblock.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/textblock.cpp #747971:747972
@@ -14,11 +14,11 @@
  *      Date   : Wed Jun 18 2003
  */
 
-
 // own header
 #include "textblock.h"
 
 // qt/kde includes
+#include <QtCore/QTextStream>
 #include <QtCore/QRegExp>
 
 // local includes
@@ -42,11 +42,12 @@
 }
 
 TextBlock::~TextBlock ()
-{ }
+{
+}
 
-void TextBlock::setParentDocument ( CodeDocument * parent )
+void TextBlock::setCanDelete(bool canDelete)
 {
-    m_parentDocument = parent;
+    m_canDelete = canDelete;
 }
 
 bool TextBlock::canDelete()
@@ -106,22 +107,22 @@
 
 QString TextBlock::getNewLineEndingChars()
 {
-    CodeGenerationPolicy * policy = UMLApp::app()->getCommonPolicy();
+    CodeGenerationPolicy* policy = UMLApp::app()->getCommonPolicy();
     return policy->getNewLineEndingChars();
 }
 
 QString TextBlock::getIndentation()
 {
-    CodeGenerationPolicy * policy = UMLApp::app()->getCommonPolicy();
+    CodeGenerationPolicy* policy = UMLApp::app()->getCommonPolicy();
     return policy->getIndentation();
 }
 
-QString TextBlock::getIndentationString ( int level )
+QString TextBlock::getIndentationString ( int level ) const
 {
     if (!level)
         level = m_indentationLevel;
     QString indentAmount = getIndentation();
-    QString indentation = "";
+    QString indentation = QString();
     for(int i=0; i<level; i++)
         indentation.append(indentAmount);
     return indentation;
@@ -144,14 +145,14 @@
 
 QString TextBlock::unformatText ( const QString & text, const QString & indent )
 {
-    // will remove indenation from this text block.
     QString output = text;
     QString myIndent = indent;
-    if(myIndent.isEmpty())
+    if (myIndent.isEmpty())
         myIndent = getIndentationString();
 
-    if(!output.isEmpty())
-        output.remove(QRegExp('^'+myIndent));
+    if (!output.isEmpty())
+        // remove indenation from this text block.
+        output.remove(QRegExp('^' + myIndent));
 
     return output;
 }
@@ -226,15 +227,12 @@
     QString endLine = UMLApp::app()->getCommonPolicy()->getNewLineEndingChars();
 
     setIndentationLevel(root.attribute("indentLevel", "0").toInt());
-    setTag(root.attribute("tag",""));
+    setTag(root.attribute("tag", ""));
     setText(decodeText(root.attribute("text", ""), endLine));
     setWriteOutText(root.attribute("writeOutText", "true") == "true" ? true : false);
     m_canDelete = root.attribute("canDelete", "true") == "true" ? true : false;
 }
 
-// encode text for XML storage
-// we simply convert all types of newLines to the "\n" or 

-// entity.
 QString TextBlock::encodeText(const QString & text, const QString & endLine)
 {
     QString encoded = text;
@@ -242,9 +240,6 @@
     return encoded;
 }
 
-// encode text for XML storage
-// we simply convert all types of newLines to the "\n" or 

-// entity.
 QString TextBlock::decodeText(const QString & text, const QString & endLine)
 {
     QString decoded = text;
@@ -252,7 +247,7 @@
     return decoded;
 }
 
-QString TextBlock::toString()
+QString TextBlock::toString() const
 {
     // simple output method
     if (m_writeOutText && !m_text.isEmpty())
@@ -260,8 +255,13 @@
         QString endLine = UMLApp::app()->getCommonPolicy()->getNewLineEndingChars();
         return formatMultiLineText(m_text, getIndentationString(), endLine);
     } else
-        return "";
+        return QString();
 }
 
+QTextStream& operator<<(QTextStream& os, const TextBlock& obj)
+{
+    os << "TextBlock: " <<  ", ...";  //:TODO:
+    return os;
+}
 
 #include "textblock.moc"
--- trunk/KDE/kdesdk/umbrello/umbrello/textblock.h #747971:747972
@@ -14,17 +14,16 @@
  *      Date   : Wed Jun 18 2003
  */
 
-
 #ifndef TEXTBLOCK_H
 #define TEXTBLOCK_H
 
-#include <qdom.h>
-#include <qobject.h>
+#include <QtXml/QDomDocument>
+#include <QtXml/QDomElement>
+#include <QtCore/QObject>
 
 class CodeDocument;
 
 /**
-  * class TextBlock
   * The fundemental unit of text within an output file containing code.
   */
 class TextBlock : virtual public QObject
@@ -34,35 +33,33 @@
     Q_OBJECT
 public:
 
-    // Constructors/Destructors
-
     /**
-     * Constructors
+     * Constructor.
      */
     explicit TextBlock ( CodeDocument * parent, const QString & text = "");
 
-    // destructor
-    ~TextBlock ( );
+    /**
+     * Destructor.
+     */
+    virtual ~TextBlock ( );
 
-    // Public attribute accessor methods
-
     /**
      * Set the value of m_text
      * The actual text of this code block.
-     * @param text the new value of m_text
+     * @param text   the new value of m_text
      */
     void setText ( const QString & text );
 
     /**
      * Add text to this object.
-     *
+     * @param text   the text to add
      */
     void appendText ( const QString & text );
 
     /**
      * Get the value of m_text
      * The actual text of this code block.
-     * @return the value of m_text
+     * @return   the value of m_text
      */
     QString getText() const;
 
@@ -70,6 +67,7 @@
      * Get the tag of this text block. This tag
      * may be used to find this text block in the code document
      * to which it belongs.
+     * @return   the tag
      */
     QString getTag() const;
 
@@ -77,6 +75,7 @@
      * Set the tag of this text block. This tag
      * may be used to find this text block in the code document
      * to which it belongs.
+     * @param value   the new value for the tag
      */
     void setTag( const QString & value );
 
@@ -89,7 +88,7 @@
     /**
      * Set the value of m_writeOutText
      * Whether or not to include the text of this TextBlock into a file.
-     * @param write the new value of m_writeOutText
+     * @param write   the new value of m_writeOutText
      */
     void setWriteOutText ( bool write );
 
@@ -104,6 +103,7 @@
      * Set how many times to indent this text block.
      * The amount of each indenatation is determined from the parent
      * codedocument codegeneration policy.
+     * @param level   the new value for the indentation level
      */
     void setIndentationLevel ( int level );
 
@@ -111,26 +111,37 @@
      * Get how many times to indent this text block.
      * The amount of each indenatation is determined from the parent
      * codedocument codegeneration policy.
+     * @return   the indentation level
      */
     int getIndentationLevel();
 
     /**
      * Get the actual amount of indentation for a given level of indentation.
+     * @param level   the level of interest
+     * @return        the indentation string
      */
-    QString getIndentationString ( int level = 0);
+    QString getIndentationString ( int level = 0) const;
 
     /**
      * Get how much a single "level" of indentation will actually indent.
+     * @return   the unit of indentation (for one level)
      */
     static QString getIndentation();
 
     /**
      * Get the new line chars which ends the line.
+     * @return   the ending chars for new line
      */
     static QString getNewLineEndingChars();
 
     /**
      * Format a long text string to be more readable.
+     * @param text...            the original text for formatting
+     * @param linePrefix..      .a line prefix
+     * @param breakStr...        a break string
+     * @param alwaysAddBreak..  .control to add always a break string
+     * @param lastLineHasBreak...control to add a break string to the last line
+     * @return                   the new formatted text
      */
     static QString formatMultiLineText ( const QString & text, const QString & linePrefix,
                                   const QString & breakStr,
@@ -139,24 +150,27 @@
     /**
      * UnFormat a long text string. Typically, this means removing
      * the indentaion (linePrefix) and/or newline chars from each line.
-     * If an indentation isnt specified, then the current indentation is used.
+     * If an indentation is not specified, then the current indentation is used.
+     * @param text..  .the original text for unformatting
+     * @param indent...the indentation
+     * @return         the unformatted text
      */
     virtual QString unformatText ( const QString & text, const QString & indent = "");
 
     /**
      * @return  QString
      */
-    virtual QString toString();
+    virtual QString toString() const;
 
     /**
-     * Encode text for XML storage
-     * we simply convert all types of newLines to the "\n" or 

+     * Encode text for XML storage.
+     * We simply convert all types of newLines to the "\n" or 

      * entity.
      */
     static QString encodeText(const QString & text , const QString & endChars);
 
     /**
-     * Decode text from XML storage
+     * Decode text from XML storage.
      * We simply convert all newLine entity 
 to chosen line ending.
      */
     static QString decodeText(const QString & text, const QString & endChars);
@@ -206,6 +220,12 @@
 protected:
 
     /**
+     * Set the attribute m_canDelete.
+     * @param canDelete   the new value to set
+     */
+    void setCanDelete(bool canDelete);
+
+    /**
      * Causes the text block to release all of its connections
      * and any other text blocks that it 'owns'.
      * needed to be called prior to deletion of the textblock.
@@ -213,12 +233,6 @@
     virtual void release ();
 
     /**
-     * Set the parent document.
-     * @param parent The new value of m_parentDoc.
-     */
-    void setParentDocument ( CodeDocument * parent );
-
-    /**
      * Set attributes of the node that represents this class
      * in the XMI document.
      */
@@ -230,7 +244,7 @@
      */
     virtual void setAttributesFromNode ( QDomElement & element);
 
-    bool m_canDelete;
+    friend QTextStream& operator<<(QTextStream& os, const TextBlock& obj);
 
 private:
 
@@ -238,6 +252,8 @@
     QString m_text;
     QString m_tag;
 
+    bool m_canDelete;
+
     // Whether or not to include the text of this TextBlock into a file.
     bool m_writeOutText;
 
@@ -246,4 +262,6 @@
 
 };
 
+QTextStream& operator<<(QTextStream& os, const TextBlock& obj);
+
 #endif // TEXTBLOCK_H




More information about the umbrello-devel mailing list