umbrello/umbrello
#include <textblock.h>
Public Member Functions | |
TextBlock (CodeDocument *parent, const QString &text="") | |
virtual | ~TextBlock () |
void | appendText (const QString &text) |
bool | canDelete () const |
virtual int | firstEditableLine () |
int | getIndentationLevel () const |
QString | getIndentationString (int level=0) const |
virtual QString | getNewEditorLine (int amount=0) |
CodeDocument * | getParentDocument () const |
QString | getTag () const |
QString | getText () const |
bool | getWriteOutText () const |
virtual int | lastEditableLine () |
virtual void | loadFromXMI (QDomElement &root)=0 |
virtual void | saveToXMI (QDomDocument &doc, QDomElement &root)=0 |
virtual void | setAttributesFromObject (TextBlock *obj) |
void | setIndentationLevel (int level) |
void | setTag (const QString &value) |
void | setText (const QString &text) |
void | setWriteOutText (bool write) |
virtual QString | toString () const |
virtual QString | unformatText (const QString &text, const QString &indent="") |
Static Public Member Functions | |
static QString | decodeText (const QString &text, const QString &endLine) |
static QString | encodeText (const QString &text, const QString &endLine) |
static QString | formatMultiLineText (const QString &work, const QString &linePrefix, const QString &breakStr, bool addBreak=true, bool lastLineHasBreak=true) |
static QString | getIndentation () |
static QString | getNewLineEndingChars () |
Protected Member Functions | |
virtual void | release () |
virtual void | setAttributesFromNode (QDomElement &root) |
virtual void | setAttributesOnNode (QDomDocument &doc, QDomElement &blockElement) |
void | setCanDelete (bool canDelete) |
Friends | |
QDebug | operator<< (QDebug os, const TextBlock &obj) |
Detailed Description
The fundemental unit of text within an output file containing code.
Definition at line 24 of file textblock.h.
Constructor & Destructor Documentation
|
explicit |
Constructor.
Definition at line 28 of file textblock.cpp.
|
virtual |
Destructor.
Definition at line 42 of file textblock.cpp.
Member Function Documentation
void TextBlock::appendText | ( | const QString & | text | ) |
Add text to this object.
- Parameters
-
text the text to add
Definition at line 89 of file textblock.cpp.
bool TextBlock::canDelete | ( | ) | const |
Determine if its OK to delete this textblock from the document.
Used by the text editor to know if deletion could cause a crash of the program.
- Returns
- the value of m_canDelete
Definition at line 61 of file textblock.cpp.
|
static |
Decode text from XML storage.
We simply convert all newLine entity 
 to chosen line ending.
- Parameters
-
text the not yet decoded text endLine the chars at the end of each line
- Returns
- the decoded text
Definition at line 392 of file textblock.cpp.
|
static |
Encode text for XML storage.
We simply convert all types of newLines to the "\n" or 
 entity.
- Parameters
-
text the not yet encoded text endLine the chars at the end of each line
- Returns
- the encoded text
Definition at line 378 of file textblock.cpp.
|
virtual |
TODO: Ush.
These are terrifically bad and must one day go away. Both methods indicate the range of lines in this textblock which may be edited by the codeeditor (assuming that any are actually editable). The default case is no lines are editable. The line numbering starts with '0' and a '-1' means no line qualifies.
- Returns
- line number
Reimplemented in DCodeDocumentation, RubyCodeDocumentation, JavaCodeDocumentation, and CPPCodeDocumentation.
Definition at line 215 of file textblock.cpp.
|
static |
Format a long text string to be more readable.
- Parameters
-
work the original text for formatting linePrefix a line prefix breakStr a break string addBreak control to add always a break string lastLineHasBreak control to add a break string to the last line
- Returns
- the new formatted text
Definition at line 288 of file textblock.cpp.
|
static |
Get how much a single "level" of indentation will actually indent.
- Returns
- the unit of indentation (for one level)
Definition at line 182 of file textblock.cpp.
int TextBlock::getIndentationLevel | ( | ) | const |
Get how many times to indent this text block.
The amount of each indenatation is determined from the parent codedocument codegeneration policy.
- Returns
- the indentation level
Definition at line 163 of file textblock.cpp.
QString TextBlock::getIndentationString | ( | int | level = 0 | ) | const |
Get the actual amount of indentation for a given level of indentation.
- Parameters
-
level the level of interest
- Returns
- the indentation string
Definition at line 193 of file textblock.cpp.
|
virtual |
Used by the CodeEditor.
It provides it with an appropriate starting string for a new line of text within the given textblock (for example a string with the proper indentation). If the indentation amount is '0' the current indentation string will be used.
TODO: Can be refactored away and replaced with getIndentationString.
- Parameters
-
amount the number of indent steps to use
- Returns
- the new line
Reimplemented in DCodeDocumentation, DCodeComment, RubyCodeDocumentation, JavaCodeDocumentation, CPPCodeDocumentation, CPPCodeComment, RubyCodeComment, and JavaCodeComment.
Definition at line 240 of file textblock.cpp.
|
static |
Get the new line chars which ends the line.
- Returns
- the ending chars for new line
Definition at line 172 of file textblock.cpp.
CodeDocument * TextBlock::getParentDocument | ( | ) | const |
Get the value of m_parentDoc.
- Returns
- the value of m_parentDoc
Definition at line 70 of file textblock.cpp.
QString TextBlock::getTag | ( | ) | const |
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.
- Returns
- the tag
Definition at line 110 of file textblock.cpp.
QString TextBlock::getText | ( | ) | const |
Get the value of m_text The actual text of this code block.
- Returns
- the value of m_text
Definition at line 99 of file textblock.cpp.
bool TextBlock::getWriteOutText | ( | ) | const |
Get the value of m_writeOutText Whether or not to include the text of this TextBlock into a file.
- Returns
- the value of m_writeOutText
Definition at line 141 of file textblock.cpp.
|
virtual |
- See also
- firstEditableLine
Reimplemented in DCodeDocumentation, RubyCodeDocumentation, JavaCodeDocumentation, CPPCodeDocumentation, CPPHeaderCodeOperation, RubyCodeOperation, DCodeOperation, and JavaCodeOperation.
Definition at line 223 of file textblock.cpp.
|
pure virtual |
Load params from the appropriate XMI element node.
- Parameters
-
root the starting point in the xmi document to load from
Implemented in OwnedHierarchicalCodeBlock, CodeAccessorMethod, HierarchicalCodeBlock, RubyClassDeclarationBlock, CodeClassFieldDeclarationBlock, CodeBlockWithComments, CPPHeaderClassDeclarationBlock, XMLElementCodeBlock, CodeOperation, DClassDeclarationBlock, JavaClassDeclarationBlock, CodeBlock, and CodeComment.
|
protectedvirtual |
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. TODO: Does nothing.
Reimplemented in HierarchicalCodeBlock, CodeMethodBlock, OwnedHierarchicalCodeBlock, CodeAccessorMethod, and CodeClassFieldDeclarationBlock.
Definition at line 275 of file textblock.cpp.
|
pure virtual |
Save the XMI representation of this object.
- Parameters
-
doc the xmi document root the starting point to append
Implemented in OwnedHierarchicalCodeBlock, CodeAccessorMethod, HierarchicalCodeBlock, CodeClassFieldDeclarationBlock, RubyCodeDocumentation, CPPCodeDocumentation, DCodeDocumentation, JavaCodeDocumentation, RubyClassDeclarationBlock, CodeBlockWithComments, CPPHeaderClassDeclarationBlock, DCodeComment, CodeOperation, CPPCodeComment, CodeBlock, XMLElementCodeBlock, DClassDeclarationBlock, JavaClassDeclarationBlock, and CodeComment.
|
protectedvirtual |
Set the class attributes of this object from the passed element node.
- Parameters
-
root the xmi element from which to load
Reimplemented in CodeMethodBlock, XMLElementCodeBlock, HierarchicalCodeBlock, OwnedHierarchicalCodeBlock, CodeAccessorMethod, CodeOperation, CodeClassFieldDeclarationBlock, DCodeAccessorMethod, JavaCodeAccessorMethod, CodeBlockWithComments, CodeBlock, and RubyCodeAccessorMethod.
Definition at line 359 of file textblock.cpp.
|
virtual |
Set the class attributes from a passed object.
- Parameters
-
obj text block from which the attributes are taken
Reimplemented in CodeMethodBlock, HierarchicalCodeBlock, OwnedHierarchicalCodeBlock, DClassDeclarationBlock, CodeAccessorMethod, CPPHeaderClassDeclarationBlock, CodeBlockWithComments, CodeOperation, CodeBlock, and CodeClassFieldDeclarationBlock.
Definition at line 345 of file textblock.cpp.
|
protectedvirtual |
Set attributes of the node that represents this class in the XMI document.
- Parameters
-
doc the xmi document blockElement the xmi element holding the attributes
Reimplemented in CodeMethodBlock, HierarchicalCodeBlock, XMLElementCodeBlock, OwnedHierarchicalCodeBlock, CodeAccessorMethod, CodeOperation, CodeClassFieldDeclarationBlock, CodeBlockWithComments, DCodeAccessorMethod, JavaCodeAccessorMethod, CodeBlock, and RubyCodeAccessorMethod.
Definition at line 322 of file textblock.cpp.
|
protected |
Set the attribute m_canDelete.
- Parameters
-
canDelete the new value to set
Definition at line 50 of file textblock.cpp.
void TextBlock::setIndentationLevel | ( | int | level | ) |
Set how many times to indent this text block.
The amount of each indenatation is determined from the parent codedocument codegeneration policy.
- Parameters
-
level the new value for the indentation level
Definition at line 152 of file textblock.cpp.
void TextBlock::setTag | ( | const QString & | value | ) |
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.
- Parameters
-
value the new value for the tag
Definition at line 121 of file textblock.cpp.
void TextBlock::setText | ( | const QString & | text | ) |
Set the value of m_text The actual text of this code block.
- Parameters
-
text the new value of m_text
Definition at line 80 of file textblock.cpp.
void TextBlock::setWriteOutText | ( | bool | write | ) |
Set the value of m_writeOutText Whether or not to include the text of this TextBlock into a file.
- Parameters
-
write the new value of m_writeOutText
Definition at line 131 of file textblock.cpp.
|
virtual |
Return the text in the right format.
Returned string is empty if m_writeOutText is false.
- Returns
- QString
Reimplemented in DCodeDocumentation, DCodeComment, HierarchicalCodeBlock, RubyCodeDocumentation, CPPCodeDocumentation, JavaCodeDocumentation, CPPCodeComment, CodeMethodBlock, RubyCodeComment, JavaCodeComment, XMLCodeComment, and CodeBlockWithComments.
Definition at line 404 of file textblock.cpp.
|
virtual |
UnFormat a long text string.
Typically, this means removing the indentaion (linePrefix) and/or newline chars from each line. If an indentation is not specified, then the current indentation is used.
- Parameters
-
text the original text for unformatting indent the indentation
- Returns
- the unformatted text
Reimplemented in DCodeDocumentation, DCodeComment, RubyCodeDocumentation, JavaCodeDocumentation, CPPCodeDocumentation, CPPCodeComment, RubyCodeComment, and JavaCodeComment.
Definition at line 253 of file textblock.cpp.
Friends And Related Function Documentation
|
friend |
Operator '<<' for TextBlock.
Definition at line 419 of file textblock.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:06:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.