00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
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
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 }
00104
00105 #include "kpttaskdialog.moc"