kplato

kptmilestoneprogresspanel.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2005 Dag Andersen <danders@get2net.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;
7 version 2 of the License.
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 "kptmilestoneprogresspanel.h"
21
22#include <tqcheckbox.h>
23
24#include <kdatetimewidget.h>
25#include <tdelocale.h>
26#include <tdemessagebox.h>
27#include <kcommand.h>
28
29#include <kdebug.h>
30
31#include "kpttask.h"
32#include "kptcommand.h"
33
34namespace KPlato
35{
36
37MilestoneProgressPanel::MilestoneProgressPanel(Task &task, TQWidget *parent, const char *name)
38 : MilestoneProgressPanelImpl(parent, name),
39 m_task(task)
40{
41 kdDebug()<<k_funcinfo<<endl;
42 m_progress = task.progress();
43 finished->setChecked(m_progress.finished);
44 finishTime->setDateTime(m_progress.finishTime);
45
46 enableWidgets();
47 finished->setFocus();
48}
49
50
51bool MilestoneProgressPanel::ok() {
52 m_progress.started = finished->isChecked();
53 m_progress.finished = finished->isChecked();
54 m_progress.startTime = finishTime->dateTime();
55 m_progress.finishTime = finishTime->dateTime();
56 m_progress.percentFinished = m_progress.finished ? 100 : 0;
57 return true;
58}
59
60KCommand *MilestoneProgressPanel::buildCommand(Part *part) {
61 KCommand *cmd = 0;
62 TQString c = i18n("Modify progress");
63 if (m_task.progress() != m_progress) {
64 cmd = new TaskModifyProgressCmd(part, m_task, m_progress, c);
65 }
66 return cmd;
67}
68
69//-------------------------------------
70
71MilestoneProgressPanelImpl::MilestoneProgressPanelImpl(TQWidget *parent, const char *name, WFlags f)
72 : MilestoneProgressPanelBase(parent, name, f) {
73
74 connect(finished, TQ_SIGNAL(toggled(bool)), TQ_SLOT(slotFinishedChanged(bool)));
75 connect(finished, TQ_SIGNAL(toggled(bool)), TQ_SLOT(slotChanged()));
76
77 connect(finishTime, TQ_SIGNAL(valueChanged(const TQDateTime &)), TQ_SLOT(slotChanged()));
78
79}
80
81void MilestoneProgressPanelImpl::slotChanged() {
82 emit changed();
83}
84
85void MilestoneProgressPanelImpl::slotFinishedChanged(bool state) {
86 if (state) {
87 if (!finishTime->dateTime().isValid()) {
88 finishTime->setDateTime(TQDateTime::currentDateTime());
89 }
90 }
91 enableWidgets();
92}
93
94
95void MilestoneProgressPanelImpl::enableWidgets() {
96 finished->setEnabled(true);
97 finishTime->setEnabled(finished->isChecked());
98}
99
100
101} //KPlato namespace
102
103#include "kptmilestoneprogresspanel.moc"
A task in the scheduling software is represented by this class.
Definition kpttask.h:40