cppcodecomment.cpp
00001 00002 /*************************************************************************** 00003 * * 00004 * This program is free software; you can redistribute it and/or modify * 00005 * it under the terms of the GNU General Public License as published by * 00006 * the Free Software Foundation; either version 2 of the License, or * 00007 * (at your option) any later version. * 00008 * * 00009 * copyright (C) 2004-2007 * 00010 * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> * 00011 ***************************************************************************/ 00012 00013 /* This code generated by: 00014 * Author : thomas 00015 * Date : Mon Sep 1 2003 00016 */ 00017 00018 // own header 00019 #include "cppcodecomment.h" 00020 00021 // qt/kde includes 00022 #include <qregexp.h> 00023 00024 // Constructors/Destructors 00025 // 00026 00027 CPPCodeComment::CPPCodeComment ( CodeDocument * doc, const QString & text ) 00028 : CodeComment (doc, text) 00029 { 00030 00031 } 00032 00033 CPPCodeComment::~CPPCodeComment ( ) { } 00034 00035 // 00036 // Methods 00037 // 00038 00039 00040 // Accessor methods 00041 // 00042 00043 00044 // Public attribute accessor methods 00045 // 00046 00047 // Other methods 00048 // 00049 00053 void CPPCodeComment::saveToXMI ( QDomDocument & doc, QDomElement & root ) { 00054 QDomElement blockElement = doc.createElement( "cppcodecomment" ); 00055 setAttributesOnNode(doc, blockElement); // as we added no additional fields to this class we may 00056 // just use parent TextBlock method 00057 root.appendChild( blockElement ); 00058 } 00059 00063 QString CPPCodeComment::toString ( ) 00064 { 00065 00066 QString output = ""; 00067 00068 // simple output method 00069 if(getWriteOutText()) 00070 { 00071 QString indent = getIndentationString(); 00072 QString endLine = getNewLineEndingChars(); 00073 output.append(formatMultiLineText (getText()+endLine, indent +"// ", endLine)); 00074 } 00075 00076 return output; 00077 } 00078 00079 QString CPPCodeComment::getNewEditorLine ( int amount ) { 00080 QString line = getIndentationString(amount) + "// "; 00081 return line; 00082 } 00083 00087 QString CPPCodeComment::unformatText ( const QString & text , const QString & indent) 00088 { 00089 00090 // remove leading or trailing comment stuff 00091 QString mytext = TextBlock::unformatText(text, indent); 00092 00093 // now leading slashes 00094 mytext.remove(QRegExp("^\\/\\/\\s*")); 00095 return mytext; 00096 } 00097 00098 #include "cppcodecomment.moc"
