kpilot
todoEditor.ccGo to the documentation of this file.00001
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
00047 TodoEditor::TodoEditor(PilotTodoEntry * p, struct ToDoAppInfo *appInfo,
00048 QWidget * parent, const char *name) :
00049 KDialogBase(parent, name, false, i18n("To-do Editor"), Ok|Cancel),
00050 fDeleteOnCancel(p == 0L),
00051 fTodo(p),
00052 fAppInfo(appInfo)
00053 {
00054 FUNCTIONSETUP;
00055
00056 fWidget=new TodoEditorBase(this);
00057 setMainWidget(fWidget);
00058 fillFields();
00059
00060 connect(parent, SIGNAL(recordChanged(PilotTodoEntry *)),
00061 this, SLOT(updateRecord(PilotTodoEntry *)));
00062
00063 }
00064
00065 TodoEditor::~TodoEditor()
00066 {
00067 FUNCTIONSETUP;
00068
00069 if (fDeleteOnCancel && fTodo)
00070 {
00071 #ifdef DEBUG
00072 DEBUGKPILOT << fname
00073 << ": Deleting private todo record." << endl;
00074 #endif
00075 delete fTodo;
00076 fTodo = 0L;
00077 }
00078
00079 #ifdef DEBUG
00080 DEBUGKPILOT << fname << ": Help! I'm deleting!" << endl;
00081 #endif
00082 }
00083
00084
00085
00086 void TodoEditor::fillFields()
00087 {
00088 FUNCTIONSETUP;
00089
00090 if (fTodo == 0L)
00091 {
00092 fTodo = new PilotTodoEntry();
00093 fDeleteOnCancel = true;
00094 }
00095
00096 fWidget->fDescription->setText(fTodo->getDescription());
00097 fWidget->fCompleted->setChecked(fTodo->getComplete());
00098 if (fTodo->getIndefinite())
00099 {
00100 fWidget->fHasEndDate->setChecked(false);
00101 }
00102 else
00103 {
00104 fWidget->fHasEndDate->setChecked(true);
00105 fWidget->fEndDate->setDate(readTm(fTodo->getDueDate()).date());
00106 }
00107 fWidget->fPriority->setCurrentItem(fTodo->getPriority());
00108
00109 fWidget->fNote->setText(fTodo->getNote());
00110 }
00111
00112
00113
00114 void TodoEditor::slotCancel()
00115 {
00116 FUNCTIONSETUP;
00117
00118 if (fDeleteOnCancel && fTodo)
00119 {
00120 delete fTodo;
00121
00122 fTodo = 0L;
00123 }
00124 KDialogBase::slotCancel();
00125 }
00126
00127 void TodoEditor::slotOk()
00128 {
00129 FUNCTIONSETUP;
00130
00131
00132 fTodo->setDescription(fWidget->fDescription->text());
00133 fTodo->setComplete(fWidget->fCompleted->isChecked());
00134 if (fWidget->fHasEndDate->isChecked())
00135 {
00136 fTodo->setIndefinite(false);
00137 struct tm duedate=writeTm(fWidget->fEndDate->date());
00138 fTodo->setDueDate(duedate);
00139 }
00140 else
00141 {
00142 fTodo->setIndefinite(true);
00143 }
00144 fTodo->setPriority(fWidget->fPriority->currentItem());
00145
00146 fTodo->setNote(fWidget->fNote->text());
00147
00148 emit(recordChangeComplete(fTodo));
00149 KDialogBase::slotOk();
00150 }
00151
00152 void TodoEditor::updateRecord(PilotTodoEntry * p)
00153 {
00154 FUNCTIONSETUP;
00155 if (p != fTodo)
00156 {
00157
00158
00159
00160 return;
00161 }
00162
00163 if (p->isDeleted())
00164 {
00165 delayedDestruct();
00166 return;
00167 }
00168 else
00169 {
00170 fillFields();
00171 }
00172 }
00173
|