kplato

kptprojectdialog.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002 Bo Thorsen bo@sonofthor.dk
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <tqpushbutton.h>
21#include <tqcombobox.h>
22#include <tqlabel.h>
23#include <tqtextedit.h>
24#include <tqlineedit.h>
25#include <tqdatetimeedit.h>
26#include <tqdatetime.h>
27#include <tqtabwidget.h>
28#include <tqtextbrowser.h>
29
30#include <kdatepicker.h>
31#include <tdelocale.h>
32
33#include <tdeabc/addressee.h>
34#include <tdeabc/addresseedialog.h>
35
36#include <kdebug.h>
37
38#include "kptprojectdialog.h"
39#include "kptproject.h"
40#include "kptresource.h"
41#include "kptprojectdialogbase.h"
42#include "kptresourcespanel.h"
43
44namespace KPlato
45{
46
47ProjectDialog::ProjectDialog(Project &p, TQWidget *parent, const char *name)
48 : KDialogBase( Swallow, i18n("Project Settings"), Ok|Cancel, Ok, parent, name, true, true),
49 project(p)
50{
51 dia = new ProjectDialogImpl(this);
52 resourcesTab = new ResourcesPanel(dia, &project);
53 dia->daTabs->insertTab(resourcesTab, i18n("Resources"), 1);
54 setMainWidget(dia);
55 enableButtonOK(false);
56
57 dia->namefield->setText(project.name());
58 dia->leaderfield->setText(project.leader());
59
60 connect(dia, TQ_SIGNAL( obligatedFieldsFilled(bool) ), this, TQ_SLOT( enableButtonOK(bool) ));
61 connect(dia, TQ_SIGNAL( schedulingTypeChanged(int) ), this, TQ_SLOT( slotSchedulingChanged(int) ));
62
63 slotSchedulingChanged(dia->schedulerType->currentItem());
64 dia->namefield->setFocus();
65
66 connect(resourcesTab, TQ_SIGNAL( changed() ), dia, TQ_SLOT( slotCheckAllFieldsFilled() ));
67}
68
69
70void ProjectDialog::slotOk() {
71 project.setConstraint((Node::ConstraintType) dia->schedulerType->currentItem());
72 //FIXME
73 project.setStartTime(TQDateTime(dia->schedulerDate->date(), dia->schedulerTime->time()));
74 project.setConstraintStartTime(TQDateTime(dia->schedulerDate->date(), dia->schedulerTime->time()));
75
76 project.setName(dia->namefield->text());
77 project.setLeader(dia->leaderfield->text());
78 project.setDescription(dia->descriptionfield->text());
79
80 resourcesTab->ok();
81
82 accept();
83}
84
85void ProjectDialog::slotSchedulingChanged(int activated) {
86 bool needDate = activated >= 2;
87 dia->schedulerTime->setEnabled(needDate);
88 dia->schedulerDate->setEnabled(needDate);
89
90 TQString label = TQString("<p><font size=\"4\" color=\"#7797BC\"><b>%1</b></font></p><p>%2</p>");
91 switch(activated) {
92 // TODO please provide nice explenations on this.
93 case 0: // ASAP
94 label = label.arg(i18n("As Soon as Possible"));
95 label = label.arg(i18n("Place all events at the earliest possible moment permitted in the schedule"));
96 break;
97 case 1: // ALAP
98 label = label.arg(i18n("As Late as Possible"));
99 label = label.arg(i18n("Place all events at the last possible moment permitted in the schedule"));
100 break;
101 case 2: // Start not earlier then
102 label = label.arg(i18n("Start not Earlier then"));
103 label = label.arg("");
104 break;
105 case 3: // Finish not later then
106 label = label.arg(i18n("Finish not Later then"));
107 label = label.arg("");
108 break;
109 case 4: // Must start on
110 label = label.arg(i18n("Must Start on"));
111 label = label.arg("");
112 break;
113 default: // error ...
114 dia->lSchedulingExplain->setText("");
115 return;
116 }
117 dia->lSchedulingExplain->setText(label);
118}
119
120ProjectDialogImpl::ProjectDialogImpl (TQWidget *parent) : ProjectDialogBase(parent) {
121 connect (namefield, TQ_SIGNAL(textChanged( const TQString& )), this, TQ_SLOT(slotCheckAllFieldsFilled()) );
122 connect (leaderfield, TQ_SIGNAL(textChanged( const TQString& )), this, TQ_SLOT(slotCheckAllFieldsFilled()) );
123 connect (schedulerType, TQ_SIGNAL(activated( int )), this, TQ_SLOT(slotSchedulingChanged( int )) );
124 connect (chooseLeader, TQ_SIGNAL(pressed()), this, TQ_SLOT(slotChooseLeader()));
125}
126
127void ProjectDialogImpl::slotCheckAllFieldsFilled() {
128 emit obligatedFieldsFilled( !(namefield->text().isEmpty() || leaderfield->text().isEmpty()));
129}
130
131void ProjectDialogImpl::slotSchedulingChanged(int activated) {
132 emit schedulingTypeChanged(activated);
133}
134
135void ProjectDialogImpl::slotChooseLeader()
136{
137 TDEABC::Addressee a = TDEABC::AddresseeDialog::getAddressee(this);
138 if (!a.isEmpty()) {
139 leaderfield->setText(a.fullEmail());
140 }
141}
142
143} //KPlato namespace
144
145#include "kptprojectdialog.moc"
Project is the main node in a project, it contains child nodes and possibly sub-projects.
Definition kptproject.h:52