template.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "template.h"
00014
00015
00016 #include <qregexp.h>
00017 #include <kdebug.h>
00018
00019
00020 #include "uml.h"
00021 #include "umldoc.h"
00022 #include "dialogs/umltemplatedialog.h"
00023
00024 UMLTemplate::UMLTemplate(const UMLObject *parent, const QString& name,
00025 Uml::IDType id, const QString& type)
00026 : UMLClassifierListItem( parent, name, id ) {
00027 setTypeName( type );
00028 m_BaseType = Uml::ot_Template;
00029 }
00030
00031 UMLTemplate::UMLTemplate(const UMLObject *parent)
00032 : UMLClassifierListItem( parent ) {
00033 m_BaseType = Uml::ot_Template;
00034 }
00035
00036 UMLTemplate::~UMLTemplate() {}
00037
00038 QString UMLTemplate::toString(Uml::Signature_Type ) {
00039 if (m_pSecondary == NULL || m_pSecondary->getName() == "class") {
00040 return getName();
00041 } else {
00042 return getName() + " : " + m_pSecondary->getName();
00043 }
00044 }
00045
00046 QString UMLTemplate::getTypeName() {
00047 if (m_pSecondary == NULL)
00048 return "class";
00049 return m_pSecondary->getName();
00050 }
00051
00052 bool UMLTemplate::operator==(UMLTemplate &rhs) {
00053 if (this == &rhs) {
00054 return true;
00055 }
00056 if ( !UMLObject::operator==( rhs ) ) {
00057 return false;
00058 }
00059 if (m_pSecondary != rhs.m_pSecondary) {
00060 return false;
00061 }
00062 return true;
00063 }
00064
00065 void UMLTemplate::copyInto(UMLTemplate *rhs) const
00066 {
00067 UMLClassifierListItem::copyInto(rhs);
00068 }
00069
00070 UMLObject* UMLTemplate::clone() const
00071 {
00072 UMLTemplate *clone = new UMLTemplate( (UMLTemplate*) parent());
00073 copyInto(clone);
00074
00075 return clone;
00076 }
00077
00078
00079 void UMLTemplate::saveToXMI(QDomDocument& qDoc, QDomElement& qElement) {
00080
00081 QDomElement attributeElement = UMLObject::save("UML:TemplateParameter", qDoc);
00082 if (m_pSecondary)
00083 attributeElement.setAttribute("type", ID2STR(m_pSecondary->getID()));
00084 qElement.appendChild(attributeElement);
00085 }
00086
00087 bool UMLTemplate::load(QDomElement& element) {
00088 m_SecondaryId = element.attribute("type", "");
00089 return true;
00090 }
00091
00092 bool UMLTemplate::showPropertiesDialog(QWidget* parent) {
00093 UMLTemplateDialog dialog(parent, this);
00094 return dialog.exec();
00095 }
This file is part of the documentation for umbrello Version 3.1.0.