-rw-r--r-- | korganizer/kotodoview.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 98c9bd9..8d957eb 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -159,1375 +159,1388 @@ KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | |||
159 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 159 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
160 | #endif | 160 | #endif |
161 | mOldCurrent = 0; | 161 | mOldCurrent = 0; |
162 | mMousePressed = false; | 162 | mMousePressed = false; |
163 | 163 | ||
164 | setAcceptDrops(true); | 164 | setAcceptDrops(true); |
165 | viewport()->setAcceptDrops(true); | 165 | viewport()->setAcceptDrops(true); |
166 | int size = 16; | 166 | int size = 16; |
167 | if (qApp->desktop()->width() < 300 ) | 167 | if (qApp->desktop()->width() < 300 ) |
168 | size = 12; | 168 | size = 12; |
169 | setTreeStepSize( size + 6 ); | 169 | setTreeStepSize( size + 6 ); |
170 | 170 | ||
171 | } | 171 | } |
172 | 172 | ||
173 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 173 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
174 | { | 174 | { |
175 | #ifndef KORG_NODND | 175 | #ifndef KORG_NODND |
176 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 176 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
177 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 177 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
178 | !QTextDrag::canDecode( e ) ) { | 178 | !QTextDrag::canDecode( e ) ) { |
179 | e->ignore(); | 179 | e->ignore(); |
180 | return; | 180 | return; |
181 | } | 181 | } |
182 | 182 | ||
183 | mOldCurrent = currentItem(); | 183 | mOldCurrent = currentItem(); |
184 | #endif | 184 | #endif |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 188 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
189 | { | 189 | { |
190 | #ifndef KORG_NODND | 190 | #ifndef KORG_NODND |
191 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 191 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
192 | 192 | ||
193 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 193 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
194 | !QTextDrag::canDecode( e ) ) { | 194 | !QTextDrag::canDecode( e ) ) { |
195 | e->ignore(); | 195 | e->ignore(); |
196 | return; | 196 | return; |
197 | } | 197 | } |
198 | 198 | ||
199 | e->accept(); | 199 | e->accept(); |
200 | #endif | 200 | #endif |
201 | } | 201 | } |
202 | 202 | ||
203 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 203 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
204 | { | 204 | { |
205 | #ifndef KORG_NODND | 205 | #ifndef KORG_NODND |
206 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 206 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
207 | 207 | ||
208 | setCurrentItem(mOldCurrent); | 208 | setCurrentItem(mOldCurrent); |
209 | setSelected(mOldCurrent,true); | 209 | setSelected(mOldCurrent,true); |
210 | #endif | 210 | #endif |
211 | } | 211 | } |
212 | 212 | ||
213 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 213 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
214 | { | 214 | { |
215 | #ifndef KORG_NODND | 215 | #ifndef KORG_NODND |
216 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 216 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
217 | 217 | ||
218 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 218 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
219 | !QTextDrag::canDecode( e ) ) { | 219 | !QTextDrag::canDecode( e ) ) { |
220 | e->ignore(); | 220 | e->ignore(); |
221 | return; | 221 | return; |
222 | } | 222 | } |
223 | 223 | ||
224 | DndFactory factory( mCalendar ); | 224 | DndFactory factory( mCalendar ); |
225 | Todo *todo = factory.createDropTodo(e); | 225 | Todo *todo = factory.createDropTodo(e); |
226 | 226 | ||
227 | if (todo) { | 227 | if (todo) { |
228 | e->acceptAction(); | 228 | e->acceptAction(); |
229 | 229 | ||
230 | KOTodoViewItem *destination = | 230 | KOTodoViewItem *destination = |
231 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 231 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
232 | Todo *destinationEvent = 0; | 232 | Todo *destinationEvent = 0; |
233 | if (destination) destinationEvent = destination->todo(); | 233 | if (destination) destinationEvent = destination->todo(); |
234 | 234 | ||
235 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 235 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
236 | 236 | ||
237 | if(existingTodo) { | 237 | if(existingTodo) { |
238 | Incidence *to = destinationEvent; | 238 | Incidence *to = destinationEvent; |
239 | while(to) { | 239 | while(to) { |
240 | if (to->uid() == todo->uid()) { | 240 | if (to->uid() == todo->uid()) { |
241 | KMessageBox::sorry(this, | 241 | KMessageBox::sorry(this, |
242 | i18n("Cannot move Todo to itself\nor a child of itself"), | 242 | i18n("Cannot move Todo to itself\nor a child of itself"), |
243 | i18n("Drop Todo")); | 243 | i18n("Drop Todo")); |
244 | delete todo; | 244 | delete todo; |
245 | return; | 245 | return; |
246 | } | 246 | } |
247 | to = to->relatedTo(); | 247 | to = to->relatedTo(); |
248 | } | 248 | } |
249 | internalDrop = true; | 249 | internalDrop = true; |
250 | if ( destinationEvent ) | 250 | if ( destinationEvent ) |
251 | reparentTodoSignal( destinationEvent, existingTodo ); | 251 | reparentTodoSignal( destinationEvent, existingTodo ); |
252 | else | 252 | else |
253 | unparentTodoSignal(existingTodo); | 253 | unparentTodoSignal(existingTodo); |
254 | delete todo; | 254 | delete todo; |
255 | } else { | 255 | } else { |
256 | mCalendar->addTodo(todo); | 256 | mCalendar->addTodo(todo); |
257 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 257 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
258 | if ( destinationEvent ) | 258 | if ( destinationEvent ) |
259 | reparentTodoSignal( destinationEvent, todo ); | 259 | reparentTodoSignal( destinationEvent, todo ); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | else { | 262 | else { |
263 | QString text; | 263 | QString text; |
264 | if (QTextDrag::decode(e,text)) { | 264 | if (QTextDrag::decode(e,text)) { |
265 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 265 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
266 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 266 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
267 | qDebug("Dropped : " + text); | 267 | qDebug("Dropped : " + text); |
268 | QStringList emails = QStringList::split(",",text); | 268 | QStringList emails = QStringList::split(",",text); |
269 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 269 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
270 | int pos = (*it).find("<"); | 270 | int pos = (*it).find("<"); |
271 | QString name = (*it).left(pos); | 271 | QString name = (*it).left(pos); |
272 | QString email = (*it).mid(pos); | 272 | QString email = (*it).mid(pos); |
273 | if (!email.isEmpty() && todoi) { | 273 | if (!email.isEmpty() && todoi) { |
274 | todoi->todo()->addAttendee(new Attendee(name,email)); | 274 | todoi->todo()->addAttendee(new Attendee(name,email)); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | } | 277 | } |
278 | else { | 278 | else { |
279 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 279 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
280 | e->ignore(); | 280 | e->ignore(); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | #endif | 283 | #endif |
284 | } | 284 | } |
285 | void KOTodoListView::wheelEvent (QWheelEvent *e) | 285 | void KOTodoListView::wheelEvent (QWheelEvent *e) |
286 | { | 286 | { |
287 | QListView::wheelEvent (e); | 287 | QListView::wheelEvent (e); |
288 | } | 288 | } |
289 | 289 | ||
290 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 290 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
291 | { | 291 | { |
292 | 292 | ||
293 | QPoint p(contentsToViewport(e->pos())); | 293 | QPoint p(contentsToViewport(e->pos())); |
294 | QListViewItem *i = itemAt(p); | 294 | QListViewItem *i = itemAt(p); |
295 | bool rootClicked = true; | 295 | bool rootClicked = true; |
296 | if (i) { | 296 | if (i) { |
297 | // if the user clicked into the root decoration of the item, don't | 297 | // if the user clicked into the root decoration of the item, don't |
298 | // try to start a drag! | 298 | // try to start a drag! |
299 | int X = p.x(); | 299 | int X = p.x(); |
300 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | 300 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); |
301 | if (X > header()->sectionPos(0) + | 301 | if (X > header()->sectionPos(0) + |
302 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 302 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
303 | itemMargin() +i->height()|| | 303 | itemMargin() +i->height()|| |
304 | X < header()->sectionPos(0)) { | 304 | X < header()->sectionPos(0)) { |
305 | rootClicked = false; | 305 | rootClicked = false; |
306 | } | 306 | } |
307 | } else { | 307 | } else { |
308 | rootClicked = false; | 308 | rootClicked = false; |
309 | } | 309 | } |
310 | #ifndef KORG_NODND | 310 | #ifndef KORG_NODND |
311 | mMousePressed = false; | 311 | mMousePressed = false; |
312 | if (! rootClicked && !( e->button() == RightButton) ) { | 312 | if (! rootClicked && !( e->button() == RightButton) ) { |
313 | mPressPos = e->pos(); | 313 | mPressPos = e->pos(); |
314 | mMousePressed = true; | 314 | mMousePressed = true; |
315 | } else { | 315 | } else { |
316 | mMousePressed = false; | 316 | mMousePressed = false; |
317 | } | 317 | } |
318 | #endif | 318 | #endif |
319 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 319 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
320 | #ifndef DESKTOP_VERSION | 320 | #ifndef DESKTOP_VERSION |
321 | if (!( e->button() == RightButton && rootClicked) ) | 321 | if (!( e->button() == RightButton && rootClicked) ) |
322 | QListView::contentsMousePressEvent(e); | 322 | QListView::contentsMousePressEvent(e); |
323 | #else | 323 | #else |
324 | QListView::contentsMousePressEvent(e); | 324 | QListView::contentsMousePressEvent(e); |
325 | #endif | 325 | #endif |
326 | } | 326 | } |
327 | void KOTodoListView::paintEvent(QPaintEvent* e) | 327 | void KOTodoListView::paintEvent(QPaintEvent* e) |
328 | { | 328 | { |
329 | emit paintNeeded(); | 329 | emit paintNeeded(); |
330 | QListView::paintEvent( e); | 330 | QListView::paintEvent( e); |
331 | } | 331 | } |
332 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 332 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
333 | { | 333 | { |
334 | 334 | ||
335 | #ifndef KORG_NODND | 335 | #ifndef KORG_NODND |
336 | //QListView::contentsMouseMoveEvent(e); | 336 | //QListView::contentsMouseMoveEvent(e); |
337 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 337 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
338 | QApplication::startDragDistance()*3) { | 338 | QApplication::startDragDistance()*3) { |
339 | mMousePressed = false; | 339 | mMousePressed = false; |
340 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 340 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
341 | if (item) { | 341 | if (item) { |
342 | DndFactory factory( mCalendar ); | 342 | DndFactory factory( mCalendar ); |
343 | ICalDrag *vd = factory.createDrag( | 343 | ICalDrag *vd = factory.createDrag( |
344 | ((KOTodoViewItem *)item)->todo(),viewport()); | 344 | ((KOTodoViewItem *)item)->todo(),viewport()); |
345 | internalDrop = false; | 345 | internalDrop = false; |
346 | // we cannot do any senseful here, because the DnD is still broken in Qt | 346 | // we cannot do any senseful here, because the DnD is still broken in Qt |
347 | if (vd->drag()) { | 347 | if (vd->drag()) { |
348 | if ( !internalDrop ) { | 348 | if ( !internalDrop ) { |
349 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 349 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
350 | qDebug("Dnd: External move: Delete drag source "); | 350 | qDebug("Dnd: External move: Delete drag source "); |
351 | } else | 351 | } else |
352 | qDebug("Dnd: Internal move "); | 352 | qDebug("Dnd: Internal move "); |
353 | 353 | ||
354 | } else { | 354 | } else { |
355 | if ( !internalDrop ) { | 355 | if ( !internalDrop ) { |
356 | qDebug("Dnd: External Copy"); | 356 | qDebug("Dnd: External Copy"); |
357 | } else | 357 | } else |
358 | qDebug("DnD: Internal copy: Copy pending"); | 358 | qDebug("DnD: Internal copy: Copy pending"); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | } | 361 | } |
362 | #endif | 362 | #endif |
363 | } | 363 | } |
364 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) | 364 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
365 | { | 365 | { |
366 | if ( !e->isAutoRepeat() ) { | 366 | if ( !e->isAutoRepeat() ) { |
367 | mFlagKeyPressed = false; | 367 | mFlagKeyPressed = false; |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | 371 | ||
372 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 372 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
373 | { | 373 | { |
374 | qApp->processEvents(); | 374 | qApp->processEvents(); |
375 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 375 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
376 | e->ignore(); | 376 | e->ignore(); |
377 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 377 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
378 | return; | 378 | return; |
379 | } | 379 | } |
380 | if (! e->isAutoRepeat() ) | 380 | if (! e->isAutoRepeat() ) |
381 | mFlagKeyPressed = true; | 381 | mFlagKeyPressed = true; |
382 | QListViewItem* cn; | 382 | QListViewItem* cn; |
383 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 383 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
384 | cn = currentItem(); | 384 | cn = currentItem(); |
385 | if ( cn ) { | 385 | if ( cn ) { |
386 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 386 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
387 | if ( ci ){ | 387 | if ( ci ){ |
388 | if ( e->state() == ShiftButton ) | 388 | if ( e->state() == ShiftButton ) |
389 | ci->setOn( false ); | 389 | ci->setOn( false ); |
390 | else | 390 | else |
391 | ci->setOn( true ); | 391 | ci->setOn( true ); |
392 | cn = cn->itemBelow(); | 392 | cn = cn->itemBelow(); |
393 | if ( cn ) { | 393 | if ( cn ) { |
394 | setCurrentItem ( cn ); | 394 | setCurrentItem ( cn ); |
395 | ensureItemVisible ( cn ); | 395 | ensureItemVisible ( cn ); |
396 | } | 396 | } |
397 | 397 | ||
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | return; | 401 | return; |
402 | } | 402 | } |
403 | 403 | ||
404 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 404 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
405 | switch ( e->key() ) { | 405 | switch ( e->key() ) { |
406 | case Qt::Key_Down: | 406 | case Qt::Key_Down: |
407 | case Qt::Key_Up: | 407 | case Qt::Key_Up: |
408 | QListView::keyPressEvent ( e ); | 408 | QListView::keyPressEvent ( e ); |
409 | break; | 409 | break; |
410 | case Qt::Key_Left: | 410 | case Qt::Key_Left: |
411 | case Qt::Key_Right: | 411 | case Qt::Key_Right: |
412 | QListView::keyPressEvent ( e ); | 412 | QListView::keyPressEvent ( e ); |
413 | e->accept(); | 413 | e->accept(); |
414 | return; | 414 | return; |
415 | break; | 415 | break; |
416 | default: | 416 | default: |
417 | e->ignore(); | 417 | e->ignore(); |
418 | break; | 418 | break; |
419 | } | 419 | } |
420 | return; | 420 | return; |
421 | } | 421 | } |
422 | e->ignore(); | 422 | e->ignore(); |
423 | } | 423 | } |
424 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 424 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
425 | { | 425 | { |
426 | QListView::contentsMouseReleaseEvent(e); | 426 | QListView::contentsMouseReleaseEvent(e); |
427 | mMousePressed = false; | 427 | mMousePressed = false; |
428 | } | 428 | } |
429 | 429 | ||
430 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 430 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
431 | { | 431 | { |
432 | if (!e) return; | 432 | if (!e) return; |
433 | 433 | ||
434 | QPoint vp = contentsToViewport(e->pos()); | 434 | QPoint vp = contentsToViewport(e->pos()); |
435 | 435 | ||
436 | QListViewItem *item = itemAt(vp); | 436 | QListViewItem *item = itemAt(vp); |
437 | 437 | ||
438 | emit double_Clicked(item); | 438 | emit double_Clicked(item); |
439 | if (!item) return; | 439 | if (!item) return; |
440 | 440 | ||
441 | emit doubleClicked(item,vp,0); | 441 | emit doubleClicked(item,vp,0); |
442 | } | 442 | } |
443 | 443 | ||
444 | ///////////////////////////////////////////////////////////////////////////// | 444 | ///////////////////////////////////////////////////////////////////////////// |
445 | 445 | ||
446 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 446 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
447 | QLineEdit(parent) | 447 | QLineEdit(parent) |
448 | { | 448 | { |
449 | setText(i18n("Click to add a new Todo")); | 449 | setText(i18n("Click to add a new Todo")); |
450 | } | 450 | } |
451 | 451 | ||
452 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 452 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
453 | { | 453 | { |
454 | if ( text()==i18n("Click to add a new Todo") ) | 454 | if ( text()==i18n("Click to add a new Todo") ) |
455 | setText(""); | 455 | setText(""); |
456 | QLineEdit::focusInEvent(ev); | 456 | QLineEdit::focusInEvent(ev); |
457 | } | 457 | } |
458 | 458 | ||
459 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 459 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
460 | { | 460 | { |
461 | setText(i18n("Click to add a new Todo")); | 461 | setText(i18n("Click to add a new Todo")); |
462 | QLineEdit::focusOutEvent(ev); | 462 | QLineEdit::focusOutEvent(ev); |
463 | } | 463 | } |
464 | 464 | ||
465 | ///////////////////////////////////////////////////////////////////////////// | 465 | ///////////////////////////////////////////////////////////////////////////// |
466 | 466 | ||
467 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 467 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
468 | KOrg::BaseView(calendar,parent,name) | 468 | KOrg::BaseView(calendar,parent,name) |
469 | { | 469 | { |
470 | mPendingUpdateBeforeRepaint = false; | 470 | mPendingUpdateBeforeRepaint = false; |
471 | isFlatDisplay = false; | 471 | isFlatDisplay = false; |
472 | mNavigator = 0; | 472 | mNavigator = 0; |
473 | QBoxLayout *topLayout = new QVBoxLayout(this); | 473 | QBoxLayout *topLayout = new QVBoxLayout(this); |
474 | mName = QString ( name ); | 474 | mName = QString ( name ); |
475 | mBlockUpdate = false; | 475 | mBlockUpdate = false; |
476 | mQuickAdd = new KOQuickTodo(this); | 476 | mQuickAdd = new KOQuickTodo(this); |
477 | topLayout->addWidget(mQuickAdd); | 477 | topLayout->addWidget(mQuickAdd); |
478 | 478 | ||
479 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 479 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
480 | 480 | ||
481 | mTodoListView = new KOTodoListView(calendar,this, name ); | 481 | mTodoListView = new KOTodoListView(calendar,this, name ); |
482 | topLayout->addWidget(mTodoListView); | 482 | topLayout->addWidget(mTodoListView); |
483 | //mTodoListView->header()->setMaximumHeight(30); | 483 | //mTodoListView->header()->setMaximumHeight(30); |
484 | mTodoListView->setRootIsDecorated(true); | 484 | mTodoListView->setRootIsDecorated(true); |
485 | mTodoListView->setAllColumnsShowFocus(true); | 485 | mTodoListView->setAllColumnsShowFocus(true); |
486 | 486 | ||
487 | mTodoListView->setShowSortIndicator(true); | 487 | mTodoListView->setShowSortIndicator(true); |
488 | 488 | ||
489 | mTodoListView->addColumn(i18n("Todo")); | 489 | mTodoListView->addColumn(i18n("Todo")); |
490 | mTodoListView->addColumn(i18n("Prio")); | 490 | mTodoListView->addColumn(i18n("Prio")); |
491 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 491 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
492 | mTodoListView->addColumn(i18n("Complete")); | 492 | mTodoListView->addColumn(i18n("Complete")); |
493 | mTodoListView->setColumnAlignment(2,AlignCenter); | 493 | mTodoListView->setColumnAlignment(2,AlignCenter); |
494 | 494 | ||
495 | mTodoListView->addColumn(i18n("Due Date")); | 495 | mTodoListView->addColumn(i18n("Due Date")); |
496 | mTodoListView->setColumnAlignment(3,AlignLeft); | 496 | mTodoListView->setColumnAlignment(3,AlignLeft); |
497 | mTodoListView->addColumn(i18n("Due Time")); | 497 | mTodoListView->addColumn(i18n("Due Time")); |
498 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 498 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
499 | 499 | ||
500 | mTodoListView->addColumn(i18n("Start Date")); | 500 | mTodoListView->addColumn(i18n("Start Date")); |
501 | mTodoListView->setColumnAlignment(5,AlignLeft); | 501 | mTodoListView->setColumnAlignment(5,AlignLeft); |
502 | mTodoListView->addColumn(i18n("Start Time")); | 502 | mTodoListView->addColumn(i18n("Start Time")); |
503 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 503 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
504 | 504 | ||
505 | mTodoListView->addColumn(i18n("Cancelled")); | 505 | mTodoListView->addColumn(i18n("Cancelled")); |
506 | mTodoListView->addColumn(i18n("Categories")); | 506 | mTodoListView->addColumn(i18n("Categories")); |
507 | mTodoListView->addColumn(i18n("Calendar")); | 507 | mTodoListView->addColumn(i18n("Calendar")); |
508 | #if 0 | 508 | #if 0 |
509 | mTodoListView->addColumn(i18n("Sort Id")); | 509 | mTodoListView->addColumn(i18n("Sort Id")); |
510 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 510 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
511 | #endif | 511 | #endif |
512 | 512 | ||
513 | mTodoListView->setMinimumHeight( 60 ); | 513 | mTodoListView->setMinimumHeight( 60 ); |
514 | mTodoListView->setItemsRenameable( true ); | 514 | mTodoListView->setItemsRenameable( true ); |
515 | mTodoListView->setRenameable( 0 ); | 515 | mTodoListView->setRenameable( 0 ); |
516 | mTodoListView->setColumnWidth( 0, 120 ); | 516 | mTodoListView->setColumnWidth( 0, 120 ); |
517 | int iii = 0; | 517 | int iii = 0; |
518 | for ( iii = 0; iii< 10 ; ++iii ) | 518 | for ( iii = 0; iii< 10 ; ++iii ) |
519 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 519 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
520 | 520 | ||
521 | 521 | ||
522 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 522 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
523 | 523 | ||
524 | mPriorityPopupMenu = new QPopupMenu(this); | 524 | mPriorityPopupMenu = new QPopupMenu(this); |
525 | for (int i = 1; i <= 5; i++) { | 525 | for (int i = 1; i <= 5; i++) { |
526 | QString label = QString ("%1").arg (i); | 526 | QString label = QString ("%1").arg (i); |
527 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 527 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
528 | } | 528 | } |
529 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 529 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
530 | 530 | ||
531 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 531 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
532 | for (int i = 0; i <= 100; i+=20) { | 532 | for (int i = 0; i <= 100; i+=20) { |
533 | QString label = QString ("%1 %").arg (i); | 533 | QString label = QString ("%1 %").arg (i); |
534 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 534 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
535 | } | 535 | } |
536 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 536 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
537 | 537 | ||
538 | 538 | ||
539 | 539 | ||
540 | mItemPopupMenu = new QPopupMenu(this); | 540 | mItemPopupMenu = new QPopupMenu(this); |
541 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 541 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
542 | SLOT (showTodo())); | 542 | SLOT (showTodo())); |
543 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 543 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
544 | SLOT (editTodo())); | 544 | SLOT (editTodo())); |
545 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 545 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
546 | SLOT (deleteTodo())); | 546 | SLOT (deleteTodo())); |
547 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 547 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
548 | SLOT (cloneTodo())); | 548 | SLOT (cloneTodo())); |
549 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 549 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
550 | SLOT (moveTodo())); | 550 | SLOT (moveTodo())); |
551 | #ifndef DESKTOP_VERSION | 551 | #ifndef DESKTOP_VERSION |
552 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 552 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
553 | SLOT (beamTodo())); | 553 | SLOT (beamTodo())); |
554 | #endif | 554 | #endif |
555 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 555 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
556 | SLOT (cancelTodo())); | 556 | SLOT (cancelTodo())); |
557 | mItemPopupMenu->insertSeparator(); | 557 | mItemPopupMenu->insertSeparator(); |
558 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 558 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
559 | SLOT (toggleRunningItem())); | 559 | SLOT (toggleRunningItem())); |
560 | mItemPopupMenu->insertSeparator(); | 560 | mItemPopupMenu->insertSeparator(); |
561 | /* | 561 | /* |
562 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 562 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
563 | SLOT (newTodo())); | 563 | SLOT (newTodo())); |
564 | */ | 564 | */ |
565 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 565 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
566 | SLOT (newSubTodo())); | 566 | SLOT (newSubTodo())); |
567 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 567 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
568 | SLOT (unparentTodo()),0,21); | 568 | SLOT (unparentTodo()),0,21); |
569 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 569 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
570 | SLOT (reparentTodo()),0,22); | 570 | SLOT (reparentTodo()),0,22); |
571 | mItemPopupMenu->insertSeparator(); | 571 | mItemPopupMenu->insertSeparator(); |
572 | #if 0 | 572 | #if 0 |
573 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 573 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
574 | this, SLOT( purgeCompleted() ) ); | 574 | this, SLOT( purgeCompleted() ) ); |
575 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 575 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
576 | this, SLOT( toggleCompleted() ),0, 33 ); | 576 | this, SLOT( toggleCompleted() ),0, 33 ); |
577 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 577 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
578 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 578 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
579 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 579 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
580 | this, SLOT( toggleRunning() ),0, 35 ); | 580 | this, SLOT( toggleRunning() ),0, 35 ); |
581 | 581 | ||
582 | #endif | 582 | #endif |
583 | mPopupMenu = new QPopupMenu(this); | 583 | mPopupMenu = new QPopupMenu(this); |
584 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 584 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
585 | SLOT (newTodo()),0,1); | 585 | SLOT (newTodo()),0,1); |
586 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 586 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
587 | this, SLOT(purgeCompleted()),0,2); | 587 | this, SLOT(purgeCompleted()),0,2); |
588 | mPopupMenu->insertItem(i18n("Show Completed"), | 588 | mPopupMenu->insertItem(i18n("Show Completed"), |
589 | this, SLOT( toggleCompleted() ),0,3 ); | 589 | this, SLOT( toggleCompleted() ),0,3 ); |
590 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 590 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
591 | this, SLOT( toggleRunning() ),0,5 ); | 591 | this, SLOT( toggleRunning() ),0,5 ); |
592 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 592 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
593 | this, SLOT( setAllOpen() ),0,6 ); | 593 | this, SLOT( setAllOpen() ),0,6 ); |
594 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 594 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
595 | this, SLOT( setAllClose() ),0,7 ); | 595 | this, SLOT( setAllClose() ),0,7 ); |
596 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 596 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
597 | this, SLOT( setAllFlat() ),0,8 ); | 597 | this, SLOT( setAllFlat() ),0,8 ); |
598 | mPopupMenu->insertSeparator(); | 598 | mPopupMenu->insertSeparator(); |
599 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 599 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
600 | this, SLOT( toggleQuickTodo() ),0,4 ); | 600 | this, SLOT( toggleQuickTodo() ),0,4 ); |
601 | mDocPrefs = new DocPrefs( name ); | 601 | mDocPrefs = new DocPrefs( name ); |
602 | 602 | ||
603 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 603 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
604 | mPopupMenu->setCheckable( true ); | 604 | mPopupMenu->setCheckable( true ); |
605 | mItemPopupMenu->setCheckable( true ); | 605 | mItemPopupMenu->setCheckable( true ); |
606 | 606 | ||
607 | 607 | ||
608 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 608 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
609 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 609 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
610 | 610 | ||
611 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 611 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
612 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 612 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
613 | 613 | ||
614 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 614 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
615 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 615 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
616 | 616 | ||
617 | 617 | ||
618 | // Double clicking conflicts with opening/closing the subtree | 618 | // Double clicking conflicts with opening/closing the subtree |
619 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 619 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
620 | SLOT( editItem( QListViewItem *) ) ); | 620 | SLOT( editItem( QListViewItem *) ) ); |
621 | /* | 621 | /* |
622 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 622 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
623 | const QPoint &,int ) ), | 623 | const QPoint &,int ) ), |
624 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 624 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
625 | */ | 625 | */ |
626 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 626 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
627 | const QPoint &,int ) ), | 627 | const QPoint &,int ) ), |
628 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 628 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
629 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 629 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
630 | SLOT( itemClicked( QListViewItem * ) ) ); | 630 | SLOT( itemClicked( QListViewItem * ) ) ); |
631 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 631 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
632 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 632 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
633 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 633 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
634 | SLOT( updateView() ) ); | 634 | SLOT( updateView() ) ); |
635 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 635 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
636 | SLOT( todoModified(Todo *, int) ) ); | 636 | SLOT( todoModified(Todo *, int) ) ); |
637 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 637 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
638 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 638 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
639 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 639 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
640 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 640 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
641 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 641 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
642 | SLOT( paintNeeded()) ); | 642 | SLOT( paintNeeded()) ); |
643 | 643 | ||
644 | #if 0 | 644 | #if 0 |
645 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 645 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
646 | SLOT(selectionChanged(QListViewItem *))); | 646 | SLOT(selectionChanged(QListViewItem *))); |
647 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 647 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
648 | SLOT(selectionChanged(QListViewItem *))); | 648 | SLOT(selectionChanged(QListViewItem *))); |
649 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 649 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
650 | SLOT(selectionChanged(QListViewItem *))); | 650 | SLOT(selectionChanged(QListViewItem *))); |
651 | #endif | 651 | #endif |
652 | 652 | ||
653 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 653 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
654 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 654 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
655 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 655 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
656 | 656 | ||
657 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 657 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
658 | SLOT( processSelectionChange() ) ); | 658 | SLOT( processSelectionChange() ) ); |
659 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 659 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
660 | SLOT( addQuickTodo() ) ); | 660 | SLOT( addQuickTodo() ) ); |
661 | 661 | ||
662 | } | 662 | } |
663 | 663 | ||
664 | KOTodoView::~KOTodoView() | 664 | KOTodoView::~KOTodoView() |
665 | { | 665 | { |
666 | 666 | ||
667 | #if QT_VERSION >= 0x030000 | 667 | #if QT_VERSION >= 0x030000 |
668 | 668 | ||
669 | #else | 669 | #else |
670 | delete mKOTodoViewWhatsThis; | 670 | delete mKOTodoViewWhatsThis; |
671 | #endif | 671 | #endif |
672 | 672 | ||
673 | delete mDocPrefs; | 673 | delete mDocPrefs; |
674 | } | 674 | } |
675 | QString KOTodoView::getWhatsThisText(QPoint p) | 675 | QString KOTodoView::getWhatsThisText(QPoint p) |
676 | { | 676 | { |
677 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 677 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
678 | if ( item ) | 678 | if ( item ) |
679 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 679 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
680 | KOPrefs::instance()->mWTshowDetails, | 680 | KOPrefs::instance()->mWTshowDetails, |
681 | KOPrefs::instance()->mWTshowCreated, | 681 | KOPrefs::instance()->mWTshowCreated, |
682 | KOPrefs::instance()->mWTshowChanged); | 682 | KOPrefs::instance()->mWTshowChanged); |
683 | return i18n("That is the todo view" ); | 683 | return i18n("That is the todo view" ); |
684 | 684 | ||
685 | } | 685 | } |
686 | 686 | ||
687 | void KOTodoView::jumpToDate () | 687 | void KOTodoView::jumpToDate () |
688 | { | 688 | { |
689 | // if (mActiveItem) { | 689 | // if (mActiveItem) { |
690 | // mActiveItem->todo()); | 690 | // mActiveItem->todo()); |
691 | // if ( mActiveItem->todo()->hasDueDate() ) | 691 | // if ( mActiveItem->todo()->hasDueDate() ) |
692 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 692 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
693 | } | 693 | } |
694 | void KOTodoView::paintNeeded() | 694 | void KOTodoView::paintNeeded() |
695 | { | 695 | { |
696 | if ( mPendingUpdateBeforeRepaint ) { | 696 | if ( mPendingUpdateBeforeRepaint ) { |
697 | updateView(); | 697 | updateView(); |
698 | mPendingUpdateBeforeRepaint = false; | 698 | mPendingUpdateBeforeRepaint = false; |
699 | } | 699 | } |
700 | } | 700 | } |
701 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 701 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
702 | { | 702 | { |
703 | if ( mPendingUpdateBeforeRepaint ) { | 703 | if ( mPendingUpdateBeforeRepaint ) { |
704 | updateView(); | 704 | updateView(); |
705 | mPendingUpdateBeforeRepaint = false; | 705 | mPendingUpdateBeforeRepaint = false; |
706 | } | 706 | } |
707 | KOrg::BaseView::paintEvent( pevent); | 707 | KOrg::BaseView::paintEvent( pevent); |
708 | } | 708 | } |
709 | 709 | ||
710 | void KOTodoView::updateView() | 710 | void KOTodoView::updateView() |
711 | { | 711 | { |
712 | pendingSubtodo = 0; | 712 | pendingSubtodo = 0; |
713 | if ( mBlockUpdate ) { | 713 | if ( mBlockUpdate ) { |
714 | return; | 714 | return; |
715 | } | 715 | } |
716 | if ( !isVisible() ) { | 716 | if ( !isVisible() ) { |
717 | mPendingUpdateBeforeRepaint = true; | 717 | mPendingUpdateBeforeRepaint = true; |
718 | return; | 718 | return; |
719 | } | 719 | } |
720 | storeCurrentItem(); | 720 | storeCurrentItem(); |
721 | //qDebug("KOTodoView::updateView() %x", this); | 721 | //qDebug("KOTodoView::updateView() %x", this); |
722 | if ( isFlatDisplay ) { | 722 | if ( isFlatDisplay ) { |
723 | displayAllFlat(); | 723 | displayAllFlat(); |
724 | resetCurrentItem(); | 724 | resetCurrentItem(); |
725 | return; | 725 | return; |
726 | } | 726 | } |
727 | //qDebug("update "); | 727 | //qDebug("update "); |
728 | // kdDebug() << "KOTodoView::updateView()" << endl; | 728 | // kdDebug() << "KOTodoView::updateView()" << endl; |
729 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 729 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
730 | 730 | ||
731 | 731 | ||
732 | mTodoListView->clear(); | 732 | mTodoListView->clear(); |
733 | if ( mName == "todolistsmall" ) { | 733 | if ( mName == "todolistsmall" ) { |
734 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 734 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
735 | int ps = fo.pointSize() -2; | 735 | int ps = fo.pointSize() -2; |
736 | if ( ps > 12 ) | 736 | if ( ps > 12 ) |
737 | ps -= 2; | 737 | ps -= 2; |
738 | fo.setPointSize( ps ); | 738 | fo.setPointSize( ps ); |
739 | } | 739 | } |
740 | } | 740 | } |
741 | 741 | ||
742 | mTodoListView->setFont( fo ); | 742 | mTodoListView->setFont( fo ); |
743 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 743 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
744 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 744 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
745 | QPtrList<Todo> todoList = calendar()->todos(); | 745 | QPtrList<Todo> todoList = calendar()->todos(); |
746 | 746 | ||
747 | /* | 747 | /* |
748 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 748 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
749 | Event *t; | 749 | Event *t; |
750 | for(t = todoList.first(); t; t = todoList.next()) { | 750 | for(t = todoList.first(); t; t = todoList.next()) { |
751 | kdDebug() << " " << t->getSummary() << endl; | 751 | kdDebug() << " " << t->getSummary() << endl; |
752 | 752 | ||
753 | if (t->getRelatedTo()) { | 753 | if (t->getRelatedTo()) { |
754 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 754 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
755 | } | 755 | } |
756 | 756 | ||
757 | QPtrList<Event> l = t->getRelations(); | 757 | QPtrList<Event> l = t->getRelations(); |
758 | Event *c; | 758 | Event *c; |
759 | for(c=l.first();c;c=l.next()) { | 759 | for(c=l.first();c;c=l.next()) { |
760 | kdDebug() << " - relation: " << c->getSummary() << endl; | 760 | kdDebug() << " - relation: " << c->getSummary() << endl; |
761 | } | 761 | } |
762 | } | 762 | } |
763 | */ | 763 | */ |
764 | 764 | ||
765 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 765 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
766 | // specific order of events. That means that we have to generate parent items | 766 | // specific order of events. That means that we have to generate parent items |
767 | // recursively for proper hierarchical display of Todos. | 767 | // recursively for proper hierarchical display of Todos. |
768 | mTodoMap.clear(); | 768 | mTodoMap.clear(); |
769 | Todo *todo; | 769 | Todo *todo; |
770 | todo = todoList.first();// todo; todo = todoList.next()) { | 770 | todo = todoList.first();// todo; todo = todoList.next()) { |
771 | while ( todo ) { | 771 | while ( todo ) { |
772 | bool next = true; | 772 | bool next = true; |
773 | // qDebug("todo %s ", todo->summary().latin1()); | 773 | // qDebug("todo %s ", todo->summary().latin1()); |
774 | Incidence *incidence = todo->relatedTo(); | 774 | Incidence *incidence = todo->relatedTo(); |
775 | while ( incidence ) { | 775 | while ( incidence ) { |
776 | if ( incidence->typeID() == todoID ) { | 776 | if ( incidence->typeID() == todoID ) { |
777 | //qDebug("related %s ",incidence->summary().latin1() ); | 777 | //qDebug("related %s ",incidence->summary().latin1() ); |
778 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 778 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
779 | //qDebug("related not found "); | 779 | //qDebug("related not found "); |
780 | todoList.remove( ); | 780 | todoList.remove( ); |
781 | todo = todoList.current(); | 781 | todo = todoList.current(); |
782 | next = false; | 782 | next = false; |
783 | incidence = 0; | 783 | incidence = 0; |
784 | 784 | ||
785 | } else { | 785 | } else { |
786 | //qDebug("related found "); | 786 | //qDebug("related found "); |
787 | incidence = incidence->relatedTo(); | 787 | incidence = incidence->relatedTo(); |
788 | } | 788 | } |
789 | } else | 789 | } else |
790 | incidence = 0; | 790 | incidence = 0; |
791 | } | 791 | } |
792 | if ( next ) | 792 | if ( next ) |
793 | todo = todoList.next(); | 793 | todo = todoList.next(); |
794 | } | 794 | } |
795 | 795 | ||
796 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 796 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
797 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 797 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
798 | { | 798 | { |
799 | insertTodoItem(todo); | 799 | insertTodoItem(todo); |
800 | } | 800 | } |
801 | } | 801 | } |
802 | // Restore opened/closed state | 802 | // Restore opened/closed state |
803 | mTodoListView->blockSignals( true ); | 803 | mTodoListView->blockSignals( true ); |
804 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 804 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
805 | mTodoListView->blockSignals( false ); | 805 | mTodoListView->blockSignals( false ); |
806 | resetCurrentItem(); | 806 | resetCurrentItem(); |
807 | processSelectionChange(); | 807 | processSelectionChange(); |
808 | } | 808 | } |
809 | 809 | ||
810 | void KOTodoView::storeCurrentItem() | 810 | void KOTodoView::storeCurrentItem() |
811 | { | 811 | { |
812 | mCurItem = 0; | 812 | mCurItem = 0; |
813 | mCurItemRootParent = 0; | 813 | mCurItemRootParent = 0; |
814 | mCurItemParent = 0; | 814 | mCurItemParent = 0; |
815 | mCurItemAbove = 0; | 815 | mCurItemAbove = 0; |
816 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 816 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
817 | if (mActiveItem) { | 817 | if (mActiveItem) { |
818 | mCurItem = mActiveItem->todo(); | 818 | mCurItem = mActiveItem->todo(); |
819 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 819 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
820 | if ( activeItemAbove ) | 820 | if ( activeItemAbove ) |
821 | mCurItemAbove = activeItemAbove->todo(); | 821 | mCurItemAbove = activeItemAbove->todo(); |
822 | mCurItemRootParent = mCurItem; | 822 | mCurItemRootParent = mCurItem; |
823 | mCurItemParent = mCurItemRootParent->relatedTo(); | 823 | mCurItemParent = mCurItemRootParent->relatedTo(); |
824 | while ( mCurItemRootParent->relatedTo() != 0 ) | 824 | while ( mCurItemRootParent->relatedTo() != 0 ) |
825 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 825 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
826 | } | 826 | } |
827 | mActiveItem = 0; | 827 | mActiveItem = 0; |
828 | } | 828 | } |
829 | 829 | ||
830 | void KOTodoView::resetCurrentItem() | 830 | void KOTodoView::resetCurrentItem() |
831 | { | 831 | { |
832 | mTodoListView->setFocus(); | 832 | mTodoListView->setFocus(); |
833 | KOTodoViewItem* foundItem = 0; | 833 | KOTodoViewItem* foundItem = 0; |
834 | KOTodoViewItem* foundItemRoot = 0; | 834 | KOTodoViewItem* foundItemRoot = 0; |
835 | KOTodoViewItem* foundItemParent = 0; | 835 | KOTodoViewItem* foundItemParent = 0; |
836 | KOTodoViewItem* foundItemAbove = 0; | 836 | KOTodoViewItem* foundItemAbove = 0; |
837 | if ( mTodoListView->firstChild () ) { | 837 | if ( mTodoListView->firstChild () ) { |
838 | if ( mCurItem ) { | 838 | if ( mCurItem ) { |
839 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 839 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
840 | while ( item ) { | 840 | while ( item ) { |
841 | if ( item->todo() == mCurItem ) { | 841 | if ( item->todo() == mCurItem ) { |
842 | foundItem = item; | 842 | foundItem = item; |
843 | break; | 843 | break; |
844 | } else if ( item->todo() == mCurItemAbove ) { | 844 | } else if ( item->todo() == mCurItemAbove ) { |
845 | foundItemAbove = item; | 845 | foundItemAbove = item; |
846 | 846 | ||
847 | } | 847 | } |
848 | if ( item->todo() == mCurItemRootParent ) { | 848 | if ( item->todo() == mCurItemRootParent ) { |
849 | foundItemRoot = item; | 849 | foundItemRoot = item; |
850 | } | 850 | } |
851 | if ( item->todo() == mCurItemParent ) { | 851 | if ( item->todo() == mCurItemParent ) { |
852 | foundItemParent = item; | 852 | foundItemParent = item; |
853 | } | 853 | } |
854 | item = (KOTodoViewItem*)item->itemBelow(); | 854 | item = (KOTodoViewItem*)item->itemBelow(); |
855 | } | 855 | } |
856 | if ( ! foundItem ) { | 856 | if ( ! foundItem ) { |
857 | if ( foundItemParent ) { | 857 | if ( foundItemParent ) { |
858 | foundItem = foundItemParent; | 858 | foundItem = foundItemParent; |
859 | } else { | 859 | } else { |
860 | if ( foundItemRoot ) | 860 | if ( foundItemRoot ) |
861 | foundItem = foundItemRoot; | 861 | foundItem = foundItemRoot; |
862 | else | 862 | else |
863 | foundItem = foundItemAbove; | 863 | foundItem = foundItemAbove; |
864 | } | 864 | } |
865 | } | 865 | } |
866 | } | 866 | } |
867 | if ( foundItem ) { | 867 | if ( foundItem ) { |
868 | mTodoListView->setCurrentItem( foundItem ); | 868 | mTodoListView->setCurrentItem( foundItem ); |
869 | mTodoListView->ensureItemVisible( foundItem ); | 869 | mTodoListView->ensureItemVisible( foundItem ); |
870 | } else { | 870 | } else { |
871 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 871 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
872 | } | 872 | } |
873 | } | 873 | } |
874 | mTodoListView->setFocus(); | 874 | mTodoListView->setFocus(); |
875 | } | 875 | } |
876 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 876 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
877 | bool KOTodoView::checkTodo( Todo * todo ) | 877 | bool KOTodoView::checkTodo( Todo * todo ) |
878 | { | 878 | { |
879 | 879 | ||
880 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 880 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
881 | return false; | 881 | return false; |
882 | if ( !todo->isCompleted() ) { | 882 | if ( !todo->isCompleted() ) { |
883 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 883 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
884 | return true; | 884 | return true; |
885 | } | 885 | } |
886 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 886 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
887 | if ( todo->hasStartDate() ) | 887 | if ( todo->hasStartDate() ) |
888 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 888 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
889 | return false; | 889 | return false; |
890 | if ( todo->hasDueDate() ) | 890 | if ( todo->hasDueDate() ) |
891 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 891 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
892 | return false; | 892 | return false; |
893 | } | 893 | } |
894 | return true; | 894 | return true; |
895 | } | 895 | } |
896 | 896 | ||
897 | void KOTodoView::restoreItemState( QListViewItem *item ) | 897 | void KOTodoView::restoreItemState( QListViewItem *item ) |
898 | { | 898 | { |
899 | pendingSubtodo = 0; | 899 | pendingSubtodo = 0; |
900 | while( item ) { | 900 | while( item ) { |
901 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 901 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
902 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 902 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
903 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 903 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
904 | item = item->nextSibling(); | 904 | item = item->nextSibling(); |
905 | } | 905 | } |
906 | } | 906 | } |
907 | 907 | ||
908 | 908 | ||
909 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 909 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
910 | KOTodoView::insertTodoItem(Todo *todo) | 910 | KOTodoView::insertTodoItem(Todo *todo) |
911 | { | 911 | { |
912 | 912 | ||
913 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 913 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
914 | // TODO: Check, if dynmaic cast is necessary | 914 | // TODO: Check, if dynmaic cast is necessary |
915 | 915 | ||
916 | pendingSubtodo = 0; | 916 | pendingSubtodo = 0; |
917 | Incidence *incidence = todo->relatedTo(); | 917 | Incidence *incidence = todo->relatedTo(); |
918 | while ( incidence && !incidence->calEnabled() ) | 918 | while ( incidence && !incidence->calEnabled() ) |
919 | incidence = incidence->relatedTo(); | 919 | incidence = incidence->relatedTo(); |
920 | if (incidence && incidence->typeID() == todoID ) { | 920 | if (incidence && incidence->typeID() == todoID ) { |
921 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 921 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
922 | 922 | ||
923 | // kdDebug() << " has Related" << endl; | 923 | // kdDebug() << " has Related" << endl; |
924 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 924 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
925 | itemIterator = mTodoMap.find(relatedTodo); | 925 | itemIterator = mTodoMap.find(relatedTodo); |
926 | if (itemIterator == mTodoMap.end()) { | 926 | if (itemIterator == mTodoMap.end()) { |
927 | // kdDebug() << " related not yet in list" << endl; | 927 | // kdDebug() << " related not yet in list" << endl; |
928 | itemIterator = insertTodoItem (relatedTodo); | 928 | itemIterator = insertTodoItem (relatedTodo); |
929 | } | 929 | } |
930 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 930 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
931 | // and one into the map. Sure finding is more easy but why? -zecke | 931 | // and one into the map. Sure finding is more easy but why? -zecke |
932 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 932 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
933 | return mTodoMap.insert(todo,todoItem); | 933 | return mTodoMap.insert(todo,todoItem); |
934 | } else { | 934 | } else { |
935 | // kdDebug() << " no Related" << endl; | 935 | // kdDebug() << " no Related" << endl; |
936 | // see above -zecke | 936 | // see above -zecke |
937 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 937 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
938 | return mTodoMap.insert(todo,todoItem); | 938 | return mTodoMap.insert(todo,todoItem); |
939 | } | 939 | } |
940 | } | 940 | } |
941 | 941 | ||
942 | 942 | ||
943 | void KOTodoView::updateConfig() | 943 | void KOTodoView::updateConfig() |
944 | { | 944 | { |
945 | updateView(); | 945 | updateView(); |
946 | mTodoListView->repaintContents(); | 946 | mTodoListView->repaintContents(); |
947 | } | 947 | } |
948 | 948 | ||
949 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 949 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
950 | { | 950 | { |
951 | QPtrList<Incidence> selected; | 951 | QPtrList<Incidence> selected; |
952 | 952 | ||
953 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 953 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
954 | // if (!item) item = mActiveItem; | 954 | // if (!item) item = mActiveItem; |
955 | if (item) selected.append(item->todo()); | 955 | if (item) selected.append(item->todo()); |
956 | 956 | ||
957 | return selected; | 957 | return selected; |
958 | } | 958 | } |
959 | 959 | ||
960 | QPtrList<Todo> KOTodoView::selectedTodos() | 960 | QPtrList<Todo> KOTodoView::selectedTodos() |
961 | { | 961 | { |
962 | QPtrList<Todo> selected; | 962 | QPtrList<Todo> selected; |
963 | 963 | ||
964 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 964 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
965 | // if (!item) item = mActiveItem; | 965 | // if (!item) item = mActiveItem; |
966 | if (item) selected.append(item->todo()); | 966 | if (item) selected.append(item->todo()); |
967 | 967 | ||
968 | return selected; | 968 | return selected; |
969 | } | 969 | } |
970 | 970 | ||
971 | void KOTodoView::changeEventDisplay(Event *, int) | 971 | void KOTodoView::changeEventDisplay(Event *, int) |
972 | { | 972 | { |
973 | updateView(); | 973 | updateView(); |
974 | } | 974 | } |
975 | 975 | ||
976 | void KOTodoView::showDates(const QDate &, const QDate &) | 976 | void KOTodoView::showDates(const QDate &, const QDate &) |
977 | { | 977 | { |
978 | } | 978 | } |
979 | 979 | ||
980 | void KOTodoView::showEvents(QPtrList<Event>) | 980 | void KOTodoView::showEvents(QPtrList<Event>) |
981 | { | 981 | { |
982 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 982 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
983 | } | 983 | } |
984 | 984 | ||
985 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 985 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
986 | const QDate &td) | 986 | const QDate &td) |
987 | { | 987 | { |
988 | #ifndef KORG_NOPRINTER | 988 | #ifndef KORG_NOPRINTER |
989 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 989 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
990 | #endif | 990 | #endif |
991 | } | 991 | } |
992 | 992 | ||
993 | void KOTodoView::editItem(QListViewItem *item ) | 993 | void KOTodoView::editItem(QListViewItem *item ) |
994 | { | 994 | { |
995 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 995 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
996 | } | 996 | } |
997 | 997 | ||
998 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 998 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
999 | { | 999 | { |
1000 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 1000 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 1003 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
1004 | { | 1004 | { |
1005 | pendingSubtodo = 0; | 1005 | pendingSubtodo = 0; |
1006 | mActiveItem = (KOTodoViewItem *)item; | 1006 | mActiveItem = (KOTodoViewItem *)item; |
1007 | if (item) { | 1007 | if (item) { |
1008 | switch (column){ | 1008 | switch (column){ |
1009 | case 1: | 1009 | case 1: |
1010 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 1010 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
1011 | case 2: | 1011 | case 2: |
1012 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 1012 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
1013 | case 3: | 1013 | case 3: |
1014 | moveTodo(); | 1014 | moveTodo(); |
1015 | break; | 1015 | break; |
1016 | case 8: | 1016 | case 8: |
1017 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 1017 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
1018 | default: | 1018 | default: |
1019 | mItemPopupMenu->popup(QCursor::pos()); | 1019 | mItemPopupMenu->popup(QCursor::pos()); |
1020 | } | 1020 | } |
1021 | } else mPopupMenu->popup(QCursor::pos()); | 1021 | } else mPopupMenu->popup(QCursor::pos()); |
1022 | } | 1022 | } |
1023 | void KOTodoView::newTodo() | 1023 | void KOTodoView::newTodo() |
1024 | { | 1024 | { |
1025 | emit newTodoSignal(); | 1025 | emit newTodoSignal(); |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | void KOTodoView::newSubTodo() | 1028 | void KOTodoView::newSubTodo() |
1029 | { | 1029 | { |
1030 | if (mActiveItem) { | 1030 | if (mActiveItem) { |
1031 | emit newSubTodoSignal(mActiveItem->todo()); | 1031 | emit newSubTodoSignal(mActiveItem->todo()); |
1032 | } | 1032 | } |
1033 | } | 1033 | } |
1034 | void KOTodoView::unparentTodo() | 1034 | void KOTodoView::unparentTodo() |
1035 | { | 1035 | { |
1036 | if (mActiveItem) { | 1036 | if (mActiveItem) { |
1037 | emit unparentTodoSignal(mActiveItem->todo()); | 1037 | emit unparentTodoSignal(mActiveItem->todo()); |
1038 | } | 1038 | } |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | void KOTodoView::reparentTodo() | 1041 | void KOTodoView::reparentTodo() |
1042 | { | 1042 | { |
1043 | if (mActiveItem) { | 1043 | if (mActiveItem) { |
1044 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 1044 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
1045 | pendingSubtodo = mActiveItem; | 1045 | pendingSubtodo = mActiveItem; |
1046 | } | 1046 | } |
1047 | } | 1047 | } |
1048 | void KOTodoView::editTodo() | 1048 | void KOTodoView::editTodo() |
1049 | { | 1049 | { |
1050 | if (mActiveItem) { | 1050 | if (mActiveItem) { |
1051 | emit editTodoSignal(mActiveItem->todo()); | 1051 | emit editTodoSignal(mActiveItem->todo()); |
1052 | } | 1052 | } |
1053 | } | 1053 | } |
1054 | void KOTodoView::cloneTodo() | 1054 | void KOTodoView::cloneTodo() |
1055 | { | 1055 | { |
1056 | if (mActiveItem) { | 1056 | if (mActiveItem) { |
1057 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 1057 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | void KOTodoView::cancelTodo() | 1060 | void KOTodoView::cancelTodo() |
1061 | { | 1061 | { |
1062 | if (mActiveItem) { | 1062 | if (mActiveItem) { |
1063 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 1063 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
1064 | } | 1064 | } |
1065 | } | 1065 | } |
1066 | void KOTodoView::moveTodo() | 1066 | void KOTodoView::moveTodo() |
1067 | { | 1067 | { |
1068 | if (mActiveItem) { | 1068 | if (mActiveItem) { |
1069 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 1069 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
1070 | } | 1070 | } |
1071 | } | 1071 | } |
1072 | void KOTodoView::beamTodo() | 1072 | void KOTodoView::beamTodo() |
1073 | { | 1073 | { |
1074 | if (mActiveItem) { | 1074 | if (mActiveItem) { |
1075 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 1075 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
1076 | } | 1076 | } |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | 1079 | ||
1080 | void KOTodoView::showTodo() | 1080 | void KOTodoView::showTodo() |
1081 | { | 1081 | { |
1082 | if (mActiveItem) { | 1082 | if (mActiveItem) { |
1083 | emit showTodoSignal(mActiveItem->todo()); | 1083 | emit showTodoSignal(mActiveItem->todo()); |
1084 | } | 1084 | } |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | void KOTodoView::deleteTodo() | 1087 | void KOTodoView::deleteTodo() |
1088 | { | 1088 | { |
1089 | if (mActiveItem) { | 1089 | if (mActiveItem) { |
1090 | emit deleteTodoSignal(mActiveItem->todo()); | 1090 | emit deleteTodoSignal(mActiveItem->todo()); |
1091 | } | 1091 | } |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | void KOTodoView::setNewPriority(int index) | 1094 | void KOTodoView::setNewPriority(int index) |
1095 | { | 1095 | { |
1096 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1096 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1097 | mActiveItem->todo()->setPriority(mPriority[index]); | 1097 | mActiveItem->todo()->setPriority(mPriority[index]); |
1098 | mActiveItem->construct(); | 1098 | mActiveItem->construct(); |
1099 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1099 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1100 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1100 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1101 | } | 1101 | } |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | void KOTodoView::setNewPercentage(int index) | 1104 | void KOTodoView::setNewPercentage(int index) |
1105 | { | 1105 | { |
1106 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1106 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1107 | 1107 | ||
1108 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1108 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1109 | mActiveItem->setOn( true ); | 1109 | mActiveItem->setOn( true ); |
1110 | return; | 1110 | return; |
1111 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1111 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1112 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1112 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1113 | if ( par && par->isOn() ) | 1113 | if ( par && par->isOn() ) |
1114 | par->setOn( false ); | 1114 | par->setOn( false ); |
1115 | } | 1115 | } |
1116 | if (mPercentage[index] == 100) { | 1116 | if (mPercentage[index] == 100) { |
1117 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1117 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1118 | } else { | 1118 | } else { |
1119 | mActiveItem->todo()->setCompleted(false); | 1119 | mActiveItem->todo()->setCompleted(false); |
1120 | } | 1120 | } |
1121 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1121 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1122 | mActiveItem->construct(); | 1122 | mActiveItem->construct(); |
1123 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1123 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1124 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1124 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | 1128 | ||
1129 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 1129 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
1130 | { | 1130 | { |
1131 | QPopupMenu* tempMenu = new QPopupMenu (this); | 1131 | QPopupMenu* tempMenu = new QPopupMenu (this); |
1132 | QStringList checkedCategories = todoItem->todo()->categories (); | 1132 | QStringList checkedCategories = todoItem->todo()->categories (); |
1133 | 1133 | ||
1134 | tempMenu->setCheckable (true); | 1134 | tempMenu->setCheckable (true); |
1135 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1135 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1136 | it != KOPrefs::instance()->mCustomCategories.end (); | 1136 | it != KOPrefs::instance()->mCustomCategories.end (); |
1137 | ++it) { | 1137 | ++it) { |
1138 | int index = tempMenu->insertItem (*it); | 1138 | int index = tempMenu->insertItem (*it); |
1139 | mCategory[index] = *it; | 1139 | mCategory[index] = *it; |
1140 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 1140 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 1143 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
1144 | return tempMenu; | 1144 | return tempMenu; |
1145 | 1145 | ||
1146 | 1146 | ||
1147 | } | 1147 | } |
1148 | void KOTodoView::changedCategories(int index) | 1148 | void KOTodoView::changedCategories(int index) |
1149 | { | 1149 | { |
1150 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1150 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1151 | QStringList categories = mActiveItem->todo()->categories (); | 1151 | QStringList categories = mActiveItem->todo()->categories (); |
1152 | QString colcat = categories.first(); | 1152 | QString colcat = categories.first(); |
1153 | if (categories.find (mCategory[index]) != categories.end ()) | 1153 | if (categories.find (mCategory[index]) != categories.end ()) |
1154 | categories.remove (mCategory[index]); | 1154 | categories.remove (mCategory[index]); |
1155 | else | 1155 | else |
1156 | categories.insert (categories.end(), mCategory[index]); | 1156 | categories.insert (categories.end(), mCategory[index]); |
1157 | categories.sort (); | 1157 | categories.sort (); |
1158 | if ( !colcat.isEmpty() ) { | 1158 | if ( !colcat.isEmpty() ) { |
1159 | if ( categories.find ( colcat ) != categories.end () ) { | 1159 | if ( categories.find ( colcat ) != categories.end () ) { |
1160 | categories.remove( colcat ); | 1160 | categories.remove( colcat ); |
1161 | categories.prepend( colcat ); | 1161 | categories.prepend( colcat ); |
1162 | } | 1162 | } |
1163 | } | 1163 | } |
1164 | mActiveItem->todo()->setCategories (categories); | 1164 | mActiveItem->todo()->setCategories (categories); |
1165 | mActiveItem->construct(); | 1165 | mActiveItem->construct(); |
1166 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1166 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1167 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1167 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1168 | } | 1168 | } |
1169 | } | 1169 | } |
1170 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1170 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1171 | { | 1171 | { |
1172 | if ( pendingSubtodo != 0 ) { | 1172 | if ( pendingSubtodo != 0 ) { |
1173 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1173 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1174 | } | 1174 | } |
1175 | pendingSubtodo = 0; | 1175 | pendingSubtodo = 0; |
1176 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1176 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1177 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1177 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1178 | //qDebug("ROW %d ", row); | 1178 | //qDebug("ROW %d ", row); |
1179 | if (!item) { | 1179 | if (!item) { |
1180 | newTodo(); | 1180 | newTodo(); |
1181 | return; | 1181 | return; |
1182 | } else { | 1182 | } else { |
1183 | if ( row == 2 || row == 1 ) { | 1183 | if ( row == 1 ) { |
1184 | mActiveItem = (KOTodoViewItem *) item; | 1184 | mActiveItem = (KOTodoViewItem *) item; |
1185 | newSubTodo(); | 1185 | newSubTodo(); |
1186 | return; | 1186 | return; |
1187 | } | 1187 | } |
1188 | if ( row == 5 || row == 6 ) { | 1188 | if ( row == 5 || row == 6 || row == 2) { |
1189 | mActiveItem = (KOTodoViewItem *) item; | 1189 | mActiveItem = (KOTodoViewItem *) item; |
1190 | toggleRunningItem(); | 1190 | Todo * t = mActiveItem->todo(); |
1191 | return; | 1191 | if ( t->isRunning() ) { |
1192 | if ( t->runTime() < 15) { | ||
1193 | t->stopRunning(); | ||
1194 | mActiveItem->construct(); | ||
1195 | return; | ||
1196 | } | ||
1197 | else | ||
1198 | toggleRunningItem(); | ||
1199 | return; | ||
1200 | } else { | ||
1201 | t->setRunning( true ); | ||
1202 | mActiveItem->construct(); | ||
1203 | return; | ||
1204 | } | ||
1192 | } | 1205 | } |
1193 | } | 1206 | } |
1194 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1207 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1195 | editItem( item ); | 1208 | editItem( item ); |
1196 | else | 1209 | else |
1197 | showItem( item , QPoint(), 0 ); | 1210 | showItem( item , QPoint(), 0 ); |
1198 | } | 1211 | } |
1199 | void KOTodoView::toggleRunningItem() | 1212 | void KOTodoView::toggleRunningItem() |
1200 | { | 1213 | { |
1201 | // qDebug("KOTodoView::toggleRunning() "); | 1214 | // qDebug("KOTodoView::toggleRunning() "); |
1202 | if ( ! mActiveItem ) | 1215 | if ( ! mActiveItem ) |
1203 | return; | 1216 | return; |
1204 | Todo * t = mActiveItem->todo(); | 1217 | Todo * t = mActiveItem->todo(); |
1205 | if ( t->isRunning() ) { | 1218 | if ( t->isRunning() ) { |
1206 | KOStopTodoPrefs tp ( t, this ); | 1219 | KOStopTodoPrefs tp ( t, this ); |
1207 | if (QApplication::desktop()->width() < 800 ){ | 1220 | if (QApplication::desktop()->width() < 800 ){ |
1208 | int wid = tp.width(); | 1221 | int wid = tp.width(); |
1209 | int hei = tp.height(); | 1222 | int hei = tp.height(); |
1210 | int xx = (QApplication::desktop()->width()-wid)/2; | 1223 | int xx = (QApplication::desktop()->width()-wid)/2; |
1211 | int yy = (QApplication::desktop()->height()-hei)/2; | 1224 | int yy = (QApplication::desktop()->height()-hei)/2; |
1212 | tp.setGeometry( xx,yy,wid,hei ); | 1225 | tp.setGeometry( xx,yy,wid,hei ); |
1213 | } | 1226 | } |
1214 | tp.exec(); | 1227 | tp.exec(); |
1215 | mActiveItem->construct(); | 1228 | mActiveItem->construct(); |
1216 | } else { | 1229 | } else { |
1217 | int result = KMessageBox::warningContinueCancel(this, | 1230 | int result = KMessageBox::warningContinueCancel(this, |
1218 | i18n("<center>%1</center> <center>is not running. Do you want to set\nthe state to running?</center>").arg(mActiveItem->text(0).left( 25 ) ),i18n("Start todo"),i18n("Start todo"),i18n("Cancel"), true); | 1231 | i18n("<center>%1</center> <center>is not running. Do you want to set\nthe state to running?</center>").arg(mActiveItem->text(0).left( 25 ) ),i18n("Start todo"),i18n("Start todo"),i18n("Cancel"), true); |
1219 | if (result != KMessageBox::Continue) return; | 1232 | if (result != KMessageBox::Continue) return; |
1220 | t->setRunning( true ); | 1233 | t->setRunning( true ); |
1221 | mActiveItem->construct(); | 1234 | mActiveItem->construct(); |
1222 | } | 1235 | } |
1223 | } | 1236 | } |
1224 | 1237 | ||
1225 | void KOTodoView::itemClicked(QListViewItem *item) | 1238 | void KOTodoView::itemClicked(QListViewItem *item) |
1226 | { | 1239 | { |
1227 | //qDebug("KOTodoView::itemClicked %d", item); | 1240 | //qDebug("KOTodoView::itemClicked %d", item); |
1228 | if (!item) { | 1241 | if (!item) { |
1229 | if ( pendingSubtodo != 0 ) { | 1242 | if ( pendingSubtodo != 0 ) { |
1230 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1243 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1231 | } | 1244 | } |
1232 | pendingSubtodo = 0; | 1245 | pendingSubtodo = 0; |
1233 | return; | 1246 | return; |
1234 | } | 1247 | } |
1235 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1248 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1236 | if ( pendingSubtodo != 0 ) { | 1249 | if ( pendingSubtodo != 0 ) { |
1237 | bool allowReparent = true; | 1250 | bool allowReparent = true; |
1238 | QListViewItem *par = item; | 1251 | QListViewItem *par = item; |
1239 | while ( par ) { | 1252 | while ( par ) { |
1240 | if ( par == pendingSubtodo ) { | 1253 | if ( par == pendingSubtodo ) { |
1241 | allowReparent = false; | 1254 | allowReparent = false; |
1242 | break; | 1255 | break; |
1243 | } | 1256 | } |
1244 | par = par->parent(); | 1257 | par = par->parent(); |
1245 | } | 1258 | } |
1246 | if ( !allowReparent ) { | 1259 | if ( !allowReparent ) { |
1247 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1260 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1248 | pendingSubtodo = 0; | 1261 | pendingSubtodo = 0; |
1249 | } else { | 1262 | } else { |
1250 | Todo* newParent = todoItem->todo(); | 1263 | Todo* newParent = todoItem->todo(); |
1251 | Todo* newSub = pendingSubtodo->todo(); | 1264 | Todo* newSub = pendingSubtodo->todo(); |
1252 | pendingSubtodo = 0; | 1265 | pendingSubtodo = 0; |
1253 | emit reparentTodoSignal( newParent,newSub ); | 1266 | emit reparentTodoSignal( newParent,newSub ); |
1254 | return; | 1267 | return; |
1255 | } | 1268 | } |
1256 | } | 1269 | } |
1257 | 1270 | ||
1258 | } | 1271 | } |
1259 | 1272 | ||
1260 | void KOTodoView::setDocumentId( const QString &id ) | 1273 | void KOTodoView::setDocumentId( const QString &id ) |
1261 | { | 1274 | { |
1262 | 1275 | ||
1263 | mDocPrefs->setDoc( id ); | 1276 | mDocPrefs->setDoc( id ); |
1264 | } | 1277 | } |
1265 | 1278 | ||
1266 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1279 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1267 | { | 1280 | { |
1268 | if (!item) return; | 1281 | if (!item) return; |
1269 | 1282 | ||
1270 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1283 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1271 | 1284 | ||
1272 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1285 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1273 | 1286 | ||
1274 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1287 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1275 | } | 1288 | } |
1276 | 1289 | ||
1277 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1290 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1278 | { | 1291 | { |
1279 | mTodoListView->saveLayout(config,group); | 1292 | mTodoListView->saveLayout(config,group); |
1280 | } | 1293 | } |
1281 | 1294 | ||
1282 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1295 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1283 | { | 1296 | { |
1284 | mTodoListView->restoreLayout(config,group); | 1297 | mTodoListView->restoreLayout(config,group); |
1285 | } | 1298 | } |
1286 | 1299 | ||
1287 | void KOTodoView::processSelectionChange() | 1300 | void KOTodoView::processSelectionChange() |
1288 | { | 1301 | { |
1289 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1302 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1290 | 1303 | ||
1291 | KOTodoViewItem *item = | 1304 | KOTodoViewItem *item = |
1292 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1305 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1293 | 1306 | ||
1294 | if ( !item ) { | 1307 | if ( !item ) { |
1295 | emit incidenceSelected( 0 ); | 1308 | emit incidenceSelected( 0 ); |
1296 | } else { | 1309 | } else { |
1297 | emit incidenceSelected( item->todo() ); | 1310 | emit incidenceSelected( item->todo() ); |
1298 | } | 1311 | } |
1299 | } | 1312 | } |
1300 | 1313 | ||
1301 | void KOTodoView::modified(bool b) | 1314 | void KOTodoView::modified(bool b) |
1302 | { | 1315 | { |
1303 | emit isModified(b); | 1316 | emit isModified(b); |
1304 | } | 1317 | } |
1305 | void KOTodoView::setTodoModified( Todo* todo ) | 1318 | void KOTodoView::setTodoModified( Todo* todo ) |
1306 | { | 1319 | { |
1307 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1320 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1308 | } | 1321 | } |
1309 | void KOTodoView::clearSelection() | 1322 | void KOTodoView::clearSelection() |
1310 | { | 1323 | { |
1311 | mTodoListView->selectAll( false ); | 1324 | mTodoListView->selectAll( false ); |
1312 | } | 1325 | } |
1313 | void KOTodoView::setAllOpen() | 1326 | void KOTodoView::setAllOpen() |
1314 | { | 1327 | { |
1315 | if ( isFlatDisplay ) { | 1328 | if ( isFlatDisplay ) { |
1316 | isFlatDisplay = false; | 1329 | isFlatDisplay = false; |
1317 | mPopupMenu->setItemChecked( 8,false ); | 1330 | mPopupMenu->setItemChecked( 8,false ); |
1318 | updateView(); | 1331 | updateView(); |
1319 | } else { | 1332 | } else { |
1320 | storeCurrentItem(); | 1333 | storeCurrentItem(); |
1321 | } | 1334 | } |
1322 | setOpen(mTodoListView->firstChild(), true); | 1335 | setOpen(mTodoListView->firstChild(), true); |
1323 | resetCurrentItem(); | 1336 | resetCurrentItem(); |
1324 | } | 1337 | } |
1325 | void KOTodoView::setAllClose() | 1338 | void KOTodoView::setAllClose() |
1326 | { | 1339 | { |
1327 | if ( isFlatDisplay ) { | 1340 | if ( isFlatDisplay ) { |
1328 | isFlatDisplay = false; | 1341 | isFlatDisplay = false; |
1329 | mPopupMenu->setItemChecked( 8,false ); | 1342 | mPopupMenu->setItemChecked( 8,false ); |
1330 | updateView(); | 1343 | updateView(); |
1331 | } else { | 1344 | } else { |
1332 | storeCurrentItem(); | 1345 | storeCurrentItem(); |
1333 | } | 1346 | } |
1334 | setOpen(mTodoListView->firstChild(), false); | 1347 | setOpen(mTodoListView->firstChild(), false); |
1335 | resetCurrentItem(); | 1348 | resetCurrentItem(); |
1336 | } | 1349 | } |
1337 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1350 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1338 | { | 1351 | { |
1339 | 1352 | ||
1340 | while ( item ) { | 1353 | while ( item ) { |
1341 | setOpen( item->firstChild(), setOpenI ); | 1354 | setOpen( item->firstChild(), setOpenI ); |
1342 | item->setOpen( setOpenI ); | 1355 | item->setOpen( setOpenI ); |
1343 | item = item->nextSibling(); | 1356 | item = item->nextSibling(); |
1344 | } | 1357 | } |
1345 | } | 1358 | } |
1346 | 1359 | ||
1347 | void KOTodoView::displayAllFlat() | 1360 | void KOTodoView::displayAllFlat() |
1348 | { | 1361 | { |
1349 | pendingSubtodo = 0; | 1362 | pendingSubtodo = 0; |
1350 | if ( mBlockUpdate ) { | 1363 | if ( mBlockUpdate ) { |
1351 | return; | 1364 | return; |
1352 | } | 1365 | } |
1353 | mPopupMenu->setItemChecked( 8,true ); | 1366 | mPopupMenu->setItemChecked( 8,true ); |
1354 | isFlatDisplay = true; | 1367 | isFlatDisplay = true; |
1355 | QPtrList<Todo> todoList = calendar()->todos(); | 1368 | QPtrList<Todo> todoList = calendar()->todos(); |
1356 | mTodoMap.clear(); | 1369 | mTodoMap.clear(); |
1357 | mTodoListView->clear(); | 1370 | mTodoListView->clear(); |
1358 | Todo *todo; | 1371 | Todo *todo; |
1359 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1372 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1360 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1373 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1361 | mTodoMap.insert(todo,todoItem); | 1374 | mTodoMap.insert(todo,todoItem); |
1362 | } | 1375 | } |
1363 | mTodoListView->setFocus(); | 1376 | mTodoListView->setFocus(); |
1364 | processSelectionChange(); | 1377 | processSelectionChange(); |
1365 | } | 1378 | } |
1366 | 1379 | ||
1367 | void KOTodoView::setAllFlat() | 1380 | void KOTodoView::setAllFlat() |
1368 | { | 1381 | { |
1369 | if ( isFlatDisplay ) { | 1382 | if ( isFlatDisplay ) { |
1370 | isFlatDisplay = false; | 1383 | isFlatDisplay = false; |
1371 | mPopupMenu->setItemChecked( 8,false ); | 1384 | mPopupMenu->setItemChecked( 8,false ); |
1372 | updateView(); | 1385 | updateView(); |
1373 | return; | 1386 | return; |
1374 | } | 1387 | } |
1375 | storeCurrentItem(); | 1388 | storeCurrentItem(); |
1376 | displayAllFlat(); | 1389 | displayAllFlat(); |
1377 | resetCurrentItem(); | 1390 | resetCurrentItem(); |
1378 | } | 1391 | } |
1379 | 1392 | ||
1380 | void KOTodoView::purgeCompleted() | 1393 | void KOTodoView::purgeCompleted() |
1381 | { | 1394 | { |
1382 | emit purgeCompletedSignal(); | 1395 | emit purgeCompletedSignal(); |
1383 | 1396 | ||
1384 | } | 1397 | } |
1385 | void KOTodoView::toggleQuickTodo() | 1398 | void KOTodoView::toggleQuickTodo() |
1386 | { | 1399 | { |
1387 | if ( mQuickAdd->isVisible() ) { | 1400 | if ( mQuickAdd->isVisible() ) { |
1388 | mQuickAdd->hide(); | 1401 | mQuickAdd->hide(); |
1389 | KOPrefs::instance()->mEnableQuickTodo = false; | 1402 | KOPrefs::instance()->mEnableQuickTodo = false; |
1390 | } | 1403 | } |
1391 | else { | 1404 | else { |
1392 | mQuickAdd->show(); | 1405 | mQuickAdd->show(); |
1393 | KOPrefs::instance()->mEnableQuickTodo = true; | 1406 | KOPrefs::instance()->mEnableQuickTodo = true; |
1394 | } | 1407 | } |
1395 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1408 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1396 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1409 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1397 | } | 1410 | } |
1398 | 1411 | ||
1399 | void KOTodoView::toggleRunning() | 1412 | void KOTodoView::toggleRunning() |
1400 | { | 1413 | { |
1401 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1414 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1402 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1415 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1403 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1416 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1404 | updateView(); | 1417 | updateView(); |
1405 | } | 1418 | } |
1406 | 1419 | ||
1407 | void KOTodoView::toggleCompleted() | 1420 | void KOTodoView::toggleCompleted() |
1408 | { | 1421 | { |
1409 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1422 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1410 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1423 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1411 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1424 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1412 | updateView(); | 1425 | updateView(); |
1413 | } | 1426 | } |
1414 | 1427 | ||
1415 | void KOTodoView::addQuickTodo() | 1428 | void KOTodoView::addQuickTodo() |
1416 | { | 1429 | { |
1417 | Todo *todo = new Todo(); | 1430 | Todo *todo = new Todo(); |
1418 | todo->setSummary(mQuickAdd->text()); | 1431 | todo->setSummary(mQuickAdd->text()); |
1419 | todo->setOrganizer(KOPrefs::instance()->email()); | 1432 | todo->setOrganizer(KOPrefs::instance()->email()); |
1420 | CalFilter * cf = mCalendar->filter(); | 1433 | CalFilter * cf = mCalendar->filter(); |
1421 | if ( cf ) { | 1434 | if ( cf ) { |
1422 | if ( cf->isEnabled()&& cf->showCategories()) { | 1435 | if ( cf->isEnabled()&& cf->showCategories()) { |
1423 | todo->setCategories(cf->categoryList()); | 1436 | todo->setCategories(cf->categoryList()); |
1424 | } | 1437 | } |
1425 | if ( cf->isEnabled() ) | 1438 | if ( cf->isEnabled() ) |
1426 | todo->setSecrecy( cf->getSecrecy()); | 1439 | todo->setSecrecy( cf->getSecrecy()); |
1427 | } | 1440 | } |
1428 | mCalendar->addTodo(todo); | 1441 | mCalendar->addTodo(todo); |
1429 | mQuickAdd->setText(""); | 1442 | mQuickAdd->setText(""); |
1430 | todoModified (todo, KOGlobals::EVENTADDED ); | 1443 | todoModified (todo, KOGlobals::EVENTADDED ); |
1431 | updateView(); | 1444 | updateView(); |
1432 | } | 1445 | } |
1433 | 1446 | ||
1434 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1447 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1435 | { | 1448 | { |
1436 | // e->ignore(); | 1449 | // e->ignore(); |
1437 | //return; | 1450 | //return; |
1438 | //qDebug("KOTodoView::keyPressEvent "); | 1451 | //qDebug("KOTodoView::keyPressEvent "); |
1439 | switch ( e->key() ) { | 1452 | switch ( e->key() ) { |
1440 | case Qt::Key_Down: | 1453 | case Qt::Key_Down: |
1441 | case Qt::Key_Up: | 1454 | case Qt::Key_Up: |
1442 | QWidget::keyPressEvent ( e ); | 1455 | QWidget::keyPressEvent ( e ); |
1443 | break; | 1456 | break; |
1444 | 1457 | ||
1445 | case Qt::Key_Q: | 1458 | case Qt::Key_Q: |
1446 | toggleQuickTodo(); | 1459 | toggleQuickTodo(); |
1447 | break; | 1460 | break; |
1448 | case Qt::Key_U: | 1461 | case Qt::Key_U: |
1449 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1462 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1450 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1463 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1451 | unparentTodo(); | 1464 | unparentTodo(); |
1452 | e->accept(); | 1465 | e->accept(); |
1453 | } else | 1466 | } else |
1454 | e->ignore(); | 1467 | e->ignore(); |
1455 | break; | 1468 | break; |
1456 | case Qt::Key_S: | 1469 | case Qt::Key_S: |
1457 | if ( e->state() == Qt::ControlButton ) { | 1470 | if ( e->state() == Qt::ControlButton ) { |
1458 | e->ignore(); | 1471 | e->ignore(); |
1459 | break; | 1472 | break; |
1460 | } | 1473 | } |
1461 | if ( e->state() == Qt::ShiftButton ) { | 1474 | if ( e->state() == Qt::ShiftButton ) { |
1462 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1475 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1463 | reparentTodo(); | 1476 | reparentTodo(); |
1464 | e->accept(); | 1477 | e->accept(); |
1465 | } else | 1478 | } else |
1466 | e->ignore(); | 1479 | e->ignore(); |
1467 | break; | 1480 | break; |
1468 | case Qt::Key_P: | 1481 | case Qt::Key_P: |
1469 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1482 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1470 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1483 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1471 | if ( pendingSubtodo ) | 1484 | if ( pendingSubtodo ) |
1472 | itemClicked(mActiveItem); | 1485 | itemClicked(mActiveItem); |
1473 | e->accept(); | 1486 | e->accept(); |
1474 | } else | 1487 | } else |
1475 | e->ignore(); | 1488 | e->ignore(); |
1476 | break; | 1489 | break; |
1477 | case Qt::Key_Escape: | 1490 | case Qt::Key_Escape: |
1478 | if ( pendingSubtodo ) { | 1491 | if ( pendingSubtodo ) { |
1479 | itemClicked(0); | 1492 | itemClicked(0); |
1480 | e->accept(); | 1493 | e->accept(); |
1481 | } else | 1494 | } else |
1482 | e->ignore(); | 1495 | e->ignore(); |
1483 | break; | 1496 | break; |
1484 | default: | 1497 | default: |
1485 | e->ignore(); | 1498 | e->ignore(); |
1486 | } | 1499 | } |
1487 | 1500 | ||
1488 | if ( true ) { | 1501 | if ( true ) { |
1489 | if ( e->key() == Qt::Key_I ) { | 1502 | if ( e->key() == Qt::Key_I ) { |
1490 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1503 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1491 | if ( cn ) { | 1504 | if ( cn ) { |
1492 | mActiveItem = cn; | 1505 | mActiveItem = cn; |
1493 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1506 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1494 | if ( ci ){ | 1507 | if ( ci ){ |
1495 | showTodo(); | 1508 | showTodo(); |
1496 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1509 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1497 | if ( cn ) { | 1510 | if ( cn ) { |
1498 | mTodoListView->setCurrentItem ( cn ); | 1511 | mTodoListView->setCurrentItem ( cn ); |
1499 | mTodoListView->ensureItemVisible ( cn ); | 1512 | mTodoListView->ensureItemVisible ( cn ); |
1500 | } | 1513 | } |
1501 | 1514 | ||
1502 | } | 1515 | } |
1503 | } | 1516 | } |
1504 | e->accept(); | 1517 | e->accept(); |
1505 | 1518 | ||
1506 | } | 1519 | } |
1507 | 1520 | ||
1508 | } | 1521 | } |
1509 | 1522 | ||
1510 | } | 1523 | } |
1511 | void KOTodoView::updateTodo( Todo * t, int type ) | 1524 | void KOTodoView::updateTodo( Todo * t, int type ) |
1512 | { | 1525 | { |
1513 | if ( mBlockUpdate) | 1526 | if ( mBlockUpdate) |
1514 | return; | 1527 | return; |
1515 | 1528 | ||
1516 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1529 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1517 | itemIterator = mTodoMap.find(t); | 1530 | itemIterator = mTodoMap.find(t); |
1518 | if (itemIterator != mTodoMap.end()) { | 1531 | if (itemIterator != mTodoMap.end()) { |
1519 | (*itemIterator)->construct(); | 1532 | (*itemIterator)->construct(); |
1520 | } else { | 1533 | } else { |
1521 | if ( type == KOGlobals::EVENTADDED ) { | 1534 | if ( type == KOGlobals::EVENTADDED ) { |
1522 | insertTodoItem( t ); | 1535 | insertTodoItem( t ); |
1523 | } | 1536 | } |
1524 | } | 1537 | } |
1525 | 1538 | ||
1526 | } | 1539 | } |
1527 | 1540 | ||
1528 | void KOTodoView::todoModified(Todo * t , int p ) | 1541 | void KOTodoView::todoModified(Todo * t , int p ) |
1529 | { | 1542 | { |
1530 | mBlockUpdate = true; | 1543 | mBlockUpdate = true; |
1531 | emit todoModifiedSignal ( t, p ); | 1544 | emit todoModifiedSignal ( t, p ); |
1532 | mBlockUpdate = false; | 1545 | mBlockUpdate = false; |
1533 | } | 1546 | } |