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
116
117
118
119
120
121
122
|
/* This file is part of the KDE project
Copyright (C) 2003, 2004 Dag Andersen <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation;
version 2 of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "kptrelationdialog.h"
#include "kptrelation.h"
#include "kptnode.h"
#include "kptpart.h"
#include "kptcommand.h"
#include "kptdurationwidget.h"
#include "relationpanel.h"
#include <tqlayout.h>
#include <tqvbox.h>
#include <tqlabel.h>
#include <tqbuttongroup.h>
#include <tqradiobutton.h>
#include <tdemessagebox.h>
#include <tdelocale.h>
#include <kcommand.h>
#include <kdebug.h>
namespace KPlato
{
AddRelationDialog::AddRelationDialog(Relation *rel, TQWidget *p, TQString caption, int buttons, const char *n)
: KDialogBase(Swallow, caption, buttons, Ok, p, n, true, true)
{
if (caption.isEmpty())
setCaption(i18n("Add Relationship"));
m_relation = rel;
m_panel = new RelationPanel(this);
setMainWidget(m_panel);
m_panel->setActiveWindow();
m_panel->fromName->setText(rel->parent()->name());
m_panel->toName->setText(rel->child()->name());
m_panel->relationType->setButton(rel->type());
m_panel->lag->setVisibleFields(DurationWidget::Days|DurationWidget::Hours|DurationWidget::Minutes);
m_panel->lag->setFieldUnit(0, i18n("days", "d"));
m_panel->lag->setFieldUnit(1, i18n("hours", "h"));
m_panel->lag->setFieldUnit(2, i18n("minutes", "m"));
m_panel->lag->setValue(rel->lag());
m_panel->relationType->setFocus();
enableButtonOK(true);
connect(m_panel->relationType, TQ_SIGNAL(clicked(int)), TQ_SLOT(typeClicked(int)));
connect(m_panel->lag, TQ_SIGNAL(valueChanged()), TQ_SLOT(lagChanged()));
}
KCommand *AddRelationDialog::buildCommand(Part *part) {
return new AddRelationCmd(part, m_relation, i18n("Add Relation"));
}
void AddRelationDialog::slotOk() {
if ( m_panel->relationType->selected() == 0 ) {
KMessageBox::sorry(this, i18n("You must select a relationship type"));
return;
}
accept();
}
void AddRelationDialog::lagChanged() {
enableButtonOK(true);
}
void AddRelationDialog::typeClicked(int id) {
if (id != m_relation->type())
enableButtonOK(true);
}
//////////////////
ModifyRelationDialog::ModifyRelationDialog(Relation *rel, TQWidget *p, const char *n)
: AddRelationDialog(rel, p, i18n("Edit Relationship"), Ok|Cancel|User1, n)
{
setButtonText( KDialogBase::User1, i18n("Delete") );
m_deleted = false;
enableButtonOK(false);
}
// Delete
void ModifyRelationDialog::slotUser1() {
m_deleted = true;
accept();
}
KCommand *ModifyRelationDialog::buildCommand(Part *part) {
KMacroCommand *cmd=0;
if (m_panel->relationType->selectedId() != m_relation->type()) {
if (cmd == 0)
cmd = new KMacroCommand(i18n("Modify Relation"));
cmd->addCommand(new ModifyRelationTypeCmd(part, m_relation, (Relation::Type)m_panel->relationType->selectedId()));
}
if (m_relation->lag() != m_panel->lag->value()) {
if (cmd == 0)
cmd = new KMacroCommand(i18n("Modify Relation"));
cmd->addCommand(new ModifyRelationLagCmd(part, m_relation, m_panel->lag->value()));
}
return cmd;
}
} //KPlato namespace
#include "kptrelationdialog.moc"
|