kpilot/kpilot
todoEditor.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "options.h"
00033
00034 #include <qcombobox.h>
00035 #include <qlayout.h>
00036 #include <qlabel.h>
00037 #include <qtextedit.h>
00038 #include <qcheckbox.h>
00039
00040 #include <kdatewidget.h>
00041
00042 #include "pilotTodoEntry.h"
00043 #include "todoEditor_base.h"
00044 #include "todoEditor.moc"
00045
00046 static const char *todoEditor_id =
00047 "$Id: todoEditor.cc 529452 2006-04-13 14:05:00Z mueller $";
00048
00049 TodoEditor::TodoEditor(PilotTodoEntry * p, struct ToDoAppInfo *appInfo,
00050 QWidget * parent, const char *name) :
00051 KDialogBase(parent, name, false, i18n("To-do Editor"), Ok|Cancel),
00052 fDeleteOnCancel(p == 0L),
00053 fTodo(p),
00054 fAppInfo(appInfo)
00055 {
00056 FUNCTIONSETUP;
00057
00058 fWidget=new TodoEditorBase(this);
00059 setMainWidget(fWidget);
00060 fillFields();
00061
00062 connect(parent, SIGNAL(recordChanged(PilotTodoEntry *)),
00063 this, SLOT(updateRecord(PilotTodoEntry *)));
00064
00065 (void) todoEditor_id;
00066 }
00067
00068 TodoEditor::~TodoEditor()
00069 {
00070 FUNCTIONSETUP;
00071
00072 if (fDeleteOnCancel && fTodo)
00073 {
00074 #ifdef DEBUG
00075 DEBUGKPILOT << fname
00076 << ": Deleting private todo record." << endl;
00077 #endif
00078 delete fTodo;
00079 fTodo = 0L;
00080 }
00081
00082 #ifdef DEBUG
00083 DEBUGKPILOT << fname << ": Help! I'm deleting!" << endl;
00084 #endif
00085 }
00086
00087
00088
00089 void TodoEditor::fillFields()
00090 {
00091 FUNCTIONSETUP;
00092
00093 if (fTodo == 0L)
00094 {
00095 fTodo = new PilotTodoEntry(*fAppInfo);
00096 fDeleteOnCancel = true;
00097 }
00098
00099 fWidget->fDescription->setText(fTodo->getDescription());
00100 fWidget->fCompleted->setChecked(fTodo->getComplete());
00101 if (fTodo->getIndefinite())
00102 {
00103 fWidget->fHasEndDate->setChecked(false);
00104 }
00105 else
00106 {
00107 fWidget->fHasEndDate->setChecked(true);
00108 fWidget->fEndDate->setDate(readTm(fTodo->getDueDate()).date());
00109 }
00110 fWidget->fPriority->setCurrentItem(fTodo->getPriority());
00111
00112 fWidget->fNote->setText(fTodo->getNote());
00113 }
00114
00115
00116
00117 void TodoEditor::slotCancel()
00118 {
00119 FUNCTIONSETUP;
00120
00121 if (fDeleteOnCancel && fTodo)
00122 {
00123 delete fTodo;
00124
00125 fTodo = 0L;
00126 }
00127 KDialogBase::slotCancel();
00128 }
00129
00130 void TodoEditor::slotOk()
00131 {
00132 FUNCTIONSETUP;
00133
00134
00135 fTodo->setDescription(fWidget->fDescription->text());
00136 fTodo->setComplete(fWidget->fCompleted->isChecked());
00137 if (fWidget->fHasEndDate->isChecked())
00138 {
00139 fTodo->setIndefinite(false);
00140 struct tm duedate=writeTm(fWidget->fEndDate->date());
00141 fTodo->setDueDate(duedate);
00142 }
00143 else
00144 {
00145 fTodo->setIndefinite(true);
00146 }
00147 fTodo->setPriority(fWidget->fPriority->currentItem());
00148
00149 fTodo->setNote(fWidget->fNote->text());
00150
00151 emit(recordChangeComplete(fTodo));
00152 fDeleteOnCancel = false;
00153 KDialogBase::slotOk();
00154 }
00155
00156 void TodoEditor::updateRecord(PilotTodoEntry * p)
00157 {
00158 FUNCTIONSETUP;
00159 if (p != fTodo)
00160 {
00161
00162
00163
00164 return;
00165 }
00166
00167 if (p->isDeleted())
00168 {
00169 delayedDestruct();
00170 return;
00171 }
00172 else
00173 {
00174 fillFields();
00175 }
00176 }
00177
|