summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/tableview.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index 3daf370..d980a24 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -471,159 +471,168 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
471} 471}
472QWidget* TableView::createEditor(int row, int col, bool )const { 472QWidget* TableView::createEditor(int row, int col, bool )const {
473 switch( col ) { 473 switch( col ) {
474 case 1: { 474 case 1: {
475 /* the priority stuff */ 475 /* the priority stuff */
476 QComboBox* combo = new QComboBox( viewport() ); 476 QComboBox* combo = new QComboBox( viewport() );
477 for ( int i = 0; i < 5; i++ ) { 477 for ( int i = 0; i < 5; i++ ) {
478 combo->insertItem( m_pic_priority[ i ] ); 478 combo->insertItem( m_pic_priority[ i ] );
479 } 479 }
480 combo->setCurrentItem( sorted()[row].priority()-1 ); 480 combo->setCurrentItem( sorted()[row].priority()-1 );
481 return combo; 481 return combo;
482 } 482 }
483 /* summary */ 483 /* summary */
484 case 2:{ 484 case 2:{
485 QLineEdit* edit = new QLineEdit( viewport() ); 485 QLineEdit* edit = new QLineEdit( viewport() );
486 edit->setText( sorted()[row].summary() ); 486 edit->setText( sorted()[row].summary() );
487 return edit; 487 return edit;
488 } 488 }
489 case 0: 489 case 0:
490 default: 490 default:
491 return 0l; 491 return 0l;
492 } 492 }
493} 493}
494void TableView::setCellContentFromEditor(int row, int col ) { 494void TableView::setCellContentFromEditor(int row, int col ) {
495 qWarning("set cell content from editor"); 495 qWarning("set cell content from editor");
496 if ( col == 1 ) { 496 if ( col == 1 ) {
497 QWidget* wid = cellWidget(row, 1 ); 497 QWidget* wid = cellWidget(row, 1 );
498 if ( wid->inherits("QComboBox") ) { 498 if ( wid->inherits("QComboBox") ) {
499 int pri = ((QComboBox*)wid)->currentItem() + 1; 499 int pri = ((QComboBox*)wid)->currentItem() + 1;
500 OTodo todo = sorted()[row]; 500 OTodo todo = sorted()[row];
501 if ( todo.priority() != pri ) { 501 if ( todo.priority() != pri ) {
502 todo.setPriority( pri ); 502 todo.setPriority( pri );
503 TodoView::update( todo.uid(), todo ); 503 TodoView::update( todo.uid(), todo );
504 updateView(); 504 updateView();
505 } 505 }
506 } 506 }
507 }else if ( col == 2) { 507 }else if ( col == 2) {
508 QWidget* wid = cellWidget(row, 2); 508 QWidget* wid = cellWidget(row, 2);
509 if ( wid->inherits("QLineEdit") ) { 509 if ( wid->inherits("QLineEdit") ) {
510 QString text = ((QLineEdit*)wid)->text(); 510 QString text = ((QLineEdit*)wid)->text();
511 OTodo todo = sorted()[row]; 511 OTodo todo = sorted()[row];
512 if ( todo.summary() != text ) { 512 if ( todo.summary() != text ) {
513 todo.setSummary( text ); 513 todo.setSummary( text );
514 TodoView::update( todo.uid(), todo ); 514 TodoView::update( todo.uid(), todo );
515 updateView(); 515 updateView();
516 } 516 }
517 } 517 }
518 } 518 }
519} 519}
520void TableView::slotPriority() { 520void TableView::slotPriority() {
521 setCellContentFromEditor( currentRow(), currentColumn() ); 521 setCellContentFromEditor( currentRow(), currentColumn() );
522} 522}
523/* 523/*
524 * We'll use the TimerEvent to read ahead or to keep the cahce always 524 * We'll use the TimerEvent to read ahead or to keep the cahce always
525 * filled enough. 525 * filled enough.
526 * We will try to read ahead 4 items in both ways 526 * We will try to read ahead 4 items in both ways
527 * up and down. On odd or even we will currentRow()+-4 or +-9 527 * up and down. On odd or even we will currentRow()+-4 or +-9
528 * 528 *
529 */ 529 */
530void TableView::timerEvent( QTimerEvent* ) { 530void TableView::timerEvent( QTimerEvent* ) {
531// qWarning("sorted %d", sorted().count() ); 531// qWarning("sorted %d", sorted().count() );
532 if (sorted().count() == 0 ) 532 if (sorted().count() == 0 )
533 return; 533 return;
534 534
535 int row = currentRow(); 535 int row = currentRow();
536 if ( m_row ) { 536 if ( m_row ) {
537 int ro = row-4; 537 int ro = row-4;
538 if (ro < 0 ) ro = 0; 538 if (ro < 0 ) ro = 0;
539 sorted()[ro]; 539 sorted()[ro];
540 540
541 ro = row+4; 541 ro = row+4;
542 sorted()[ro]; 542 sorted()[ro];
543 } else { 543 } else {
544 int ro = row + 8; 544 int ro = row + 8;
545 sorted()[ro]; 545 sorted()[ro];
546 546
547 ro = row-8; 547 ro = row-8;
548 if (ro < 0 ) ro = 0; 548 if (ro < 0 ) ro = 0;
549 sorted()[ro]; 549 sorted()[ro];
550 } 550 }
551 551
552 m_row = !m_row; 552 m_row = !m_row;
553} 553}
554 554
555// We want a strike through completed ;) 555// We want a strike through completed ;)
556// durchstreichen to complete 556// durchstreichen to complete
557/* 557/*
558 * MouseTracking is off this mean we only receive 558 * MouseTracking is off this mean we only receive
559 * these events if the mouse button is pressed 559 * these events if the mouse button is pressed
560 * We've the previous point saved 560 * We've the previous point saved
561 * We check if the previous and current Point are 561 * We check if the previous and current Point are
562 * in the same row. 562 * in the same row.
563 * Then we check if they're some pixel horizontal away 563 * Then we check if they're some pixel horizontal away
564 * if the distance between the two points is greater than 564 * if the distance between the two points is greater than
565 * 8 we mark the underlying todo as completed and do a repaint 565 * 8 we mark the underlying todo as completed and do a repaint
566 * 566 *
567 * BUG: When clicking on the Due column and it's scrollable 567 * BUG: When clicking on the Due column and it's scrollable
568 * the todo is marked as completed... 568 * the todo is marked as completed...
569 * REASON: QTable is doing auto scrolling which leads to a move 569 * REASON: QTable is doing auto scrolling which leads to a move
570 * in the x coordinate and this way it's able to pass the 570 * in the x coordinate and this way it's able to pass the
571 * m_completeStrokeWidth criteria 571 * m_completeStrokeWidth criteria
572 * WORKAROUND: strike through needs to strike through the same 572 * WORKAROUND: strike through needs to strike through the same
573 * row and two columns! 573 * row and two columns!
574 */ 574 */
575void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { 575void TableView::contentsMouseReleaseEvent( QMouseEvent* e) {
576 int row = rowAt(m_prevP.y()); 576 int row = rowAt(m_prevP.y());
577 int colOld = columnAt(m_prevP.x() ); 577 int colOld = columnAt(m_prevP.x() );
578 int colNew = columnAt(e->x() ); 578 int colNew = columnAt(e->x() );
579 qWarning("colNew: %d colOld: %d", colNew, colOld ); 579 qWarning("colNew: %d colOld: %d", colNew, colOld );
580 if ( row == rowAt( e->y() ) && row != -1 && 580 if ( row == rowAt( e->y() ) && row != -1 &&
581 colOld != colNew ) { 581 colOld != colNew ) {
582 TodoView::complete( sorted()[row] ); 582 TodoView::complete( sorted()[row] );
583 return; 583 return;
584 } 584 }
585 QTable::contentsMouseReleaseEvent( e ); 585 QTable::contentsMouseReleaseEvent( e );
586} 586}
587void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { 587void TableView::contentsMouseMoveEvent( QMouseEvent* e ) {
588 m_menuTimer->stop(); 588 m_menuTimer->stop();
589 QTable::contentsMouseMoveEvent( e ); 589 QTable::contentsMouseMoveEvent( e );
590} 590}
591void TableView::keyPressEvent( QKeyEvent* event) { 591void TableView::keyPressEvent( QKeyEvent* event) {
592 if ( m_editorWidget.cellWidget() ) { 592 if ( m_editorWidget.cellWidget() ) {
593// setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); 593// setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() );
594 endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), 594 endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(),
595 true, true ); 595 true, true );
596 m_editorWidget.releaseCellWidget(); 596 m_editorWidget.releaseCellWidget();
597 setFocus(); 597 setFocus();
598 } 598 }
599
600 if ( sorted().count() < 1 ) {
601 QTable::keyPressEvent( event );
602 return;
603 }
604
599 int row = currentRow(); 605 int row = currentRow();
600 int col = currentColumn(); 606 int col = currentColumn();
601 607
602 char key = ::toupper( event->ascii() ); 608 char key = ::toupper( event->ascii() );
603 /* let QTable also handle the d later */ 609 /* let QTable also handle the d letter */
604 if ( key == 'D' ) 610 if ( key == 'D' ) {
611 event->accept();
605 removeQuery( sorted().uidAt( row ) ); 612 removeQuery( sorted().uidAt( row ) );
613 return;
614 }
606 615
607 616
608 switch( event->key() ) { 617 switch( event->key() ) {
609 case Qt::Key_F33: 618 case Qt::Key_F33:
610 case Qt::Key_Enter: 619 case Qt::Key_Enter:
611 case Qt::Key_Return: 620 case Qt::Key_Return:
612 case Qt::Key_Space: 621 case Qt::Key_Space:
613 if ( col == 0 ) { 622 if ( col == 0 ) {
614 TodoView::complete(sorted()[row]); 623 TodoView::complete(sorted()[row]);
615 }else if ( col == 1 ) { 624 }else if ( col == 1 ) {
616 QWidget* wid = beginEdit(row, col, FALSE ); 625 QWidget* wid = beginEdit(row, col, FALSE );
617 m_editorWidget.setCellWidget( wid, row, col ); 626 m_editorWidget.setCellWidget( wid, row, col );
618 }else if ( col == 2 ) { 627 }else if ( col == 2 ) {
619 showTodo( sorted().uidAt( currentRow() ) ); 628 showTodo( sorted().uidAt( currentRow() ) );
620 }else if ( col == 3 ) { 629 }else if ( col == 3 ) {
621 TodoView::edit( sorted().uidAt(row) ); 630 TodoView::edit( sorted().uidAt(row) );
622 } 631 }
623 632 event->accept();
624 break; 633 break;
625 default: 634 default:
626 QTable::keyPressEvent( event ); 635 QTable::keyPressEvent( event );
627 } 636 }
628} 637}
629 638