umbrello  2.35.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  SPDX-License-Identifier: GPL-2.0-or-later
3 
4  SPDX-FileCopyrightText: 2003 Brian Thomas <thomas@mail630.gsfc.nasa.gov>
5  SPDX-FileCopyrightText: 2004-2022 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
6 */
7 
8 #ifndef TEXTBLOCK_H
9 #define TEXTBLOCK_H
10 
11 #include <QDomDocument>
12 #include <QDomElement>
13 #include <QObject>
14 #include <QXmlStreamWriter>
15 
16 class CodeDocument;
17 class QXmlStreamWriter;
18 
22 class TextBlock
23 {
25  friend class ClassifierCodeDocument;
26 public:
27 
28  explicit TextBlock(CodeDocument * parent, const QString & text = QString());
29  virtual ~TextBlock();
30 
31  void setText(const QString & text);
32  QString getText() const;
33  void appendText(const QString & text);
34 
35  void setTag(const QString & value);
36  QString getTag() const;
37 
39 
40  void setWriteOutText(bool write);
41  bool getWriteOutText() const;
42 
43  void setIndentationLevel(int level);
44  int getIndentationLevel() const;
45 
46  QString getIndentationString(int level = 0) const;
47 
48  static QString getIndentation();
49 
50  static QString getNewLineEndingChars();
51 
52  static QString formatMultiLineText(const QString & work, const QString & linePrefix,
53  const QString & breakStr,
54  bool addBreak = true, bool lastLineHasBreak = true);
55 
56  virtual QString unformatText(const QString & text, const QString & indent = QString());
57 
58  virtual QString toString() const;
59 
60  static QString encodeText(const QString & text, const QString & endLine);
61  static QString decodeText(const QString & text, const QString & endLine);
62 
67  virtual void saveToXMI(QXmlStreamWriter& writer) = 0;
68 
73  virtual void loadFromXMI(QDomElement & root) = 0;
74 
75  bool canDelete() const;
76 
77  virtual void setAttributesFromObject(TextBlock * obj);
78 
79  virtual QString getNewEditorLine(int amount = 0);
80 
81  virtual int firstEditableLine();
82  virtual int lastEditableLine();
83 
84  friend QDebug operator<<(QDebug os, const TextBlock& obj);
85 
86 protected:
87 
88  void setCanDelete(bool canDelete);
89 
90  virtual void release();
91 
92  virtual void setAttributesOnNode(QXmlStreamWriter& writer);
93  virtual void setAttributesFromNode(QDomElement & root);
94 
95 private:
96 
97  QString m_text; //< The actual text of this code block.
98  QString m_tag;
100  bool m_writeOutText; //< Flag to write the text of this TextBlock into a file.
103 
104 };
105 
106 #endif // TEXTBLOCK_H
TextBlock::getWriteOutText
bool getWriteOutText() const
Definition: textblock.cpp:137
TextBlock::m_canDelete
bool m_canDelete
Definition: textblock.h:99
TextBlock::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &root)
Definition: textblock.cpp:354
TextBlock::toString
virtual QString toString() const
Definition: textblock.cpp:400
textblock.h
TextBlock::setAttributesFromObject
virtual void setAttributesFromObject(TextBlock *obj)
Definition: textblock.cpp:340
TextBlock::encodeText
static QString encodeText(const QString &text, const QString &endLine)
Definition: textblock.cpp:374
TextBlock::setWriteOutText
void setWriteOutText(bool write)
Definition: textblock.cpp:127
UMLApp::commonPolicy
CodeGenerationPolicy * commonPolicy() const
Definition: uml.cpp:2459
TextBlock::getIndentationString
QString getIndentationString(int level=0) const
Definition: textblock.cpp:189
TextBlock::m_tag
QString m_tag
Definition: textblock.h:98
TextBlock::getIndentation
static QString getIndentation()
Definition: textblock.cpp:178
TextBlock::setTag
void setTag(const QString &value)
Definition: textblock.cpp:117
TextBlock::m_writeOutText
bool m_writeOutText
Definition: textblock.h:100
CodeDocument
Definition: codedocument.h:29
TextBlock::decodeText
static QString decodeText(const QString &text, const QString &endLine)
Definition: textblock.cpp:388
TextBlock::lastEditableLine
virtual int lastEditableLine()
Definition: textblock.cpp:219
ClassifierCodeDocument
Definition: classifiercodedocument.h:28
TextBlock::~TextBlock
virtual ~TextBlock()
Definition: textblock.cpp:38
operator<<
QDebug operator<<(QDebug os, const TextBlock &obj)
Definition: textblock.cpp:415
CodeGenObjectWithTextBlocks
Definition: codegenobjectwithtextblocks.h:28
work
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or work
Definition: GPL-2.0-only.txt:62
number
it is up to the author donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License If the distribution and or use of the Library is restricted in certain countries either by patents or by copyrighted the original copyright holder who places the Library under this License may add an geographical distribution limitation excluding those so that distribution is permitted only in or among countries not thus excluded In such this License incorporates the limitation as if written in the body of this License The Free Software Foundation may publish revised and or new versions of the Library General Public License from time to time Such new versions will be similar in spirit to the present but may differ in detail to address new problems or concerns Each version is given a distinguishing version number If the Library specifies a version number of this License which applies to it and any later you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation If the Library does not specify a license version number
Definition: LGPL-2.0-only.txt:368
TextBlock::canDelete
bool canDelete() const
Definition: textblock.cpp:57
CodeGenerationPolicy::getIndentation
QString getIndentation() const
Definition: codegenerationpolicy.cpp:300
TextBlock::m_indentationLevel
int m_indentationLevel
Definition: textblock.h:101
TextBlock::setIndentationLevel
void setIndentationLevel(int level)
Definition: textblock.cpp:148
codegenerationpolicy.h
CodeGenerationPolicy
Definition: codegenerationpolicy.h:25
TextBlock::getNewEditorLine
virtual QString getNewEditorLine(int amount=0)
Definition: textblock.cpp:236
UMLApp::app
static UMLApp * app()
Definition: uml.cpp:349
TextBlock::loadFromXMI
virtual void loadFromXMI(QDomElement &root)=0
TextBlock::unformatText
virtual QString unformatText(const QString &text, const QString &indent=QString())
Definition: textblock.cpp:249
TextBlock::m_parentDocument
CodeDocument * m_parentDocument
Definition: textblock.h:102
TextBlock::release
virtual void release()
Definition: textblock.cpp:271
TextBlock::firstEditableLine
virtual int firstEditableLine()
Definition: textblock.cpp:211
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:284
TextBlock::setCanDelete
void setCanDelete(bool canDelete)
Definition: textblock.cpp:46
uml.h
TextBlock::setAttributesOnNode
virtual void setAttributesOnNode(QXmlStreamWriter &writer)
Definition: textblock.cpp:317
CodeGenerationPolicy::getNewLineEndingChars
QString getNewLineEndingChars() const
Definition: codegenerationpolicy.cpp:249
debug_utils.h
TextBlock::getNewLineEndingChars
static QString getNewLineEndingChars()
Definition: textblock.cpp:168
TextBlock::saveToXMI
virtual void saveToXMI(QXmlStreamWriter &writer)=0
TextBlock::getParentDocument
CodeDocument * getParentDocument() const
Definition: textblock.cpp:66
TextBlock::operator<<
friend QDebug operator<<(QDebug os, const TextBlock &obj)
Definition: textblock.cpp:415
CodeDocument::ID
QString ID() const
Definition: codedocument.cpp:140
TextBlock
Definition: textblock.h:22
TextBlock::m_text
QString m_text
Definition: textblock.h:97
TextBlock::setText
void setText(const QString &text)
Definition: textblock.cpp:76
TextBlock::getIndentationLevel
int getIndentationLevel() const
Definition: textblock.cpp:159
TextBlock::getText
QString getText() const
Definition: textblock.cpp:95
TextBlock::TextBlock
TextBlock(CodeDocument *parent, const QString &text=QString())
Definition: textblock.cpp:24
TextBlock::getTag
QString getTag() const
Definition: textblock.cpp:106
TextBlock::appendText
void appendText(const QString &text)
Definition: textblock.cpp:85