author | zautrix <zautrix> | 2005-02-13 11:55:52 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-13 11:55:52 (UTC) |
commit | 0a33f91e166747406ca2ccb5819881feeecfdb40 (patch) (unidiff) | |
tree | e9130a16aaa6365e106d6733c3e1adeca01f72ac /korganizer/kotodoeditor.cpp | |
parent | 00ec9899a4727a4c9100d320935dde7da4803801 (diff) | |
download | kdepimpi-0a33f91e166747406ca2ccb5819881feeecfdb40.zip kdepimpi-0a33f91e166747406ca2ccb5819881feeecfdb40.tar.gz kdepimpi-0a33f91e166747406ca2ccb5819881feeecfdb40.tar.bz2 |
todo recurchanges
-rw-r--r-- | korganizer/kotodoeditor.cpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 70dfbd1..069dda8 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -17,71 +17,84 @@ | |||
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 | 34 | ||
34 | #include <kiconloader.h> | 35 | #include <kiconloader.h> |
35 | #include <klocale.h> | 36 | #include <klocale.h> |
36 | #include <kfiledialog.h> | 37 | #include <kfiledialog.h> |
37 | #include <kstandarddirs.h> | 38 | #include <kstandarddirs.h> |
38 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
39 | 40 | ||
40 | #include <libkdepim/categoryselectdialog.h> | 41 | #include <libkdepim/categoryselectdialog.h> |
41 | #include <libkcal/calendarlocal.h> | 42 | #include <libkcal/calendarlocal.h> |
42 | #include <libkcal/calendarresources.h> | 43 | #include <libkcal/calendarresources.h> |
43 | #include <libkcal/resourcecalendar.h> | 44 | #include <libkcal/resourcecalendar.h> |
44 | #include <libkcal/icalformat.h> | 45 | #include <libkcal/icalformat.h> |
45 | #include <kresources/resourceselectdialog.h> | 46 | #include <kresources/resourceselectdialog.h> |
47 | #include <libkdepim/kdateedit.h> | ||
46 | 48 | ||
47 | #include "koprefs.h" | 49 | #include "koprefs.h" |
48 | #include "kolocationbox.h" | 50 | #include "kolocationbox.h" |
49 | 51 | ||
50 | #include "kotodoeditor.h" | 52 | #include "kotodoeditor.h" |
51 | extern int globalFlagBlockAgenda; | 53 | extern int globalFlagBlockAgenda; |
52 | 54 | ||
53 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : | 55 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : |
54 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) | 56 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) |
55 | { | 57 | { |
56 | mTodo = 0; | 58 | mTodo = 0; |
57 | mRelatedTodo = 0; | 59 | mRelatedTodo = 0; |
58 | findButton(User1)->hide(); | 60 | findButton(User1)->hide(); |
59 | init(); | 61 | init(); |
60 | } | 62 | } |
61 | 63 | ||
62 | KOTodoEditor::~KOTodoEditor() | 64 | KOTodoEditor::~KOTodoEditor() |
63 | { | 65 | { |
64 | emit dialogClose( mTodo ); | 66 | emit dialogClose( mTodo ); |
65 | } | 67 | } |
66 | 68 | ||
67 | void KOTodoEditor::init() | 69 | void KOTodoEditor::init() |
68 | { | 70 | { |
69 | setupGeneral(); | 71 | setupGeneral(); |
70 | setupAttendeesTab(); | 72 | setupAttendeesTab(); |
73 | setupRecurrence(); | ||
74 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); | ||
71 | } | 75 | } |
76 | void KOTodoEditor::setupRecurrence() | ||
77 | { | ||
78 | QFrame *topFrame = addPage( i18n("Recurrence") ); | ||
79 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | ||
80 | |||
81 | mRecurrence = new KOEditorRecurrence( topFrame ); | ||
82 | topLayout->addWidget( mRecurrence ); | ||
83 | } | ||
84 | |||
72 | void KOTodoEditor::setCategories( QString s ) | 85 | void KOTodoEditor::setCategories( QString s ) |
73 | { | 86 | { |
74 | mGeneral->setCategories(s); | 87 | mGeneral->setCategories(s); |
75 | } | 88 | } |
76 | void KOTodoEditor::setSecrecy( int sec ) | 89 | void KOTodoEditor::setSecrecy( int sec ) |
77 | { | 90 | { |
78 | mGeneral->setSecrecy( sec ); | 91 | mGeneral->setSecrecy( sec ); |
79 | } | 92 | } |
80 | void KOTodoEditor::reload() | 93 | void KOTodoEditor::reload() |
81 | { | 94 | { |
82 | if ( mTodo ) readTodo( mTodo ); | 95 | if ( mTodo ) readTodo( mTodo ); |
83 | } | 96 | } |
84 | 97 | ||
85 | void KOTodoEditor::setupGeneral() | 98 | void KOTodoEditor::setupGeneral() |
86 | { | 99 | { |
87 | mGeneral = new KOEditorGeneralTodo(this); | 100 | mGeneral = new KOEditorGeneralTodo(this); |
@@ -181,32 +194,33 @@ void KOTodoEditor::setupGeneral() | |||
181 | 194 | ||
182 | } | 195 | } |
183 | 196 | ||
184 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | 197 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) |
185 | { | 198 | { |
186 | //init(); | 199 | //init(); |
187 | 200 | ||
188 | mTodo = todo; | 201 | mTodo = todo; |
189 | readTodo(mTodo); | 202 | readTodo(mTodo); |
190 | if ( editDescription ) { | 203 | if ( editDescription ) { |
191 | showPage( 1 ); | 204 | showPage( 1 ); |
192 | mGeneral->setFocusOn( 1 ); | 205 | mGeneral->setFocusOn( 1 ); |
193 | } else { | 206 | } else { |
194 | showPage( 0 ); | 207 | showPage( 0 ); |
195 | mGeneral->setFocusOn( 2 ); | 208 | mGeneral->setFocusOn( 2 ); |
196 | } | 209 | } |
210 | checkRecurrence(); | ||
197 | } | 211 | } |
198 | 212 | ||
199 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) | 213 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) |
200 | { | 214 | { |
201 | //init(); | 215 | //init(); |
202 | 216 | ||
203 | mTodo = 0; | 217 | mTodo = 0; |
204 | setDefaults(due,relatedTodo,allDay); | 218 | setDefaults(due,relatedTodo,allDay); |
205 | } | 219 | } |
206 | 220 | ||
207 | void KOTodoEditor::loadDefaults() | 221 | void KOTodoEditor::loadDefaults() |
208 | { | 222 | { |
209 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); | 223 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); |
210 | } | 224 | } |
211 | 225 | ||
212 | bool KOTodoEditor::processInput( bool emitTime ) | 226 | bool KOTodoEditor::processInput( bool emitTime ) |
@@ -274,54 +288,83 @@ void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | |||
274 | mGeneral->setDefaults(due,allDay); | 288 | mGeneral->setDefaults(due,allDay); |
275 | mDetails->setDefaults(); | 289 | mDetails->setDefaults(); |
276 | showPage( 0 ); | 290 | showPage( 0 ); |
277 | if ( mRelatedTodo ) { | 291 | if ( mRelatedTodo ) { |
278 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 292 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
279 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | 293 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); |
280 | if ( mRelatedTodo->priority() < 3 ) | 294 | if ( mRelatedTodo->priority() < 3 ) |
281 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); | 295 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); |
282 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); | 296 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); |
283 | int len = mRelatedTodo->summary().length(); | 297 | int len = mRelatedTodo->summary().length(); |
284 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | 298 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); |
285 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | 299 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); |
286 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | 300 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); |
287 | 301 | ||
288 | } else | 302 | } else |
289 | mGeneral->setFocusOn( 2 ); | 303 | mGeneral->setFocusOn( 2 ); |
304 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | ||
305 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | ||
306 | } | ||
307 | void KOTodoEditor::checkRecurrence() | ||
308 | { | ||
309 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | ||
310 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); | ||
311 | |||
312 | if ( mTodo ) | ||
313 | mRecurrence->readEvent( mTodo ); | ||
314 | else { | ||
315 | bool time = mGeneral->mTimeButton->isChecked(); | ||
316 | QDateTime from,to; | ||
317 | if ( time ) { | ||
318 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; | ||
319 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; | ||
320 | } else { | ||
321 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; | ||
322 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; | ||
323 | } | ||
324 | mRecurrence->setDefaults(from,to,!time); | ||
325 | } | ||
326 | } else { | ||
327 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | ||
328 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | ||
329 | } | ||
290 | } | 330 | } |
291 | |||
292 | void KOTodoEditor::readTodo(Todo *todo) | 331 | void KOTodoEditor::readTodo(Todo *todo) |
293 | { | 332 | { |
294 | mGeneral->readTodo(todo); | 333 | mGeneral->readTodo(todo); |
295 | mDetails->readEvent(todo); | 334 | mDetails->readEvent(todo); |
296 | mRelatedTodo = 0;//todo->relatedTo(); | 335 | mRelatedTodo = 0;//todo->relatedTo(); |
297 | // categories | 336 | // categories |
298 | // mCategoryDialog->setSelected(todo->categories()); | 337 | // mCategoryDialog->setSelected(todo->categories()); |
299 | 338 | ||
300 | // We should handle read-only events here. | 339 | // We should handle read-only events here. |
301 | } | 340 | } |
302 | 341 | ||
303 | void KOTodoEditor::writeTodo(Todo *event) | 342 | void KOTodoEditor::writeTodo(Todo *event) |
304 | { | 343 | { |
305 | mGeneral->writeTodo(event); | 344 | mGeneral->writeTodo(event); |
306 | mDetails->writeEvent(event); | 345 | mDetails->writeEvent(event); |
307 | 346 | ||
308 | // set related event, i.e. parent to-do in this case. | 347 | // set related event, i.e. parent to-do in this case. |
309 | if (mRelatedTodo) { | 348 | if (mRelatedTodo) { |
310 | event->setRelatedTo(mRelatedTodo); | 349 | event->setRelatedTo(mRelatedTodo); |
311 | } | 350 | } |
351 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | ||
352 | mRecurrence->writeEvent(event); | ||
353 | } else | ||
354 | event->recurrence()->unsetRecurs(); | ||
312 | } | 355 | } |
313 | 356 | ||
314 | bool KOTodoEditor::validateInput() | 357 | bool KOTodoEditor::validateInput() |
315 | { | 358 | { |
316 | if (!mGeneral->validateInput()) return false; | 359 | if (!mGeneral->validateInput()) return false; |
317 | if (!mDetails->validateInput()) return false; | 360 | if (!mDetails->validateInput()) return false; |
318 | return true; | 361 | return true; |
319 | } | 362 | } |
320 | 363 | ||
321 | int KOTodoEditor::msgItemDelete() | 364 | int KOTodoEditor::msgItemDelete() |
322 | { | 365 | { |
323 | return KMessageBox::warningContinueCancel(this, | 366 | return KMessageBox::warningContinueCancel(this, |
324 | i18n("This item will be permanently deleted."), | 367 | i18n("This item will be permanently deleted."), |
325 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 368 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
326 | } | 369 | } |
327 | 370 | ||