20#include "kptmainprojectpanel.h"
22#include <tqcheckbox.h>
23#include <tqbuttongroup.h>
24#include <tqdatetime.h>
25#include <tqdatetimeedit.h>
26#include <tqradiobutton.h>
27#include <tqpushbutton.h>
32#include <kdatewidget.h>
34#include <tdemessagebox.h>
36#include <tdeabc/addressee.h>
37#include <tdeabc/addresseedialog.h>
41#include "kptproject.h"
42#include "kptcommand.h"
43#include "kptschedule.h"
48MainProjectPanel::MainProjectPanel(
Project &p, TQWidget *parent,
const char *name)
49 : MainProjectPanelImpl(parent, name),
52 namefield->setText(project.name());
53 idfield->setText(project.id());
54 leaderfield->setText(project.leader());
55 descriptionfield->setText(project.description());
56 wbs->setText(project.wbs());
60 TQDateTime st = project.constraintStartTime();
61 TQDateTime et = project.constraintEndTime();
62 TQString s = i18n(
"Scheduling");
63 Schedule *sch = project.currentSchedule();
65 s = i18n(
"Scheduling (%1)").arg(sch->typeToString(
true));
67 schedulingGroup->setTitle(s);
68 if (project.constraint() == Node::MustStartOn) {
69 schedulingGroup->setButton(0);
71 et = project.endTime();
72 }
else if (project.constraint() == Node::MustFinishOn) {
73 schedulingGroup->setButton(1);
75 st = project.startTime();
77 kdWarning()<<k_funcinfo<<
"Illegal constraint: "<<project.constraint()<<endl;
78 schedulingGroup->setButton(0);
80 et = project.endTime();
82 startDate->setDate(st.date());
83 startTime->setTime(st.time());
84 endDate->setDate(et.date());
85 endTime->setTime(et.time());
88 namefield->setFocus();
92bool MainProjectPanel::ok() {
93 if (idfield->text() != project.id() && project.findNode(idfield->text())) {
94 KMessageBox::sorry(
this, i18n(
"Project id must be unique"));
101KCommand *MainProjectPanel::buildCommand(Part *part) {
102 KMacroCommand *m = 0;
103 TQString c = i18n(
"Modify main project");
104 if (project.name() != namefield->text()) {
105 if (!m) m =
new KMacroCommand(c);
106 m->addCommand(
new NodeModifyNameCmd(part, project, namefield->text()));
108 if (project.id() != idfield->text()) {
109 if (!m) m =
new KMacroCommand(c);
110 m->addCommand(
new NodeModifyIdCmd(part, project, idfield->text()));
112 if (project.leader() != leaderfield->text()) {
113 if (!m) m =
new KMacroCommand(c);
114 m->addCommand(
new NodeModifyLeaderCmd(part, project, leaderfield->text()));
116 if (project.description() != descriptionfield->text()) {
117 if (!m) m =
new KMacroCommand(c);
118 m->addCommand(
new NodeModifyDescriptionCmd(part, project, descriptionfield->text()));
125 if (bStartDate->state() && project.constraint() != Node::MustStartOn) {
126 if (!m) m =
new KMacroCommand(c);
127 m->addCommand(
new ProjectModifyConstraintCmd(part, project, Node::MustStartOn));
129 if (bEndDate->state() && project.constraint() != Node::MustFinishOn) {
130 if (!m) m =
new KMacroCommand(c);
131 m->addCommand(
new ProjectModifyConstraintCmd(part, project, Node::MustFinishOn));
133 if (bStartDate->state() && startDateTime() != project.constraintStartTime()) {
134 if (!m) m =
new KMacroCommand(c);
135 m->addCommand(
new ProjectModifyStartTimeCmd(part, project, startDateTime()));
137 if (bEndDate->state() && endDateTime() != project.constraintEndTime()) {
138 if (!m) m =
new KMacroCommand(c);
139 m->addCommand(
new ProjectModifyEndTimeCmd(part, project, endDateTime()));
145MainProjectPanelImpl::MainProjectPanelImpl(TQWidget *parent,
const char *name)
146 : MainProjectPanelBase(parent, name) {
149 connect( bStartDate, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotStartDateClicked() ) );
150 connect( bEndDate, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotEndDateClicked() ) );
151 connect( bStartDate, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotCheckAllFieldsFilled() ) );
152 connect( bEndDate, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotCheckAllFieldsFilled() ) );
153 connect( descriptionfield, TQ_SIGNAL( textChanged() ),
this, TQ_SLOT( slotCheckAllFieldsFilled() ) );
154 connect( endDate, TQ_SIGNAL( changed(TQDate) ),
this, TQ_SLOT( slotCheckAllFieldsFilled() ) );
155 connect( endTime, TQ_SIGNAL( valueChanged(
const TQTime&) ),
this, TQ_SLOT( slotCheckAllFieldsFilled() ) );
156 connect( startDate, TQ_SIGNAL( changed(TQDate) ),
this, TQ_SLOT( slotCheckAllFieldsFilled() ) );
157 connect( startTime, TQ_SIGNAL( valueChanged(
const TQTime&) ),
this, TQ_SLOT( slotCheckAllFieldsFilled() ) );
159 connect( namefield, TQ_SIGNAL( textChanged(
const TQString&) ),
this, TQ_SLOT( slotCheckAllFieldsFilled() ) );
160 connect( idfield, TQ_SIGNAL( textChanged(
const TQString&) ),
this, TQ_SLOT( slotCheckAllFieldsFilled() ) );
161 connect( leaderfield, TQ_SIGNAL( textChanged(
const TQString&) ),
this, TQ_SLOT( slotCheckAllFieldsFilled() ) );
163 connect( chooseLeader, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotChooseLeader() ) );
166void MainProjectPanelImpl::slotCheckAllFieldsFilled()
169 emit obligatedFieldsFilled(!namefield->text().isEmpty() && !idfield->text().isEmpty() && !leaderfield->text().isEmpty());
173void MainProjectPanelImpl::slotChooseLeader()
175 TDEABC::Addressee a = TDEABC::AddresseeDialog::getAddressee(
this);
178 leaderfield->setText(a.fullEmail());
183void MainProjectPanelImpl::slotStartDateClicked()
189void MainProjectPanelImpl::slotEndDateClicked()
196void MainProjectPanelImpl::enableDateTime()
198 if (schedulingGroup->selected() == bStartDate)
200 startTime->setEnabled(
true);
201 startDate->setEnabled(
true);
202 endTime->setEnabled(
false);
203 endDate->setEnabled(
false);
205 if (schedulingGroup->selected() == bEndDate)
207 startTime->setEnabled(
false);
208 startDate->setEnabled(
false);
209 endTime->setEnabled(
true);
210 endDate->setEnabled(
true);
215TQDateTime MainProjectPanelImpl::startDateTime()
217 return TQDateTime(startDate->date(), startTime->time());
221TQDateTime MainProjectPanelImpl::endDateTime()
223 return TQDateTime(endDate->date(), endTime->time());
227void MainProjectPanelImpl::slotBaseline()
231 namefield->setReadOnly(b);
232 idfield->setReadOnly(b);
233 leaderfield->setReadOnly(b);
234 chooseLeader->setEnabled(!b);
235 schedulingGroup->setEnabled(!b);
240#include "kptmainprojectpanel.moc"
Project is the main node in a project, it contains child nodes and possibly sub-projects.