summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/tableview.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index faf4611..d229f52 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -5,401 +5,403 @@
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
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#include <stdlib.h>
29#include <cmath> 29#include <cmath>
30 30
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qpoint.h> 34#include <qpoint.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36 36
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qpe/resource.h> 38#include <qpe/resource.h>
39 39
40#include <opie/orecur.h> 40#include <opie/orecur.h>
41 41
42#include "mainwindow.h" 42#include "mainwindow.h"
43//#include "tableitems.h" 43//#include "tableitems.h"
44#include "tableview.h" 44#include "tableview.h"
45 45
46using namespace Todo; 46using namespace Todo;
47 47
48namespace { 48namespace {
49 static const int BoxSize = 14; 49 static const int BoxSize = 14;
50 static const int RowHeight = 20; 50 static const int RowHeight = 20;
51} 51}
52 52
53 53
54void TableView::initConfig() { 54void TableView::initConfig() {
55 Config config( "todo" ); 55 Config config( "todo" );
56 config.setGroup( "Options" ); 56 config.setGroup( "Options" );
57 m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); 57 m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 );
58} 58}
59 59
60TableView::TableView( MainWindow* window, QWidget* wid ) 60TableView::TableView( MainWindow* window, QWidget* wid )
61 : QTable( wid ), TodoView( window ) { 61 : QTable( wid ), TodoView( window ) {
62 setUpdatesEnabled( false ); 62 setUpdatesEnabled( false );
63 viewport()->setUpdatesEnabled( false ); 63 viewport()->setUpdatesEnabled( false );
64 m_enablePaint = false; 64 m_enablePaint = false;
65 setNumRows(0); 65 setNumRows(0);
66 setNumCols(4); 66 setNumCols(4);
67 67
68 horizontalHeader()->setLabel( 0, tr("C.") ); 68 horizontalHeader()->setLabel( 0, tr("C.") );
69 horizontalHeader()->setLabel( 1, tr("Prior.") ); 69 horizontalHeader()->setLabel( 1, tr("Priority") );
70 horizontalHeader()->setLabel( 2, tr("Description" ) ); 70 horizontalHeader()->setLabel( 2, tr("Description" ) );
71 horizontalHeader()->setLabel( 3, tr("Deadline") ); 71 horizontalHeader()->setLabel( 3, tr("Deadline") );
72 72
73 setShowDeadline( todoWindow()->showDeadline() );
74
73 setSorting( TRUE ); 75 setSorting( TRUE );
74 setSelectionMode( NoSelection ); 76 setSelectionMode( NoSelection );
75 77
76 setLeftMargin( 0 ); 78 setLeftMargin( 0 );
77 verticalHeader()->hide(); 79 verticalHeader()->hide();
78 80
79 if ( todoWindow()->showDeadline() )
80 showColumn( 3 );
81 else
82 hideColumn( 3 );
83
84 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), 81 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ),
85 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); 82 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) );
86 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), 83 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ),
87 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); 84 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) );
88 connect((QTable*)this, SIGNAL(valueChanged(int, int) ), 85 connect((QTable*)this, SIGNAL(valueChanged(int, int) ),
89 this, SLOT( slotValueChanged(int, int) ) ); 86 this, SLOT( slotValueChanged(int, int) ) );
90 connect((QTable*)this, SIGNAL(currentChanged(int, int) ), 87 connect((QTable*)this, SIGNAL(currentChanged(int, int) ),
91 this, SLOT( slotCurrentChanged(int, int) ) ); 88 this, SLOT( slotCurrentChanged(int, int) ) );
92 89
93 m_menuTimer = new QTimer( this ); 90 m_menuTimer = new QTimer( this );
94 connect( m_menuTimer, SIGNAL(timeout()), 91 connect( m_menuTimer, SIGNAL(timeout()),
95 this, SLOT(slotShowMenu()) ); 92 this, SLOT(slotShowMenu()) );
96 93
97 m_enablePaint = true; 94 m_enablePaint = true;
98 setUpdatesEnabled( true ); 95 setUpdatesEnabled( true );
99 viewport()->setUpdatesEnabled( true ); 96 viewport()->setUpdatesEnabled( true );
100 viewport()->update(); 97 viewport()->update();
101 setSortOrder( 0 ); 98 setSortOrder( 0 );
102 setAscending( TRUE ); 99 setAscending( TRUE );
103 m_first = true; 100 m_first = true;
104 101
105 // Load icons 102 // Load icons
106 // TODO - probably should be done globally somewhere else, see also quickeditimpl.cpp/h 103 // TODO - probably should be done globally somewhere else, see also quickeditimpl.cpp/h
107 m_pic_completed = Resource::loadPixmap( "todo/completed" ); 104 m_pic_completed = Resource::loadPixmap( "todo/completed" );
108 QString namestr; 105 QString namestr;
109 for ( unsigned int i = 1; i < 6; i++ ) { 106 for ( unsigned int i = 1; i < 6; i++ ) {
110 namestr = "todo/priority"; 107 namestr = "todo/priority";
111 namestr.append( QString::number( i ) ); 108 namestr.append( QString::number( i ) );
112 m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); 109 m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr );
113 } 110 }
114 111
115 // Try to intelligently size columns
116 int col2width = 240;
117 int width = m_pic_completed.width();
118 setColumnWidth( 0, width );
119 col2width -= width;
120 width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width()+8;
121 setColumnWidth( 1, width );
122 col2width -= width;
123 width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width()+8;
124 setColumnWidth( 3, width );
125 col2width -= width;
126 setColumnWidth( 2, col2width - 2 );
127
128 /* now let's init the config */ 112 /* now let's init the config */
129 initConfig(); 113 initConfig();
130} 114}
131/* a new day has started 115/* a new day has started
132 * update the day 116 * update the day
133 */ 117 */
134void TableView::newDay() { 118void TableView::newDay() {
135 clear(); 119 clear();
136 updateView(); 120 updateView();
137} 121}
138TableView::~TableView() { 122TableView::~TableView() {
139 123
140} 124}
141void TableView::slotShowMenu() { 125void TableView::slotShowMenu() {
142 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); 126 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() );
143 menu->exec(QCursor::pos() ); 127 menu->exec(QCursor::pos() );
144 delete menu; 128 delete menu;
145} 129}
146QString TableView::type() const { 130QString TableView::type() const {
147 return QString::fromLatin1( tr("Table View") ); 131 return QString::fromLatin1( tr("Table View") );
148} 132}
149int TableView::current() { 133int TableView::current() {
150 int uid = sorted().uidAt(currentRow() ); 134 int uid = sorted().uidAt(currentRow() );
151 135
152 return uid; 136 return uid;
153} 137}
154QString TableView::currentRepresentation() { 138QString TableView::currentRepresentation() {
155 OTodo to = sorted()[currentRow()]; 139 OTodo to = sorted()[currentRow()];
156 return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; 140 return to.summary().isEmpty() ? to.description().left(20) : to.summary() ;
157} 141}
158/* show overdue */ 142/* show overdue */
159void TableView::showOverDue( bool ) { 143void TableView::showOverDue( bool ) {
160 clear(); 144 clear();
161 updateView(); 145 updateView();
162} 146}
163 147
164void TableView::updateView( ) { 148void TableView::updateView( ) {
165 qWarning("update view"); 149 qWarning("update view");
166 m_row = false; 150 m_row = false;
167 static int id; 151 static int id;
168 id = startTimer(4000 ); 152 id = startTimer(4000 );
169 /* FIXME we want one page to be read! 153 /* FIXME we want one page to be read!
170 * 154 *
171 * Calculate that screensize 155 * Calculate that screensize
172 */ 156 */
173 todoWindow()->setReadAhead( 4 ); 157 todoWindow()->setReadAhead( 4 );
174 sort(); 158 sort();
175 OTodoAccess::List::Iterator it, end; 159 OTodoAccess::List::Iterator it, end;
176 it = sorted().begin(); 160 it = sorted().begin();
177 end = sorted().end(); 161 end = sorted().end();
178 162
179 qWarning("setTodos"); 163 qWarning("setTodos");
180 QTime time; 164 QTime time;
181 time.start(); 165 time.start();
182 m_enablePaint = false; 166 m_enablePaint = false;
183 setUpdatesEnabled( false ); 167 setUpdatesEnabled( false );
184 viewport()->setUpdatesEnabled( false ); 168 viewport()->setUpdatesEnabled( false );
185 169
186 setNumRows( it.count() ); 170 setNumRows( it.count() );
187 if ( it.count() == 0 ) 171 if ( it.count() == 0 )
188 killTimer(id); 172 killTimer(id);
189 173
190// int elc = time.elapsed(); 174// int elc = time.elapsed();
191 setUpdatesEnabled( true ); 175 setUpdatesEnabled( true );
192 viewport()->setUpdatesEnabled( true ); 176 viewport()->setUpdatesEnabled( true );
193 viewport()->update(); 177 viewport()->update();
194 178
195 m_enablePaint = true; 179 m_enablePaint = true;
196// int el = time.elapsed(); 180// int el = time.elapsed();
197} 181}
198void TableView::setTodo( int, const OTodo&) { 182void TableView::setTodo( int, const OTodo&) {
199 sort(); 183 sort();
200 184
201 /* repaint */ 185 /* repaint */
202 repaint(); 186 repaint();
203} 187}
204void TableView::addEvent( const OTodo&) { 188void TableView::addEvent( const OTodo&) {
205 189
206 /* fix problems of not showing the 'Haken' */ 190 /* fix problems of not showing the 'Haken' */
207 updateView(); 191 updateView();
208} 192}
209/* 193/*
210 * find the event 194 * find the event
211 * and then replace the complete row 195 * and then replace the complete row
212 */ 196 */
213void TableView::replaceEvent( const OTodo& ev) { 197void TableView::replaceEvent( const OTodo& ev) {
214 addEvent( ev ); 198 addEvent( ev );
215} 199}
216/* 200/*
217 * re aligning table can be slow too 201 * re aligning table can be slow too
218 * FIXME: look what performs better 202 * FIXME: look what performs better
219 * either this or the old align table 203 * either this or the old align table
220 */ 204 */
221void TableView::removeEvent( int ) { 205void TableView::removeEvent( int ) {
222 updateView(); 206 updateView();
223} 207}
224void TableView::setShowCompleted( bool b) { 208void TableView::setShowCompleted( bool b) {
225 qWarning("Show Completed %d" + b ); 209 qWarning("Show Completed %d" + b );
226 updateView(); 210 updateView();
227} 211}
228void TableView::setShowDeadline( bool b) { 212void TableView::setShowDeadline( bool b ) {
229 qWarning("Show DeadLine %d" + b ); 213 qWarning( "Show DeadLine %d" + b );
230 if (b) 214 if ( b )
231 showColumn(3 ); 215 showColumn( 3 );
232 else 216 else
233 hideColumn(3 ); 217 hideColumn( 3 );
218
219 // Try to intelligently size columns
220 // TODO - would use width() below, but doesn't have valid value at time of c'tor
221 int col2width = 238;
222 int width = m_pic_completed.width();
223 setColumnWidth( 0, width );
224 col2width -= width;
225 width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8;
226 setColumnWidth( 1, width );
227 col2width -= width;
228 if ( b ) {
229 width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8;
230 setColumnWidth( 3, width );
231 col2width -= width;
232 }
233 setColumnWidth( 2, col2width );
234} 234}
235void TableView::setShowCategory( const QString& str) { 235void TableView::setShowCategory( const QString& str) {
236 qWarning("setShowCategory"); 236 qWarning("setShowCategory");
237 if ( str != m_oleCat || m_first ) 237 if ( str != m_oleCat || m_first )
238 updateView(); 238 updateView();
239 239
240 m_oleCat = str; 240 m_oleCat = str;
241 m_first = false; 241 m_first = false;
242 242
243} 243}
244void TableView::clear() { 244void TableView::clear() {
245 setNumRows(0); 245 setNumRows(0);
246} 246}
247void TableView::slotClicked(int row, int col, int, 247void TableView::slotClicked(int row, int col, int,
248 const QPoint& point) { 248 const QPoint& point) {
249 if ( !cellGeometry(row, col ).contains(point ) ) 249 if ( !cellGeometry(row, col ).contains(point ) )
250 return; 250 return;
251 251
252 int ui= sorted().uidAt( row ); 252 int ui= sorted().uidAt( row );
253 253
254 254
255 switch( col ) { 255 switch( col ) {
256 case 0:{ 256 case 0:{
257 int x = point.x() -columnPos( col ); 257 int x = point.x() -columnPos( col );
258 int y = point.y() -rowPos( row ); 258 int y = point.y() -rowPos( row );
259 int w = columnWidth( col ); 259 int w = columnWidth( col );
260 int h = rowHeight( row ); 260 int h = rowHeight( row );
261 if ( x >= ( w - BoxSize ) / 2 && 261 if ( x >= ( w - BoxSize ) / 2 &&
262 x <= ( w - BoxSize ) / 2 + BoxSize && 262 x <= ( w - BoxSize ) / 2 + BoxSize &&
263 y >= ( h - BoxSize ) / 2 && 263 y >= ( h - BoxSize ) / 2 &&
264 y <= ( h - BoxSize ) / 2 + BoxSize ) { 264 y <= ( h - BoxSize ) / 2 + BoxSize ) {
265 TodoView::complete(sorted()[row] ); 265 TodoView::complete(sorted()[row] );
266 } 266 }
267 } 267 }
268 break; 268 break;
269 269
270 case 1: 270 case 1:
271 break; 271 break;
272 272
273 case 2: { 273 case 2: {
274 m_menuTimer->stop(); 274 m_menuTimer->stop();
275 showTodo( ui ); 275 showTodo( ui );
276 break; 276 break;
277 } 277 }
278 case 3: { 278 case 3: {
279 m_menuTimer->stop(); 279 m_menuTimer->stop();
280 TodoView::edit( ui ); 280 TodoView::edit( ui );
281 break; 281 break;
282 } 282 }
283 } 283 }
284 284
285 285
286} 286}
287void TableView::slotPressed(int row, int col, int, 287void TableView::slotPressed(int row, int col, int,
288 const QPoint& point) { 288 const QPoint& point) {
289 289
290 qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() ); 290 qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() );
291 m_prevP = point; 291 m_prevP = point;
292 /* TextColumn column */ 292 /* TextColumn column */
293 if ( col == 2 && cellGeometry( row, col ).contains( point ) ) 293 if ( col == 2 && cellGeometry( row, col ).contains( point ) )
294 m_menuTimer->start( 750, TRUE ); 294 m_menuTimer->start( 750, TRUE );
295} 295}
296void TableView::slotValueChanged( int, int ) { 296void TableView::slotValueChanged( int, int ) {
297 qWarning("Value Changed"); 297 qWarning("Value Changed");
298} 298}
299void TableView::slotCurrentChanged(int, int ) { 299void TableView::slotCurrentChanged(int, int ) {
300 m_menuTimer->stop(); 300 m_menuTimer->stop();
301} 301}
302QWidget* TableView::widget() { 302QWidget* TableView::widget() {
303 return this; 303 return this;
304} 304}
305/* 305/*
306 * We need to overwrite sortColumn 306 * We need to overwrite sortColumn
307 * because we want to sort whole row 307 * because we want to sort whole row
308 * based 308 * based
309 * We event want to set the setOrder 309 * We event want to set the setOrder
310 * to a sort() and update() 310 * to a sort() and update()
311 */ 311 */
312void TableView::sortColumn( int col, bool asc, bool ) { 312void TableView::sortColumn( int col, bool asc, bool ) {
313 qWarning("bool %d", asc ); 313 qWarning("bool %d", asc );
314 setSortOrder( col ); 314 setSortOrder( col );
315 setAscending( asc ); 315 setAscending( asc );
316 updateView(); 316 updateView();
317} 317}
318void TableView::viewportPaintEvent( QPaintEvent* e) { 318void TableView::viewportPaintEvent( QPaintEvent* e) {
319 if (m_enablePaint ) 319 if (m_enablePaint )
320 QTable::viewportPaintEvent( e ); 320 QTable::viewportPaintEvent( e );
321} 321}
322/* 322/*
323 * This segment is copyrighted by TT 323 * This segment is copyrighted by TT
324 * it was taken from their todolist 324 * it was taken from their todolist
325 * application this code is GPL 325 * application this code is GPL
326 */ 326 */
327void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 327void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
328 const QColorGroup &cg = colorGroup(); 328 const QColorGroup &cg = colorGroup();
329 329
330 p->save(); 330 p->save();
331 331
332 OTodo task = sorted()[row]; 332 OTodo task = sorted()[row];
333 333
334 // TODO - give user option for grid or bars? 334 // TODO - give user option for grid or bars?
335 335
336 // Paint alternating background bars 336 // Paint alternating background bars
337 if ( (row % 2 ) == 0 ) { 337 if ( (row % 2 ) == 0 ) {
338 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 338 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
339 p->setPen( QPen( cg.text() ) );
339 } 340 }
340 else { 341 else {
341 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); 342 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) );
343 p->setPen( QPen( cg.buttonText() ) );
342 } 344 }
343 345
344 // Paint grid 346 // Paint grid
345 //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 347 //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
346 //QPen op = p->pen(); 348 //QPen op = p->pen();
347 //p->setPen(cg.mid()); 349 //p->setPen(cg.mid());
348 //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); 350 //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 );
349 //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); 351 //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 );
350 //p->setPen(op); 352 //p->setPen(op);
351 353
352 QFont f = p->font(); 354 QFont f = p->font();
353 QFontMetrics fm(f); 355 QFontMetrics fm(f);
354 356
355 int marg = ( cr.width() - BoxSize ) / 2; 357 int marg = ( cr.width() - BoxSize ) / 2;
356 int x = 0; 358 int x = 0;
357 int y = ( cr.height() - BoxSize ) / 2; 359 int y = ( cr.height() - BoxSize ) / 2;
358 360
359 switch(col) { 361 switch(col) {
360 case 0: // completed field 362 case 0: // completed field
361 { 363 {
362 //p->setPen( QPen( cg.text() ) ); 364 //p->setPen( QPen( cg.text() ) );
363 //p->drawRect( x + marg, y, BoxSize, BoxSize ); 365 //p->drawRect( x + marg, y, BoxSize, BoxSize );
364 //p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); 366 //p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
365 if ( task.isCompleted() ) { 367 if ( task.isCompleted() ) {
366 p->drawPixmap( x + marg, y, m_pic_completed ); 368 p->drawPixmap( x + marg, y, m_pic_completed );
367 } 369 }
368 } 370 }
369 break; 371 break;
370 case 1: // priority field 372 case 1: // priority field
371 { 373 {
372 p->drawPixmap( x + marg, y, m_pic_priority[ task.priority() - 1 ] ); 374 p->drawPixmap( x + marg, y, m_pic_priority[ task.priority() - 1 ] );
373 } 375 }
374 break; 376 break;
375 case 2: // description field 377 case 2: // description field
376 { 378 {
377 QString text = task.summary().isEmpty() ? 379 QString text = task.summary().isEmpty() ?
378 task.description().left(20) : 380 task.description().left(20) :
379 task.summary(); 381 task.summary();
380 p->drawText(2,2 + fm.ascent(), text); 382 p->drawText(2,2 + fm.ascent(), text);
381 } 383 }
382 break; 384 break;
383 case 3: 385 case 3:
384 { 386 {
385 QString text; 387 QString text;
386 if (task.hasDueDate()) { 388 if (task.hasDueDate()) {
387 int off = QDate::currentDate().daysTo( task.dueDate() ); 389 int off = QDate::currentDate().daysTo( task.dueDate() );
388 text = tr( "%1 day(s)").arg(QString::number(off)); 390 text = tr( "%1 day(s)").arg(QString::number(off));
389 /* 391 /*
390 * set color if not completed 392 * set color if not completed
391 */ 393 */
392 if (!task.isCompleted() ) { 394 if (!task.isCompleted() ) {
393 QColor color = Qt::black; 395 QColor color = Qt::black;
394 if ( off < 0 ) 396 if ( off < 0 )
395 color = Qt::red; 397 color = Qt::red;
396 else if ( off == 0 ) 398 else if ( off == 0 )
397 color = Qt::yellow; 399 color = Qt::yellow;
398 else if ( off > 0 ) 400 else if ( off > 0 )
399 color = Qt::green; 401 color = Qt::green;
400 p->setPen(color ); 402 p->setPen(color );
401 } 403 }
402 } else { 404 } else {
403 text = tr("None"); 405 text = tr("None");
404 } 406 }
405 p->drawText(2,2 + fm.ascent(), text); 407 p->drawText(2,2 + fm.ascent(), text);