summaryrefslogtreecommitdiff
path: root/core/pim/todo/tableview.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/todo/tableview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/todo/tableview.cpp84
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
@@ -28,9 +28,9 @@
#include <stdlib.h>
#include <cmath>
+#include <cctype>
#include <qcombobox.h>
#include <qlineedit.h>
#include <qtimer.h>
-#include <qpoint.h>
#include <qpopupmenu.h>
@@ -51,4 +51,25 @@ 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;
+}
+
void TableView::initConfig() {
@@ -144,9 +165,22 @@ QString TableView::type() const {
}
int TableView::current() {
- if (numRows() == 0 ) return 1;
+ if (numRows() == 0 ) return 0;
int uid = sorted().uidAt(currentRow() );
return uid;
}
+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() {
OTodo to = sorted()[currentRow()];
@@ -220,9 +254,9 @@ void TableView::removeEvent( int ) {
}
void TableView::setShowCompleted( bool b) {
- qWarning("Show Completed %d" + b );
+ qWarning("Show Completed %d" , b );
updateView();
}
void TableView::setShowDeadline( bool b ) {
- qWarning( "Show DeadLine %d" + b );
+ qWarning( "Show DeadLine %d" , b );
if ( b )
showColumn( 3 );
@@ -260,4 +294,11 @@ void TableView::clear() {
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 ) )
return;
@@ -281,5 +322,9 @@ void TableView::slotClicked(int row, int col, int,
break;
- case 1:
+ // Priority emit a double click...
+ case 1:{
+ QWidget* wid = beginEdit( row, col, FALSE );
+ m_editorWidget.setCellWidget( wid, row, col );
+ }
break;
@@ -447,4 +492,5 @@ 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 ) {
QWidget* wid = cellWidget(row, 1 );
@@ -543,9 +589,36 @@ 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() ) {
case Qt::Key_F33:
case Qt::Key_Enter:
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;
default:
@@ -553,2 +626,3 @@ void TableView::keyPressEvent( QKeyEvent* event) {
}
}
+