• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

umbrello/umbrello

  • sources
  • kde-4.12
  • kdesdk
  • umbrello
  • umbrello
  • codegenerators
  • cpp
cppcodecomment.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * This program is free software; you can redistribute it and/or modify *
3  * it under the terms of the GNU General Public License as published by *
4  * the Free Software Foundation; either version 2 of the License, or *
5  * (at your option) any later version. *
6  * *
7  * copyright (C) 2003 Brian Thomas <thomas@mail630.gsfc.nasa.gov> *
8  * copyright (C) 2004-2013 *
9  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
10  ***************************************************************************/
11 
12 // own header
13 #include "cppcodecomment.h"
14 
15 // qt includes
16 #include <QRegExp>
17 
18 
19 CPPCodeComment::CPPCodeComment (CodeDocument * doc, const QString & text)
20  : CodeComment (doc, text)
21 {
22 }
23 
24 CPPCodeComment::~CPPCodeComment ()
25 {
26 }
27 
28 void CPPCodeComment::saveToXMI (QDomDocument & doc, QDomElement & root)
29 {
30  QDomElement blockElement = doc.createElement("cppcodecomment");
31  setAttributesOnNode(doc, blockElement); // as we added no additional fields to this class we may
32  // just use parent TextBlock method
33  root.appendChild(blockElement);
34 }
35 
36 QString CPPCodeComment::toString () const
37 {
38  QString output = "";
39 
40  // simple output method
41  if(getWriteOutText())
42  {
43  QString indent = getIndentationString();
44  QString endLine = getNewLineEndingChars();
45  output.append(formatMultiLineText (getText()+endLine, indent +"// ", endLine));
46  }
47 
48  return output;
49 }
50 
51 QString CPPCodeComment::getNewEditorLine (int amount)
52 {
53  QString line = getIndentationString(amount) + "// ";
54  return line;
55 }
56 
57 QString CPPCodeComment::unformatText (const QString & text, const QString & indent)
58 {
59  // remove leading or trailing comment stuff
60  QString mytext = TextBlock::unformatText(text, indent);
61 
62  // now leading slashes
63  mytext.remove(QRegExp("^\\/\\/\\s*"));
64  return mytext;
65 }
TextBlock::unformatText
virtual QString unformatText(const QString &text, const QString &indent="")
UnFormat a long text string.
Definition: textblock.cpp:253
TextBlock::getNewLineEndingChars
static QString getNewLineEndingChars()
Get the new line chars which ends the line.
Definition: textblock.cpp:172
CPPCodeComment::toString
QString toString() const
Definition: cppcodecomment.cpp:36
CPPCodeComment::unformatText
virtual QString unformatText(const QString &text, const QString &indent="")
UnFormat a long text string.
Definition: cppcodecomment.cpp:57
TextBlock::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
Set attributes of the node that represents this class in the XMI document.
Definition: textblock.cpp:322
CodeDocument
A document containing the code for one file.
Definition: codedocument.h:32
cppcodecomment.h
CPPCodeComment::CPPCodeComment
CPPCodeComment(CodeDocument *doc, const QString &text="")
Constructors.
Definition: cppcodecomment.cpp:19
CPPCodeComment::getNewEditorLine
virtual QString getNewEditorLine(int amount)
A special version here because we want to not only indent the new line, but to add the "//" sequence ...
Definition: cppcodecomment.cpp:51
TextBlock::formatMultiLineText
static QString formatMultiLineText(const QString &work, const QString &linePrefix, const QString &breakStr, bool addBreak=true, bool lastLineHasBreak=true)
Format a long text string to be more readable.
Definition: textblock.cpp:288
CPPCodeComment::~CPPCodeComment
virtual ~CPPCodeComment()
Empty Destructor.
Definition: cppcodecomment.cpp:24
TextBlock::getIndentationString
QString getIndentationString(int level=0) const
Get the actual amount of indentation for a given level of indentation.
Definition: textblock.cpp:193
CPPCodeComment::saveToXMI
virtual void saveToXMI(QDomDocument &doc, QDomElement &root)
Save the XMI representation of this object.
Definition: cppcodecomment.cpp:28
TextBlock::getWriteOutText
bool getWriteOutText() const
Get the value of m_writeOutText Whether or not to include the text of this TextBlock into a file...
Definition: textblock.cpp:141
CodeComment
Text which will be comments.
Definition: codecomment.h:23
TextBlock::getText
QString getText() const
Get the value of m_text The actual text of this code block.
Definition: textblock.cpp:99
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:05:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

umbrello/umbrello

Skip menu "umbrello/umbrello"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal