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

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 - 2006 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 "kptsummarytaskgeneralpanel.h"
00021 #include "kptsummarytaskdialog.h"
00022 #include "kpttask.h"
00023 #include "kptcommand.h"
00024 #include "kptconfig.h"
00025 #include "kptpart.h"
00026 
00027 #include <kmessagebox.h>
00028 #include <klineedit.h>
00029 #include <ktextedit.h>
00030 #include <kcombobox.h>
00031 #include <kdatetimewidget.h>
00032 #include <klocale.h>
00033 #include <kcommand.h>
00034 #include <kabc/addressee.h>
00035 #include <kabc/addresseedialog.h>
00036 
00037 #include <QPushButton>
00038 #include <QLayout>
00039 #include <QLabel>
00040 #include <QGroupBox>
00041 #include <kdebug.h>
00042 
00043 namespace KPlato
00044 {
00045 
00046 SummaryTaskGeneralPanel::SummaryTaskGeneralPanel(Task &task, QWidget *p, const char *n)
00047     : QWidget(p),
00048       m_task(task)
00049 {
00050     setObjectName(n);
00051     setupUi(this);
00052     
00053     setStartValues(task);
00054     
00055     connect(namefield, SIGNAL(textChanged(const QString&)), SLOT(slotObligatedFieldsFilled()));
00056     connect(leaderfield, SIGNAL(textChanged(const QString&)), SLOT(slotObligatedFieldsFilled()));
00057     connect(idfield, SIGNAL(textChanged(const QString&)), SLOT(slotObligatedFieldsFilled()));
00058     connect(descriptionfield, SIGNAL(textChanged()), SLOT(slotObligatedFieldsFilled()));
00059     
00060     connect(chooseLeader, SIGNAL(clicked()), SLOT(slotChooseResponsible()));
00061 
00062 }
00063 
00064 void SummaryTaskGeneralPanel::setStartValues(Task &task) {
00065     namefield->setText(task.name());
00066     leaderfield->setText(task.leader());
00067     descriptionfield->setText(task.description());
00068     idfield->setText(task.id());
00069     wbsfield->setText(task.wbs());
00070     
00071     namefield->setFocus();
00072     
00073 }
00074 
00075 void SummaryTaskGeneralPanel::slotObligatedFieldsFilled() {
00076     emit obligatedFieldsFilled(!namefield->text().isEmpty() && !idfield->text().isEmpty());
00077 }
00078 
00079 KMacroCommand *SummaryTaskGeneralPanel::buildCommand(Part *part) {
00080     KMacroCommand *cmd = new KMacroCommand(i18n("Modify Task"));
00081     bool modified = false;
00082 
00083     if (!namefield->isHidden() && m_task.name() != namefield->text()) {
00084         cmd->addCommand(new NodeModifyNameCmd(part, m_task, namefield->text()));
00085         modified = true;
00086     }
00087     if (!leaderfield->isHidden() && m_task.leader() != leaderfield->text()) {
00088         cmd->addCommand(new NodeModifyLeaderCmd(part, m_task, leaderfield->text()));
00089         modified = true;
00090     }
00091     if (!descriptionfield->isHidden() && 
00092         m_task.description() != descriptionfield->text()) {
00093         cmd->addCommand(new NodeModifyDescriptionCmd(part, m_task, descriptionfield->text()));
00094         modified = true;
00095     }
00096     if (!idfield->isHidden() && idfield->text() != m_task.id()) {
00097         cmd->addCommand(new NodeModifyIdCmd(part, m_task, idfield->text()));
00098         modified = true;
00099     }
00100     if (!modified) {
00101         delete cmd;
00102         return 0;
00103     }
00104     return cmd;
00105 }
00106 
00107 bool SummaryTaskGeneralPanel::ok() {
00108     if (idfield->text() != m_task.id() && m_task.findNode(idfield->text())) {
00109         KMessageBox::sorry(this, i18n("Task id must be unique"));
00110         idfield->setFocus();
00111         return false;
00112     }
00113     return true;
00114 }
00115 
00116 void SummaryTaskGeneralPanel::slotChooseResponsible() {
00117     KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this);
00118     if (!a.isEmpty()) {
00119         leaderfield->setText(a.fullEmail());
00120         leaderfield->setFocus();
00121     }
00122 }
00123 
00124 
00125 }  //KPlato namespace
00126 
00127 #include "kptsummarytaskgeneralpanel.moc"

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