00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <qpushbutton.h>
00021 #include <qcombobox.h>
00022 #include <qlabel.h>
00023 #include <qtextedit.h>
00024 #include <qlineedit.h>
00025 #include <qdatetimeedit.h>
00026 #include <qdatetime.h>
00027 #include <qtabwidget.h>
00028 #include <qtextbrowser.h>
00029
00030 #include <kdatepicker.h>
00031 #include <klocale.h>
00032
00033 #include <kabc/addressee.h>
00034 #include <kabc/addresseedialog.h>
00035
00036 #include <kdebug.h>
00037
00038 #include "kptprojectdialog.h"
00039 #include "kptproject.h"
00040 #include "kptresource.h"
00041 #include "kptprojectdialogbase.h"
00042 #include "kptresourcespanel.h"
00043
00044 namespace KPlato
00045 {
00046
00047 ProjectDialog::ProjectDialog(Project &p, QWidget *parent, const char *name)
00048 : KDialogBase( Swallow, i18n("Project Settings"), Ok|Cancel, Ok, parent, name, true, true),
00049 project(p)
00050 {
00051 dia = new ProjectDialogImpl(this);
00052 resourcesTab = new ResourcesPanel(dia, &project);
00053 dia->daTabs->insertTab(resourcesTab, i18n("Resources"), 1);
00054 setMainWidget(dia);
00055 enableButtonOK(false);
00056
00057 dia->namefield->setText(project.name());
00058 dia->leaderfield->setText(project.leader());
00059
00060 connect(dia, SIGNAL( obligatedFieldsFilled(bool) ), this, SLOT( enableButtonOK(bool) ));
00061 connect(dia, SIGNAL( schedulingTypeChanged(int) ), this, SLOT( slotSchedulingChanged(int) ));
00062
00063 slotSchedulingChanged(dia->schedulerType->currentItem());
00064 dia->namefield->setFocus();
00065
00066 connect(resourcesTab, SIGNAL( changed() ), dia, SLOT( slotCheckAllFieldsFilled() ));
00067 }
00068
00069
00070 void ProjectDialog::slotOk() {
00071 project.setConstraint((Node::ConstraintType) dia->schedulerType->currentItem());
00072
00073 project.setStartTime(QDateTime(dia->schedulerDate->date(), dia->schedulerTime->time()));
00074 project.setConstraintStartTime(QDateTime(dia->schedulerDate->date(), dia->schedulerTime->time()));
00075
00076 project.setName(dia->namefield->text());
00077 project.setLeader(dia->leaderfield->text());
00078 project.setDescription(dia->descriptionfield->text());
00079
00080 resourcesTab->ok();
00081
00082 accept();
00083 }
00084
00085 void ProjectDialog::slotSchedulingChanged(int activated) {
00086 bool needDate = activated >= 2;
00087 dia->schedulerTime->setEnabled(needDate);
00088 dia->schedulerDate->setEnabled(needDate);
00089
00090 QString label = QString("<p><font size=\"4\" color=\"#7797BC\"><b>%1</b></font></p><p>%2</p>");
00091 switch(activated) {
00092
00093 case 0:
00094 label = label.arg(i18n("As Soon as Possible"));
00095 label = label.arg(i18n("Place all events at the earliest possible moment permitted in the schedule"));
00096 break;
00097 case 1:
00098 label = label.arg(i18n("As Late as Possible"));
00099 label = label.arg(i18n("Place all events at the last possible moment permitted in the schedule"));
00100 break;
00101 case 2:
00102 label = label.arg(i18n("Start not Earlier then"));
00103 label = label.arg(i18n(""));
00104 break;
00105 case 3:
00106 label = label.arg(i18n("Finish not Later then"));
00107 label = label.arg(i18n(""));
00108 break;
00109 case 4:
00110 label = label.arg(i18n("Must Start on"));
00111 label = label.arg(i18n(""));
00112 break;
00113 default:
00114 dia->lSchedulingExplain->setText("");
00115 return;
00116 }
00117 dia->lSchedulingExplain->setText(label);
00118 }
00119
00120 ProjectDialogImpl::ProjectDialogImpl (QWidget *parent) : ProjectDialogBase(parent) {
00121 connect (namefield, SIGNAL(textChanged( const QString& )), this, SLOT(slotCheckAllFieldsFilled()) );
00122 connect (leaderfield, SIGNAL(textChanged( const QString& )), this, SLOT(slotCheckAllFieldsFilled()) );
00123 connect (schedulerType, SIGNAL(activated( int )), this, SLOT(slotSchedulingChanged( int )) );
00124 connect (chooseLeader, SIGNAL(pressed()), this, SLOT(slotChooseLeader()));
00125 }
00126
00127 void ProjectDialogImpl::slotCheckAllFieldsFilled() {
00128 emit obligatedFieldsFilled( !(namefield->text().isEmpty() || leaderfield->text().isEmpty()));
00129 }
00130
00131 void ProjectDialogImpl::slotSchedulingChanged(int activated) {
00132 emit schedulingTypeChanged(activated);
00133 }
00134
00135 void ProjectDialogImpl::slotChooseLeader()
00136 {
00137 KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this);
00138 if (!a.isEmpty()) {
00139 leaderfield->setText(a.fullEmail());
00140 }
00141 }
00142
00143 }
00144
00145 #include "kptprojectdialog.moc"