author | eilers <eilers> | 2003-08-01 14:22:29 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-01 14:22:29 (UTC) |
commit | 7d51872c86155fbbf27aeb8e49e7a336d909caac (patch) (unidiff) | |
tree | 55ecf3452d6711065e36c6bceab8ec52bd5525d8 /core/pim/todo/tableview.cpp | |
parent | 34991bac7d96b1c17601be6a5607819342571e0c (diff) | |
download | opie-7d51872c86155fbbf27aeb8e49e7a336d909caac.zip opie-7d51872c86155fbbf27aeb8e49e7a336d909caac.tar.gz opie-7d51872c86155fbbf27aeb8e49e7a336d909caac.tar.bz2 |
Merging changes from BRANCH_1_0 to HEAD
-rw-r--r-- | core/pim/todo/tableview.cpp | 86 |
1 files changed, 80 insertions, 6 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 @@ | |||
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <cmath> | 29 | #include <cmath> |
30 | #include <cctype> | ||
30 | 31 | ||
31 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
32 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
33 | #include <qtimer.h> | 34 | #include <qtimer.h> |
34 | #include <qpoint.h> | ||
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | 36 | ||
@@ -51,4 +51,25 @@ namespace { | |||
51 | } | 51 | } |
52 | 52 | ||
53 | TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) { | ||
54 | } | ||
55 | void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) { | ||
56 | m_wid = wid; | ||
57 | m_row = row; | ||
58 | m_col = col; | ||
59 | } | ||
60 | void TableView::EditorWidget::releaseCellWidget() { | ||
61 | m_wid = 0; | ||
62 | m_row = m_col = -1; | ||
63 | } | ||
64 | QWidget* TableView::EditorWidget::cellWidget()const { | ||
65 | return m_wid; | ||
66 | } | ||
67 | int TableView::EditorWidget::cellRow()const { | ||
68 | return m_row; | ||
69 | } | ||
70 | int TableView::EditorWidget::cellCol()const { | ||
71 | return m_col; | ||
72 | } | ||
73 | |||
53 | 74 | ||
54 | void TableView::initConfig() { | 75 | void TableView::initConfig() { |
@@ -144,9 +165,22 @@ QString TableView::type() const { | |||
144 | } | 165 | } |
145 | int TableView::current() { | 166 | int TableView::current() { |
146 | if (numRows() == 0 ) return 1; | 167 | if (numRows() == 0 ) return 0; |
147 | int uid = sorted().uidAt(currentRow() ); | 168 | int uid = sorted().uidAt(currentRow() ); |
148 | 169 | ||
149 | return uid; | 170 | return uid; |
150 | } | 171 | } |
172 | int TableView::next() { | ||
173 | if ( numRows() == 0 ) return 0; | ||
174 | if ( currentRow() + 1 >= numRows() ) return 0; | ||
175 | setCurrentCell( currentRow() +1, currentColumn() ); | ||
176 | return sorted().uidAt( currentRow() ); | ||
177 | } | ||
178 | int TableView::prev() { | ||
179 | if ( numRows() == 0 ) return 0; | ||
180 | if ( currentRow() - 1 < 0 ) return 0; | ||
181 | setCurrentCell( currentRow() -1, currentColumn() ); | ||
182 | return sorted().uidAt( currentRow() ); | ||
183 | |||
184 | } | ||
151 | QString TableView::currentRepresentation() { | 185 | QString TableView::currentRepresentation() { |
152 | OTodo to = sorted()[currentRow()]; | 186 | OTodo to = sorted()[currentRow()]; |
@@ -220,9 +254,9 @@ void TableView::removeEvent( int ) { | |||
220 | } | 254 | } |
221 | void TableView::setShowCompleted( bool b) { | 255 | void TableView::setShowCompleted( bool b) { |
222 | qWarning("Show Completed %d" + b ); | 256 | qWarning("Show Completed %d" , b ); |
223 | updateView(); | 257 | updateView(); |
224 | } | 258 | } |
225 | void TableView::setShowDeadline( bool b ) { | 259 | void TableView::setShowDeadline( bool b ) { |
226 | qWarning( "Show DeadLine %d" + b ); | 260 | qWarning( "Show DeadLine %d" , b ); |
227 | if ( b ) | 261 | if ( b ) |
228 | showColumn( 3 ); | 262 | showColumn( 3 ); |
@@ -260,4 +294,11 @@ void TableView::clear() { | |||
260 | void TableView::slotClicked(int row, int col, int, | 294 | void TableView::slotClicked(int row, int col, int, |
261 | const QPoint& point) { | 295 | const QPoint& point) { |
296 | if ( m_editorWidget.cellWidget() ) { | ||
297 | //setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); | ||
298 | endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), | ||
299 | true, true ); | ||
300 | m_editorWidget.releaseCellWidget(); | ||
301 | } | ||
302 | |||
262 | if ( !cellGeometry(row, col ).contains(point ) ) | 303 | if ( !cellGeometry(row, col ).contains(point ) ) |
263 | return; | 304 | return; |
@@ -281,5 +322,9 @@ void TableView::slotClicked(int row, int col, int, | |||
281 | break; | 322 | break; |
282 | 323 | ||
283 | case 1: | 324 | // Priority emit a double click... |
325 | case 1:{ | ||
326 | QWidget* wid = beginEdit( row, col, FALSE ); | ||
327 | m_editorWidget.setCellWidget( wid, row, col ); | ||
328 | } | ||
284 | break; | 329 | break; |
285 | 330 | ||
@@ -447,4 +492,5 @@ QWidget* TableView::createEditor(int row, int col, bool )const { | |||
447 | } | 492 | } |
448 | void TableView::setCellContentFromEditor(int row, int col ) { | 493 | void TableView::setCellContentFromEditor(int row, int col ) { |
494 | qWarning("set cell content from editor"); | ||
449 | if ( col == 1 ) { | 495 | if ( col == 1 ) { |
450 | QWidget* wid = cellWidget(row, 1 ); | 496 | QWidget* wid = cellWidget(row, 1 ); |
@@ -543,9 +589,36 @@ void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { | |||
543 | } | 589 | } |
544 | void TableView::keyPressEvent( QKeyEvent* event) { | 590 | void TableView::keyPressEvent( QKeyEvent* event) { |
591 | if ( m_editorWidget.cellWidget() ) { | ||
592 | // setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); | ||
593 | endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), | ||
594 | true, true ); | ||
595 | m_editorWidget.releaseCellWidget(); | ||
596 | setFocus(); | ||
597 | } | ||
598 | int row = currentRow(); | ||
599 | int col = currentColumn(); | ||
600 | |||
601 | char key = ::toupper( event->ascii() ); | ||
602 | /* let QTable also handle the d later */ | ||
603 | if ( key == 'D' ) | ||
604 | removeQuery( sorted().uidAt( row ) ); | ||
605 | |||
606 | |||
545 | switch( event->key() ) { | 607 | switch( event->key() ) { |
546 | case Qt::Key_F33: | 608 | case Qt::Key_F33: |
547 | case Qt::Key_Enter: | 609 | case Qt::Key_Enter: |
548 | case Qt::Key_Return: | 610 | case Qt::Key_Return: |
549 | showTodo( sorted().uidAt( currentRow() ) ); | 611 | case Qt::Key_Space: |
612 | if ( col == 0 ) { | ||
613 | TodoView::complete(sorted()[row]); | ||
614 | }else if ( col == 1 ) { | ||
615 | QWidget* wid = beginEdit(row, col, FALSE ); | ||
616 | m_editorWidget.setCellWidget( wid, row, col ); | ||
617 | }else if ( col == 2 ) { | ||
618 | showTodo( sorted().uidAt( currentRow() ) ); | ||
619 | }else if ( col == 3 ) { | ||
620 | TodoView::edit( sorted().uidAt(row) ); | ||
621 | } | ||
622 | |||
550 | break; | 623 | break; |
551 | default: | 624 | default: |
@@ -553,2 +626,3 @@ void TableView::keyPressEvent( QKeyEvent* event) { | |||
553 | } | 626 | } |
554 | } | 627 | } |
628 | |||