umbrello: umbrello/codegenerators/textblock.h Source File

umbrello 2.32.1 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 #include <QXmlStreamWriter>
19
20 class CodeDocument;
21 class QXmlStreamWriter;
22
26 class TextBlock
27 {
28 friend class CodeGenObjectWithTextBlocks;
29 friend class ClassifierCodeDocument;
30 public:
31
32 explicit TextBlock(CodeDocument * parent, const QString & text = QString());
33 virtual ~TextBlock();
34
35 void setText(const QString & text);
36 QString getText() const;
37 void appendText(const QString & text);
38
39 void setTag(const QString & value);
40 QString getTag() const;
41
42 CodeDocument * getParentDocument() const;
43
44 void setWriteOutText(bool write);
45 bool getWriteOutText() const;
46
47 void setIndentationLevel(int level);
48 int getIndentationLevel() const;
49
50 QString getIndentationString(int level = 0) const;
51
52 static QString getIndentation();
53
54 static QString getNewLineEndingChars();
55
56 static QString formatMultiLineText(const QString & work, const QString & linePrefix,
57 const QString & breakStr,
58 bool addBreak = true, bool lastLineHasBreak = true);
59
60 virtual QString unformatText(const QString & text, const QString & indent = QString());
61
62 virtual QString toString() const;
63
64 static QString encodeText(const QString & text, const QString & endLine);
65 static QString decodeText(const QString & text, const QString & endLine);
66
72 virtual void saveToXMI1(QXmlStreamWriter& writer) = 0;
73
78 virtual void loadFromXMI1(QDomElement & root) = 0;
79
80 bool canDelete() const;
81
82 virtual void setAttributesFromObject(TextBlock * obj);
83
84 virtual QString getNewEditorLine(int amount = 0);
85
86 virtual int firstEditableLine();
87 virtual int lastEditableLine();
88
89 friend QDebug operator<<(QDebug os, const TextBlock& obj);
90
91 protected:
92
93 void setCanDelete(bool canDelete);
94
95 virtual void release();
96
97 virtual void setAttributesOnNode(QXmlStreamWriter& writer);
98 virtual void setAttributesFromNode(QDomElement & root);
99
100 private:
101
102 QString m_text; //< The actual text of this code block.
103 QString m_tag;
104 bool m_canDelete;
105 bool m_writeOutText; //< Flag to write the text of this TextBlock into a file.
106 int m_indentationLevel;
107 CodeDocument * m_parentDocument;
108
109 };
110
111 #endif // TEXTBLOCK_H
ClassifierCodeDocument
Definition: classifiercodedocument.h:33
CodeDocument
Definition: codedocument.h:34
CodeGenObjectWithTextBlocks
Definition: codegenobjectwithtextblocks.h:33
TextBlock
Definition: textblock.h:27
TextBlock::unformatText
virtual QString unformatText(const QString &text, const QString &indent=QString())
Definition: textblock.cpp:253
TextBlock::decodeText
static QString decodeText(const QString &text, const QString &endLine)
Definition: textblock.cpp:393
TextBlock::getIndentationLevel
int getIndentationLevel() const
Definition: textblock.cpp:163
TextBlock::m_tag
QString m_tag
Definition: textblock.h:103
TextBlock::firstEditableLine
virtual int firstEditableLine()
Definition: textblock.cpp:215
TextBlock::getNewLineEndingChars
static QString getNewLineEndingChars()
Definition: textblock.cpp:172
TextBlock::release
virtual void release()
Definition: textblock.cpp:275
TextBlock::setText
void setText(const QString &text)
Definition: textblock.cpp:80
TextBlock::appendText
void appendText(const QString &text)
Definition: textblock.cpp:89
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::setIndentationLevel
void setIndentationLevel(int level)
Definition: textblock.cpp:152
TextBlock::toString
virtual QString toString() const
Definition: textblock.cpp:405
TextBlock::setWriteOutText
void setWriteOutText(bool write)
Definition: textblock.cpp:131
TextBlock::m_canDelete
bool m_canDelete
Definition: textblock.h:104
TextBlock::getIndentation
static QString getIndentation()
Definition: textblock.cpp:182
TextBlock::canDelete
bool canDelete() const
Definition: textblock.cpp:61
TextBlock::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &root)
Definition: textblock.cpp:359
TextBlock::setAttributesOnNode
virtual void setAttributesOnNode(QXmlStreamWriter &writer)
Definition: textblock.cpp:322
TextBlock::getNewEditorLine
virtual QString getNewEditorLine(int amount=0)
Definition: textblock.cpp:240
TextBlock::m_parentDocument
CodeDocument * m_parentDocument
Definition: textblock.h:107
TextBlock::getText
QString getText() const
Definition: textblock.cpp:99
TextBlock::~TextBlock
virtual ~TextBlock()
Definition: textblock.cpp:42
TextBlock::saveToXMI1
virtual void saveToXMI1(QXmlStreamWriter &writer)=0
TextBlock::getIndentationString
QString getIndentationString(int level=0) const
Definition: textblock.cpp:193
TextBlock::getTag
QString getTag() const
Definition: textblock.cpp:110
TextBlock::getParentDocument
CodeDocument * getParentDocument() const
Definition: textblock.cpp:70
TextBlock::TextBlock
TextBlock(CodeDocument *parent, const QString &text=QString())
Definition: textblock.cpp:28
TextBlock::operator<<
friend QDebug operator<<(QDebug os, const TextBlock &obj)
Definition: textblock.cpp:420
TextBlock::m_text
QString m_text
Definition: textblock.h:102
TextBlock::loadFromXMI1
virtual void loadFromXMI1(QDomElement &root)=0
TextBlock::m_indentationLevel
int m_indentationLevel
Definition: textblock.h:106
TextBlock::setTag
void setTag(const QString &value)
Definition: textblock.cpp:121
TextBlock::setCanDelete
void setCanDelete(bool canDelete)
Definition: textblock.cpp:50
TextBlock::m_writeOutText
bool m_writeOutText
Definition: textblock.h:105
TextBlock::getWriteOutText
bool getWriteOutText() const
Definition: textblock.cpp:141
TextBlock::encodeText
static QString encodeText(const QString &text, const QString &endLine)
Definition: textblock.cpp:379
TextBlock::setAttributesFromObject
virtual void setAttributesFromObject(TextBlock *obj)
Definition: textblock.cpp:345
TextBlock::lastEditableLine
virtual int lastEditableLine()
Definition: textblock.cpp:223