• 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
codeclassfielddeclarationblock.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 "codeclassfielddeclarationblock.h"
13 
14 #include "codeclassfield.h"
15 #include "umlrole.h"
16 
20 CodeClassFieldDeclarationBlock::CodeClassFieldDeclarationBlock(CodeClassField * parentCF)
21  : OwnedCodeBlock((UMLObject*) parentCF->getParentObject()),
22  CodeBlockWithComments((CodeDocument*) parentCF->getParentDocument())
23 {
24  init(parentCF);
25 }
26 
30 CodeClassFieldDeclarationBlock::~CodeClassFieldDeclarationBlock()
31 {
32  // Q: is this needed??
33  // m_parentclassfield->getParentObject()->disconnect(this);
34 }
35 
40 CodeClassField * CodeClassFieldDeclarationBlock::getParentClassField()
41 {
42  return m_parentclassfield;
43 }
44 
48 UMLObject * CodeClassFieldDeclarationBlock::getParentObject()
49 {
50  return m_parentclassfield->getParentObject();
51 }
52 
53 // this type of textblock is special
54 // we DON'T release it when resetTextBlocks is
55 // called because we re-use it over and over
56 // until the codeclassfield is released.
57 void CodeClassFieldDeclarationBlock::release()
58 {
59  // do nothing
60 }
61 
65 void CodeClassFieldDeclarationBlock::forceRelease()
66 {
67  if (m_parentclassfield)
68  {
69  // m_parentclassfield->getParentObject()->disconnect(this);
70  m_parentclassfield->disconnect(this);
71  }
72  m_parentclassfield = 0;
73  OwnedCodeBlock::release();
74  TextBlock::release();
75 }
76 
80 void CodeClassFieldDeclarationBlock::saveToXMI(QDomDocument & doc, QDomElement & elem)
81 {
82  QDomElement docElement = doc.createElement("ccfdeclarationcodeblock");
83  setAttributesOnNode(doc, docElement);
84  elem.appendChild(docElement);
85 }
86 
90 void CodeClassFieldDeclarationBlock::loadFromXMI (QDomElement & root)
91 {
92  setAttributesFromNode(root);
93 }
94 
99 void CodeClassFieldDeclarationBlock::setAttributesOnNode (QDomDocument & doc, QDomElement & elem)
100 {
101  // set super-class attributes
102  CodeBlockWithComments::setAttributesOnNode(doc, elem);
103  OwnedCodeBlock::setAttributesOnNode(doc, elem);
104 }
105 
110 void CodeClassFieldDeclarationBlock::setAttributesFromNode(QDomElement & root)
111 {
112  // set attributes from the XMI
113  CodeBlockWithComments::setAttributesFromNode(root); // superclass load
114  OwnedCodeBlock::setAttributesFromNode(root); // superclass load
115 
116  syncToParent();
117 }
118 
122 void CodeClassFieldDeclarationBlock::setAttributesFromObject (TextBlock * obj)
123 {
124  CodeBlockWithComments::setAttributesFromObject(obj);
125 
126  CodeClassFieldDeclarationBlock * ccb = dynamic_cast<CodeClassFieldDeclarationBlock*>(obj);
127  if (ccb)
128  {
129  m_parentclassfield->disconnect(this);
130  init(ccb->getParentClassField());
131 
132  syncToParent();
133  }
134 }
135 
136 void CodeClassFieldDeclarationBlock::syncToParent ()
137 {
138  // for role-based accessors, we DON'T write ourselves out when
139  // the name of the role is not defined.
140  if (!(getParentClassField()->parentIsAttribute()))
141  {
142  UMLRole * parent = dynamic_cast<UMLRole*>(getParentObject());
143  if (parent == NULL)
144  return;
145  if (parent->name().isEmpty())
146  {
147  getComment()->setWriteOutText(false);
148  setWriteOutText(false);
149  } else {
150  getComment()->setWriteOutText(true);
151  setWriteOutText(true);
152  }
153  }
154 
155  // only update IF we are NOT AutoGenerated
156  if (contentType() != AutoGenerated)
157  return;
158 
159  updateContent();
160 }
161 
162 void CodeClassFieldDeclarationBlock::init (CodeClassField * parentCF)
163 {
164  m_parentclassfield = parentCF;
165  setCanDelete(false);
166  connect(m_parentclassfield, SIGNAL(modified()), this, SLOT(syncToParent()));
167 }
168 
169 #include "codeclassfielddeclarationblock.moc"
OwnedCodeBlock::release
virtual void release()
Causes the text block to release all of its connections and any other text blocks that it 'owns'...
Definition: ownedcodeblock.cpp:52
CodeClassField
class CodeClassField a special type of parameter.
Definition: codeclassfield.h:29
CodeClassFieldDeclarationBlock::forceRelease
void forceRelease()
So parent can actually release this block.
Definition: codeclassfielddeclarationblock.cpp:65
CodeBlockWithComments::getComment
CodeComment * getComment() const
Get the Comment object.
Definition: codeblockwithcomments.cpp:46
OwnedCodeBlock::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
Definition: ownedcodeblock.cpp:81
CodeBlockWithComments::setAttributesFromObject
virtual void setAttributesFromObject(TextBlock *obj)
Set the class attributes from a passed object.
Definition: codeblockwithcomments.cpp:83
CodeBlockWithComments::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
Set attributes of the node that represents this class in the XMI document.
Definition: codeblockwithcomments.cpp:68
CodeBlock::AutoGenerated
the content was generated by code generation itself
Definition: codeblock.h:28
umlrole.h
CodeClassFieldDeclarationBlock::~CodeClassFieldDeclarationBlock
virtual ~CodeClassFieldDeclarationBlock()
Empty Destructor.
Definition: codeclassfielddeclarationblock.cpp:30
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
CodeClassFieldDeclarationBlock
Used to declare classifier fields (e.g.
Definition: codeclassfielddeclarationblock.h:29
CodeClassFieldDeclarationBlock::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
Set attributes of the node that represents this class in the XMI document.
Definition: codeclassfielddeclarationblock.cpp:99
CodeClassFieldDeclarationBlock::getParentObject
UMLObject * getParentObject()
A utility method to get the parent object of the parentCodeClassfield.
Definition: codeclassfielddeclarationblock.cpp:48
CodeClassFieldDeclarationBlock::CodeClassFieldDeclarationBlock
CodeClassFieldDeclarationBlock(CodeClassField *parent)
Constructor.
Definition: codeclassfielddeclarationblock.cpp:20
UMLObject
This class is the non-graphical version of UMLWidget.
Definition: umlobject.h:41
CodeBlockWithComments
class CodeBlockWithComments A very common type of text block in any type of code. ...
Definition: codeblockwithcomments.h:24
TextBlock::setCanDelete
void setCanDelete(bool canDelete)
Set the attribute m_canDelete.
Definition: textblock.cpp:50
TextBlock::setWriteOutText
void setWriteOutText(bool write)
Set the value of m_writeOutText Whether or not to include the text of this TextBlock into a file...
Definition: textblock.cpp:131
CodeDocument
A document containing the code for one file.
Definition: codedocument.h:32
OwnedCodeBlock
Describes any codeblock which is 'owned' by a UMLobject of some sort and should be in sync with that ...
Definition: ownedcodeblock.h:26
codeclassfield.h
CodeBlockWithComments::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Set the class attributes of this object from the passed element node.
Definition: codeblockwithcomments.cpp:105
CodeClassFieldDeclarationBlock::loadFromXMI
virtual void loadFromXMI(QDomElement &root)
Load params from the appropriate XMI element node.
Definition: codeclassfielddeclarationblock.cpp:90
CodeClassFieldDeclarationBlock::saveToXMI
virtual void saveToXMI(QDomDocument &doc, QDomElement &root)
Save the XMI representation of this object.
Definition: codeclassfielddeclarationblock.cpp:80
CodeClassFieldDeclarationBlock::updateContent
virtual void updateContent()=0
CodeClassFieldDeclarationBlock::release
virtual void release()
Causes the text block to release all of its connections and any other text blocks that it 'owns'...
Definition: codeclassfielddeclarationblock.cpp:57
TextBlock
The fundemental unit of text within an output file containing code.
Definition: textblock.h:24
CodeClassFieldDeclarationBlock::getParentClassField
CodeClassField * getParentClassField()
Get the value of m_parentclassfield.
Definition: codeclassfielddeclarationblock.cpp:40
OwnedCodeBlock::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Set the class attributes of this object from the passed element node.
Definition: ownedcodeblock.cpp:106
UMLRole
This class contains the non-graphic representation of an association role.
Definition: umlrole.h:24
CodeClassFieldDeclarationBlock::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Set the class attributes of this object from the passed element node.
Definition: codeclassfielddeclarationblock.cpp:110
codeclassfielddeclarationblock.h
CodeClassFieldDeclarationBlock::setAttributesFromObject
virtual void setAttributesFromObject(TextBlock *obj)
Set the class attributes from a passed object.
Definition: codeclassfielddeclarationblock.cpp:122
UMLObject::name
QString name() const
Returns a copy of m_name.
Definition: umlobject.cpp:185
CodeClassFieldDeclarationBlock::syncToParent
virtual void syncToParent()
Definition: codeclassfielddeclarationblock.cpp:136
CodeParameter::getParentObject
UMLObject * getParentObject()
Get the ParentObject object.
Definition: codeparameter.cpp:141
TextBlock::release
virtual void release()
Causes the text block to release all of its connections and any other text blocks that it 'owns'...
Definition: textblock.cpp:275
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