• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

umbrello/umbrello

  • sources
  • kde-4.12
  • kdesdk
  • umbrello
  • umbrello
  • codegenerators
codeblock.cpp
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-2013 *
9  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
10  ***************************************************************************/
11 
12 #include "codeblock.h"
13 
14 #include "codedocument.h"
15 #include "debug_utils.h"
16 
17 #include <QTextStream>
18 
24 CodeBlock::CodeBlock(CodeDocument * doc, const QString & body)
25  : TextBlock(doc, body),
26  m_contentType(AutoGenerated)
27 {
28 }
29 
33 CodeBlock::~CodeBlock()
34 {
35 }
36 
43 void CodeBlock::setContentType(ContentType new_var)
44 {
45  m_contentType = new_var;
46 }
47 
54 CodeBlock::ContentType CodeBlock::contentType() const
55 {
56  return m_contentType;
57 }
58 
64 void CodeBlock::saveToXMI(QDomDocument & doc, QDomElement & root)
65 {
66  QDomElement blockElement = doc.createElement("codeblock");
67  // set attributes
68  setAttributesOnNode(doc, blockElement);
69  root.appendChild(blockElement);
70 }
71 
78 void CodeBlock::setAttributesOnNode(QDomDocument & doc, QDomElement & blockElement)
79 {
80  // call super-class
81  TextBlock::setAttributesOnNode(doc, blockElement);
82  // local attributes
83  if (m_contentType != AutoGenerated)
84  blockElement.setAttribute("contentType", contentType());
85 }
86 
91 void CodeBlock::loadFromXMI(QDomElement & root)
92 {
93  setAttributesFromNode(root);
94 }
95 
101 void CodeBlock::setAttributesFromNode(QDomElement & elem)
102 {
103  // set attributes from the XMI in super-class
104  TextBlock::setAttributesFromNode(elem);
105  // set local fields now
106  setContentType(((ContentType) elem.attribute("contentType","0").toInt()));
107 }
108 
113 void CodeBlock::setAttributesFromObject(TextBlock * obj)
114 {
115  TextBlock::setAttributesFromObject(obj);
116  CodeBlock * cb = dynamic_cast<CodeBlock*>(obj);
117  if (cb)
118  setContentType(cb->contentType());
119 }
120 
127 QString CodeBlock::enumToString(const ContentType& val)
128 {
129  if (val == AutoGenerated) {
130  return QString("AutoGenerated");
131  }
132  else {
133  return QString("UserGenerated");
134  }
135 }
136 
137 QDebug operator<<(QDebug str, const CodeBlock& obj)
138 {
139  str.nospace() << "CodeBlock: " << CodeBlock::enumToString(obj.contentType())
140  << ", ..." << static_cast<TextBlock*>(const_cast<CodeBlock*>(&obj));
141  return str.space();
142 }
CodeBlock::loadFromXMI
virtual void loadFromXMI(QDomElement &root)
Load params from the appropriate XMI element node.
Definition: codeblock.cpp:91
CodeBlock::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
Set attributes of the node that represents this class in the XMI document.
Definition: codeblock.cpp:78
CodeBlock
A "chunk" of code within the code document.
Definition: codeblock.h:20
codedocument.h
CodeBlock::AutoGenerated
the content was generated by code generation itself
Definition: codeblock.h:28
CodeBlock::contentType
ContentType contentType() const
Get the value of m_contentType specifies whether the content (text) of this object was generated by t...
Definition: codeblock.cpp:54
codeblock.h
CodeBlock::ContentType
ContentType
Describes the creation of the content.
Definition: codeblock.h:27
debug_utils.h
TextBlock::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
Set attributes of the node that represents this class in the XMI document.
Definition: textblock.cpp:322
CodeBlock::CodeBlock
CodeBlock(CodeDocument *parent, const QString &body="")
Constructor.
Definition: codeblock.cpp:24
CodeBlock::enumToString
static QString enumToString(const ContentType &val)
Return a string representation of ContentType.
Definition: codeblock.cpp:127
CodeDocument
A document containing the code for one file.
Definition: codedocument.h:32
TextBlock::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &root)
Set the class attributes of this object from the passed element node.
Definition: textblock.cpp:359
CodeBlock::saveToXMI
virtual void saveToXMI(QDomDocument &doc, QDomElement &root)
Save the XMI representation of this object.
Definition: codeblock.cpp:64
TextBlock
The fundemental unit of text within an output file containing code.
Definition: textblock.h:24
CodeBlock::setContentType
void setContentType(ContentType new_var)
Set the value of m_contentType specifies whether the content (text) of this object was generated by t...
Definition: codeblock.cpp:43
CodeBlock::~CodeBlock
virtual ~CodeBlock()
Empty Destructor.
Definition: codeblock.cpp:33
TextBlock::setAttributesFromObject
virtual void setAttributesFromObject(TextBlock *obj)
Set the class attributes from a passed object.
Definition: textblock.cpp:345
operator<<
QDebug operator<<(QDebug str, const CodeBlock &obj)
Definition: codeblock.cpp:137
CodeBlock::setAttributesFromObject
virtual void setAttributesFromObject(TextBlock *obj)
Set the class attributes from a passed object.
Definition: codeblock.cpp:113
CodeBlock::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Set the class attributes of this object from the passed element node.
Definition: codeblock.cpp:101
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:05:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

umbrello/umbrello

Skip menu "umbrello/umbrello"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal