umbrello 2.32.3 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

textblock.h
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-2020 *
9 * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
10 ***************************************************************************/
11
12 #ifndef TEXTBLOCK_H
13 #define TEXTBLOCK_H
14
15 #include <QDomDocument>
16 #include <QDomElement>
17 #include <QObject>
18
19 class CodeDocument;
20
24 class TextBlock
25 {
26 friend class CodeGenObjectWithTextBlocks;
27 friend class ClassifierCodeDocument;
28 public:
29
30 explicit TextBlock(CodeDocument * parent, const QString & text = QString());
31 virtual ~TextBlock();
32
33 void setText(const QString & text);
34 QString getText() const;
35 void appendText(const QString & text);
36
37 void setTag(const QString & value);
38 QString getTag() const;
39
40 CodeDocument * getParentDocument() const;
41
42 void setWriteOutText(bool write);
43 bool getWriteOutText() const;
44
45 void setIndentationLevel(int level);
46 int getIndentationLevel() const;
47
48 QString getIndentationString(int level = 0) const;
49
50 static QString getIndentation();
51
52 static QString getNewLineEndingChars();
53
54 static QString formatMultiLineText(const QString & work, const QString & linePrefix,
55 const QString & breakStr,
56 bool addBreak = true, bool lastLineHasBreak = true);
57
58 virtual QString unformatText(const QString & text, const QString & indent = QString());
59
60 virtual QString toString() const;
61
62 static QString encodeText(const QString & text, const QString & endLine);
63 static QString decodeText(const QString & text, const QString & endLine);
64
70 virtual void saveToXMI1(QDomDocument & doc, QDomElement & root) = 0;
71
76 virtual void loadFromXMI1(QDomElement & root) = 0;
77
78 bool canDelete() const;
79
80 virtual void setAttributesFromObject(TextBlock * obj);
81
82 virtual QString getNewEditorLine(int amount = 0);
83
84 virtual int firstEditableLine();
85 virtual int lastEditableLine();
86
87 friend QDebug operator<<(QDebug os, const TextBlock& obj);
88
89 protected:
90
91 void setCanDelete(bool canDelete);
92
93 virtual void release();
94
95 virtual void setAttributesOnNode(QDomDocument & doc, QDomElement & blockElement);
96 virtual void setAttributesFromNode(QDomElement & root);
97
98 private:
99
100 QString m_text; //< The actual text of this code block.
101 QString m_tag;
102 bool m_canDelete;
103 bool m_writeOutText; //< Flag to write the text of this TextBlock into a file.
104 int m_indentationLevel;
105 CodeDocument * m_parentDocument;
106
107 };
108
109 #endif // TEXTBLOCK_H
TextBlock::getWriteOutText
bool getWriteOutText() const
Definition: textblock.cpp:141
TextBlock::m_canDelete
bool m_canDelete
Definition: textblock.h:102
TextBlock::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &root)
Definition: textblock.cpp:361
TextBlock::toString
virtual QString toString() const
Definition: textblock.cpp:407
textblock.h
TextBlock::setAttributesFromObject
virtual void setAttributesFromObject(TextBlock *obj)
Definition: textblock.cpp:347
TextBlock::encodeText
static QString encodeText(const QString &text, const QString &endLine)
Definition: textblock.cpp:381
TextBlock::setWriteOutText
void setWriteOutText(bool write)
Definition: textblock.cpp:131
UMLApp::commonPolicy
CodeGenerationPolicy * commonPolicy() const
Definition: uml.cpp:2283
TextBlock::getIndentationString
QString getIndentationString(int level=0) const
Definition: textblock.cpp:193
TextBlock::m_tag
QString m_tag
Definition: textblock.h:101
TextBlock::getIndentation
static QString getIndentation()
Definition: textblock.cpp:182
TextBlock::setTag
void setTag(const QString &value)
Definition: textblock.cpp:121
TextBlock::m_writeOutText
bool m_writeOutText
Definition: textblock.h:103
CodeDocument
Definition: codedocument.h:33
TextBlock::decodeText
static QString decodeText(const QString &text, const QString &endLine)
Definition: textblock.cpp:395
TextBlock::lastEditableLine
virtual int lastEditableLine()
Definition: textblock.cpp:223
ClassifierCodeDocument
Definition: classifiercodedocument.h:33
TextBlock::~TextBlock
virtual ~TextBlock()
Definition: textblock.cpp:42
TextBlock::saveToXMI1
virtual void saveToXMI1(QDomDocument &doc, QDomElement &root)=0
operator<<
QDebug operator<<(QDebug os, const TextBlock &obj)
Definition: textblock.cpp:422
CodeGenObjectWithTextBlocks
Definition: codegenobjectwithtextblocks.h:32
TextBlock::loadFromXMI1
virtual void loadFromXMI1(QDomElement &root)=0
TextBlock::canDelete
bool canDelete() const
Definition: textblock.cpp:61
CodeGenerationPolicy::getIndentation
QString getIndentation() const
Definition: codegenerationpolicy.cpp:304
TextBlock::m_indentationLevel
int m_indentationLevel
Definition: textblock.h:104
TextBlock::setIndentationLevel
void setIndentationLevel(int level)
Definition: textblock.cpp:152
codegenerationpolicy.h
CodeGenerationPolicy
Definition: codegenerationpolicy.h:30
TextBlock::getNewEditorLine
virtual QString getNewEditorLine(int amount=0)
Definition: textblock.cpp:240
UMLApp::app
static UMLApp * app()
Definition: uml.cpp:278
TextBlock::unformatText
virtual QString unformatText(const QString &text, const QString &indent=QString())
Definition: textblock.cpp:253
TextBlock::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
Definition: textblock.cpp:322
TextBlock::m_parentDocument
CodeDocument * m_parentDocument
Definition: textblock.h:105
TextBlock::release
virtual void release()
Definition: textblock.cpp:275
TextBlock::firstEditableLine
virtual int firstEditableLine()
Definition: textblock.cpp:215
codedocument.h
TextBlock::formatMultiLineText
static QString formatMultiLineText(const QString &work, const QString &linePrefix, const QString &breakStr, bool addBreak=true, bool lastLineHasBreak=true)
Definition: textblock.cpp:288
TextBlock::setCanDelete
void setCanDelete(bool canDelete)
Definition: textblock.cpp:50
uml.h
CodeGenerationPolicy::getNewLineEndingChars
QString getNewLineEndingChars() const
Definition: codegenerationpolicy.cpp:253
debug_utils.h
TextBlock::getNewLineEndingChars
static QString getNewLineEndingChars()
Definition: textblock.cpp:172
TextBlock::getParentDocument
CodeDocument * getParentDocument() const
Definition: textblock.cpp:70
TextBlock::operator<<
friend QDebug operator<<(QDebug os, const TextBlock &obj)
Definition: textblock.cpp:422
CodeDocument::ID
QString ID() const
Definition: codedocument.cpp:143
TextBlock
Definition: textblock.h:25
TextBlock::m_text
QString m_text
Definition: textblock.h:100
TextBlock::setText
void setText(const QString &text)
Definition: textblock.cpp:80
TextBlock::getIndentationLevel
int getIndentationLevel() const
Definition: textblock.cpp:163
TextBlock::getText
QString getText() const
Definition: textblock.cpp:99
TextBlock::TextBlock
TextBlock(CodeDocument *parent, const QString &text=QString())
Definition: textblock.cpp:28
TextBlock::getTag
QString getTag() const
Definition: textblock.cpp:110
TextBlock::appendText
void appendText(const QString &text)
Definition: textblock.cpp:89