kplato

kptmilestoneprogresspanel.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2005 Dag Andersen <danders@get2net.dk>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation;
00007    version 2 of the License.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "kptmilestoneprogresspanel.h"
00021 
00022 #include <qcheckbox.h>
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     kdDebug()<<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, WFlags f)
00072     : MilestoneProgressPanelBase(parent, name, f) {
00073     
00074     connect(finished, SIGNAL(toggled(bool)), SLOT(slotFinishedChanged(bool)));
00075     connect(finished, SIGNAL(toggled(bool)), SLOT(slotChanged()));
00076 
00077     connect(finishTime, SIGNAL(valueChanged(const QDateTime &)), SLOT(slotChanged()));
00078     
00079 }
00080 
00081 void MilestoneProgressPanelImpl::slotChanged() {
00082     emit changed();
00083 }
00084 
00085 void MilestoneProgressPanelImpl::slotFinishedChanged(bool state) {
00086     if (state) {
00087         if (!finishTime->dateTime().isValid()) {
00088             finishTime->setDateTime(QDateTime::currentDateTime());
00089         }
00090     }   
00091     enableWidgets();
00092 }
00093 
00094 
00095 void MilestoneProgressPanelImpl::enableWidgets() {
00096     finished->setEnabled(true);
00097     finishTime->setEnabled(finished->isChecked());
00098 }
00099 
00100 
00101 }  //KPlato namespace
00102 
00103 #include "kptmilestoneprogresspanel.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys