~ubuntu-branches/ubuntu/intrepid/kdesdk/intrepid-updates

« back to all changes in this revision

Viewing changes to umbrello/umbrello/dialogs/umltemplatedialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-28 10:11:43 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: james.westby@ubuntu.com-20080528101143-gzc3styjz1b70zxu
Tags: upstream-4.0.80
ImportĀ upstreamĀ versionĀ 4.0.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#include "umltemplatedialog.h"
14
14
 
15
15
// qt includes
16
 
#include <qlayout.h>
17
 
#include <qgroupbox.h>
18
 
#include <qcombobox.h>
19
 
#include <qlabel.h>
20
 
#include <qlineedit.h>
 
16
#include <QtGui/QLayout>
 
17
#include <q3groupbox.h>
 
18
#include <QtGui/QComboBox>
 
19
#include <QtGui/QLabel>
 
20
#include <QtGui/QVBoxLayout>
 
21
#include <QtGui/QGridLayout>
21
22
 
22
23
// kde includes
 
24
#include <klineedit.h>
23
25
#include <kcombobox.h>
24
26
#include <klocale.h>
25
27
#include <kmessagebox.h>
26
28
#include <kdebug.h>
27
29
 
28
30
// app includes
29
 
#include "../template.h"
30
 
#include "../classifier.h"
31
 
#include "../umldoc.h"
32
 
#include "../uml.h"
33
 
#include "../dialog_utils.h"
 
31
#include "template.h"
 
32
#include "classifier.h"
 
33
#include "umldoc.h"
 
34
#include "uml.h"
 
35
#include "dialog_utils.h"
34
36
 
35
37
UMLTemplateDialog::UMLTemplateDialog(QWidget* pParent, UMLTemplate* pTemplate)
36
 
        : KDialogBase( Plain, i18n("Template Properties"), Help | Ok | Cancel , Ok, pParent, "_UMLTemplateDLG_", true, true) {
 
38
        : KDialog( pParent)
 
39
{
37
40
    m_pTemplate = pTemplate;
 
41
    setCaption( i18n("Template Properties") );
 
42
    setButtons( Help | Ok | Cancel );
 
43
    setDefaultButton( Ok );
 
44
    setModal( true );
 
45
    showButtonSeparator( true );
38
46
    setupDialog();
39
 
}
40
 
 
41
 
UMLTemplateDialog::~UMLTemplateDialog() {}
42
 
 
43
 
void UMLTemplateDialog::setupDialog() {
 
47
    connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
 
48
    connect(this,SIGNAL(applyClicked()),this,SLOT(slotApply()));
 
49
}
 
50
 
 
51
UMLTemplateDialog::~UMLTemplateDialog()
 
52
{
 
53
}
 
54
 
 
55
void UMLTemplateDialog::setupDialog()
 
56
{
44
57
    int margin = fontMetrics().height();
45
58
 
46
 
    QVBoxLayout* mainLayout = new QVBoxLayout( plainPage() );
 
59
    QFrame *frame = new QFrame( this );
 
60
    setMainWidget( frame );
 
61
    QVBoxLayout* mainLayout = new QVBoxLayout( frame );
47
62
 
48
 
    m_pValuesGB = new QGroupBox(i18n("General Properties"), plainPage() );
49
 
    QGridLayout* valuesLayout = new QGridLayout(m_pValuesGB, 3, 2);
 
63
    m_pValuesGB = new Q3GroupBox(i18n("General Properties"), frame );
 
64
    QGridLayout* valuesLayout = new QGridLayout(m_pValuesGB);
50
65
    valuesLayout->setMargin(margin);
51
66
    valuesLayout->setSpacing(10);
52
67
 
58
73
    m_pTypeL->setBuddy(m_pTypeCB);
59
74
 
60
75
    Dialog_Utils::makeLabeledEditField( m_pValuesGB, valuesLayout, 1,
61
 
                                    m_pNameL, i18n("&Name:"),
 
76
                                    m_pNameL, i18nc("template name", "&Name:"),
62
77
                                    m_pNameLE, m_pTemplate->getName() );
63
78
 
64
79
    Dialog_Utils::makeLabeledEditField( m_pValuesGB, valuesLayout, 2,
72
87
    // Add the active data types to combo box
73
88
    UMLDoc *pDoc = UMLApp::app()->getDocument();
74
89
    UMLClassifierList namesList( pDoc->getConcepts() );
75
 
    UMLClassifier* obj = 0;
76
 
    for (obj = namesList.first(); obj; obj = namesList.next()) {
 
90
    foreach (UMLClassifier* obj, namesList ) {
77
91
        insertType( obj->getName() );
78
92
    }
79
93
 
86
100
    int typeBoxCount = 0;
87
101
    bool foundType = false;
88
102
    while (typeBoxCount < m_pTypeCB->count() && foundType == false) {
89
 
        QString typeBoxString = m_pTypeCB->text(typeBoxCount);
 
103
        QString typeBoxString = m_pTypeCB->itemText(typeBoxCount);
90
104
        if ( typeBoxString == m_pTemplate->getTypeName() ) {
91
105
            foundType = true;
92
 
            m_pTypeCB->setCurrentItem(typeBoxCount);
 
106
            m_pTypeCB->setCurrentIndex(typeBoxCount);
93
107
        } else {
94
108
            typeBoxCount++;
95
109
        }
97
111
 
98
112
    if (!foundType) {
99
113
        insertType( m_pTemplate->getTypeName(), 0 );
100
 
        m_pTypeCB->setCurrentItem(0);
 
114
        m_pTypeCB->setCurrentIndex(0);
101
115
    }
102
116
 
103
117
    m_pNameLE->setFocus();
105
119
 
106
120
void UMLTemplateDialog::insertType( const QString& type, int index )
107
121
{
108
 
    m_pTypeCB->insertItem( type, index );
 
122
    m_pTypeCB->insertItem( index, type );
109
123
    m_pTypeCB->completionObject()->addItem( type );
110
124
}
111
125
 
112
 
bool UMLTemplateDialog::apply() {
 
126
bool UMLTemplateDialog::apply()
 
127
{
113
128
    QString typeName = m_pTypeCB->currentText();
114
129
    UMLDoc *pDoc = UMLApp::app()->getDocument();
115
130
    UMLClassifierList namesList( pDoc->getConcepts() );
116
131
    UMLClassifier* obj = 0;
117
 
    for (obj = namesList.first(); obj; obj = namesList.next()) {
 
132
    foreach ( obj, namesList ) {
118
133
        if (typeName == obj->getName()) {
119
134
            m_pTemplate->setType( obj );
120
135
        }
148
163
    return true;
149
164
}
150
165
 
151
 
void UMLTemplateDialog::slotApply() {
 
166
void UMLTemplateDialog::slotApply()
 
167
{
152
168
    apply();
153
169
}
154
170
 
155
 
void UMLTemplateDialog::slotOk() {
 
171
void UMLTemplateDialog::slotOk()
 
172
{
156
173
    if ( apply() ) {
157
174
        accept();
158
175
    }