summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-23 21:07:13 (UTC)
committer zecke <zecke>2002-10-23 21:07:13 (UTC)
commit71f52c08e595cb3bfa3697baa97b4279325fa9ac (patch) (unidiff)
treec33c935ea2da643c5c08ef564898a76a66ebd951
parent60bd9ae80a48f1e2bbd1e1d75a53de0039e979d0 (diff)
downloadopie-71f52c08e595cb3bfa3697baa97b4279325fa9ac.zip
opie-71f52c08e595cb3bfa3697baa97b4279325fa9ac.tar.gz
opie-71f52c08e595cb3bfa3697baa97b4279325fa9ac.tar.bz2
Fix not beeing resizable.. now the Deadline is too wide...
Fix a crash when being somewhere else but releasing the mouse over the table bug Fix one more thing I don't remember Add InlineEditing of summaries. It would actually work on double click but we use the single click for viewing.. Ok these things need to be configurable
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/tableview.cpp174
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
@@ -29,2 +29,3 @@
29 29
30#include <qlineedit.h>
30#include <qtimer.h> 31#include <qtimer.h>
@@ -55,5 +56,7 @@ TableView::TableView( MainWindow* window, QWidget* wid )
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
@@ -66,4 +69,4 @@ TableView::TableView( MainWindow* window, QWidget* wid )
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") );
@@ -313,74 +316,74 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
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 }
@@ -401,2 +404,8 @@ QWidget* TableView::createEditor(int row, int col, bool )const {
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:
@@ -418,2 +427,13 @@ void TableView::setCellContentFromEditor(int row, int col ) {
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 }
@@ -431,2 +451,3 @@ void TableView::slotPriority() {
431void TableView::timerEvent( QTimerEvent* ev ) { 451void TableView::timerEvent( QTimerEvent* ev ) {
452 qWarning("sorted %d", sorted().count() );
432 if (sorted().count() == 0 ) 453 if (sorted().count() == 0 )
@@ -468,4 +489,5 @@ 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];