summaryrefslogtreecommitdiff
path: root/core/pim/todo/tableview.cpp
Unidiff
Diffstat (limited to 'core/pim/todo/tableview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/todo/tableview.cpp25
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
@@ -26,24 +26,26 @@
26 26
27*/ 27*/
28#include <stdlib.h> 28#include <stdlib.h>
29#include <cmath> 29#include <cmath>
30 30
31#include <qlineedit.h> 31#include <qlineedit.h>
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
42using namespace Todo; 44using namespace Todo;
43 45
44namespace { 46namespace {
45 static const int BoxSize = 14; 47 static const int BoxSize = 14;
46 static const int RowHeight = 20; 48 static const int RowHeight = 20;
47} 49}
48 50
49 51
@@ -111,50 +113,51 @@ TableView::TableView( MainWindow* window, QWidget* wid )
111} 113}
112/* a new day has started 114/* a new day has started
113 * update the day 115 * update the day
114 */ 116 */
115void TableView::newDay() { 117void TableView::newDay() {
116 clear(); 118 clear();
117 updateView(); 119 updateView();
118} 120}
119TableView::~TableView() { 121TableView::~TableView() {
120 122
121} 123}
122void TableView::slotShowMenu() { 124void 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}
127QString TableView::type() const { 129QString TableView::type() const {
128 return QString::fromLatin1( tr("Table View") ); 130 return QString::fromLatin1( tr("Table View") );
129} 131}
130int TableView::current() { 132int 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}
135QString TableView::currentRepresentation() { 137QString 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 */
139void TableView::showOverDue( bool ) { 142void TableView::showOverDue( bool ) {
140 clear(); 143 clear();
141 updateView(); 144 updateView();
142} 145}
143 146
144void TableView::updateView( ) { 147void 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();
155 OTodoAccess::List::Iterator it, end; 158 OTodoAccess::List::Iterator it, end;
156 it = sorted().begin(); 159 it = sorted().begin();
157 end = sorted().end(); 160 end = sorted().end();
158 161
159 qWarning("setTodos"); 162 qWarning("setTodos");
160 QTime time; 163 QTime time;
@@ -233,28 +236,25 @@ void TableView::slotClicked(int row, int col, int,
233 236
234 237
235 switch( col ) { 238 switch( col ) {
236 case 0:{ 239 case 0:{
237 int x = point.x() -columnPos( col ); 240 int x = point.x() -columnPos( col );
238 int y = point.y() -rowPos( row ); 241 int y = point.y() -rowPos( row );
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;
255 255
256 case 2: { 256 case 2: {
257 m_menuTimer->stop(); 257 m_menuTimer->stop();
258 showTodo( ui ); 258 showTodo( ui );
259 break; 259 break;
260 } 260 }
@@ -360,25 +360,25 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
360 break; 360 break;
361 case 1: 361 case 1:
362 // priority field 362 // priority field
363 { 363 {
364 QString text = QString::number(task.priority()); 364 QString text = QString::number(task.priority());
365 p->drawText(2,2 + fm.ascent(), text); 365 p->drawText(2,2 + fm.ascent(), text);
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 {
379 QString text; 379 QString text;
380 if (task.hasDueDate()) { 380 if (task.hasDueDate()) {
381 int off = QDate::currentDate().daysTo( task.dueDate() ); 381 int off = QDate::currentDate().daysTo( task.dueDate() );
382 text = QString::number(off) + tr(" day(s)"); 382 text = QString::number(off) + tr(" day(s)");
383 /* 383 /*
384 * set color if not completed 384 * set color if not completed
@@ -453,25 +453,25 @@ void TableView::setCellContentFromEditor(int row, int col ) {
453} 453}
454void TableView::slotPriority() { 454void TableView::slotPriority() {
455 setCellContentFromEditor( currentRow(), currentColumn() ); 455 setCellContentFromEditor( currentRow(), currentColumn() );
456} 456}
457/* 457/*
458 * We'll use the TimerEvent to read ahead or to keep the cahce always 458 * We'll use the TimerEvent to read ahead or to keep the cahce always
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 */
464void TableView::timerEvent( QTimerEvent* ev ) { 464void 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;
472 if (ro < 0 ) ro = 0; 472 if (ro < 0 ) ro = 0;
473 sorted()[ro]; 473 sorted()[ro];
474 474
475 ro = row+4; 475 ro = row+4;
476 sorted()[ro]; 476 sorted()[ro];
477 } else { 477 } else {
@@ -504,24 +504,21 @@ void TableView::timerEvent( QTimerEvent* ev ) {
504 * in the x coordinate and this way it's able to pass the 504 * in the x coordinate and this way it's able to pass the
505 * m_completeStrokeWidth criteria 505 * m_completeStrokeWidth criteria
506 * WORKAROUND: strike through needs to strike through the same 506 * WORKAROUND: strike through needs to strike through the same
507 * row and two columns! 507 * row and two columns!
508 */ 508 */
509void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { 509void 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}
524void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { 521void TableView::contentsMouseMoveEvent( QMouseEvent* e ) {
525 m_menuTimer->stop(); 522 m_menuTimer->stop();
526 QTable::contentsMouseMoveEvent( e ); 523 QTable::contentsMouseMoveEvent( e );
527} 524}