summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/stereotype.cpp
blob: 688dbd385330e5ad711930848c5c2073d67aca3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   copyright (C) 2003-2006                                               *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

// own header
#include "stereotype.h"

// qt/kde includes
#include <tdelocale.h>
#include <kdebug.h>
#include <kinputdialog.h>

// local includes
#include "umldoc.h"
#include "uml.h"

UMLStereotype::UMLStereotype(const TQString &name, Uml::IDType id /* = Uml::id_None */)
        : UMLObject( name, id ) {
    m_BaseType = Uml::ot_Stereotype;
    UMLStereotype * existing = UMLApp::app()->getDocument()->findStereotype(name);
    if (existing) {
        kError() << "UMLStereotype constructor: " << name << " already exists"
                  << kdBacktrace(25) << endl;
    }
    m_refCount = 0;
}

UMLStereotype::UMLStereotype() : UMLObject() {
    m_BaseType = Uml::ot_Stereotype;
    m_refCount = 0;
}

UMLStereotype::~UMLStereotype() {}

bool UMLStereotype::operator==( UMLStereotype &rhs) {
    if (this == &rhs) {
        return true;
    }

    if ( !UMLObject::operator==( rhs ) ) {
        return false;
    }

    return true;
}

void UMLStereotype::copyInto(UMLStereotype *rhs) const
{
    UMLObject::copyInto(rhs);
}

UMLObject* UMLStereotype::clone() const
{
    UMLStereotype *clone = new UMLStereotype();
    copyInto(clone);

    return clone;
}


void UMLStereotype::saveToXMI(TQDomDocument& qDoc, TQDomElement& qElement) {
    //FIXME: uml13.dtd compliance
    TQDomElement stereotypeElement = UMLObject::save("UML:Stereotype", qDoc);
    qElement.appendChild( stereotypeElement );
}

bool UMLStereotype::showPropertiesDialog(TQWidget* parent) {
    bool ok;
    TQString name = KInputDialog::getText(i18n("Stereotype"), i18n("Enter name:"), getName(),&ok, parent);
    if (ok) {
        setName(name);
    }
    return ok;
}

void UMLStereotype::incrRefCount() {
    m_refCount++;
}

void UMLStereotype::decrRefCount() {
    m_refCount--;
}

int UMLStereotype::refCount() const {
    return m_refCount;
}