[Uml-devel] KDE/kdesdk/umbrello/umbrello
Andi Fischer
andi.fischer at hispeed.ch
Thu Dec 13 09:07:28 UTC 2007
SVN commit 747974 by fischer:
Some code and documentation format changes.
M +21 -7 codeblock.cpp
M +19 -3 codeblock.h
M +7 -25 codecomment.cpp
M +5 -14 codecomment.h
M +3 -17 codegenerators/cppheadercodeclassfielddeclarationblock.cpp
M +9 -25 codegenerators/javaclassdeclarationblock.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/codeblock.cpp #747973:747974
@@ -13,6 +13,8 @@
* Date : Wed Jun 18 2003
*/
+#include "kdebug.h"
+
#include "codeblock.h"
#include "codedocument.h"
@@ -31,7 +33,7 @@
m_contentType = new_var;
}
-CodeBlock::ContentType CodeBlock::getContentType ( )
+CodeBlock::ContentType CodeBlock::getContentType ( ) const
{
return m_contentType;
}
@@ -39,21 +41,19 @@
void CodeBlock::saveToXMI ( QDomDocument & doc, QDomElement & root )
{
QDomElement blockElement = doc.createElement( "codeblock" );
-
// set attributes
setAttributesOnNode(doc, blockElement);
-
root.appendChild( blockElement );
+ uDebug() << "******************* " << this;
}
void CodeBlock::setAttributesOnNode( QDomDocument & doc, QDomElement & blockElement)
{
// call super-class
TextBlock::setAttributesOnNode(doc, blockElement);
-
// local attributes
if (m_contentType != AutoGenerated)
- blockElement.setAttribute("contentType",getContentType());
+ blockElement.setAttribute("contentType", getContentType());
}
void CodeBlock::loadFromXMI ( QDomElement & root )
@@ -65,7 +65,6 @@
{
// set attributes from the XMI in super-class
TextBlock::setAttributesFromNode(elem);
-
// set local fields now
setContentType(((ContentType) elem.attribute("contentType","0").toInt()));
}
@@ -73,11 +72,26 @@
void CodeBlock::setAttributesFromObject(TextBlock * obj)
{
TextBlock::setAttributesFromObject(obj);
-
CodeBlock * cb = dynamic_cast<CodeBlock*>(obj);
if (cb)
setContentType(cb->getContentType());
}
+QString CodeBlock::toString(const ContentType& val)
+{
+ if (val == AutoGenerated) {
+ return QString("AutoGenerated");
+ }
+ else {
+ return QString("UserGenerated");
+ }
+}
+QTextStream& operator<<(QTextStream& os, const CodeBlock& obj)
+{
+ os << "CodeBlock: " << CodeBlock::toString(obj.getContentType()) << ", ..." /*<< static_cast<TextBlock>(obj)*/; //:TODO:
+ return os;
+}
+
+
#include "codeblock.moc"
--- trunk/KDE/kdesdk/umbrello/umbrello/codeblock.h #747973:747974
@@ -14,7 +14,6 @@
* Date : Wed Jun 18 2003
*/
-
#ifndef CODEBLOCK_H
#define CODEBLOCK_H
@@ -25,7 +24,6 @@
/**
- * class CodeBlock
* A "chunk" of code within the code document.
*/
@@ -34,6 +32,12 @@
Q_OBJECT
public:
+ /**
+ * Describes the creation of the content.
+ * <p>
+ * @param AutoGenerated the content was generated by code generation itself
+ * @param UserGenerated the content was entered by the user
+ */
enum ContentType {AutoGenerated=0, UserGenerated };
/**
@@ -61,9 +65,17 @@
* generator or was supplied by the user.
* @return the value of m_contentType
*/
- ContentType getContentType ( );
+ ContentType getContentType ( ) const;
/**
+ * Return a string representation of ContentType.
+ *
+ * @param val the enum value of the ContentType
+ * @return the string representation of the enum
+ */
+ static QString toString(const ContentType& val);
+
+ /**
* Save the XMI representation of this object
*/
virtual void saveToXMI ( QDomDocument & doc, QDomElement & root );
@@ -92,6 +104,8 @@
*/
virtual void setAttributesFromNode ( QDomElement & element);
+ friend QTextStream& operator<<(QTextStream& os, const CodeBlock& obj);
+
private:
// specifies whether the content (text) of this object
@@ -100,4 +114,6 @@
};
+QTextStream& operator<<(QTextStream& os, const CodeBlock& obj);
+
#endif // CODEBLOCK_H
--- trunk/KDE/kdesdk/umbrello/umbrello/codecomment.cpp #747973:747974
@@ -17,43 +17,25 @@
#include "codedocument.h"
#include <kdebug.h>
-// Constructors/Destructors
-//
-
CodeComment::CodeComment (CodeDocument * doc, const QString & comment )
: TextBlock ( doc, comment )
{
+}
+CodeComment::~CodeComment ( )
+{
}
-CodeComment::~CodeComment ( ) { }
-
-//
-// Methods
-//
-
-
-// Accessor methods
-//
-
-
-// Other methods
-//
-
-/**
- * Save the XMI representation of this object
- */
-void CodeComment::saveToXMI ( QDomDocument & doc, QDomElement & root ) {
+void CodeComment::saveToXMI ( QDomDocument & doc, QDomElement & root )
+{
QDomElement blockElement = doc.createElement( "codecomment" );
setAttributesOnNode(doc, blockElement); // as we added no additional fields to this class we may
// just use parent TextBlock method
root.appendChild( blockElement );
}
-/**
- * load params from the appropriate XMI element node.
- */
-void CodeComment::loadFromXMI ( QDomElement & root ) {
+void CodeComment::loadFromXMI ( QDomElement & root )
+{
setAttributesFromNode(root);
}
--- trunk/KDE/kdesdk/umbrello/umbrello/codecomment.h #747973:747974
@@ -13,17 +13,14 @@
* Date : Wed Jun 18 2003
*/
-
-
#ifndef CODECOMMENT_H
#define CODECOMMENT_H
-#include <qstring.h>
+#include <QtCore/QString>
#include "textblock.h"
/**
- * class CodeComment
* Text which will be comments. These should be bracketed by what ever code type
* comment the language requires.
*/
@@ -33,27 +30,23 @@
Q_OBJECT
public:
- // Constructors/Destructors
- //
-
-
/**
- * Empty Constructor
+ * Empty Constructor.
*/
explicit CodeComment ( CodeDocument * doc, const QString & comment = "");
/**
- * Empty Destructor
+ * Empty Destructor.
*/
virtual ~CodeComment ( );
/**
- * Save the XMI representation of this object
+ * Save the XMI representation of this object.
*/
virtual void saveToXMI ( QDomDocument & doc, QDomElement & root );
/**
- * load params from the appropriate XMI element node.
+ * Load params from the appropriate XMI element node.
*/
virtual void loadFromXMI ( QDomElement & root );
@@ -61,8 +54,6 @@
private:
-
-
};
#endif // CODECOMMENT_H
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/cppheadercodeclassfielddeclarationblock.cpp #747973:747974
@@ -18,8 +18,6 @@
#include "cppcodeclassfield.h"
#include "cppheadercodedocument.h"
-// Constructors/Destructors
-//
CPPHeaderCodeClassFieldDeclarationBlock::CPPHeaderCodeClassFieldDeclarationBlock ( CodeClassField * parent )
: CodeClassFieldDeclarationBlock ( parent )
@@ -27,17 +25,9 @@
setOverallIndentationLevel(1);
}
-CPPHeaderCodeClassFieldDeclarationBlock::~CPPHeaderCodeClassFieldDeclarationBlock ( ) { }
+CPPHeaderCodeClassFieldDeclarationBlock::~CPPHeaderCodeClassFieldDeclarationBlock ( )
+{ }
-//
-// Methods
-//
-
-// Other methods
-//
-
-/**
- */
void CPPHeaderCodeClassFieldDeclarationBlock::updateContent( )
{
UMLObject *umlparent = CodeClassFieldDeclarationBlock::getParentObject();
@@ -51,12 +41,11 @@
// Set the comment
QString notes = umlparent->getDoc();
getComment()->setText(notes);
- if(notes.isEmpty())
+ if (notes.isEmpty())
getComment()->setWriteOutText(false);
else
getComment()->setWriteOutText(true);
-
// Set the body
QString staticValue = umlparent->getStatic() ? "static " : "";
QString typeName = hcppcf->getTypeName();
@@ -67,11 +56,8 @@
typeName = hcppcf->getListFieldClassName();
QString body = staticValue + ' ' + typeName + ' ' + fieldName + ';';
-
setText(body);
-
}
-
#include "cppheadercodeclassfielddeclarationblock.moc"
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/javaclassdeclarationblock.cpp #747973:747974
@@ -13,14 +13,13 @@
* Author : thomas
* Date : Wed Jul 16 2003
*/
+
#include "javaclassdeclarationblock.h"
#include "javacodedocumentation.h"
#include "../codegenerator.h"
#include "../codegenerationpolicy.h"
#include "../uml.h"
-// Constructors/Destructors
-//
JavaClassDeclarationBlock::JavaClassDeclarationBlock
( JavaClassifierCodeDocument * parentDoc, const QString &startText, const QString &endText, const QString &comment)
@@ -29,20 +28,16 @@
init(parentDoc, comment);
}
-JavaClassDeclarationBlock::~JavaClassDeclarationBlock ( ) { }
+JavaClassDeclarationBlock::~JavaClassDeclarationBlock ( )
+{ }
-//
-// Methods
-//
-
/**
* Save the XMI representation of this object
*/
-void JavaClassDeclarationBlock::saveToXMI ( QDomDocument & doc, QDomElement & root ) {
+void JavaClassDeclarationBlock::saveToXMI ( QDomDocument & doc, QDomElement & root )
+{
QDomElement blockElement = doc.createElement( "javaclassdeclarationblock" );
-
setAttributesOnNode(doc, blockElement);
-
root.appendChild( blockElement );
}
@@ -54,18 +49,11 @@
setAttributesFromNode(root);
}
-// Accessor methods
-//
-
-// Other methods
-//
-
/**
* update the start and end text for this ownedhierarchicalcodeblock.
*/
void JavaClassDeclarationBlock::updateContent ( )
{
-
JavaClassifierCodeDocument *parentDoc = dynamic_cast<JavaClassifierCodeDocument*>(getParentDocument());
UMLClassifier *c = parentDoc->getParentClassifier();
CodeGenerationPolicy *commonPolicy = UMLApp::app()->getCommonPolicy();
@@ -74,18 +62,17 @@
QString JavaClassName = parentDoc->getJavaClassName(c->getName());
// COMMENT
- if(isInterface)
+ if (isInterface)
getComment()->setText("Interface "+JavaClassName+endLine+c->getDoc());
else
getComment()->setText("Class "+JavaClassName+endLine+c->getDoc());
bool forceDoc = UMLApp::app()->getCommonPolicy()->getCodeVerboseDocumentComments();
- if(forceDoc || !c->getDoc().isEmpty())
+ if (forceDoc || !c->getDoc().isEmpty())
getComment()->setWriteOutText(true);
else
getComment()->setWriteOutText(false);
-
// Now set START/ENDING Text
QString startText = "";
// In Java, we need declare abstract only on classes
@@ -101,7 +88,7 @@
} else
startText.append("public ");
- if(parentDoc->parentIsInterface())
+ if (parentDoc->parentIsInterface())
startText.append("interface ");
else
startText.append("class ");
@@ -118,7 +105,7 @@
// write out inheritance
int i = 0;
- if(nrof_superclasses >0)
+ if (nrof_superclasses >0)
startText.append(" extends ");
foreach (UMLClassifier* concept, superclasses ) {
startText.append(parentDoc->cleanName(concept->getName()));
@@ -148,15 +135,12 @@
setStartText(startText+" {");
// setEndText("}"); // not needed
-
}
void JavaClassDeclarationBlock::init (JavaClassifierCodeDocument *parentDoc, const QString &comment)
{
-
setComment(new JavaCodeDocumentation(parentDoc));
getComment()->setText(comment);
-
setEndText("}");
}
More information about the umbrello-devel
mailing list