-rw-r--r-- | core/pim/todo/tableview.cpp | 84 |
1 files changed, 79 insertions, 5 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index d9cda09..2e252d5 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp @@ -29,2 +29,3 @@ #include <cmath> +#include <cctype> @@ -33,3 +34,2 @@ #include <qtimer.h> -#include <qpoint.h> #include <qpopupmenu.h> @@ -52,2 +52,23 @@ namespace { +TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) { +} +void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) { + m_wid = wid; + m_row = row; + m_col = col; +} +void TableView::EditorWidget::releaseCellWidget() { + m_wid = 0; + m_row = m_col = -1; +} +QWidget* TableView::EditorWidget::cellWidget()const { + return m_wid; +} +int TableView::EditorWidget::cellRow()const { + return m_row; +} +int TableView::EditorWidget::cellCol()const { + return m_col; +} + @@ -145,3 +166,3 @@ QString TableView::type() const { int TableView::current() { - if (numRows() == 0 ) return 1; + if (numRows() == 0 ) return 0; int uid = sorted().uidAt(currentRow() ); @@ -150,2 +171,15 @@ int TableView::current() { } +int TableView::next() { + if ( numRows() == 0 ) return 0; + if ( currentRow() + 1 >= numRows() ) return 0; + setCurrentCell( currentRow() +1, currentColumn() ); + return sorted().uidAt( currentRow() ); +} +int TableView::prev() { + if ( numRows() == 0 ) return 0; + if ( currentRow() - 1 < 0 ) return 0; + setCurrentCell( currentRow() -1, currentColumn() ); + return sorted().uidAt( currentRow() ); + +} QString TableView::currentRepresentation() { @@ -221,3 +255,3 @@ void TableView::removeEvent( int ) { void TableView::setShowCompleted( bool b) { - qWarning("Show Completed %d" + b ); + qWarning("Show Completed %d" , b ); updateView(); @@ -225,3 +259,3 @@ void TableView::setShowCompleted( bool b) { void TableView::setShowDeadline( bool b ) { - qWarning( "Show DeadLine %d" + b ); + qWarning( "Show DeadLine %d" , b ); if ( b ) @@ -261,2 +295,9 @@ void TableView::slotClicked(int row, int col, int, const QPoint& point) { + if ( m_editorWidget.cellWidget() ) { + //setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); + endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), + true, true ); + m_editorWidget.releaseCellWidget(); + } + if ( !cellGeometry(row, col ).contains(point ) ) @@ -282,3 +323,7 @@ void TableView::slotClicked(int row, int col, int, - case 1: + // Priority emit a double click... + case 1:{ + QWidget* wid = beginEdit( row, col, FALSE ); + m_editorWidget.setCellWidget( wid, row, col ); + } break; @@ -448,2 +493,3 @@ QWidget* TableView::createEditor(int row, int col, bool )const { void TableView::setCellContentFromEditor(int row, int col ) { + qWarning("set cell content from editor"); if ( col == 1 ) { @@ -544,2 +590,18 @@ void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { void TableView::keyPressEvent( QKeyEvent* event) { + if ( m_editorWidget.cellWidget() ) { +// setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); + endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), + true, true ); + m_editorWidget.releaseCellWidget(); + setFocus(); + } + int row = currentRow(); + int col = currentColumn(); + + char key = ::toupper( event->ascii() ); + /* let QTable also handle the d later */ + if ( key == 'D' ) + removeQuery( sorted().uidAt( row ) ); + + switch( event->key() ) { @@ -548,3 +610,14 @@ void TableView::keyPressEvent( QKeyEvent* event) { case Qt::Key_Return: + case Qt::Key_Space: + if ( col == 0 ) { + TodoView::complete(sorted()[row]); + }else if ( col == 1 ) { + QWidget* wid = beginEdit(row, col, FALSE ); + m_editorWidget.setCellWidget( wid, row, col ); + }else if ( col == 2 ) { showTodo( sorted().uidAt( currentRow() ) ); + }else if ( col == 3 ) { + TodoView::edit( sorted().uidAt(row) ); + } + break; @@ -554 +627,2 @@ void TableView::keyPressEvent( QKeyEvent* event) { } + |