umbrello 2.34.70-5524f40e1
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
TextBlock Class Referenceabstract

#include <textblock.h>

Inheritance diagram for TextBlock:
Collaboration diagram for TextBlock:

Public Member Functions

 TextBlock (CodeDocument *parent, const QString &text=QString())
 
virtual ~TextBlock ()
 
void setText (const QString &text)
 
QString getText () const
 
void appendText (const QString &text)
 
void setTag (const QString &value)
 
QString getTag () const
 
CodeDocumentgetParentDocument () const
 
void setWriteOutText (bool write)
 
bool getWriteOutText () const
 
void setIndentationLevel (int level)
 
int getIndentationLevel () const
 
QString getIndentationString (int level=0) const
 
virtual QString unformatText (const QString &text, const QString &indent=QString())
 
virtual QString toString () const
 
virtual void saveToXMI (QXmlStreamWriter &writer)=0
 
virtual void loadFromXMI (QDomElement &root)=0
 
bool canDelete () const
 
virtual void setAttributesFromObject (TextBlock *obj)
 
virtual QString getNewEditorLine (int amount=0)
 
virtual int firstEditableLine ()
 
virtual int lastEditableLine ()
 

Static Public Member Functions

static QString getIndentation ()
 
static QString getNewLineEndingChars ()
 
static QString formatMultiLineText (const QString &work, const QString &linePrefix, const QString &breakStr, bool addBreak=true, bool lastLineHasBreak=true)
 
static QString encodeText (const QString &text, const QString &endLine)
 
static QString decodeText (const QString &text, const QString &endLine)
 

Protected Member Functions

void setCanDelete (bool canDelete)
 
virtual void release ()
 
virtual void setAttributesOnNode (QXmlStreamWriter &writer)
 
virtual void setAttributesFromNode (QDomElement &root)
 

Private Attributes

QString m_text
 
QString m_tag
 
bool m_canDelete
 
bool m_writeOutText
 
int m_indentationLevel
 
CodeDocumentm_parentDocument
 

Friends

class CodeGenObjectWithTextBlocks
 
class ClassifierCodeDocument
 
QDebug operator<< (QDebug os, const TextBlock &obj)
 

Detailed Description

The fundamental unit of text within an output file containing code.

Constructor & Destructor Documentation

◆ TextBlock()

TextBlock::TextBlock ( CodeDocument parent,
const QString &  text = QString() 
)
explicit

Constructor.

Here is the call graph for this function:

◆ ~TextBlock()

TextBlock::~TextBlock ( )
virtual

Destructor.

Member Function Documentation

◆ appendText()

void TextBlock::appendText ( const QString &  text)

Add text to this object.

Parameters
textthe text to add

◆ canDelete()

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

◆ decodeText()

QString TextBlock::decodeText ( const QString &  text,
const QString &  endLine 
)
static

Decode text from XML storage. We simply convert all newLine entity &#010; to chosen line ending.

Parameters
textthe not yet decoded text
endLinethe chars at the end of each line
Returns
the decoded text

◆ encodeText()

QString TextBlock::encodeText ( const QString &  text,
const QString &  endLine 
)
static

Encode text for XML storage. We simply convert all types of newLines to the "\n" or &#010; entity.

Parameters
textthe not yet encoded text
endLinethe chars at the end of each line
Returns
the encoded text

◆ firstEditableLine()

int TextBlock::firstEditableLine ( )
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 CPPCodeDocumentation, DCodeDocumentation, JavaCodeDocumentation, and RubyCodeDocumentation.

◆ formatMultiLineText()

QString TextBlock::formatMultiLineText ( const QString &  work,
const QString &  linePrefix,
const QString &  breakStr,
bool  addBreak = true,
bool  lastLineHasBreak = true 
)
static

Format a long text string to be more readable.

Parameters
workthe original text for formatting
linePrefixa line prefix
breakStra break string
addBreakcontrol to add always a break string
lastLineHasBreakcontrol to add a break string to the last line
Returns
the new formatted text
Here is the call graph for this function:

◆ getIndentation()

QString TextBlock::getIndentation ( )
static

Get how much a single "level" of indentation will actually indent.

Returns
the unit of indentation (for one level)
Here is the call graph for this function:

◆ getIndentationLevel()

int TextBlock::getIndentationLevel ( ) const

Get how many times to indent this text block. The amount of each indentation is determined from the parent codedocument codegeneration policy.

Returns
the indentation level

◆ getIndentationString()

QString TextBlock::getIndentationString ( int  level = 0) const

Get the actual amount of indentation for a given level of indentation.

Parameters
levelthe level of interest
Returns
the indentation string
Here is the call graph for this function:

◆ getNewEditorLine()

QString TextBlock::getNewEditorLine ( int  amount = 0)
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
amountthe number of indent steps to use
Returns
the new line

Reimplemented in CPPCodeComment, CPPCodeDocumentation, DCodeComment, DCodeDocumentation, JavaCodeComment, JavaCodeDocumentation, RubyCodeComment, and RubyCodeDocumentation.

Here is the call graph for this function:

◆ getNewLineEndingChars()

QString TextBlock::getNewLineEndingChars ( )
static

Get the new line chars which ends the line.

Returns
the ending chars for new line
Here is the call graph for this function:

◆ getParentDocument()

CodeDocument * TextBlock::getParentDocument ( ) const

Get the value of m_parentDoc

Returns
the value of m_parentDoc

◆ getTag()

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

◆ getText()

QString TextBlock::getText ( ) const

Get the value of m_text The actual text of this code block.

Returns
the value of m_text

◆ getWriteOutText()

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

◆ lastEditableLine()

int TextBlock::lastEditableLine ( )
virtual

◆ loadFromXMI()

virtual void TextBlock::loadFromXMI ( QDomElement &  root)
pure virtual

◆ release()

void TextBlock::release ( )
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 CodeAccessorMethod, CodeClassFieldDeclarationBlock, CodeMethodBlock, HierarchicalCodeBlock, and OwnedHierarchicalCodeBlock.

◆ saveToXMI()

virtual void TextBlock::saveToXMI ( QXmlStreamWriter &  writer)
pure virtual

◆ setAttributesFromNode()

void TextBlock::setAttributesFromNode ( QDomElement &  root)
protectedvirtual

Set the class attributes of this object from the passed element node.

Parameters
rootthe xmi element from which to load

Reimplemented in CodeAccessorMethod, CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeMethodBlock, CodeOperation, DCodeAccessorMethod, HierarchicalCodeBlock, JavaCodeAccessorMethod, OwnedHierarchicalCodeBlock, RubyCodeAccessorMethod, and XMLElementCodeBlock.

Here is the call graph for this function:

◆ setAttributesFromObject()

void TextBlock::setAttributesFromObject ( TextBlock obj)
virtual

Set the class attributes from a passed object.

Parameters
objtext block from which the attributes are taken

Reimplemented in CodeAccessorMethod, CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeMethodBlock, CodeOperation, CPPHeaderClassDeclarationBlock, DClassDeclarationBlock, HierarchicalCodeBlock, and OwnedHierarchicalCodeBlock.

Here is the call graph for this function:

◆ setAttributesOnNode()

void TextBlock::setAttributesOnNode ( QXmlStreamWriter &  writer)
protectedvirtual

Set attributes of the node that represents this class in the XMI document.

Parameters
writerthe QXmlStreamWriter serialization target

Reimplemented in CodeAccessorMethod, CodeBlock, CodeBlockWithComments, CodeClassFieldDeclarationBlock, CodeMethodBlock, CodeOperation, DCodeAccessorMethod, HierarchicalCodeBlock, JavaCodeAccessorMethod, OwnedHierarchicalCodeBlock, RubyCodeAccessorMethod, and XMLElementCodeBlock.

Here is the call graph for this function:

◆ setCanDelete()

void TextBlock::setCanDelete ( bool  canDelete)
protected

Set the attribute m_canDelete.

Parameters
canDeletethe new value to set
Here is the call graph for this function:

◆ setIndentationLevel()

void TextBlock::setIndentationLevel ( int  level)

Set how many times to indent this text block. The amount of each indentation is determined from the parent codedocument codegeneration policy.

Parameters
levelthe new value for the indentation level

◆ setTag()

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
valuethe new value for the tag

◆ setText()

void TextBlock::setText ( const QString &  text)

Set the value of m_text The actual text of this code block.

Parameters
textthe new value of m_text

◆ setWriteOutText()

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
writethe new value of m_writeOutText

◆ toString()

QString TextBlock::toString ( ) const
virtual

Return the text in the right format. Returned string is empty if m_writeOutText is false.

Returns
QString

Reimplemented in CodeBlockWithComments, CodeMethodBlock, CPPCodeComment, CPPCodeDocumentation, DCodeComment, DCodeDocumentation, HierarchicalCodeBlock, JavaCodeComment, JavaCodeDocumentation, RubyCodeComment, RubyCodeDocumentation, and XMLCodeComment.

Here is the call graph for this function:

◆ unformatText()

QString TextBlock::unformatText ( const QString &  text,
const QString &  indent = QString() 
)
virtual

UnFormat a long text string. Typically, this means removing the indentation (linePrefix) and/or newline chars from each line. If an indentation is not specified, then the current indentation is used.

Parameters
textthe original text for unformatting
indentthe indentation
Returns
the unformatted text

Reimplemented in CPPCodeComment, CPPCodeDocumentation, DCodeComment, DCodeDocumentation, JavaCodeComment, JavaCodeDocumentation, RubyCodeComment, and RubyCodeDocumentation.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ ClassifierCodeDocument

friend class ClassifierCodeDocument
friend

◆ CodeGenObjectWithTextBlocks

friend class CodeGenObjectWithTextBlocks
friend

◆ operator<<

QDebug operator<< ( QDebug  os,
const TextBlock obj 
)
friend

Operator '<<' for TextBlock.

Member Data Documentation

◆ m_canDelete

bool TextBlock::m_canDelete
private

◆ m_indentationLevel

int TextBlock::m_indentationLevel
private

◆ m_parentDocument

CodeDocument* TextBlock::m_parentDocument
private

◆ m_tag

QString TextBlock::m_tag
private

◆ m_text

QString TextBlock::m_text
private

◆ m_writeOutText

bool TextBlock::m_writeOutText
private

The documentation for this class was generated from the following files: