-rw-r--r-- | core/pim/todo/tableview.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index ded2dbd..0f683c9 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -32,12 +32,14 @@ | |||
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qpoint.h> | 33 | #include <qpoint.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | #include <opie/orecur.h> | ||
39 | |||
38 | #include "mainwindow.h" | 40 | #include "mainwindow.h" |
39 | //#include "tableitems.h" | 41 | //#include "tableitems.h" |
40 | #include "tableview.h" | 42 | #include "tableview.h" |
41 | 43 | ||
42 | using namespace Todo; | 44 | using namespace Todo; |
43 | 45 | ||
@@ -117,38 +119,39 @@ void TableView::newDay() { | |||
117 | updateView(); | 119 | updateView(); |
118 | } | 120 | } |
119 | TableView::~TableView() { | 121 | TableView::~TableView() { |
120 | 122 | ||
121 | } | 123 | } |
122 | void TableView::slotShowMenu() { | 124 | void TableView::slotShowMenu() { |
123 | QPopupMenu *menu = todoWindow()->contextMenu( current() ); | 125 | QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); |
124 | menu->exec(QCursor::pos() ); | 126 | menu->exec(QCursor::pos() ); |
125 | delete menu; | 127 | delete menu; |
126 | } | 128 | } |
127 | QString TableView::type() const { | 129 | QString TableView::type() const { |
128 | return QString::fromLatin1( tr("Table View") ); | 130 | return QString::fromLatin1( tr("Table View") ); |
129 | } | 131 | } |
130 | int TableView::current() { | 132 | int TableView::current() { |
131 | int uid = sorted().uidAt(currentRow() ); | 133 | int uid = sorted().uidAt(currentRow() ); |
132 | qWarning("uid %d", uid ); | 134 | |
133 | return uid; | 135 | return uid; |
134 | } | 136 | } |
135 | QString TableView::currentRepresentation() { | 137 | QString TableView::currentRepresentation() { |
136 | return text( currentRow(), 2); | 138 | OTodo to = sorted()[currentRow()]; |
139 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; | ||
137 | } | 140 | } |
138 | /* show overdue */ | 141 | /* show overdue */ |
139 | void TableView::showOverDue( bool ) { | 142 | void TableView::showOverDue( bool ) { |
140 | clear(); | 143 | clear(); |
141 | updateView(); | 144 | updateView(); |
142 | } | 145 | } |
143 | 146 | ||
144 | void TableView::updateView( ) { | 147 | void TableView::updateView( ) { |
145 | qWarning("update view"); | 148 | qWarning("update view"); |
146 | m_row = false; | 149 | m_row = false; |
147 | static int id; | 150 | static int id; |
148 | id = startTimer(2000 ); | 151 | id = startTimer(4000 ); |
149 | /* FIXME we want one page to be read! | 152 | /* FIXME we want one page to be read! |
150 | * | 153 | * |
151 | * Calculate that screensize | 154 | * Calculate that screensize |
152 | */ | 155 | */ |
153 | todoWindow()->setReadAhead( 4 ); | 156 | todoWindow()->setReadAhead( 4 ); |
154 | sort(); | 157 | sort(); |
@@ -239,16 +242,13 @@ void TableView::slotClicked(int row, int col, int, | |||
239 | int w = columnWidth( col ); | 242 | int w = columnWidth( col ); |
240 | int h = rowHeight( row ); | 243 | int h = rowHeight( row ); |
241 | if ( x >= ( w - BoxSize ) / 2 && | 244 | if ( x >= ( w - BoxSize ) / 2 && |
242 | x <= ( w - BoxSize ) / 2 + BoxSize && | 245 | x <= ( w - BoxSize ) / 2 + BoxSize && |
243 | y >= ( h - BoxSize ) / 2 && | 246 | y >= ( h - BoxSize ) / 2 && |
244 | y <= ( h - BoxSize ) / 2 + BoxSize ) { | 247 | y <= ( h - BoxSize ) / 2 + BoxSize ) { |
245 | OTodo todo = sorted()[row]; | 248 | TodoView::complete(sorted()[row] ); |
246 | todo.setCompleted( !todo.isCompleted() ); | ||
247 | TodoView::update( todo.uid(), todo ); | ||
248 | updateView(); | ||
249 | } | 249 | } |
250 | } | 250 | } |
251 | break; | 251 | break; |
252 | 252 | ||
253 | case 1: | 253 | case 1: |
254 | break; | 254 | break; |
@@ -366,13 +366,13 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool | |||
366 | } | 366 | } |
367 | break; | 367 | break; |
368 | case 2: | 368 | case 2: |
369 | // description field | 369 | // description field |
370 | { | 370 | { |
371 | QString text = task.summary().isEmpty() ? | 371 | QString text = task.summary().isEmpty() ? |
372 | task.description() : | 372 | task.description().left(20) : |
373 | task.summary(); | 373 | task.summary(); |
374 | p->drawText(2,2 + fm.ascent(), text); | 374 | p->drawText(2,2 + fm.ascent(), text); |
375 | } | 375 | } |
376 | break; | 376 | break; |
377 | case 3: | 377 | case 3: |
378 | { | 378 | { |
@@ -459,13 +459,13 @@ void TableView::slotPriority() { | |||
459 | * filled enough. | 459 | * filled enough. |
460 | * We will try to read ahead 4 items in both ways | 460 | * We will try to read ahead 4 items in both ways |
461 | * up and down. On odd or even we will currentRow()+-4 or +-9 | 461 | * up and down. On odd or even we will currentRow()+-4 or +-9 |
462 | * | 462 | * |
463 | */ | 463 | */ |
464 | void TableView::timerEvent( QTimerEvent* ev ) { | 464 | void TableView::timerEvent( QTimerEvent* ev ) { |
465 | qWarning("sorted %d", sorted().count() ); | 465 | // qWarning("sorted %d", sorted().count() ); |
466 | if (sorted().count() == 0 ) | 466 | if (sorted().count() == 0 ) |
467 | return; | 467 | return; |
468 | 468 | ||
469 | int row = currentRow(); | 469 | int row = currentRow(); |
470 | if ( m_row ) { | 470 | if ( m_row ) { |
471 | int ro = row-4; | 471 | int ro = row-4; |
@@ -510,16 +510,13 @@ void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { | |||
510 | int row = rowAt(m_prevP.y()); | 510 | int row = rowAt(m_prevP.y()); |
511 | int colOld = columnAt(m_prevP.x() ); | 511 | int colOld = columnAt(m_prevP.x() ); |
512 | int colNew = columnAt(e->x() ); | 512 | int colNew = columnAt(e->x() ); |
513 | qWarning("colNew: %d colOld: %d", colNew, colOld ); | 513 | qWarning("colNew: %d colOld: %d", colNew, colOld ); |
514 | if ( row == rowAt( e->y() ) && row != -1 && | 514 | if ( row == rowAt( e->y() ) && row != -1 && |
515 | colOld != colNew ) { | 515 | colOld != colNew ) { |
516 | OTodo todo = sorted()[row]; | 516 | TodoView::complete( sorted()[row] ); |
517 | todo.setCompleted( !todo.isCompleted() ); | ||
518 | TodoView::update( todo.uid(), todo ); | ||
519 | updateView(); | ||
520 | return; | 517 | return; |
521 | } | 518 | } |
522 | QTable::contentsMouseReleaseEvent( e ); | 519 | QTable::contentsMouseReleaseEvent( e ); |
523 | } | 520 | } |
524 | void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { | 521 | void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { |
525 | m_menuTimer->stop(); | 522 | m_menuTimer->stop(); |