umbrello API Documentation

template.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2003-2006                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 // own header
00013 #include "template.h"
00014 
00015 // qt/kde includes
00016 #include <qregexp.h>
00017 #include <kdebug.h>
00018 
00019 // app includes
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 /*sig = st_NoSig*/) {
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     //FIXME: uml13.dtd compliance
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 }
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:00 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003