00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kptmilestoneprogresspanel.h"
00021
00022 #include <QCheckBox>
00023
00024 #include <kdatetimewidget.h>
00025 #include <klocale.h>
00026 #include <kmessagebox.h>
00027 #include <kcommand.h>
00028
00029 #include <kdebug.h>
00030
00031 #include "kpttask.h"
00032 #include "kptcommand.h"
00033
00034 namespace KPlato
00035 {
00036
00037 MilestoneProgressPanel::MilestoneProgressPanel(Task &task, QWidget *parent, const char *name)
00038 : MilestoneProgressPanelImpl(parent, name),
00039 m_task(task)
00040 {
00041 kDebug()<<k_funcinfo<<endl;
00042 m_progress = task.progress();
00043 finished->setChecked(m_progress.finished);
00044 finishTime->setDateTime(m_progress.finishTime);
00045
00046 enableWidgets();
00047 finished->setFocus();
00048 }
00049
00050
00051 bool MilestoneProgressPanel::ok() {
00052 m_progress.started = finished->isChecked();
00053 m_progress.finished = finished->isChecked();
00054 m_progress.startTime = finishTime->dateTime();
00055 m_progress.finishTime = finishTime->dateTime();
00056 m_progress.percentFinished = m_progress.finished ? 100 : 0;
00057 return true;
00058 }
00059
00060 KCommand *MilestoneProgressPanel::buildCommand(Part *part) {
00061 KCommand *cmd = 0;
00062 QString c = i18n("Modify progress");
00063 if (m_task.progress() != m_progress) {
00064 cmd = new TaskModifyProgressCmd(part, m_task, m_progress, c);
00065 }
00066 return cmd;
00067 }
00068
00069
00070
00071 MilestoneProgressPanelImpl::MilestoneProgressPanelImpl(QWidget *parent, const char *name)
00072 : QWidget(parent) {
00073
00074 setObjectName(name);
00075 setupUi(this);
00076
00077 connect(finished, SIGNAL(toggled(bool)), SLOT(slotFinishedChanged(bool)));
00078 connect(finished, SIGNAL(toggled(bool)), SLOT(slotChanged()));
00079
00080 connect(finishTime, SIGNAL(valueChanged(const QDateTime &)), SLOT(slotChanged()));
00081
00082 }
00083
00084 void MilestoneProgressPanelImpl::slotChanged() {
00085 emit changed();
00086 }
00087
00088 void MilestoneProgressPanelImpl::slotFinishedChanged(bool state) {
00089 if (state) {
00090 if (!finishTime->dateTime().isValid()) {
00091 finishTime->setDateTime(QDateTime::currentDateTime());
00092 }
00093 }
00094 enableWidgets();
00095 }
00096
00097
00098 void MilestoneProgressPanelImpl::enableWidgets() {
00099 finished->setEnabled(true);
00100 finishTime->setEnabled(finished->isChecked());
00101 }
00102
00103
00104 }
00105
00106 #include "kptmilestoneprogresspanel.moc"