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

Aller à la documentation de ce fichier.
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 <kvbox.h>
00030 #include <kdebug.h>
00031 
00032 namespace KPlato
00033 {
00034 
00035 TaskDialog::TaskDialog(Task &task, Accounts &accounts, StandardWorktime *workTime, QWidget *p)
00036     : KPageDialog(p)
00037 {
00038     setCaption( i18n("Task Settings") );
00039     setButtons( Ok|Cancel );
00040     setDefaultButton( Ok );
00041     setFaceType( KPageDialog::Tabbed );
00042     showButtonSeparator( true );
00043     KVBox *page;
00044 
00045     // Create all the tabs.
00046     page =  new KVBox();
00047     addPage(page, i18n("&General"));
00048     m_generalTab = new TaskGeneralPanel(task, workTime, page);
00049 
00050     page =  new KVBox();
00051 
00052     addPage(page, i18n("&Resources"));
00053     m_resourcesTab = new RequestResourcesPanel(page, task);
00054     page =  new KVBox();
00055     addPage(page, i18n("&Cost"));
00056     m_costTab = new TaskCostPanel(task, accounts, page);
00057 
00058     // Set the state of all the child widgets.
00059     enableButtonOk(false);
00060 
00061     connect(this, SIGNAL(okClicked()), SLOT(slotOk()));
00062     connect(m_generalTab, SIGNAL( obligatedFieldsFilled(bool) ), this, SLOT( enableButtonOk(bool) ));
00063     connect(m_resourcesTab, SIGNAL( changed() ), m_generalTab, SLOT( checkAllFieldsFilled() ));
00064     connect(m_costTab, SIGNAL( changed() ), m_generalTab, SLOT( checkAllFieldsFilled() ));
00065 }
00066 
00067 
00068 KCommand *TaskDialog::buildCommand(Part *part) {
00069     KMacroCommand *m = new KMacroCommand(i18n("Modify Task"));
00070     bool modified = false;
00071     KCommand *cmd = m_generalTab->buildCommand(part);
00072     if (cmd) {
00073         m->addCommand(cmd);
00074         modified = true;
00075     }
00076     cmd = m_resourcesTab->buildCommand(part);
00077     if (cmd) {
00078         m->addCommand(cmd);
00079         modified = true;
00080     }
00081     cmd = m_costTab->buildCommand(part);
00082     if (cmd) {
00083         m->addCommand(cmd);
00084         modified = true;
00085     }
00086     if (!modified) {
00087         delete m;
00088         return 0;
00089     }
00090     return m;
00091 }
00092 
00093 void TaskDialog::slotOk() {
00094     if (!m_generalTab->ok())
00095         return;
00096     if (!m_resourcesTab->ok())
00097         return;
00098 
00099     accept();
00100 }
00101 
00102 
00103 }  //KPlato namespace
00104 
00105 #include "kpttaskdialog.moc"

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