summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/dialogs/umlroleproperties.cpp
blob: fe2e2f5f52b999f1103a58a9e7eabbc5da1761a3 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/***************************************************************************
 *                                                                         *
 *   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-2007                                               *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

// own header
#include "umlroleproperties.h"

// qt/kde includes
#include <tqradiobutton.h>
#include <tqtextedit.h>
#include <tqlineedit.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kdebug.h>


UMLRoleProperties::UMLRoleProperties ( TQWidget *parent, UMLRole *role)
        : UMLRolePropertiesBase (parent)
{

    m_pRole = role;
    constructWidget();

}

UMLRoleProperties::~UMLRoleProperties() { }

void UMLRoleProperties::constructWidget() {

    // Use Parent Role to set starting Properties
    //

    // Rolename
    m_pRoleLE -> setText(m_pRole->getName());

    // Multiplicity
    m_pMultiLE -> setText(m_pRole->getMultiplicity());

    // Visibility
    Uml::Visibility scope = m_pRole->getVisibility();
    if( scope == Uml::Visibility::Public )
        m_pPublicRB -> setChecked( true );
    else if( scope == Uml::Visibility::Private )
        m_pPrivateRB -> setChecked( true );
    else if( scope == Uml::Visibility::Protected )
        m_pProtectedRB -> setChecked( true );
    else if( scope == Uml::Visibility::Implementation )
        m_pImplementationRB -> setChecked( true );

    // Changeability
    Uml::Changeability_Type changeability = m_pRole->getChangeability();
    if( changeability == Uml::chg_Changeable )
        m_pChangeableRB -> setChecked( true );
    else if( changeability == Uml::chg_Frozen )
        m_pFrozenRB -> setChecked( true );
    else
        m_pAddOnlyRB -> setChecked( true );

    // Documentation
    //
    m_pDocTE-> setText(m_pRole-> getDoc());
    //m_pDocTE->setWordWrap(TQMultiLineEdit::WidgetWidth);
}

void UMLRoleProperties::updateObject() {

    if(m_pRole) {

        // block signals to save work load..we only need to emit modified once,
        // not each time we update an attribute of the association. I suppose
        // we could check to see IF anything changed, but thats a lot more code,
        // and not much gained. THis way is easier, if less 'beautiful'. -b.t.

        m_pRole->blockSignals(true);

        // set props
        m_pRole->setName(m_pRoleLE->text());
        m_pRole->setMultiplicity(m_pMultiLE->text());

        if(m_pPrivateRB->isChecked())
            m_pRole->setVisibility(Uml::Visibility::Private);
        else if(m_pProtectedRB->isChecked())
            m_pRole->setVisibility(Uml::Visibility::Protected);
        else if(m_pPublicRB->isChecked())
            m_pRole->setVisibility(Uml::Visibility::Public);
        else if(m_pImplementationRB->isChecked())
            m_pRole->setVisibility(Uml::Visibility::Implementation);

        if(m_pFrozenRB->isChecked())
            m_pRole->setChangeability(Uml::chg_Frozen);
        else if(m_pAddOnlyRB->isChecked())
            m_pRole->setChangeability(Uml::chg_AddOnly);
        else
            m_pRole->setChangeability(Uml::chg_Changeable);

        m_pRole->setDoc(m_pDocTE->text());

        m_pRole->blockSignals(false);

        m_pRole->emitModified();

    } //end if m_pRole

}


#include "umlroleproperties.moc"