-rw-r--r-- | core/pim/todo/tableview.cpp | 174 |
1 files changed, 98 insertions, 76 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index c4165db..6299113 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -28,4 +28,5 @@ | |||
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | 29 | ||
30 | #include <qlineedit.h> | ||
30 | #include <qtimer.h> | 31 | #include <qtimer.h> |
31 | #include <qpoint.h> | 32 | #include <qpoint.h> |
@@ -54,7 +55,9 @@ TableView::TableView( MainWindow* window, QWidget* wid ) | |||
54 | setSorting( TRUE ); | 55 | setSorting( TRUE ); |
55 | setSelectionMode( NoSelection ); | 56 | setSelectionMode( NoSelection ); |
56 | setColumnStretchable( 2, TRUE ); | 57 | // setColumnStretchable( 2, TRUE ); |
58 | setColumnStretchable( 3, FALSE ); | ||
57 | setColumnWidth(0, 20 ); | 59 | setColumnWidth(0, 20 ); |
58 | setColumnWidth(1, 35 ); | 60 | setColumnWidth(1, 35 ); |
61 | setColumnWidth(3, 18 ); | ||
59 | 62 | ||
60 | setLeftMargin( 0 ); | 63 | setLeftMargin( 0 ); |
@@ -65,6 +68,6 @@ TableView::TableView( MainWindow* window, QWidget* wid ) | |||
65 | horizontalHeader()->setLabel(2, tr("Description" ) ); | 68 | horizontalHeader()->setLabel(2, tr("Description" ) ); |
66 | 69 | ||
67 | setColumnStretchable(3, FALSE ); | 70 | // setColumnStretchable(3, FALSE ); |
68 | setColumnWidth(3, 20 ); | 71 | |
69 | horizontalHeader()->setLabel(3, tr("Deadline") ); | 72 | horizontalHeader()->setLabel(3, tr("Deadline") ); |
70 | 73 | ||
@@ -312,76 +315,76 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool | |||
312 | switch(col) { | 315 | switch(col) { |
313 | case 0: | 316 | case 0: |
314 | { | 317 | { |
315 | // completed field | 318 | // completed field |
316 | int marg = ( cr.width() - BoxSize ) / 2; | 319 | int marg = ( cr.width() - BoxSize ) / 2; |
317 | int x = 0; | 320 | int x = 0; |
318 | int y = ( cr.height() - BoxSize ) / 2; | 321 | int y = ( cr.height() - BoxSize ) / 2; |
319 | p->setPen( QPen( cg.text() ) ); | 322 | p->setPen( QPen( cg.text() ) ); |
320 | p->drawRect( x + marg, y, BoxSize, BoxSize ); | 323 | p->drawRect( x + marg, y, BoxSize, BoxSize ); |
321 | p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); | 324 | p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); |
322 | p->setPen( darkGreen ); | 325 | p->setPen( darkGreen ); |
323 | x += 1; | 326 | x += 1; |
324 | y += 1; | 327 | y += 1; |
325 | if ( task.isCompleted() ) { | 328 | if ( task.isCompleted() ) { |
326 | QPointArray a( 9*2 ); | 329 | QPointArray a( 9*2 ); |
327 | int i, xx, yy; | 330 | int i, xx, yy; |
328 | xx = x+2+marg; | 331 | xx = x+2+marg; |
329 | yy = y+4; | 332 | yy = y+4; |
330 | for ( i=0; i<4; i++ ) { | 333 | for ( i=0; i<4; i++ ) { |
331 | a.setPoint( 2*i, xx, yy ); | 334 | a.setPoint( 2*i, xx, yy ); |
332 | a.setPoint( 2*i+1, xx, yy+2 ); | 335 | a.setPoint( 2*i+1, xx, yy+2 ); |
333 | xx++; yy++; | 336 | xx++; yy++; |
334 | } | 337 | } |
335 | yy -= 2; | 338 | yy -= 2; |
336 | for ( i=4; i<9; i++ ) { | 339 | for ( i=4; i<9; i++ ) { |
337 | a.setPoint( 2*i, xx, yy ); | 340 | a.setPoint( 2*i, xx, yy ); |
338 | a.setPoint( 2*i+1, xx, yy+2 ); | 341 | a.setPoint( 2*i+1, xx, yy+2 ); |
339 | xx++; yy--; | 342 | xx++; yy--; |
340 | } | 343 | } |
341 | p->drawLineSegments( a ); | 344 | p->drawLineSegments( a ); |
342 | } | 345 | } |
343 | } | 346 | } |
344 | break; | 347 | break; |
345 | case 1: | 348 | case 1: |
346 | // priority field | 349 | // priority field |
347 | { | 350 | { |
348 | QString text = QString::number(task.priority()); | 351 | QString text = QString::number(task.priority()); |
349 | p->drawText(2,2 + fm.ascent(), text); | 352 | p->drawText(2,2 + fm.ascent(), text); |
350 | } | 353 | } |
351 | break; | 354 | break; |
352 | case 2: | 355 | case 2: |
353 | // description field | 356 | // description field |
354 | { | 357 | { |
355 | QString text = task.summary().isEmpty() ? | 358 | QString text = task.summary().isEmpty() ? |
356 | task.description() : | 359 | task.description() : |
357 | task.summary(); | 360 | task.summary(); |
358 | p->drawText(2,2 + fm.ascent(), text); | 361 | p->drawText(2,2 + fm.ascent(), text); |
359 | } | 362 | } |
360 | break; | 363 | break; |
361 | case 3: | 364 | case 3: |
362 | { | 365 | { |
363 | QString text; | 366 | QString text; |
364 | if (task.hasDueDate()) { | 367 | if (task.hasDueDate()) { |
365 | int off = QDate::currentDate().daysTo( task.dueDate() ); | 368 | int off = QDate::currentDate().daysTo( task.dueDate() ); |
366 | text = QString::number(off) + tr(" day(s)"); | 369 | text = QString::number(off) + tr(" day(s)"); |
367 | /* | 370 | /* |
368 | * set color if not completed | 371 | * set color if not completed |
369 | */ | 372 | */ |
370 | if (!task.isCompleted() ) { | 373 | if (!task.isCompleted() ) { |
371 | QColor color = Qt::black; | 374 | QColor color = Qt::black; |
372 | if ( off < 0 ) | 375 | if ( off < 0 ) |
373 | color = Qt::red; | 376 | color = Qt::red; |
374 | else if ( off == 0 ) | 377 | else if ( off == 0 ) |
375 | color = Qt::yellow; | 378 | color = Qt::yellow; |
376 | else if ( off > 0 ) | 379 | else if ( off > 0 ) |
377 | color = Qt::green; | 380 | color = Qt::green; |
378 | p->setPen(color ); | 381 | p->setPen(color ); |
379 | } | 382 | } |
380 | } else { | 383 | } else { |
381 | text = tr("None"); | 384 | text = tr("None"); |
382 | } | 385 | } |
383 | p->drawText(2,2 + fm.ascent(), text); | 386 | p->drawText(2,2 + fm.ascent(), text); |
384 | } | 387 | } |
385 | break; | 388 | break; |
386 | } | 389 | } |
387 | p->restore(); | 390 | p->restore(); |
@@ -400,4 +403,10 @@ QWidget* TableView::createEditor(int row, int col, bool )const { | |||
400 | return combo; | 403 | return combo; |
401 | } | 404 | } |
405 | /* summary */ | ||
406 | case 2:{ | ||
407 | QLineEdit* edit = new QLineEdit( viewport() ); | ||
408 | edit->setText( sorted()[row].summary() ); | ||
409 | return edit; | ||
410 | } | ||
402 | case 0: | 411 | case 0: |
403 | default: | 412 | default: |
@@ -417,4 +426,15 @@ void TableView::setCellContentFromEditor(int row, int col ) { | |||
417 | } | 426 | } |
418 | } | 427 | } |
428 | }else if ( col == 2) { | ||
429 | QWidget* wid = cellWidget(row, 2); | ||
430 | if ( wid->inherits("QLineEdit") ) { | ||
431 | QString text = ((QLineEdit*)wid)->text(); | ||
432 | OTodo todo = sorted()[row]; | ||
433 | if ( todo.summary() != text ) { | ||
434 | todo.setSummary( text ); | ||
435 | TodoView::update( todo.uid(), todo ); | ||
436 | updateView(); | ||
437 | } | ||
438 | } | ||
419 | } | 439 | } |
420 | } | 440 | } |
@@ -430,4 +450,5 @@ void TableView::slotPriority() { | |||
430 | */ | 450 | */ |
431 | void TableView::timerEvent( QTimerEvent* ev ) { | 451 | void TableView::timerEvent( QTimerEvent* ev ) { |
452 | qWarning("sorted %d", sorted().count() ); | ||
432 | if (sorted().count() == 0 ) | 453 | if (sorted().count() == 0 ) |
433 | return; | 454 | return; |
@@ -467,6 +488,7 @@ void TableView::timerEvent( QTimerEvent* ev ) { | |||
467 | void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { | 488 | void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { |
468 | int row = rowAt(m_prevP.y()); | 489 | int row = rowAt(m_prevP.y()); |
469 | if ( row == rowAt( e->y() ) ) { | 490 | if ( row == rowAt( e->y() ) && row != -1 ) { |
470 | if ( abs( m_prevP.x() - e->x() ) >= 8 ) { | 491 | if ( abs( m_prevP.x() - e->x() ) >= 8 ) { |
492 | qWarning("current row %d", row ); | ||
471 | OTodo todo = sorted()[row]; | 493 | OTodo todo = sorted()[row]; |
472 | todo.setCompleted( !todo.isCompleted() ); | 494 | todo.setCompleted( !todo.isCompleted() ); |