F:/KPlato/koffice/kplato/kptmilestoneprogresspanel.cc

Aller à la documentation de ce fichier.
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>
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 }  //KPlato namespace
00105 
00106 #include "kptmilestoneprogresspanel.moc"

Généré le Wed Nov 22 23:40:56 2006 pour KPlato par  doxygen 1.5.1-p1