-rw-r--r-- | korganizer/kotodoeditor.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 9073bca..8b90ae5 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -1,173 +1,175 @@ | |||
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 <qframe.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qhbox.h> | 29 | #include <qhbox.h> |
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | #include <qtabwidget.h> | 33 | #include <qtabwidget.h> |
34 | 34 | ||
35 | #include <kiconloader.h> | 35 | #include <kiconloader.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kfiledialog.h> | 37 | #include <kfiledialog.h> |
38 | #include <kstandarddirs.h> | 38 | #include <kstandarddirs.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | 40 | ||
41 | #include <libkdepim/categoryselectdialog.h> | 41 | #include <libkdepim/categoryselectdialog.h> |
42 | #include <libkcal/calendarlocal.h> | 42 | #include <libkcal/calendarlocal.h> |
43 | #include <libkcal/calendarresources.h> | 43 | #include <libkcal/calendarresources.h> |
44 | #include <libkcal/resourcecalendar.h> | 44 | #include <libkcal/resourcecalendar.h> |
45 | #include <libkcal/icalformat.h> | 45 | #include <libkcal/icalformat.h> |
46 | #include <kresources/resourceselectdialog.h> | 46 | #include <kresources/resourceselectdialog.h> |
47 | #include <libkdepim/kdateedit.h> | 47 | #include <libkdepim/kdateedit.h> |
48 | 48 | ||
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #include "kolocationbox.h" | 50 | #include "kolocationbox.h" |
51 | 51 | ||
52 | #include "kotodoeditor.h" | 52 | #include "kotodoeditor.h" |
53 | extern int globalFlagBlockAgenda; | 53 | extern int globalFlagBlockAgenda; |
54 | 54 | ||
55 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : | 55 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : |
56 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) | 56 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) |
57 | { | 57 | { |
58 | mTodo = 0; | 58 | mTodo = 0; |
59 | mRelatedTodo = 0; | 59 | mRelatedTodo = 0; |
60 | findButton(User1)->hide(); | 60 | findButton(User1)->hide(); |
61 | init(); | 61 | init(); |
62 | if ( QApplication::desktop()->height() <= 240 ) | 62 | if ( QApplication::desktop()->height() <= 240 ) |
63 | hideButtons(); | 63 | hideButtons(); |
64 | } | 64 | } |
65 | 65 | ||
66 | KOTodoEditor::~KOTodoEditor() | 66 | KOTodoEditor::~KOTodoEditor() |
67 | { | 67 | { |
68 | emit dialogClose( mTodo ); | 68 | emit dialogClose( mTodo ); |
69 | } | 69 | } |
70 | 70 | ||
71 | void KOTodoEditor::init() | 71 | void KOTodoEditor::init() |
72 | { | 72 | { |
73 | setupGeneral(); | 73 | setupGeneral(); |
74 | setupAttendeesTab(); | 74 | setupAttendeesTab(); |
75 | setupRecurrence(); | 75 | setupRecurrence(); |
76 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); | 76 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); |
77 | mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); | 77 | mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); |
78 | connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), | ||
79 | mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); | ||
78 | } | 80 | } |
79 | void KOTodoEditor::setupRecurrence() | 81 | void KOTodoEditor::setupRecurrence() |
80 | { | 82 | { |
81 | QFrame *topFrame = addPage( i18n("Recurrence") ); | 83 | QFrame *topFrame = addPage( i18n("Recurrence") ); |
82 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | 84 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); |
83 | 85 | ||
84 | mRecurrence = new KOEditorRecurrence( topFrame ); | 86 | mRecurrence = new KOEditorRecurrence( topFrame ); |
85 | topLayout->addWidget( mRecurrence ); | 87 | topLayout->addWidget( mRecurrence ); |
86 | } | 88 | } |
87 | 89 | ||
88 | void KOTodoEditor::setCategories( QString s ) | 90 | void KOTodoEditor::setCategories( QString s ) |
89 | { | 91 | { |
90 | mGeneral->setCategories(s); | 92 | mGeneral->setCategories(s); |
91 | } | 93 | } |
92 | void KOTodoEditor::setSecrecy( int sec ) | 94 | void KOTodoEditor::setSecrecy( int sec ) |
93 | { | 95 | { |
94 | mGeneral->setSecrecy( sec ); | 96 | mGeneral->setSecrecy( sec ); |
95 | } | 97 | } |
96 | void KOTodoEditor::reload() | 98 | void KOTodoEditor::reload() |
97 | { | 99 | { |
98 | if ( mTodo ) readTodo( mTodo ); | 100 | if ( mTodo ) readTodo( mTodo ); |
99 | } | 101 | } |
100 | 102 | ||
101 | void KOTodoEditor::setupGeneral() | 103 | void KOTodoEditor::setupGeneral() |
102 | { | 104 | { |
103 | mGeneral = new KOEditorGeneralTodo(this); | 105 | mGeneral = new KOEditorGeneralTodo(this); |
104 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 106 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
105 | 107 | ||
106 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 108 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
107 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), | 109 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), |
108 | // mGeneral,SLOT(setCategories(const QString &))); | 110 | // mGeneral,SLOT(setCategories(const QString &))); |
109 | 111 | ||
110 | if (KOPrefs::instance()->mCompactDialogs) { | 112 | if (KOPrefs::instance()->mCompactDialogs) { |
111 | QFrame *topFrame = addPage(i18n("General")); | 113 | QFrame *topFrame = addPage(i18n("General")); |
112 | 114 | ||
113 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 115 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
114 | if ( QApplication::desktop()->width() < 480 ) { | 116 | if ( QApplication::desktop()->width() < 480 ) { |
115 | topLayout->setMargin(marginHintSmall()); | 117 | topLayout->setMargin(marginHintSmall()); |
116 | topLayout->setSpacing(spacingHintSmall()); | 118 | topLayout->setSpacing(spacingHintSmall()); |
117 | } else { | 119 | } else { |
118 | topLayout->setMargin(marginHint()); | 120 | topLayout->setMargin(marginHint()); |
119 | topLayout->setSpacing(spacingHint()); | 121 | topLayout->setSpacing(spacingHint()); |
120 | } | 122 | } |
121 | mGeneral->initHeader(topFrame,topLayout); | 123 | mGeneral->initHeader(topFrame,topLayout); |
122 | mGeneral->initTime(topFrame,topLayout); | 124 | mGeneral->initTime(topFrame,topLayout); |
123 | mGeneral->initAlarm(topFrame,topLayout); | 125 | mGeneral->initAlarm(topFrame,topLayout); |
124 | mGeneral->enableAlarm( false ); | 126 | mGeneral->enableAlarm( false ); |
125 | 127 | ||
126 | 128 | ||
127 | QBoxLayout *priorityLayout; | 129 | QBoxLayout *priorityLayout; |
128 | if ( QApplication::desktop()->width() < 500 ) | 130 | if ( QApplication::desktop()->width() < 500 ) |
129 | priorityLayout = new QVBoxLayout( topLayout ); | 131 | priorityLayout = new QVBoxLayout( topLayout ); |
130 | else | 132 | else |
131 | priorityLayout = new QHBoxLayout( topLayout ); | 133 | priorityLayout = new QHBoxLayout( topLayout ); |
132 | QWidget* prioWidget = new QWidget (topFrame); | 134 | QWidget* prioWidget = new QWidget (topFrame); |
133 | priorityLayout->addWidget( prioWidget ); | 135 | priorityLayout->addWidget( prioWidget ); |
134 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); | 136 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); |
135 | 137 | ||
136 | 138 | ||
137 | QIconSet icon; | 139 | QIconSet icon; |
138 | if ( QApplication::desktop()->width() < 321 ) | 140 | if ( QApplication::desktop()->width() < 321 ) |
139 | icon = SmallIcon("fileimport16"); | 141 | icon = SmallIcon("fileimport16"); |
140 | else | 142 | else |
141 | icon = SmallIcon("fileimport"); | 143 | icon = SmallIcon("fileimport"); |
142 | QPushButton * loadTemplate = new QPushButton( prioWidget); | 144 | QPushButton * loadTemplate = new QPushButton( prioWidget); |
143 | loadTemplate->setIconSet (icon ) ; | 145 | loadTemplate->setIconSet (icon ) ; |
144 | int size = loadTemplate->sizeHint().height(); | 146 | int size = loadTemplate->sizeHint().height(); |
145 | loadTemplate->setFixedSize( size, size ); | 147 | loadTemplate->setFixedSize( size, size ); |
146 | if ( QApplication::desktop()->width() < 321 ) | 148 | if ( QApplication::desktop()->width() < 321 ) |
147 | icon = SmallIcon("fileexport16"); | 149 | icon = SmallIcon("fileexport16"); |
148 | else | 150 | else |
149 | icon = SmallIcon("fileexport"); | 151 | icon = SmallIcon("fileexport"); |
150 | QPushButton * saveTemplate = new QPushButton( prioWidget); | 152 | QPushButton * saveTemplate = new QPushButton( prioWidget); |
151 | saveTemplate->setIconSet (icon ) ; | 153 | saveTemplate->setIconSet (icon ) ; |
152 | saveTemplate->setFixedSize( size, size ); | 154 | saveTemplate->setFixedSize( size, size ); |
153 | 155 | ||
154 | priorityLayout2->addWidget(loadTemplate); | 156 | priorityLayout2->addWidget(loadTemplate); |
155 | priorityLayout2->addWidget(saveTemplate); | 157 | priorityLayout2->addWidget(saveTemplate); |
156 | mGeneral->initPriority(prioWidget,priorityLayout2); | 158 | mGeneral->initPriority(prioWidget,priorityLayout2); |
157 | mGeneral->initCategories( topFrame, priorityLayout ); | 159 | mGeneral->initCategories( topFrame, priorityLayout ); |
158 | topLayout->addStretch(1); | 160 | topLayout->addStretch(1); |
159 | 161 | ||
160 | QFrame *topFrame2 = addPage(i18n("Details")); | 162 | QFrame *topFrame2 = addPage(i18n("Details")); |
161 | 163 | ||
162 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 164 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); |
163 | topLayout2->setMargin(marginHint()); | 165 | topLayout2->setMargin(marginHint()); |
164 | topLayout2->setSpacing(spacingHint()); | 166 | topLayout2->setSpacing(spacingHint()); |
165 | 167 | ||
166 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); | 168 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); |
167 | mGeneral->initCompletion(topFrame2,completionLayout); | 169 | mGeneral->initCompletion(topFrame2,completionLayout); |
168 | 170 | ||
169 | 171 | ||
170 | mGeneral->initSecrecy( topFrame2, topLayout2 ); | 172 | mGeneral->initSecrecy( topFrame2, topLayout2 ); |
171 | mGeneral->initDescription(topFrame2,topLayout2); | 173 | mGeneral->initDescription(topFrame2,topLayout2); |
172 | 174 | ||
173 | // QHBox * hb = new QHBox ( topFrame2 ); | 175 | // QHBox * hb = new QHBox ( topFrame2 ); |
@@ -212,218 +214,218 @@ void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | |||
212 | } | 214 | } |
213 | checkRecurrence(); | 215 | checkRecurrence(); |
214 | } | 216 | } |
215 | 217 | ||
216 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) | 218 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) |
217 | { | 219 | { |
218 | //init(); | 220 | //init(); |
219 | 221 | ||
220 | mTodo = 0; | 222 | mTodo = 0; |
221 | setDefaults(due,relatedTodo,allDay); | 223 | setDefaults(due,relatedTodo,allDay); |
222 | } | 224 | } |
223 | 225 | ||
224 | void KOTodoEditor::loadDefaults() | 226 | void KOTodoEditor::loadDefaults() |
225 | { | 227 | { |
226 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); | 228 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); |
227 | } | 229 | } |
228 | 230 | ||
229 | bool KOTodoEditor::processInput( bool emitTime ) | 231 | bool KOTodoEditor::processInput( bool emitTime ) |
230 | { | 232 | { |
231 | if (!validateInput()) return false; | 233 | if (!validateInput()) return false; |
232 | 234 | ||
233 | Todo *todo = 0; | 235 | Todo *todo = 0; |
234 | 236 | ||
235 | if (mTodo) todo = mTodo; | 237 | if (mTodo) todo = mTodo; |
236 | else { | 238 | else { |
237 | todo = new Todo; | 239 | todo = new Todo; |
238 | todo->setOrganizer(KOPrefs::instance()->email()); | 240 | todo->setOrganizer(KOPrefs::instance()->email()); |
239 | } | 241 | } |
240 | 242 | ||
241 | writeTodo(todo); | 243 | writeTodo(todo); |
242 | if ( emitTime ) { | 244 | if ( emitTime ) { |
243 | globalFlagBlockAgenda = 1; | 245 | globalFlagBlockAgenda = 1; |
244 | emit showAgendaView( false ); | 246 | emit showAgendaView( false ); |
245 | if ( todo->hasDueDate() ) | 247 | if ( todo->hasDueDate() ) |
246 | emit jumpToTime( todo->dtDue().date() ); | 248 | emit jumpToTime( todo->dtDue().date() ); |
247 | globalFlagBlockAgenda = 2; | 249 | globalFlagBlockAgenda = 2; |
248 | } | 250 | } |
249 | if (mTodo) { | 251 | if (mTodo) { |
250 | todo->setRevision(todo->revision()+1); | 252 | todo->setRevision(todo->revision()+1); |
251 | emit todoChanged(todo); | 253 | emit todoChanged(todo); |
252 | } else { | 254 | } else { |
253 | mCalendar->addTodo(todo); | 255 | mCalendar->addTodo(todo); |
254 | mTodo = todo; | 256 | mTodo = todo; |
255 | emit todoAdded(todo); | 257 | emit todoAdded(todo); |
256 | } | 258 | } |
257 | 259 | ||
258 | return true; | 260 | return true; |
259 | } | 261 | } |
260 | 262 | ||
261 | void KOTodoEditor::deleteTodo() | 263 | void KOTodoEditor::deleteTodo() |
262 | { | 264 | { |
263 | if (mTodo) { | 265 | if (mTodo) { |
264 | if (KOPrefs::instance()->mConfirm) { | 266 | if (KOPrefs::instance()->mConfirm) { |
265 | switch (msgItemDelete()) { | 267 | switch (msgItemDelete()) { |
266 | case KMessageBox::Continue: // OK | 268 | case KMessageBox::Continue: // OK |
267 | emit todoToBeDeleted(mTodo); | 269 | emit todoToBeDeleted(mTodo); |
268 | emit dialogClose(mTodo); | 270 | emit dialogClose(mTodo); |
269 | mCalendar->deleteTodo(mTodo); | 271 | mCalendar->deleteTodo(mTodo); |
270 | emit todoDeleted(); | 272 | emit todoDeleted(); |
271 | reject(); | 273 | reject(); |
272 | break; | 274 | break; |
273 | } | 275 | } |
274 | } | 276 | } |
275 | else { | 277 | else { |
276 | emit todoToBeDeleted(mTodo); | 278 | emit todoToBeDeleted(mTodo); |
277 | emit dialogClose(mTodo); | 279 | emit dialogClose(mTodo); |
278 | mCalendar->deleteTodo(mTodo); | 280 | mCalendar->deleteTodo(mTodo); |
279 | emit todoDeleted(); | 281 | emit todoDeleted(); |
280 | reject(); | 282 | reject(); |
281 | } | 283 | } |
282 | } else { | 284 | } else { |
283 | reject(); | 285 | reject(); |
284 | } | 286 | } |
285 | } | 287 | } |
286 | 288 | ||
287 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | 289 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) |
288 | { | 290 | { |
289 | mRelatedTodo = relatedEvent; | 291 | mRelatedTodo = relatedEvent; |
290 | 292 | ||
291 | mGeneral->setDefaults(due,allDay); | 293 | mGeneral->setDefaults(due,allDay); |
292 | mDetails->setDefaults(); | 294 | mDetails->setDefaults(); |
293 | showPage( 0 ); | 295 | showPage( 0 ); |
294 | if ( mRelatedTodo ) { | 296 | if ( mRelatedTodo ) { |
295 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 297 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
296 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | 298 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); |
297 | if ( mRelatedTodo->priority() < 3 ) | 299 | if ( mRelatedTodo->priority() < 3 ) |
298 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); | 300 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); |
299 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); | 301 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); |
300 | int len = mRelatedTodo->summary().length(); | 302 | int len = mRelatedTodo->summary().length(); |
301 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | 303 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); |
302 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | 304 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); |
303 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | 305 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); |
304 | 306 | ||
305 | } else | 307 | } else |
306 | mGeneral->setFocusOn( 2 ); | 308 | mGeneral->setFocusOn( 2 ); |
307 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 309 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
308 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | 310 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); |
309 | } | 311 | } |
310 | void KOTodoEditor::checkRecurrence() | 312 | void KOTodoEditor::checkRecurrence() |
311 | { | 313 | { |
312 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 314 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
313 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); | 315 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); |
314 | 316 | ||
315 | if ( mTodo ) | 317 | if ( mTodo ) |
316 | mRecurrence->readEvent( mTodo ); | 318 | mRecurrence->readEvent( mTodo ); |
317 | else { | 319 | else { |
318 | bool time = mGeneral->mTimeButton->isChecked(); | 320 | bool time = mGeneral->mTimeButton->isChecked(); |
319 | QDateTime from,to; | 321 | QDateTime from,to; |
320 | if ( time ) { | 322 | if ( time ) { |
321 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; | 323 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; |
322 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; | 324 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; |
323 | } else { | 325 | } else { |
324 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; | 326 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; |
325 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; | 327 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; |
326 | } | 328 | } |
327 | if ( to < from ) | 329 | if ( to < from ) |
328 | to = from; | 330 | to = from; |
329 | mRecurrence->setDefaults(from,to,!time); | 331 | mRecurrence->setDefaults(from,to); |
330 | } | 332 | } |
331 | } else { | 333 | } else { |
332 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 334 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
333 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | 335 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); |
334 | } | 336 | } |
335 | } | 337 | } |
336 | void KOTodoEditor::readTodo(Todo *todo) | 338 | void KOTodoEditor::readTodo(Todo *todo) |
337 | { | 339 | { |
338 | mGeneral->readTodo(todo); | 340 | mGeneral->readTodo(todo); |
339 | mDetails->readEvent(todo); | 341 | mDetails->readEvent(todo); |
340 | mRelatedTodo = 0;//todo->relatedTo(); | 342 | mRelatedTodo = 0;//todo->relatedTo(); |
341 | // categories | 343 | // categories |
342 | // mCategoryDialog->setSelected(todo->categories()); | 344 | // mCategoryDialog->setSelected(todo->categories()); |
343 | 345 | ||
344 | // We should handle read-only events here. | 346 | // We should handle read-only events here. |
345 | } | 347 | } |
346 | 348 | ||
347 | void KOTodoEditor::writeTodo(Todo *event) | 349 | void KOTodoEditor::writeTodo(Todo *event) |
348 | { | 350 | { |
349 | bool maybeComputeRecurrenceTime = false; | 351 | bool maybeComputeRecurrenceTime = false; |
350 | if( event->hasRecurrenceID() && event->percentComplete() < 100) | 352 | if( event->hasRecurrenceID() && event->percentComplete() < 100) |
351 | maybeComputeRecurrenceTime = true; | 353 | maybeComputeRecurrenceTime = true; |
352 | event->setHasRecurrenceID( false ); | 354 | event->setHasRecurrenceID( false ); |
353 | mGeneral->writeTodo(event); | 355 | mGeneral->writeTodo(event); |
354 | mDetails->writeEvent(event); | 356 | mDetails->writeEvent(event); |
355 | 357 | ||
356 | // set related event, i.e. parent to-do in this case. | 358 | // set related event, i.e. parent to-do in this case. |
357 | if (mRelatedTodo) { | 359 | if (mRelatedTodo) { |
358 | event->setRelatedTo(mRelatedTodo); | 360 | event->setRelatedTo(mRelatedTodo); |
359 | } | 361 | } |
360 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 362 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
361 | mRecurrence->writeEvent(event); | 363 | mRecurrence->writeEvent(event); |
362 | if ( event->doesRecur() ) { | 364 | if ( event->doesRecur() ) { |
363 | int addSec = -1 ; | 365 | int addSec = -1 ; |
364 | if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 ) | 366 | if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 ) |
365 | addSec = 1; | 367 | addSec = 1; |
366 | event->setRecurrenceID( event->dtStart().addSecs( addSec ) ); | 368 | event->setRecurrenceID( event->dtStart().addSecs( addSec ) ); |
367 | event->setRecurDates(); | 369 | event->setRecurDates(); |
368 | } else { | 370 | } else { |
369 | event->setHasRecurrenceID( false ); | 371 | event->setHasRecurrenceID( false ); |
370 | } | 372 | } |
371 | } else { | 373 | } else { |
372 | event->setHasRecurrenceID( false ); | 374 | event->setHasRecurrenceID( false ); |
373 | event->recurrence()->unsetRecurs(); | 375 | event->recurrence()->unsetRecurs(); |
374 | } | 376 | } |
375 | } | 377 | } |
376 | 378 | ||
377 | bool KOTodoEditor::validateInput() | 379 | bool KOTodoEditor::validateInput() |
378 | { | 380 | { |
379 | if (!mGeneral->validateInput()) return false; | 381 | if (!mGeneral->validateInput()) return false; |
380 | if (!mDetails->validateInput()) return false; | 382 | if (!mDetails->validateInput()) return false; |
381 | return true; | 383 | return true; |
382 | } | 384 | } |
383 | 385 | ||
384 | int KOTodoEditor::msgItemDelete() | 386 | int KOTodoEditor::msgItemDelete() |
385 | { | 387 | { |
386 | return KMessageBox::warningContinueCancel(this, | 388 | return KMessageBox::warningContinueCancel(this, |
387 | i18n("This item will be permanently deleted."), | 389 | i18n("This item will be permanently deleted."), |
388 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 390 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
389 | } | 391 | } |
390 | 392 | ||
391 | void KOTodoEditor::modified (int modification) | 393 | void KOTodoEditor::modified (int modification) |
392 | { | 394 | { |
393 | if (modification == KOGlobals::CATEGORY_MODIFIED || | 395 | if (modification == KOGlobals::CATEGORY_MODIFIED || |
394 | KOGlobals::UNKNOWN_MODIFIED == modification ) | 396 | KOGlobals::UNKNOWN_MODIFIED == modification ) |
395 | // mCategoryDialog->setSelected (mTodo->categories ()); | 397 | // mCategoryDialog->setSelected (mTodo->categories ()); |
396 | mGeneral->modified (mTodo, modification); | 398 | mGeneral->modified (mTodo, modification); |
397 | 399 | ||
398 | } | 400 | } |
399 | 401 | ||
400 | void KOTodoEditor::slotLoadTemplate() | 402 | void KOTodoEditor::slotLoadTemplate() |
401 | { | 403 | { |
402 | 404 | ||
403 | QString fileName =locateLocal( "templates", "todos" ); | 405 | QString fileName =locateLocal( "templates", "todos" ); |
404 | QDir t_dir; | 406 | QDir t_dir; |
405 | if ( !t_dir.exists(fileName) ) | 407 | if ( !t_dir.exists(fileName) ) |
406 | t_dir.mkdir ( fileName ); | 408 | t_dir.mkdir ( fileName ); |
407 | fileName += "/todo"; | 409 | fileName += "/todo"; |
408 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); | 410 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); |
409 | if ( fileName.length() == 0 ) | 411 | if ( fileName.length() == 0 ) |
410 | return; | 412 | return; |
411 | CalendarLocal cal; | 413 | CalendarLocal cal; |
412 | ICalFormat format; | 414 | ICalFormat format; |
413 | if ( !format.load( &cal, fileName ) ) { | 415 | if ( !format.load( &cal, fileName ) ) { |
414 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 416 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
415 | .arg( fileName ) ); | 417 | .arg( fileName ) ); |
416 | return ; | 418 | return ; |
417 | } | 419 | } |
418 | QPtrList<Todo> todos = cal.todos(); | 420 | QPtrList<Todo> todos = cal.todos(); |
419 | Todo * todo = todos.first(); | 421 | Todo * todo = todos.first(); |
420 | if ( !todo ) { | 422 | if ( !todo ) { |
421 | KMessageBox::error( this, | 423 | KMessageBox::error( this, |
422 | i18n("Template does not\ncontain a valid Todo.")); | 424 | i18n("Template does not\ncontain a valid Todo.")); |
423 | } else { | 425 | } else { |
424 | readTodo( todo ); | 426 | readTodo( todo ); |
425 | } | 427 | } |
426 | 428 | ||
427 | } | 429 | } |
428 | 430 | ||
429 | void KOTodoEditor::slotSaveTemplate() | 431 | void KOTodoEditor::slotSaveTemplate() |