-rw-r--r-- | core/pim/todo/tableview.cpp | 39 | ||||
-rw-r--r-- | core/pim/todo/tableview.h | 3 |
2 files changed, 36 insertions, 6 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index 34b8b3c..c4165db 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -16,24 +16,25 @@ | |||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | #include <stdlib.h> | ||
28 | 29 | ||
29 | #include <qtimer.h> | 30 | #include <qtimer.h> |
30 | #include <qpoint.h> | 31 | #include <qpoint.h> |
31 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
32 | 33 | ||
33 | #include "mainwindow.h" | 34 | #include "mainwindow.h" |
34 | //#include "tableitems.h" | 35 | //#include "tableitems.h" |
35 | #include "tableview.h" | 36 | #include "tableview.h" |
36 | 37 | ||
37 | using namespace Todo; | 38 | using namespace Todo; |
38 | 39 | ||
39 | namespace { | 40 | namespace { |
@@ -138,38 +139,35 @@ void TableView::updateView( ) { | |||
138 | sort(); | 139 | sort(); |
139 | OTodoAccess::List::Iterator it, end; | 140 | OTodoAccess::List::Iterator it, end; |
140 | it = sorted().begin(); | 141 | it = sorted().begin(); |
141 | end = sorted().end(); | 142 | end = sorted().end(); |
142 | 143 | ||
143 | qWarning("setTodos"); | 144 | qWarning("setTodos"); |
144 | QTime time; | 145 | QTime time; |
145 | time.start(); | 146 | time.start(); |
146 | m_enablePaint = false; | 147 | m_enablePaint = false; |
147 | setUpdatesEnabled( false ); | 148 | setUpdatesEnabled( false ); |
148 | viewport()->setUpdatesEnabled( false ); | 149 | viewport()->setUpdatesEnabled( false ); |
149 | 150 | ||
150 | QTime t; | ||
151 | t.start(); | ||
152 | setNumRows( it.count() ); | 151 | setNumRows( it.count() ); |
153 | if ( it.count() == 0 ) | 152 | if ( it.count() == 0 ) |
154 | killTimer(id); | 153 | killTimer(id); |
154 | |||
155 | int elc = time.elapsed(); | 155 | int elc = time.elapsed(); |
156 | qWarning("Adding took %d", elc/1000 ); | ||
157 | setUpdatesEnabled( true ); | 156 | setUpdatesEnabled( true ); |
158 | viewport()->setUpdatesEnabled( true ); | 157 | viewport()->setUpdatesEnabled( true ); |
159 | viewport()->update(); | 158 | viewport()->update(); |
160 | 159 | ||
161 | m_enablePaint = true; | 160 | m_enablePaint = true; |
162 | int el = time.elapsed(); | 161 | int el = time.elapsed(); |
163 | qWarning("adding took %d", el/1000 ); | ||
164 | } | 162 | } |
165 | void TableView::setTodo( int, const OTodo&) { | 163 | void TableView::setTodo( int, const OTodo&) { |
166 | sort(); | 164 | sort(); |
167 | 165 | ||
168 | /* repaint */ | 166 | /* repaint */ |
169 | repaint(); | 167 | repaint(); |
170 | } | 168 | } |
171 | void TableView::addEvent( const OTodo&) { | 169 | void TableView::addEvent( const OTodo&) { |
172 | 170 | ||
173 | /* fix problems of not showing the 'Haken' */ | 171 | /* fix problems of not showing the 'Haken' */ |
174 | updateView(); | 172 | updateView(); |
175 | } | 173 | } |
@@ -248,24 +246,25 @@ void TableView::slotClicked(int row, int col, int, | |||
248 | case 3: { | 246 | case 3: { |
249 | m_menuTimer->stop(); | 247 | m_menuTimer->stop(); |
250 | TodoView::edit( ui ); | 248 | TodoView::edit( ui ); |
251 | break; | 249 | break; |
252 | } | 250 | } |
253 | } | 251 | } |
254 | 252 | ||
255 | 253 | ||
256 | } | 254 | } |
257 | void TableView::slotPressed(int row, int col, int, | 255 | void TableView::slotPressed(int row, int col, int, |
258 | const QPoint& point) { | 256 | const QPoint& point) { |
259 | 257 | ||
258 | m_prevP = point; | ||
260 | /* TextColumn column */ | 259 | /* TextColumn column */ |
261 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) | 260 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) |
262 | m_menuTimer->start( 750, TRUE ); | 261 | m_menuTimer->start( 750, TRUE ); |
263 | } | 262 | } |
264 | void TableView::slotValueChanged( int, int ) { | 263 | void TableView::slotValueChanged( int, int ) { |
265 | qWarning("Value Changed"); | 264 | qWarning("Value Changed"); |
266 | } | 265 | } |
267 | void TableView::slotCurrentChanged(int, int ) { | 266 | void TableView::slotCurrentChanged(int, int ) { |
268 | m_menuTimer->stop(); | 267 | m_menuTimer->stop(); |
269 | } | 268 | } |
270 | QWidget* TableView::widget() { | 269 | QWidget* TableView::widget() { |
271 | return this; | 270 | return this; |
@@ -275,25 +274,24 @@ QWidget* TableView::widget() { | |||
275 | * because we want to sort whole row | 274 | * because we want to sort whole row |
276 | * based | 275 | * based |
277 | * We event want to set the setOrder | 276 | * We event want to set the setOrder |
278 | * to a sort() and update() | 277 | * to a sort() and update() |
279 | */ | 278 | */ |
280 | void TableView::sortColumn( int col, bool asc, bool ) { | 279 | void TableView::sortColumn( int col, bool asc, bool ) { |
281 | qWarning("bool %d", asc ); | 280 | qWarning("bool %d", asc ); |
282 | setSortOrder( col ); | 281 | setSortOrder( col ); |
283 | setAscending( asc ); | 282 | setAscending( asc ); |
284 | updateView(); | 283 | updateView(); |
285 | } | 284 | } |
286 | void TableView::viewportPaintEvent( QPaintEvent* e) { | 285 | void TableView::viewportPaintEvent( QPaintEvent* e) { |
287 | qWarning("Paint event" ); | ||
288 | if (m_enablePaint ) | 286 | if (m_enablePaint ) |
289 | QTable::viewportPaintEvent( e ); | 287 | QTable::viewportPaintEvent( e ); |
290 | } | 288 | } |
291 | /* | 289 | /* |
292 | * This segment is copyrighted by TT | 290 | * This segment is copyrighted by TT |
293 | * it was taken from their todolist | 291 | * it was taken from their todolist |
294 | * application this code is GPL | 292 | * application this code is GPL |
295 | */ | 293 | */ |
296 | void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { | 294 | void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { |
297 | const QColorGroup &cg = colorGroup(); | 295 | const QColorGroup &cg = colorGroup(); |
298 | 296 | ||
299 | p->save(); | 297 | p->save(); |
@@ -426,31 +424,60 @@ void TableView::slotPriority() { | |||
426 | /* | 424 | /* |
427 | * We'll use the TimerEvent to read ahead or to keep the cahce always | 425 | * We'll use the TimerEvent to read ahead or to keep the cahce always |
428 | * filled enough. | 426 | * filled enough. |
429 | * We will try to read ahead 4 items in both ways | 427 | * We will try to read ahead 4 items in both ways |
430 | * up and down. On odd or even we will currentRow()+-4 or +-9 | 428 | * up and down. On odd or even we will currentRow()+-4 or +-9 |
431 | * | 429 | * |
432 | */ | 430 | */ |
433 | void TableView::timerEvent( QTimerEvent* ev ) { | 431 | void TableView::timerEvent( QTimerEvent* ev ) { |
434 | if (sorted().count() == 0 ) | 432 | if (sorted().count() == 0 ) |
435 | return; | 433 | return; |
436 | 434 | ||
437 | int row = currentRow(); | 435 | int row = currentRow(); |
438 | qWarning("TimerEvent %d", row); | ||
439 | if ( m_row ) { | 436 | if ( m_row ) { |
440 | int ro = row-4; | 437 | int ro = row-4; |
441 | if (ro < 0 ) ro = 0; | 438 | if (ro < 0 ) ro = 0; |
442 | sorted()[ro]; | 439 | sorted()[ro]; |
443 | 440 | ||
444 | ro = row+4; | 441 | ro = row+4; |
445 | sorted()[ro]; | 442 | sorted()[ro]; |
446 | } else { | 443 | } else { |
447 | int ro = row + 8; | 444 | int ro = row + 8; |
448 | sorted()[ro]; | 445 | sorted()[ro]; |
449 | 446 | ||
450 | ro = row-8; | 447 | ro = row-8; |
451 | if (ro < 0 ) ro = 0; | 448 | if (ro < 0 ) ro = 0; |
452 | sorted()[ro]; | 449 | sorted()[ro]; |
453 | } | 450 | } |
454 | 451 | ||
455 | m_row = !m_row; | 452 | m_row = !m_row; |
456 | } | 453 | } |
454 | |||
455 | // We want a strike through completed ;) | ||
456 | // durchstreichen to complete | ||
457 | /* | ||
458 | * MouseTracking is off this mean we only receive | ||
459 | * these events if the mouse button is pressed | ||
460 | * We've the previous point saved | ||
461 | * We check if the previous and current Point are | ||
462 | * in the same row. | ||
463 | * Then we check if they're some pixel horizontal away | ||
464 | * if the distance between the two points is greater than | ||
465 | * 8 we mark the underlying todo as completed and do a repaint | ||
466 | */ | ||
467 | void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { | ||
468 | int row = rowAt(m_prevP.y()); | ||
469 | if ( row == rowAt( e->y() ) ) { | ||
470 | if ( abs( m_prevP.x() - e->x() ) >= 8 ) { | ||
471 | OTodo todo = sorted()[row]; | ||
472 | todo.setCompleted( !todo.isCompleted() ); | ||
473 | TodoView::update( todo.uid(), todo ); | ||
474 | updateView(); | ||
475 | return; | ||
476 | } | ||
477 | } | ||
478 | QTable::contentsMouseReleaseEvent( e ); | ||
479 | } | ||
480 | void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { | ||
481 | m_menuTimer->stop(); | ||
482 | QTable::contentsMouseMoveEvent( e ); | ||
483 | } | ||
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h index fe65ca9..0c3e865 100644 --- a/core/pim/todo/tableview.h +++ b/core/pim/todo/tableview.h | |||
@@ -73,31 +73,34 @@ namespace Todo { | |||
73 | * OTodos where we only show 10 at a time! | 73 | * OTodos where we only show 10 at a time! |
74 | */ | 74 | */ |
75 | void paintCell(QPainter* p, int row, int col, const QRect&, bool ); | 75 | void paintCell(QPainter* p, int row, int col, const QRect&, bool ); |
76 | private: | 76 | private: |
77 | /* reimplented for internal reasons */ | 77 | /* reimplented for internal reasons */ |
78 | void viewportPaintEvent( QPaintEvent* ); | 78 | void viewportPaintEvent( QPaintEvent* ); |
79 | QTimer *m_menuTimer; | 79 | QTimer *m_menuTimer; |
80 | bool m_enablePaint:1; | 80 | bool m_enablePaint:1; |
81 | QString m_oleCat; | 81 | QString m_oleCat; |
82 | bool m_first : 1; | 82 | bool m_first : 1; |
83 | 83 | ||
84 | protected: | 84 | protected: |
85 | void contentsMouseReleaseEvent( QMouseEvent* ); | ||
86 | void contentsMouseMoveEvent( QMouseEvent* ); | ||
85 | void timerEvent( QTimerEvent* e ); | 87 | void timerEvent( QTimerEvent* e ); |
86 | QWidget* createEditor(int row, int col, bool initFromCell )const; | 88 | QWidget* createEditor(int row, int col, bool initFromCell )const; |
87 | void setCellContentFromEditor( int row, int col ); | 89 | void setCellContentFromEditor( int row, int col ); |
88 | 90 | ||
89 | private slots: | 91 | private slots: |
90 | void slotShowMenu(); | 92 | void slotShowMenu(); |
91 | void slotClicked(int, int, int, | 93 | void slotClicked(int, int, int, |
92 | const QPoint& ); | 94 | const QPoint& ); |
93 | void slotPressed(int, int, int, | 95 | void slotPressed(int, int, int, |
94 | const QPoint& ); | 96 | const QPoint& ); |
95 | void slotValueChanged(int, int); | 97 | void slotValueChanged(int, int); |
96 | void slotCurrentChanged(int, int ); | 98 | void slotCurrentChanged(int, int ); |
97 | void slotPriority(); | 99 | void slotPriority(); |
98 | private: | 100 | private: |
99 | bool m_row : 1; | 101 | bool m_row : 1; |
102 | QPoint m_prevP; | ||
100 | }; | 103 | }; |
101 | }; | 104 | }; |
102 | 105 | ||
103 | #endif | 106 | #endif |