kplato

kpttaskdialog.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002 Bo Thorsen bo@sonofthor.dk
3 Copyright (C) 2004 Dag Andersen <danders@get2net.dk>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include "kpttaskdialog.h"
22#include "kpttaskcostpanel.h"
23#include "kpttaskgeneralpanel.h"
24#include "kptrequestresourcespanel.h"
25
26#include <tdelocale.h>
27#include <kcommand.h>
28
29#include <tqvbox.h>
30#include <kdebug.h>
31
32namespace KPlato
33{
34
35TaskDialog::TaskDialog(Task &task, Accounts &accounts, StandardWorktime *workTime, bool baseline, TQWidget *p)
36 : KDialogBase(Tabbed, i18n("Task Settings"), Ok|Cancel, Ok, p, "Task Settings Dialog", true, true)
37{
38 TQVBox *page;
39
40 // Create all the tabs.
41 page = addVBoxPage(i18n("&General"));
42 m_generalTab = new TaskGeneralPanel(task, workTime, baseline, page);
43
44 page = addVBoxPage(i18n("&Resources"));
45 m_resourcesTab = new RequestResourcesPanel(page, task, baseline);
46
47 page = addVBoxPage(i18n("&Cost"));
48 m_costTab = new TaskCostPanel(task, accounts, page);
49
50 // Set the state of all the child widgets.
51 enableButtonOK(false);
52
53 connect(m_generalTab, TQ_SIGNAL( obligatedFieldsFilled(bool) ), this, TQ_SLOT( enableButtonOK(bool) ));
54 connect(m_resourcesTab, TQ_SIGNAL( changed() ), m_generalTab, TQ_SLOT( checkAllFieldsFilled() ));
55 connect(m_costTab, TQ_SIGNAL( changed() ), m_generalTab, TQ_SLOT( checkAllFieldsFilled() ));
56}
57
58
59KCommand *TaskDialog::buildCommand(Part *part) {
60 KMacroCommand *m = new KMacroCommand(i18n("Modify Task"));
61 bool modified = false;
62 KCommand *cmd = m_generalTab->buildCommand(part);
63 if (cmd) {
64 m->addCommand(cmd);
65 modified = true;
66 }
67 cmd = m_resourcesTab->buildCommand(part);
68 if (cmd) {
69 m->addCommand(cmd);
70 modified = true;
71 }
72 cmd = m_costTab->buildCommand(part);
73 if (cmd) {
74 m->addCommand(cmd);
75 modified = true;
76 }
77 if (!modified) {
78 delete m;
79 return 0;
80 }
81 return m;
82}
83
84void TaskDialog::slotOk() {
85 if (!m_generalTab->ok())
86 return;
87 if (!m_resourcesTab->ok())
88 return;
89
90 accept();
91}
92
93
94} //KPlato namespace
95
96#include "kpttaskdialog.moc"
Accounts administrates all accounts.
Definition kptaccount.h:180
TaskDialog(Task &task, Accounts &accounts, StandardWorktime *workTime=0, bool baseline=false, TQWidget *parent=0)
The constructor for the task settings dialog.
A task in the scheduling software is represented by this class.
Definition kpttask.h:40