summaryrefslogtreecommitdiff
authorzecke <zecke>2004-02-08 16:18:37 (UTC)
committer zecke <zecke>2004-02-08 16:18:37 (UTC)
commitd8129e2deeffcb5256c5c9d22fbd1fa743e8b6fe (patch) (unidiff)
tree5f57bc4073015cb39ec1ddae12825ae9c3b8c02e
parent6506eeeeaa8d52ae0895630de00e38bc2b8ff10c (diff)
downloadopie-d8129e2deeffcb5256c5c9d22fbd1fa743e8b6fe.zip
opie-d8129e2deeffcb5256c5c9d22fbd1fa743e8b6fe.tar.gz
opie-d8129e2deeffcb5256c5c9d22fbd1fa743e8b6fe.tar.bz2
Fix two problems:
1.) accept the key event so it does not reoccur and reoccur 2.) do not crash if asked to delete and there is nothing to delete
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
@@ -575,55 +575,64 @@ void TableView::timerEvent( QTimerEvent* ) {
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