author | zautrix <zautrix> | 2005-11-30 08:30:24 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-30 08:30:24 (UTC) |
commit | 042f35a481acf6c4e711e98184abb6c9f6542429 (patch) (unidiff) | |
tree | 47622f89ebfb6c677797d7906f167ba80976ab7d /korganizer/kotodoeditor.cpp | |
parent | 14bd7cc7412ffdbca09e1cd63a230222a3fbfd53 (diff) | |
download | kdepimpi-042f35a481acf6c4e711e98184abb6c9f6542429.zip kdepimpi-042f35a481acf6c4e711e98184abb6c9f6542429.tar.gz kdepimpi-042f35a481acf6c4e711e98184abb6c9f6542429.tar.bz2 |
commit
-rw-r--r-- | korganizer/kotodoeditor.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 682f83b..20a35d2 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -1,77 +1,78 @@ | |||
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 <qtimer.h> | ||
30 | #include <qdir.h> | 31 | #include <qdir.h> |
31 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
32 | #include <qapplication.h> | 33 | #include <qapplication.h> |
33 | #include <qtabwidget.h> | 34 | #include <qtabwidget.h> |
34 | 35 | ||
35 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
36 | #include <klocale.h> | 37 | #include <klocale.h> |
37 | #include <kfiledialog.h> | 38 | #include <kfiledialog.h> |
38 | #include <kstandarddirs.h> | 39 | #include <kstandarddirs.h> |
39 | #include <kmessagebox.h> | 40 | #include <kmessagebox.h> |
40 | 41 | ||
41 | #include <libkdepim/categoryselectdialog.h> | 42 | #include <libkdepim/categoryselectdialog.h> |
42 | #include <libkcal/calendarlocal.h> | 43 | #include <libkcal/calendarlocal.h> |
43 | #include <libkcal/calendarresources.h> | 44 | #include <libkcal/calendarresources.h> |
44 | #include <libkcal/resourcecalendar.h> | 45 | #include <libkcal/resourcecalendar.h> |
45 | #include <libkcal/icalformat.h> | 46 | #include <libkcal/icalformat.h> |
46 | #include <kresources/resourceselectdialog.h> | 47 | #include <kresources/resourceselectdialog.h> |
47 | #include <libkdepim/kdateedit.h> | 48 | #include <libkdepim/kdateedit.h> |
48 | 49 | ||
49 | #include "koprefs.h" | 50 | #include "koprefs.h" |
50 | #include "kolocationbox.h" | 51 | #include "kolocationbox.h" |
51 | 52 | ||
52 | #include "kotodoeditor.h" | 53 | #include "kotodoeditor.h" |
53 | extern int globalFlagBlockAgenda; | 54 | extern int globalFlagBlockAgenda; |
54 | 55 | ||
55 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : | 56 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : |
56 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) | 57 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) |
57 | { | 58 | { |
58 | mTodo = 0; | 59 | mTodo = 0; |
59 | mRelatedTodo = 0; | 60 | mRelatedTodo = 0; |
60 | findButton(User1)->hide(); | 61 | findButton(User1)->hide(); |
61 | init(); | 62 | init(); |
62 | if ( QApplication::desktop()->height() <= 240 ) | 63 | if ( QApplication::desktop()->height() <= 240 ) |
63 | hideButtons(); | 64 | hideButtons(); |
64 | } | 65 | } |
65 | 66 | ||
66 | KOTodoEditor::~KOTodoEditor() | 67 | KOTodoEditor::~KOTodoEditor() |
67 | { | 68 | { |
68 | emit dialogClose( mTodo ); | 69 | emit dialogClose( mTodo ); |
69 | } | 70 | } |
70 | 71 | ||
71 | void KOTodoEditor::init() | 72 | void KOTodoEditor::init() |
72 | { | 73 | { |
73 | setupGeneral(); | 74 | setupGeneral(); |
74 | setupAttendeesTab(); | 75 | setupAttendeesTab(); |
75 | setupRecurrence(); | 76 | setupRecurrence(); |
76 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); | 77 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); |
77 | mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); | 78 | mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); |
@@ -214,96 +215,99 @@ void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | |||
214 | mGeneral->setFocusOn( 1 ); | 215 | mGeneral->setFocusOn( 1 ); |
215 | } else { | 216 | } else { |
216 | showPage( 0 ); | 217 | showPage( 0 ); |
217 | mGeneral->setFocusOn( 2 ); | 218 | mGeneral->setFocusOn( 2 ); |
218 | } | 219 | } |
219 | checkRecurrence(); | 220 | checkRecurrence(); |
220 | } | 221 | } |
221 | 222 | ||
222 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) | 223 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) |
223 | { | 224 | { |
224 | //init(); | 225 | //init(); |
225 | 226 | ||
226 | mTodo = 0; | 227 | mTodo = 0; |
227 | setDefaults(due,relatedTodo,allDay); | 228 | setDefaults(due,relatedTodo,allDay); |
228 | } | 229 | } |
229 | 230 | ||
230 | void KOTodoEditor::loadDefaults() | 231 | void KOTodoEditor::loadDefaults() |
231 | { | 232 | { |
232 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); | 233 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); |
233 | } | 234 | } |
234 | 235 | ||
235 | bool KOTodoEditor::processInput( bool emitTime ) | 236 | bool KOTodoEditor::processInput( bool emitTime ) |
236 | { | 237 | { |
237 | if (!validateInput()) return false; | 238 | if (!validateInput()) return false; |
238 | 239 | ||
239 | Todo *todo = 0; | 240 | Todo *todo = 0; |
240 | 241 | ||
241 | if (mTodo) todo = mTodo; | 242 | if (mTodo) todo = mTodo; |
242 | else { | 243 | else { |
243 | todo = new Todo; | 244 | todo = new Todo; |
244 | todo->setOrganizer(KOPrefs::instance()->email()); | 245 | todo->setOrganizer(KOPrefs::instance()->email()); |
245 | } | 246 | } |
246 | 247 | ||
247 | writeTodo(todo); | 248 | writeTodo(todo); |
248 | if ( emitTime ) { | 249 | if ( emitTime ) { |
249 | globalFlagBlockAgenda = 1; | 250 | globalFlagBlockAgenda = 1; |
250 | emit showAgendaView( false ); | 251 | emit showAgendaView( false ); |
251 | if ( todo->hasDueDate() ) | 252 | if ( todo->hasDueDate() ) |
252 | emit jumpToTime( todo->dtDue().date() ); | 253 | emit jumpToTime( todo->dtDue().date() ); |
253 | globalFlagBlockAgenda = 2; | 254 | globalFlagBlockAgenda = 2; |
254 | } | 255 | } |
255 | if (mTodo) { | 256 | if (mTodo) { |
256 | todo->setRevision(todo->revision()+1); | 257 | todo->setRevision(todo->revision()+1); |
257 | emit todoChanged(todo); | 258 | emit todoChanged(todo); |
258 | } else { | 259 | } else { |
259 | mCalendar->addTodo(todo); | 260 | mCalendar->addTodo(todo); |
260 | mTodo = todo; | 261 | mTodo = todo; |
261 | emit todoAdded(todo); | 262 | emit todoAdded(todo); |
263 | if ( todo->isAlarmEnabled () && !todo->alarmEnabled () ) { | ||
264 | QTimer::singleShot( 0, this, SLOT ( alarmWarning() ) ); | ||
265 | } | ||
262 | } | 266 | } |
263 | 267 | ||
264 | return true; | 268 | return true; |
265 | } | 269 | } |
266 | 270 | ||
267 | void KOTodoEditor::deleteTodo() | 271 | void KOTodoEditor::deleteTodo() |
268 | { | 272 | { |
269 | if (mTodo) { | 273 | if (mTodo) { |
270 | if (KOPrefs::instance()->mConfirm) { | 274 | if (KOPrefs::instance()->mConfirm) { |
271 | switch (msgItemDelete()) { | 275 | switch (msgItemDelete()) { |
272 | case KMessageBox::Continue: // OK | 276 | case KMessageBox::Continue: // OK |
273 | emit todoToBeDeleted(mTodo); | 277 | emit todoToBeDeleted(mTodo); |
274 | emit dialogClose(mTodo); | 278 | emit dialogClose(mTodo); |
275 | mCalendar->deleteTodo(mTodo); | 279 | mCalendar->deleteTodo(mTodo); |
276 | emit todoDeleted(); | 280 | emit todoDeleted(); |
277 | reject(); | 281 | reject(); |
278 | break; | 282 | break; |
279 | } | 283 | } |
280 | } | 284 | } |
281 | else { | 285 | else { |
282 | emit todoToBeDeleted(mTodo); | 286 | emit todoToBeDeleted(mTodo); |
283 | emit dialogClose(mTodo); | 287 | emit dialogClose(mTodo); |
284 | mCalendar->deleteTodo(mTodo); | 288 | mCalendar->deleteTodo(mTodo); |
285 | emit todoDeleted(); | 289 | emit todoDeleted(); |
286 | reject(); | 290 | reject(); |
287 | } | 291 | } |
288 | } else { | 292 | } else { |
289 | reject(); | 293 | reject(); |
290 | } | 294 | } |
291 | } | 295 | } |
292 | 296 | ||
293 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | 297 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) |
294 | { | 298 | { |
295 | mRelatedTodo = relatedEvent; | 299 | mRelatedTodo = relatedEvent; |
296 | 300 | ||
297 | mGeneral->setDefaults(due,allDay); | 301 | mGeneral->setDefaults(due,allDay); |
298 | mDetails->setDefaults(); | 302 | mDetails->setDefaults(); |
299 | showPage( 0 ); | 303 | showPage( 0 ); |
300 | if ( mRelatedTodo ) { | 304 | if ( mRelatedTodo ) { |
301 | mGeneral->fillCalCombo(mRelatedTodo->calID() ); | 305 | mGeneral->fillCalCombo(mRelatedTodo->calID() ); |
302 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 306 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
303 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | 307 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); |
304 | if ( mRelatedTodo->priority() < 3 ) | 308 | if ( mRelatedTodo->priority() < 3 ) |
305 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); | 309 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); |
306 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); | 310 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); |
307 | int len = mRelatedTodo->summary().length(); | 311 | int len = mRelatedTodo->summary().length(); |
308 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | 312 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); |
309 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | 313 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); |