kplato

kpttaskdialog.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002 Bo Thorsen  bo@sonofthor.dk
00003    Copyright (C) 2004 Dag Andersen <danders@get2net.dk>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "kpttaskdialog.h"
00022 #include "kpttaskcostpanel.h"
00023 #include "kpttaskgeneralpanel.h"
00024 #include "kptrequestresourcespanel.h"
00025 
00026 #include <klocale.h>
00027 #include <kcommand.h>
00028 
00029 #include <qvbox.h>
00030 #include <kdebug.h>
00031 
00032 namespace KPlato
00033 {
00034 
00035 TaskDialog::TaskDialog(Task &task, Accounts &accounts, StandardWorktime *workTime, bool baseline, QWidget *p)
00036     : KDialogBase(Tabbed, i18n("Task Settings"), Ok|Cancel, Ok, p, "Task Settings Dialog", true, true)
00037 {
00038     QVBox *page;
00039     
00040     // Create all the tabs.
00041     page = addVBoxPage(i18n("&General"));
00042     m_generalTab = new TaskGeneralPanel(task, workTime, baseline, page);
00043 
00044     page = addVBoxPage(i18n("&Resources"));
00045     m_resourcesTab = new RequestResourcesPanel(page, task, baseline);
00046     
00047     page = addVBoxPage(i18n("&Cost"));
00048     m_costTab = new TaskCostPanel(task, accounts, page);
00049     
00050     // Set the state of all the child widgets.
00051     enableButtonOK(false);
00052     
00053     connect(m_generalTab, SIGNAL( obligatedFieldsFilled(bool) ), this, SLOT( enableButtonOK(bool) ));
00054     connect(m_resourcesTab, SIGNAL( changed() ), m_generalTab, SLOT( checkAllFieldsFilled() ));
00055     connect(m_costTab, SIGNAL( changed() ), m_generalTab, SLOT( checkAllFieldsFilled() ));
00056 }
00057 
00058 
00059 KCommand *TaskDialog::buildCommand(Part *part) {
00060     KMacroCommand *m = new KMacroCommand(i18n("Modify Task"));
00061     bool modified = false;
00062     KCommand *cmd = m_generalTab->buildCommand(part);
00063     if (cmd) {
00064         m->addCommand(cmd);
00065         modified = true;
00066     }
00067     cmd = m_resourcesTab->buildCommand(part);
00068     if (cmd) {
00069         m->addCommand(cmd);
00070         modified = true;
00071     }
00072     cmd = m_costTab->buildCommand(part);
00073     if (cmd) {
00074         m->addCommand(cmd);
00075         modified = true;
00076     }
00077     if (!modified) {
00078         delete m;
00079         return 0;
00080     }
00081     return m;
00082 }
00083 
00084 void TaskDialog::slotOk() {
00085     if (!m_generalTab->ok())
00086         return;
00087     if (!m_resourcesTab->ok())
00088         return;
00089     
00090     accept();
00091 }
00092 
00093 
00094 }  //KPlato namespace
00095 
00096 #include "kpttaskdialog.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys