summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoeditor.cpp
Unidiff
Diffstat (limited to 'korganizer/kotodoeditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoeditor.cpp43
1 files changed, 24 insertions, 19 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 20a35d2..aeab92a 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -1,295 +1,300 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1997, 1998 Preston Brown 3 Copyright (c) 1997, 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qframe.h> 26#include <q3frame.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qhbox.h> 29#include <q3hbox.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qapplication.h> 33#include <qapplication.h>
34#include <QDesktopWidget>
34#include <qtabwidget.h> 35#include <qtabwidget.h>
36//Added by qt3to4:
37#include <Q3HBoxLayout>
38#include <Q3PtrList>
39#include <Q3VBoxLayout>
35 40
36#include <kiconloader.h> 41#include <kiconloader.h>
37#include <klocale.h> 42#include <klocale.h>
38#include <kfiledialog.h> 43#include <kfiledialog.h>
39#include <kstandarddirs.h> 44#include <kstandarddirs.h>
40#include <kmessagebox.h> 45#include <kmessagebox.h>
41 46
42#include <libkdepim/categoryselectdialog.h> 47#include <libkdepim/categoryselectdialog.h>
43#include <libkcal/calendarlocal.h> 48#include <libkcal/calendarlocal.h>
44#include <libkcal/calendarresources.h> 49#include <libkcal/calendarresources.h>
45#include <libkcal/resourcecalendar.h> 50#include <libkcal/resourcecalendar.h>
46#include <libkcal/icalformat.h> 51#include <libkcal/icalformat.h>
47#include <kresources/resourceselectdialog.h> 52#include <kresources/resourceselectdialog.h>
48#include <libkdepim/kdateedit.h> 53#include <libkdepim/kdateedit.h>
49 54
50#include "koprefs.h" 55#include "koprefs.h"
51#include "kolocationbox.h" 56#include "kolocationbox.h"
52 57
53#include "kotodoeditor.h" 58#include "kotodoeditor.h"
54extern int globalFlagBlockAgenda; 59extern int globalFlagBlockAgenda;
55 60
56KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : 61KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) :
57 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) 62 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent )
58{ 63{
59 mTodo = 0; 64 mTodo = 0;
60 mRelatedTodo = 0; 65 mRelatedTodo = 0;
61 findButton(User1)->hide(); 66 findButton(User1)->hide();
62 init(); 67 init();
63 if ( QApplication::desktop()->height() <= 240 ) 68 if ( QApplication::desktop()->height() <= 240 )
64 hideButtons(); 69 hideButtons();
65} 70}
66 71
67KOTodoEditor::~KOTodoEditor() 72KOTodoEditor::~KOTodoEditor()
68{ 73{
69 emit dialogClose( mTodo ); 74 emit dialogClose( mTodo );
70} 75}
71 76
72void KOTodoEditor::init() 77void KOTodoEditor::init()
73{ 78{
74 setupGeneral(); 79 setupGeneral();
75 setupAttendeesTab(); 80 setupAttendeesTab();
76 setupRecurrence(); 81 setupRecurrence();
77 connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); 82 connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence()));
78 mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); 83 mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") );
79 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), 84 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
80 mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); 85 mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime)));
81} 86}
82void KOTodoEditor::setupRecurrence() 87void KOTodoEditor::setupRecurrence()
83{ 88{
84 QFrame *topFrame = addPage( i18n("Recurrence") ); 89 Q3Frame *topFrame = addPage( i18n("Recurrence") );
85 QBoxLayout *topLayout = new QVBoxLayout( topFrame ); 90 Q3BoxLayout *topLayout = new Q3VBoxLayout( topFrame );
86 91
87 mRecurrence = new KOEditorRecurrence( topFrame ); 92 mRecurrence = new KOEditorRecurrence( topFrame );
88 topLayout->addWidget( mRecurrence ); 93 topLayout->addWidget( mRecurrence );
89} 94}
90 95
91void KOTodoEditor::setCategories( QString s ) 96void KOTodoEditor::setCategories( QString s )
92{ 97{
93 mGeneral->setCategories(s); 98 mGeneral->setCategories(s);
94} 99}
95void KOTodoEditor::setSecrecy( int sec ) 100void KOTodoEditor::setSecrecy( int sec )
96{ 101{
97 mGeneral->setSecrecy( sec ); 102 mGeneral->setSecrecy( sec );
98} 103}
99void KOTodoEditor::reload() 104void KOTodoEditor::reload()
100{ 105{
101 if ( mTodo ) readTodo( mTodo ); 106 if ( mTodo ) readTodo( mTodo );
102} 107}
103 108
104void KOTodoEditor::setupGeneral() 109void KOTodoEditor::setupGeneral()
105{ 110{
106 mGeneral = new KOEditorGeneralTodo(this); 111 mGeneral = new KOEditorGeneralTodo(this);
107 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); 112 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
108 113
109 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); 114 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
110 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), 115 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)),
111 // mGeneral,SLOT(setCategories(const QString &))); 116 // mGeneral,SLOT(setCategories(const QString &)));
112 117
113 if (KOPrefs::instance()->mCompactDialogs) { 118 if (KOPrefs::instance()->mCompactDialogs) {
114 QFrame *topFrame = addPage(i18n("General")); 119 Q3Frame *topFrame = addPage(i18n("General"));
115 120
116 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 121 Q3BoxLayout *topLayout = new Q3VBoxLayout(topFrame);
117 if ( QApplication::desktop()->width() < 480 ) { 122 if ( QApplication::desktop()->width() < 480 ) {
118 topLayout->setMargin(marginHintSmall()); 123 topLayout->setMargin(marginHintSmall());
119 topLayout->setSpacing(spacingHintSmall()); 124 topLayout->setSpacing(spacingHintSmall());
120 } else { 125 } else {
121 topLayout->setMargin(marginHint()); 126 topLayout->setMargin(marginHint());
122 topLayout->setSpacing(spacingHint()); 127 topLayout->setSpacing(spacingHint());
123 } 128 }
124 topLayout->addStretch( 1 ); 129 topLayout->addStretch( 1 );
125 mGeneral->initHeader(topFrame,topLayout); 130 mGeneral->initHeader(topFrame,topLayout);
126 topLayout->addStretch( 1 ); 131 topLayout->addStretch( 1 );
127 mGeneral->initTime(topFrame,topLayout); 132 mGeneral->initTime(topFrame,topLayout);
128 topLayout->addStretch( 1 ); 133 topLayout->addStretch( 1 );
129 mGeneral->initAlarm(topFrame,topLayout); 134 mGeneral->initAlarm(topFrame,topLayout);
130 topLayout->addStretch( 1 ); 135 topLayout->addStretch( 1 );
131 mGeneral->enableAlarm( false ); 136 mGeneral->enableAlarm( false );
132 137
133 138
134 QBoxLayout *priorityLayout; 139 Q3BoxLayout *priorityLayout;
135 if ( QApplication::desktop()->width() < 500 ) 140 if ( QApplication::desktop()->width() < 500 )
136 priorityLayout = new QVBoxLayout( topLayout ); 141 priorityLayout = new Q3VBoxLayout( topLayout );
137 else 142 else
138 priorityLayout = new QHBoxLayout( topLayout ); 143 priorityLayout = new Q3HBoxLayout( topLayout );
139 QWidget* prioWidget = new QWidget (topFrame); 144 QWidget* prioWidget = new QWidget (topFrame);
140 priorityLayout->addWidget( prioWidget ); 145 priorityLayout->addWidget( prioWidget );
141 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); 146 Q3HBoxLayout* priorityLayout2 = new Q3HBoxLayout( prioWidget);
142 147
143 148
144 QIconSet icon; 149 QIcon icon;
145 if ( QApplication::desktop()->width() < 321 ) 150 if ( QApplication::desktop()->width() < 321 )
146 icon = SmallIcon("fileimport16"); 151 icon = SmallIcon("fileimport16");
147 else 152 else
148 icon = SmallIcon("fileimport"); 153 icon = SmallIcon("fileimport");
149 QPushButton * loadTemplate = new QPushButton( prioWidget); 154 QPushButton * loadTemplate = new QPushButton( prioWidget);
150 loadTemplate->setIconSet (icon ) ; 155 loadTemplate->setIconSet (icon ) ;
151 int size = loadTemplate->sizeHint().height(); 156 int size = loadTemplate->sizeHint().height();
152 loadTemplate->setFixedSize( size, size ); 157 loadTemplate->setFixedSize( size, size );
153 if ( QApplication::desktop()->width() < 321 ) 158 if ( QApplication::desktop()->width() < 321 )
154 icon = SmallIcon("fileexport16"); 159 icon = SmallIcon("fileexport16");
155 else 160 else
156 icon = SmallIcon("fileexport"); 161 icon = SmallIcon("fileexport");
157 QPushButton * saveTemplate = new QPushButton( prioWidget); 162 QPushButton * saveTemplate = new QPushButton( prioWidget);
158 saveTemplate->setIconSet (icon ) ; 163 saveTemplate->setIconSet (icon ) ;
159 saveTemplate->setFixedSize( size, size ); 164 saveTemplate->setFixedSize( size, size );
160 165
161 priorityLayout2->addWidget(loadTemplate); 166 priorityLayout2->addWidget(loadTemplate);
162 priorityLayout2->addWidget(saveTemplate); 167 priorityLayout2->addWidget(saveTemplate);
163 mGeneral->initPriority(prioWidget,priorityLayout2); 168 mGeneral->initPriority(prioWidget,priorityLayout2);
164 mGeneral->initCategories( topFrame, priorityLayout ); 169 mGeneral->initCategories( topFrame, priorityLayout );
165 topLayout->addStretch(1); 170 topLayout->addStretch(1);
166 171
167 QFrame *topFrame2 = addPage(i18n("Details")); 172 Q3Frame *topFrame2 = addPage(i18n("Details"));
168 173
169 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); 174 Q3BoxLayout *topLayout2 = new Q3VBoxLayout(topFrame2);
170 topLayout2->setMargin(marginHint()); 175 topLayout2->setMargin(marginHint());
171 topLayout2->setSpacing(spacingHint()); 176 topLayout2->setSpacing(spacingHint());
172 177
173 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); 178 Q3HBoxLayout *completionLayout = new Q3HBoxLayout( topLayout2 );
174 mGeneral->initCompletion(topFrame2,completionLayout); 179 mGeneral->initCompletion(topFrame2,completionLayout);
175 180
176 181
177 mGeneral->initSecrecy( topFrame2, topLayout2 ); 182 mGeneral->initSecrecy( topFrame2, topLayout2 );
178 mGeneral->initDescription(topFrame2,topLayout2); 183 mGeneral->initDescription(topFrame2,topLayout2);
179 184
180 // QHBox * hb = new QHBox ( topFrame2 ); 185 // QHBox * hb = new QHBox ( topFrame2 );
181 // topLayout2->addWidget(hb); 186 // topLayout2->addWidget(hb);
182 // hb->setSpacing( 3 ); 187 // hb->setSpacing( 3 );
183 188
184 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 189 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
185 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 190 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
186 191
187 } else { 192 } else {
188 QFrame *topFrame = addPage(i18n("General")); 193 Q3Frame *topFrame = addPage(i18n("General"));
189 194
190 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 195 Q3BoxLayout *topLayout = new Q3VBoxLayout(topFrame);
191 topLayout->setSpacing(spacingHint()); 196 topLayout->setSpacing(spacingHint());
192 197
193 mGeneral->initHeader(topFrame,topLayout); 198 mGeneral->initHeader(topFrame,topLayout);
194 mGeneral->initTime(topFrame,topLayout); 199 mGeneral->initTime(topFrame,topLayout);
195 mGeneral->initStatus(topFrame,topLayout); 200 mGeneral->initStatus(topFrame,topLayout);
196 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 201 Q3BoxLayout *alarmLineLayout = new Q3HBoxLayout(topLayout);
197 mGeneral->initAlarm(topFrame,alarmLineLayout); 202 mGeneral->initAlarm(topFrame,alarmLineLayout);
198 mGeneral->initDescription(topFrame,topLayout); 203 mGeneral->initDescription(topFrame,topLayout);
199 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); 204 Q3BoxLayout *detailsLayout = new Q3HBoxLayout(topLayout);
200 mGeneral->initCategories( topFrame, detailsLayout ); 205 mGeneral->initCategories( topFrame, detailsLayout );
201 mGeneral->initSecrecy( topFrame, detailsLayout ); 206 mGeneral->initSecrecy( topFrame, detailsLayout );
202 } 207 }
203 mGeneral->finishSetup(); 208 mGeneral->finishSetup();
204 209
205} 210}
206 211
207void KOTodoEditor::editTodo(Todo *todo, bool editDescription) 212void KOTodoEditor::editTodo(Todo *todo, bool editDescription)
208{ 213{
209 //init(); 214 //init();
210 215
211 mTodo = todo; 216 mTodo = todo;
212 readTodo(mTodo); 217 readTodo(mTodo);
213 if ( editDescription ) { 218 if ( editDescription ) {
214 showPage( 1 ); 219 showPage( 1 );
215 mGeneral->setFocusOn( 1 ); 220 mGeneral->setFocusOn( 1 );
216 } else { 221 } else {
217 showPage( 0 ); 222 showPage( 0 );
218 mGeneral->setFocusOn( 2 ); 223 mGeneral->setFocusOn( 2 );
219 } 224 }
220 checkRecurrence(); 225 checkRecurrence();
221} 226}
222 227
223void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) 228void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay)
224{ 229{
225 //init(); 230 //init();
226 231
227 mTodo = 0; 232 mTodo = 0;
228 setDefaults(due,relatedTodo,allDay); 233 setDefaults(due,relatedTodo,allDay);
229} 234}
230 235
231void KOTodoEditor::loadDefaults() 236void KOTodoEditor::loadDefaults()
232{ 237{
233 setDefaults(QDateTime::currentDateTime().addDays(7),0,false); 238 setDefaults(QDateTime::currentDateTime().addDays(7),0,false);
234} 239}
235 240
236bool KOTodoEditor::processInput( bool emitTime ) 241bool KOTodoEditor::processInput( bool emitTime )
237{ 242{
238 if (!validateInput()) return false; 243 if (!validateInput()) return false;
239 244
240 Todo *todo = 0; 245 Todo *todo = 0;
241 246
242 if (mTodo) todo = mTodo; 247 if (mTodo) todo = mTodo;
243 else { 248 else {
244 todo = new Todo; 249 todo = new Todo;
245 todo->setOrganizer(KOPrefs::instance()->email()); 250 todo->setOrganizer(KOPrefs::instance()->email());
246 } 251 }
247 252
248 writeTodo(todo); 253 writeTodo(todo);
249 if ( emitTime ) { 254 if ( emitTime ) {
250 globalFlagBlockAgenda = 1; 255 globalFlagBlockAgenda = 1;
251 emit showAgendaView( false ); 256 emit showAgendaView( false );
252 if ( todo->hasDueDate() ) 257 if ( todo->hasDueDate() )
253 emit jumpToTime( todo->dtDue().date() ); 258 emit jumpToTime( todo->dtDue().date() );
254 globalFlagBlockAgenda = 2; 259 globalFlagBlockAgenda = 2;
255 } 260 }
256 if (mTodo) { 261 if (mTodo) {
257 todo->setRevision(todo->revision()+1); 262 todo->setRevision(todo->revision()+1);
258 emit todoChanged(todo); 263 emit todoChanged(todo);
259 } else { 264 } else {
260 mCalendar->addTodo(todo); 265 mCalendar->addTodo(todo);
261 mTodo = todo; 266 mTodo = todo;
262 emit todoAdded(todo); 267 emit todoAdded(todo);
263 if ( todo->isAlarmEnabled () && !todo->alarmEnabled () ) { 268 if ( todo->isAlarmEnabled () && !todo->alarmEnabled () ) {
264 QTimer::singleShot( 0, this, SLOT ( alarmWarning() ) ); 269 QTimer::singleShot( 0, this, SLOT ( alarmWarning() ) );
265 } 270 }
266 } 271 }
267 272
268 return true; 273 return true;
269} 274}
270 275
271void KOTodoEditor::deleteTodo() 276void KOTodoEditor::deleteTodo()
272{ 277{
273 if (mTodo) { 278 if (mTodo) {
274 if (KOPrefs::instance()->mConfirm) { 279 if (KOPrefs::instance()->mConfirm) {
275 switch (msgItemDelete()) { 280 switch (msgItemDelete()) {
276 case KMessageBox::Continue: // OK 281 case KMessageBox::Continue: // OK
277 emit todoToBeDeleted(mTodo); 282 emit todoToBeDeleted(mTodo);
278 emit dialogClose(mTodo); 283 emit dialogClose(mTodo);
279 mCalendar->deleteTodo(mTodo); 284 mCalendar->deleteTodo(mTodo);
280 emit todoDeleted(); 285 emit todoDeleted();
281 reject(); 286 reject();
282 break; 287 break;
283 } 288 }
284 } 289 }
285 else { 290 else {
286 emit todoToBeDeleted(mTodo); 291 emit todoToBeDeleted(mTodo);
287 emit dialogClose(mTodo); 292 emit dialogClose(mTodo);
288 mCalendar->deleteTodo(mTodo); 293 mCalendar->deleteTodo(mTodo);
289 emit todoDeleted(); 294 emit todoDeleted();
290 reject(); 295 reject();
291 } 296 }
292 } else { 297 } else {
293 reject(); 298 reject();
294 } 299 }
295} 300}
@@ -334,125 +339,125 @@ void KOTodoEditor::checkRecurrence()
334 } else { 339 } else {
335 to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; 340 to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ;
336 from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; 341 from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ;
337 } 342 }
338 if ( to < from ) 343 if ( to < from )
339 to = from; 344 to = from;
340 mRecurrence->setDefaults(from,to); 345 mRecurrence->setDefaults(from,to);
341 } 346 }
342 } else { 347 } else {
343 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); 348 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false );
344 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); 349 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ));
345 } 350 }
346} 351}
347void KOTodoEditor::readTodo(Todo *todo) 352void KOTodoEditor::readTodo(Todo *todo)
348{ 353{
349 mGeneral->readTodo(todo); 354 mGeneral->readTodo(todo);
350 mDetails->readEvent(todo); 355 mDetails->readEvent(todo);
351 mRelatedTodo = 0;//todo->relatedTo(); 356 mRelatedTodo = 0;//todo->relatedTo();
352 // categories 357 // categories
353 // mCategoryDialog->setSelected(todo->categories()); 358 // mCategoryDialog->setSelected(todo->categories());
354 359
355 // We should handle read-only events here. 360 // We should handle read-only events here.
356} 361}
357 362
358void KOTodoEditor::writeTodo(Todo *event) 363void KOTodoEditor::writeTodo(Todo *event)
359{ 364{
360 bool maybeComputeRecurrenceTime = false; 365 bool maybeComputeRecurrenceTime = false;
361 if( event->hasRecurrenceID() && event->percentComplete() < 100) 366 if( event->hasRecurrenceID() && event->percentComplete() < 100)
362 maybeComputeRecurrenceTime = true; 367 maybeComputeRecurrenceTime = true;
363 event->setHasRecurrenceID( false ); 368 event->setHasRecurrenceID( false );
364 mGeneral->writeTodo(event); 369 mGeneral->writeTodo(event);
365 mDetails->writeEvent(event); 370 mDetails->writeEvent(event);
366 371
367 // set related event, i.e. parent to-do in this case. 372 // set related event, i.e. parent to-do in this case.
368 if (mRelatedTodo) { 373 if (mRelatedTodo) {
369 event->setRelatedTo(mRelatedTodo); 374 event->setRelatedTo(mRelatedTodo);
370 } 375 }
371 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { 376 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
372 mRecurrence->writeEvent(event); 377 mRecurrence->writeEvent(event);
373 if ( event->doesRecur() ) { 378 if ( event->doesRecur() ) {
374 int addSec = -1 ; 379 int addSec = -1 ;
375 if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 ) 380 if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 )
376 addSec = 1; 381 addSec = 1;
377 event->setRecurrenceID( event->dtStart().addSecs( addSec ) ); 382 event->setRecurrenceID( event->dtStart().addSecs( addSec ) );
378 event->setRecurDates(); 383 event->setRecurDates();
379 } else { 384 } else {
380 event->setHasRecurrenceID( false ); 385 event->setHasRecurrenceID( false );
381 } 386 }
382 } else { 387 } else {
383 event->setHasRecurrenceID( false ); 388 event->setHasRecurrenceID( false );
384 if ( event->doesRecur() ) 389 if ( event->doesRecur() )
385 event->recurrence()->unsetRecurs(); 390 event->recurrence()->unsetRecurs();
386 } 391 }
387} 392}
388 393
389bool KOTodoEditor::validateInput() 394bool KOTodoEditor::validateInput()
390{ 395{
391 if (!mGeneral->validateInput()) return false; 396 if (!mGeneral->validateInput()) return false;
392 if (!mDetails->validateInput()) return false; 397 if (!mDetails->validateInput()) return false;
393 return true; 398 return true;
394} 399}
395 400
396int KOTodoEditor::msgItemDelete() 401int KOTodoEditor::msgItemDelete()
397{ 402{
398 return KMessageBox::warningContinueCancel(this, 403 return KMessageBox::warningContinueCancel(this,
399 i18n("This item will be permanently deleted."), 404 i18n("This item will be permanently deleted."),
400 i18n("KOrganizer Confirmation"),i18n("Delete")); 405 i18n("KOrganizer Confirmation"),i18n("Delete"));
401} 406}
402 407
403void KOTodoEditor::modified (int modification) 408void KOTodoEditor::modified (int modification)
404{ 409{
405 if (modification == KOGlobals::CATEGORY_MODIFIED || 410 if (modification == KOGlobals::CATEGORY_MODIFIED ||
406 KOGlobals::UNKNOWN_MODIFIED == modification ) 411 KOGlobals::UNKNOWN_MODIFIED == modification )
407 // mCategoryDialog->setSelected (mTodo->categories ()); 412 // mCategoryDialog->setSelected (mTodo->categories ());
408 mGeneral->modified (mTodo, modification); 413 mGeneral->modified (mTodo, modification);
409 414
410} 415}
411 416
412void KOTodoEditor::slotLoadTemplate() 417void KOTodoEditor::slotLoadTemplate()
413{ 418{
414 419
415 QString fileName =locateLocal( "templates", "todos" ); 420 QString fileName =locateLocal( "templates", "todos" );
416 QDir t_dir; 421 QDir t_dir;
417 if ( !t_dir.exists(fileName) ) 422 if ( !t_dir.exists(fileName) )
418 t_dir.mkdir ( fileName ); 423 t_dir.mkdir ( fileName );
419 fileName += "/todo"; 424 fileName += "/todo";
420 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); 425 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this );
421 if ( fileName.length() == 0 ) 426 if ( fileName.length() == 0 )
422 return; 427 return;
423 CalendarLocal cal; 428 CalendarLocal cal;
424 ICalFormat format; 429 ICalFormat format;
425 if ( !format.load( &cal, fileName ) ) { 430 if ( !format.load( &cal, fileName ) ) {
426 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 431 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
427 .arg( fileName ) ); 432 .arg( fileName ) );
428 return ; 433 return ;
429 } 434 }
430 QPtrList<Todo> todos = cal.todos(); 435 Q3PtrList<Todo> todos = cal.todos();
431 Todo * todo = todos.first(); 436 Todo * todo = todos.first();
432 if ( !todo ) { 437 if ( !todo ) {
433 KMessageBox::error( this, 438 KMessageBox::error( this,
434 i18n("Template does not\ncontain a valid Todo.")); 439 i18n("Template does not\ncontain a valid Todo."));
435 } else { 440 } else {
436 readTodo( todo ); 441 readTodo( todo );
437 } 442 }
438 443
439} 444}
440 445
441void KOTodoEditor::slotSaveTemplate() 446void KOTodoEditor::slotSaveTemplate()
442{ 447{
443 QString fileName =locateLocal( "templates", "todos" ); 448 QString fileName =locateLocal( "templates", "todos" );
444 QDir t_dir; 449 QDir t_dir;
445 if ( !t_dir.exists(fileName) ) 450 if ( !t_dir.exists(fileName) )
446 t_dir.mkdir ( fileName ); 451 t_dir.mkdir ( fileName );
447 fileName += "/todo"; 452 fileName += "/todo";
448 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); 453 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this );
449 if ( fileName.length() > 0 ) 454 if ( fileName.length() > 0 )
450 saveTemplate( fileName ); 455 saveTemplate( fileName );
451} 456}
452 457
453void KOTodoEditor::saveTemplate( const QString &templateName ) 458void KOTodoEditor::saveTemplate( const QString &templateName )
454{ 459{
455 Todo *todo = new Todo; 460 Todo *todo = new Todo;
456 writeTodo( todo ); 461 writeTodo( todo );
457 saveAsTemplate( todo, templateName ); 462 saveAsTemplate( todo, templateName );
458} 463}