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