-rw-r--r-- | core/pim/todo/mainwindow.cpp | 3 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 3 |
2 files changed, 3 insertions, 3 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index a28fc3e..294f37c 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -311,138 +311,139 @@ TodoWindow::~TodoWindow() | |||
311 | 311 | ||
312 | void TodoWindow::slotDelete() | 312 | void TodoWindow::slotDelete() |
313 | { | 313 | { |
314 | if(syncing) { | 314 | if(syncing) { |
315 | QMessageBox::warning(this, tr("Todo"), | 315 | QMessageBox::warning(this, tr("Todo"), |
316 | tr("Can not edit data, currently syncing")); | 316 | tr("Can not edit data, currently syncing")); |
317 | return; | 317 | return; |
318 | } | 318 | } |
319 | 319 | ||
320 | if ( table->currentRow() == -1 ) | 320 | if ( table->currentRow() == -1 ) |
321 | return; | 321 | return; |
322 | 322 | ||
323 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 323 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
324 | 324 | ||
325 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) | 325 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) |
326 | return; | 326 | return; |
327 | 327 | ||
328 | 328 | ||
329 | 329 | ||
330 | table->setPaintingEnabled( false ); | 330 | table->setPaintingEnabled( false ); |
331 | table->removeCurrentEntry(); | 331 | table->removeCurrentEntry(); |
332 | table->setPaintingEnabled( true ); | 332 | table->setPaintingEnabled( true ); |
333 | 333 | ||
334 | if ( table->numRows() == 0 ) { | 334 | if ( table->numRows() == 0 ) { |
335 | currentEntryChanged( -1, 0 ); | 335 | currentEntryChanged( -1, 0 ); |
336 | findAction->setEnabled( FALSE ); | 336 | findAction->setEnabled( FALSE ); |
337 | } | 337 | } |
338 | mStack->raiseWidget(1); | 338 | mStack->raiseWidget(1); |
339 | } | 339 | } |
340 | void TodoWindow::slotDeleteAll() | 340 | void TodoWindow::slotDeleteAll() |
341 | { | 341 | { |
342 | if(syncing) { | 342 | if(syncing) { |
343 | QMessageBox::warning(this, tr("Todo"), | 343 | QMessageBox::warning(this, tr("Todo"), |
344 | tr("Can not edit data, currently syncing")); | 344 | tr("Can not edit data, currently syncing")); |
345 | return; | 345 | return; |
346 | } | 346 | } |
347 | 347 | ||
348 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 348 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
349 | 349 | ||
350 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) | 350 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) |
351 | return; | 351 | return; |
352 | 352 | ||
353 | 353 | ||
354 | 354 | ||
355 | table->setPaintingEnabled( false ); | 355 | table->setPaintingEnabled( false ); |
356 | table->removeAllEntries(); | 356 | table->removeAllEntries(); |
357 | table->setPaintingEnabled( true ); | 357 | table->setPaintingEnabled( true ); |
358 | 358 | ||
359 | if ( table->numRows() == 0 ) { | 359 | if ( table->numRows() == 0 ) { |
360 | currentEntryChanged( -1, 0 ); | 360 | currentEntryChanged( -1, 0 ); |
361 | findAction->setEnabled( FALSE ); | 361 | findAction->setEnabled( FALSE ); |
362 | } | 362 | } |
363 | mStack->raiseWidget(1 ); | 363 | mStack->raiseWidget(1 ); |
364 | } | 364 | } |
365 | 365 | ||
366 | void TodoWindow::slotEdit() | 366 | void TodoWindow::slotEdit() |
367 | { | 367 | { |
368 | if(syncing) { | 368 | if(syncing) { |
369 | QMessageBox::warning(this, tr("Todo"), | 369 | QMessageBox::warning(this, tr("Todo"), |
370 | tr("Can not edit data, currently syncing")); | 370 | tr("Can not edit data, currently syncing")); |
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | 373 | ||
374 | ToDoEvent todo = table->currentEntry(); | 374 | ToDoEvent todo = table->currentEntry(); |
375 | 375 | qWarning("slotEdit" ); | |
376 | NewTaskDialog e( todo, this, 0, TRUE ); | 376 | NewTaskDialog e( todo, this, 0, TRUE ); |
377 | e.setCaption( tr( "Edit Task" ) ); | 377 | e.setCaption( tr( "Edit Task" ) ); |
378 | 378 | ||
379 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 379 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
380 | e.showMaximized(); | 380 | e.showMaximized(); |
381 | #endif | 381 | #endif |
382 | int ret = e.exec(); | 382 | int ret = e.exec(); |
383 | 383 | ||
384 | if ( ret == QDialog::Accepted ) { | 384 | if ( ret == QDialog::Accepted ) { |
385 | qWarning("Replacing now" ); | ||
385 | table->setPaintingEnabled( false ); | 386 | table->setPaintingEnabled( false ); |
386 | todo = e.todoEntry(); | 387 | todo = e.todoEntry(); |
387 | table->replaceCurrentEntry( todo ); | 388 | table->replaceCurrentEntry( todo ); |
388 | table->setPaintingEnabled( true ); | 389 | table->setPaintingEnabled( true ); |
389 | } | 390 | } |
390 | populateCategories(); | 391 | populateCategories(); |
391 | mStack->raiseWidget( 1 ); | 392 | mStack->raiseWidget( 1 ); |
392 | } | 393 | } |
393 | void TodoWindow::slotDuplicate() | 394 | void TodoWindow::slotDuplicate() |
394 | { | 395 | { |
395 | if(syncing) { | 396 | if(syncing) { |
396 | QMessageBox::warning(this, tr("Todo"), | 397 | QMessageBox::warning(this, tr("Todo"), |
397 | tr("Can not edit data, currently syncing")); | 398 | tr("Can not edit data, currently syncing")); |
398 | return; | 399 | return; |
399 | } | 400 | } |
400 | ToDoEvent ev = table->currentEntry(); | 401 | ToDoEvent ev = table->currentEntry(); |
401 | ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid | 402 | ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid |
402 | int uid; | 403 | int uid; |
403 | { // uid | 404 | { // uid |
404 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); | 405 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); |
405 | uid = uidgen->generate(); | 406 | uid = uidgen->generate(); |
406 | delete uidgen; | 407 | delete uidgen; |
407 | } | 408 | } |
408 | ev2.setUid( uid ); | 409 | ev2.setUid( uid ); |
409 | table->setPaintingEnabled( false ); | 410 | table->setPaintingEnabled( false ); |
410 | table->addEntry( ev2 ); | 411 | table->addEntry( ev2 ); |
411 | table->setPaintingEnabled( true ); | 412 | table->setPaintingEnabled( true ); |
412 | 413 | ||
413 | mStack->raiseWidget( 1 ); | 414 | mStack->raiseWidget( 1 ); |
414 | } | 415 | } |
415 | void TodoWindow::slotShowPopup( const QPoint &p ) | 416 | void TodoWindow::slotShowPopup( const QPoint &p ) |
416 | { | 417 | { |
417 | contextMenu->popup( p ); | 418 | contextMenu->popup( p ); |
418 | } | 419 | } |
419 | 420 | ||
420 | void TodoWindow::showCompleted( bool s ) | 421 | void TodoWindow::showCompleted( bool s ) |
421 | { | 422 | { |
422 | if ( !table->isUpdatesEnabled() ) | 423 | if ( !table->isUpdatesEnabled() ) |
423 | return; | 424 | return; |
424 | table->setPaintingEnabled( false ); | 425 | table->setPaintingEnabled( false ); |
425 | table->setShowCompleted( s ); | 426 | table->setShowCompleted( s ); |
426 | table->setPaintingEnabled( true ); | 427 | table->setPaintingEnabled( true ); |
427 | mStack->raiseWidget( 1 ); | 428 | mStack->raiseWidget( 1 ); |
428 | } | 429 | } |
429 | 430 | ||
430 | void TodoWindow::currentEntryChanged( int r, int ) | 431 | void TodoWindow::currentEntryChanged( int r, int ) |
431 | { | 432 | { |
432 | if ( r != -1 && table->rowHeight( r ) > 0 ) { | 433 | if ( r != -1 && table->rowHeight( r ) > 0 ) { |
433 | editAction->setEnabled( TRUE ); | 434 | editAction->setEnabled( TRUE ); |
434 | deleteAction->setEnabled( TRUE ); | 435 | deleteAction->setEnabled( TRUE ); |
435 | duplicateAction->setEnabled( TRUE ); | 436 | duplicateAction->setEnabled( TRUE ); |
436 | deleteAllAction->setEnabled( TRUE ); | 437 | deleteAllAction->setEnabled( TRUE ); |
437 | } else { | 438 | } else { |
438 | editAction->setEnabled( FALSE ); | 439 | editAction->setEnabled( FALSE ); |
439 | deleteAction->setEnabled( FALSE ); | 440 | deleteAction->setEnabled( FALSE ); |
440 | duplicateAction->setEnabled( FALSE ); | 441 | duplicateAction->setEnabled( FALSE ); |
441 | deleteAllAction->setEnabled( FALSE ); | 442 | deleteAllAction->setEnabled( FALSE ); |
442 | } | 443 | } |
443 | } | 444 | } |
444 | 445 | ||
445 | void TodoWindow::setCategory( int c ) | 446 | void TodoWindow::setCategory( int c ) |
446 | { | 447 | { |
447 | if ( c <= 0 ) return; | 448 | if ( c <= 0 ) return; |
448 | if ( !table->isUpdatesEnabled() ) | 449 | if ( !table->isUpdatesEnabled() ) |
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index dc60cc4..208a084 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp | |||
@@ -580,130 +580,129 @@ void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) | |||
580 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; | 580 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; |
581 | } | 581 | } |
582 | buf += "/>\n"; | 582 | buf += "/>\n"; |
583 | str = buf.utf8(); | 583 | str = buf.utf8(); |
584 | f.writeBlock( str.data(), str.length() ); | 584 | f.writeBlock( str.data(), str.length() ); |
585 | f.close(); | 585 | f.close(); |
586 | } | 586 | } |
587 | 587 | ||
588 | void TodoTable::rowHeightChanged( int row ) | 588 | void TodoTable::rowHeightChanged( int row ) |
589 | { | 589 | { |
590 | if ( enablePainting ) | 590 | if ( enablePainting ) |
591 | QTable::rowHeightChanged( row ); | 591 | QTable::rowHeightChanged( row ); |
592 | } | 592 | } |
593 | 593 | ||
594 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) | 594 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) |
595 | { | 595 | { |
596 | 596 | ||
597 | QList<ToDoEvent> list; | 597 | QList<ToDoEvent> list; |
598 | ToDoDB todoDB; | 598 | ToDoDB todoDB; |
599 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); | 599 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); |
600 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ | 600 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ |
601 | ToDoEvent *event = new ToDoEvent( (*it) ); | 601 | ToDoEvent *event = new ToDoEvent( (*it) ); |
602 | list.append( event ); | 602 | list.append( event ); |
603 | } | 603 | } |
604 | vaList.clear(); | 604 | vaList.clear(); |
605 | // qDebug("parsing done=%d", t.elapsed() ); | 605 | // qDebug("parsing done=%d", t.elapsed() ); |
606 | if ( list.count() > 0 ) { | 606 | if ( list.count() > 0 ) { |
607 | internalAddEntries( list ); | 607 | internalAddEntries( list ); |
608 | list.clear(); | 608 | list.clear(); |
609 | } | 609 | } |
610 | // qDebug("loading done: t=%d", t.elapsed() ); | 610 | // qDebug("loading done: t=%d", t.elapsed() ); |
611 | } | 611 | } |
612 | 612 | ||
613 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) | 613 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) |
614 | { | 614 | { |
615 | QString strTodo; | 615 | QString strTodo; |
616 | strTodo = todo.description().left(40).simplifyWhiteSpace(); | 616 | strTodo = todo.description().left(40).simplifyWhiteSpace(); |
617 | if ( row == -1 ) { | 617 | if ( row == -1 ) { |
618 | QMapIterator<CheckItem*, ToDoEvent *> it; | 618 | QMapIterator<CheckItem*, ToDoEvent *> it; |
619 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { | 619 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { |
620 | if ( *(*it) == todo ) { | 620 | if ( *(*it) == todo ) { |
621 | row = it.key()->row(); | 621 | row = it.key()->row(); |
622 | it.key()->setChecked( todo.isCompleted() ); | 622 | it.key()->setChecked( todo.isCompleted() ); |
623 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 623 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
624 | item( row, 2 )->setText( strTodo ); | 624 | item( row, 2 )->setText( strTodo ); |
625 | 625 | ||
626 | if (showDeadl){ | 626 | if (showDeadl){ |
627 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 627 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
628 | } | 628 | } |
629 | 629 | ||
630 | *(*it) = todo; | 630 | *(*it) = todo; |
631 | } | 631 | } |
632 | } | 632 | } |
633 | } else { | 633 | } else { |
634 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; | 634 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; |
635 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); | 635 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); |
636 | delete t; | 636 | delete t; |
637 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); | 637 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); |
638 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 638 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
639 | item( row, 2 )->setText( strTodo ); | 639 | item( row, 2 )->setText( strTodo ); |
640 | 640 | ||
641 | if (showDeadl){ | 641 | if (showDeadl){ |
642 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 642 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
643 | } | 643 | } |
644 | ToDoEvent *ev = new ToDoEvent( todo ); | 644 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); |
645 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(ev) ); | ||
646 | } | 645 | } |
647 | } | 646 | } |
648 | 647 | ||
649 | void TodoTable::journalFreeRemoveEntry( int row ) | 648 | void TodoTable::journalFreeRemoveEntry( int row ) |
650 | { | 649 | { |
651 | CheckItem *chk; | 650 | CheckItem *chk; |
652 | chk = static_cast<CheckItem*>(item(row, 0 )); | 651 | chk = static_cast<CheckItem*>(item(row, 0 )); |
653 | if ( !chk ) | 652 | if ( !chk ) |
654 | return; | 653 | return; |
655 | todoList.remove( chk ); | 654 | todoList.remove( chk ); |
656 | 655 | ||
657 | realignTable( row ); | 656 | realignTable( row ); |
658 | } | 657 | } |
659 | 658 | ||
660 | void TodoTable::keyPressEvent( QKeyEvent *e ) | 659 | void TodoTable::keyPressEvent( QKeyEvent *e ) |
661 | { | 660 | { |
662 | if ( e->key() == Key_Space || e->key() == Key_Return ) { | 661 | if ( e->key() == Key_Space || e->key() == Key_Return ) { |
663 | switch ( currentColumn() ) { | 662 | switch ( currentColumn() ) { |
664 | case 0: { | 663 | case 0: { |
665 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), | 664 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), |
666 | currentColumn())); | 665 | currentColumn())); |
667 | if ( i ) | 666 | if ( i ) |
668 | i->toggle(); | 667 | i->toggle(); |
669 | break; | 668 | break; |
670 | } | 669 | } |
671 | case 1: | 670 | case 1: |
672 | break; | 671 | break; |
673 | case 2: | 672 | case 2: |
674 | emit signalEdit(); | 673 | emit signalEdit(); |
675 | default: | 674 | default: |
676 | break; | 675 | break; |
677 | } | 676 | } |
678 | } else { | 677 | } else { |
679 | QTable::keyPressEvent( e ); | 678 | QTable::keyPressEvent( e ); |
680 | } | 679 | } |
681 | } | 680 | } |
682 | 681 | ||
683 | QStringList TodoTable::categories() | 682 | QStringList TodoTable::categories() |
684 | { | 683 | { |
685 | // This is called seldom, so calling a load in here | 684 | // This is called seldom, so calling a load in here |
686 | // should be fine. | 685 | // should be fine. |
687 | mCat.load( categoryFileName() ); | 686 | mCat.load( categoryFileName() ); |
688 | QStringList categoryList = mCat.labels( "Todo List" ); | 687 | QStringList categoryList = mCat.labels( "Todo List" ); |
689 | return categoryList; | 688 | return categoryList; |
690 | } | 689 | } |
691 | 690 | ||
692 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, | 691 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, |
693 | bool backwards, int category ) | 692 | bool backwards, int category ) |
694 | { | 693 | { |
695 | // we have to iterate through the table, this gives the illusion that | 694 | // we have to iterate through the table, this gives the illusion that |
696 | // sorting is actually being used. | 695 | // sorting is actually being used. |
697 | if ( currFindRow < -1 ) | 696 | if ( currFindRow < -1 ) |
698 | currFindRow = currentRow() - 1; | 697 | currFindRow = currentRow() - 1; |
699 | clearSelection( TRUE ); | 698 | clearSelection( TRUE ); |
700 | int rows, | 699 | int rows, |
701 | row; | 700 | row; |
702 | CheckItem *chk; | 701 | CheckItem *chk; |
703 | QRegExp r( findString ); | 702 | QRegExp r( findString ); |
704 | 703 | ||
705 | r.setCaseSensitive( caseSensitive ); | 704 | r.setCaseSensitive( caseSensitive ); |
706 | rows = numRows(); | 705 | rows = numRows(); |
707 | static bool wrapAround = true; | 706 | static bool wrapAround = true; |
708 | 707 | ||
709 | if ( !backwards ) { | 708 | if ( !backwards ) { |