summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/dialogs/assocpropdlg.cpp
blob: 945117940f96209a2ac846cacf8564ac574692a8 (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
115
/***************************************************************************
 *                                                                         *
 *   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) 2002-2007                                               *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

// own header
#include "assocpropdlg.h"

// qt/kde includes
#include <tqlayout.h>
#include <tqlabel.h>

#include <tdelocale.h>
#include <tdemessagebox.h>
#include <kiconloader.h>
#include <kdebug.h>

// local includes
#include "assocgenpage.h"
#include "assocrolepage.h"
#include "classpropdlg.h"
#include "classgenpage.h"
#include "umlwidgetcolorpage.h"

#include "../umlobject.h"
#include "../umldoc.h"
#include "../objectwidget.h"
#include "../uml.h"
#include "../umlview.h"


AssocPropDlg::AssocPropDlg (TQWidget *parent, AssociationWidget * assocWidget, int pageNum)
        : KDialogBase(IconList, i18n("Association Properties"), Ok | Apply | Cancel | Help,
                      Ok, parent, "_ASSOCPROPDLG_", true, true)
{
    init();
    m_pAssoc = assocWidget;

    m_pDoc = ((UMLApp *)parent) -> getDocument(); // needed?

    setupPages(assocWidget);
    showPage(pageNum);
}

AssocPropDlg::~AssocPropDlg() { }

void AssocPropDlg::init ( )
{
    m_pAssoc = 0;
    m_pGenPage = 0;
    m_pRolePage = 0;
}

void AssocPropDlg::slotOk() {
    slotApply();
    KDialogBase::accept();
}

void AssocPropDlg::slotApply() {

    if (m_pGenPage) {
        m_pGenPage->updateObject();
    }

    if (m_pRolePage) {
        m_pRolePage->updateObject();
    }

    if (m_pAssoc) {
        m_pAssoc->lwSetFont( m_pChooser->font() );
    }


}

// void AssocPropDlg::setupPages (UMLObject * c)
void AssocPropDlg::setupPages (AssociationWidget *assocWidget)
{

    // general page
    TQFrame *page = addPage( i18n("General"), i18n("General Settings"), DesktopIcon( "misc") );
    TQHBoxLayout *genLayout = new TQHBoxLayout(page);
    page -> setMinimumSize(310, 330);
    m_pGenPage = new AssocGenPage (m_pDoc, page, assocWidget);
    genLayout -> addWidget(m_pGenPage);

    // role page
    TQFrame * newPage = addPage( i18n("Roles"), i18n("Role Settings"), DesktopIcon( "misc") );
    TQHBoxLayout * roleLayout = new TQHBoxLayout(newPage);
    // newPage -> setMinimumSize(310, 330);
    m_pRolePage = new AssocRolePage(m_pDoc, newPage, assocWidget);
    roleLayout -> addWidget(m_pRolePage);

    setupFontPage();

}

void AssocPropDlg::setupFontPage()
{
    if( !m_pAssoc)
        return;

    TQVBox *page = addVBoxPage( i18n("Font"), i18n("Font Settings"), DesktopIcon( "fonts"));
    m_pChooser = new TDEFontChooser( (TQWidget*)page, "font", false, TQStringList(), false);
    m_pChooser->setFont( m_pAssoc->getFont());
    m_pChooser->setSampleText(i18n("Association font"));
}

#include "assocpropdlg.moc"