summaryrefslogtreecommitdiff
authorzecke <zecke>2002-11-02 13:47:01 (UTC)
committer zecke <zecke>2002-11-02 13:47:01 (UTC)
commitd21d693d91af8ee8fb54478a6db67f5a0590a767 (patch) (unidiff)
treeb38c34f39d70d056fb99cdd35515e2308b06c74a
parentf655415f77b200f9edfbe5732cd5f8da2b4dec47 (diff)
downloadopie-d21d693d91af8ee8fb54478a6db67f5a0590a767.zip
opie-d21d693d91af8ee8fb54478a6db67f5a0590a767.tar.gz
opie-d21d693d91af8ee8fb54478a6db67f5a0590a767.tar.bz2
Cut some warning
and applied trekres customStrokeWidth patch
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/tableview.cpp14
-rw-r--r--core/pim/todo/tableview.h2
-rw-r--r--core/pim/todo/todoview.cpp4
3 files changed, 17 insertions, 3 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index 6299113..743deb7 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -1,505 +1,517 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
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 30
30#include <qlineedit.h> 31#include <qlineedit.h>
31#include <qtimer.h> 32#include <qtimer.h>
32#include <qpoint.h> 33#include <qpoint.h>
33#include <qpopupmenu.h> 34#include <qpopupmenu.h>
34 35
36#include <qpe/config.h>
37
35#include "mainwindow.h" 38#include "mainwindow.h"
36//#include "tableitems.h" 39//#include "tableitems.h"
37#include "tableview.h" 40#include "tableview.h"
38 41
39using namespace Todo; 42using namespace Todo;
40 43
41namespace { 44namespace {
42 static const int BoxSize = 14; 45 static const int BoxSize = 14;
43 static const int RowHeight = 20; 46 static const int RowHeight = 20;
44} 47}
45 48
46 49
50void TableView::initConfig() {
51 Config config( "todo" );
52 config.setGroup( "Options" );
53 m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 );
54}
55
47TableView::TableView( MainWindow* window, QWidget* wid ) 56TableView::TableView( MainWindow* window, QWidget* wid )
48 : QTable( wid ), TodoView( window ) { 57 : QTable( wid ), TodoView( window ) {
49 setUpdatesEnabled( false ); 58 setUpdatesEnabled( false );
50 viewport()->setUpdatesEnabled( false ); 59 viewport()->setUpdatesEnabled( false );
51 m_enablePaint = false; 60 m_enablePaint = false;
52 setNumRows(0); 61 setNumRows(0);
53 setNumCols(4); 62 setNumCols(4);
54 63
55 setSorting( TRUE ); 64 setSorting( TRUE );
56 setSelectionMode( NoSelection ); 65 setSelectionMode( NoSelection );
57// setColumnStretchable( 2, TRUE ); 66// setColumnStretchable( 2, TRUE );
58 setColumnStretchable( 3, FALSE ); 67 setColumnStretchable( 3, FALSE );
59 setColumnWidth(0, 20 ); 68 setColumnWidth(0, 20 );
60 setColumnWidth(1, 35 ); 69 setColumnWidth(1, 35 );
61 setColumnWidth(3, 18 ); 70 setColumnWidth(3, 18 );
62 71
63 setLeftMargin( 0 ); 72 setLeftMargin( 0 );
64 verticalHeader()->hide(); 73 verticalHeader()->hide();
65 74
66 horizontalHeader()->setLabel(0, tr("C.") ); 75 horizontalHeader()->setLabel(0, tr("C.") );
67 horizontalHeader()->setLabel(1, tr("Prior.") ); 76 horizontalHeader()->setLabel(1, tr("Prior.") );
68 horizontalHeader()->setLabel(2, tr("Description" ) ); 77 horizontalHeader()->setLabel(2, tr("Description" ) );
69 78
70// setColumnStretchable(3, FALSE ); 79// setColumnStretchable(3, FALSE );
71 80
72 horizontalHeader()->setLabel(3, tr("Deadline") ); 81 horizontalHeader()->setLabel(3, tr("Deadline") );
73 82
74 if ( todoWindow()->showDeadline() ) 83 if ( todoWindow()->showDeadline() )
75 showColumn( 3); 84 showColumn( 3);
76 else 85 else
77 hideColumn(3 ); 86 hideColumn(3 );
78 87
79 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), 88 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ),
80 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); 89 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) );
81 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), 90 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ),
82 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); 91 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) );
83 connect((QTable*)this, SIGNAL(valueChanged(int, int) ), 92 connect((QTable*)this, SIGNAL(valueChanged(int, int) ),
84 this, SLOT( slotValueChanged(int, int) ) ); 93 this, SLOT( slotValueChanged(int, int) ) );
85 connect((QTable*)this, SIGNAL(currentChanged(int, int) ), 94 connect((QTable*)this, SIGNAL(currentChanged(int, int) ),
86 this, SLOT( slotCurrentChanged(int, int) ) ); 95 this, SLOT( slotCurrentChanged(int, int) ) );
87 96
88 m_menuTimer = new QTimer( this ); 97 m_menuTimer = new QTimer( this );
89 connect( m_menuTimer, SIGNAL(timeout()), 98 connect( m_menuTimer, SIGNAL(timeout()),
90 this, SLOT(slotShowMenu()) ); 99 this, SLOT(slotShowMenu()) );
91 100
92 m_enablePaint = true; 101 m_enablePaint = true;
93 setUpdatesEnabled( true ); 102 setUpdatesEnabled( true );
94 viewport()->setUpdatesEnabled( true ); 103 viewport()->setUpdatesEnabled( true );
95 viewport()->update(); 104 viewport()->update();
96 setSortOrder( 0 ); 105 setSortOrder( 0 );
97 setAscending( TRUE ); 106 setAscending( TRUE );
98 m_first = true; 107 m_first = true;
108
109 /* now let's init the config */
110 initConfig();
99} 111}
100/* a new day has started 112/* a new day has started
101 * update the day 113 * update the day
102 */ 114 */
103void TableView::newDay() { 115void TableView::newDay() {
104 clear(); 116 clear();
105 updateView(); 117 updateView();
106} 118}
107TableView::~TableView() { 119TableView::~TableView() {
108 120
109} 121}
110void TableView::slotShowMenu() { 122void TableView::slotShowMenu() {
111 QPopupMenu *menu = todoWindow()->contextMenu( current() ); 123 QPopupMenu *menu = todoWindow()->contextMenu( current() );
112 menu->exec(QCursor::pos() ); 124 menu->exec(QCursor::pos() );
113 delete menu; 125 delete menu;
114} 126}
115QString TableView::type() const { 127QString TableView::type() const {
116 return QString::fromLatin1( tr("Table View") ); 128 return QString::fromLatin1( tr("Table View") );
117} 129}
118int TableView::current() { 130int TableView::current() {
119 int uid = sorted().uidAt(currentRow() ); 131 int uid = sorted().uidAt(currentRow() );
120 qWarning("uid %d", uid ); 132 qWarning("uid %d", uid );
121 return uid; 133 return uid;
122} 134}
123QString TableView::currentRepresentation() { 135QString TableView::currentRepresentation() {
124 return text( currentRow(), 2); 136 return text( currentRow(), 2);
125} 137}
126/* show overdue */ 138/* show overdue */
127void TableView::showOverDue( bool ) { 139void TableView::showOverDue( bool ) {
128 clear(); 140 clear();
129 updateView(); 141 updateView();
130} 142}
131 143
132void TableView::updateView( ) { 144void TableView::updateView( ) {
133 qWarning("update view"); 145 qWarning("update view");
134 m_row = false; 146 m_row = false;
135 static int id; 147 static int id;
136 id = startTimer(2000 ); 148 id = startTimer(2000 );
137 /* FIXME we want one page to be read! 149 /* FIXME we want one page to be read!
138 * 150 *
139 * Calculate that screensize 151 * Calculate that screensize
140 */ 152 */
141 todoWindow()->setReadAhead( 4 ); 153 todoWindow()->setReadAhead( 4 );
142 sort(); 154 sort();
143 OTodoAccess::List::Iterator it, end; 155 OTodoAccess::List::Iterator it, end;
144 it = sorted().begin(); 156 it = sorted().begin();
145 end = sorted().end(); 157 end = sorted().end();
146 158
147 qWarning("setTodos"); 159 qWarning("setTodos");
148 QTime time; 160 QTime time;
149 time.start(); 161 time.start();
150 m_enablePaint = false; 162 m_enablePaint = false;
151 setUpdatesEnabled( false ); 163 setUpdatesEnabled( false );
152 viewport()->setUpdatesEnabled( false ); 164 viewport()->setUpdatesEnabled( false );
153 165
154 setNumRows( it.count() ); 166 setNumRows( it.count() );
155 if ( it.count() == 0 ) 167 if ( it.count() == 0 )
156 killTimer(id); 168 killTimer(id);
157 169
158 int elc = time.elapsed(); 170 int elc = time.elapsed();
159 setUpdatesEnabled( true ); 171 setUpdatesEnabled( true );
160 viewport()->setUpdatesEnabled( true ); 172 viewport()->setUpdatesEnabled( true );
161 viewport()->update(); 173 viewport()->update();
162 174
163 m_enablePaint = true; 175 m_enablePaint = true;
164 int el = time.elapsed(); 176 int el = time.elapsed();
165} 177}
166void TableView::setTodo( int, const OTodo&) { 178void TableView::setTodo( int, const OTodo&) {
167 sort(); 179 sort();
168 180
169 /* repaint */ 181 /* repaint */
170 repaint(); 182 repaint();
171} 183}
172void TableView::addEvent( const OTodo&) { 184void TableView::addEvent( const OTodo&) {
173 185
174 /* fix problems of not showing the 'Haken' */ 186 /* fix problems of not showing the 'Haken' */
175 updateView(); 187 updateView();
176} 188}
177/* 189/*
178 * find the event 190 * find the event
179 * and then replace the complete row 191 * and then replace the complete row
180 */ 192 */
181void TableView::replaceEvent( const OTodo& ev) { 193void TableView::replaceEvent( const OTodo& ev) {
182 addEvent( ev ); 194 addEvent( ev );
183} 195}
184/* 196/*
185 * re aligning table can be slow too 197 * re aligning table can be slow too
186 * FIXME: look what performs better 198 * FIXME: look what performs better
187 * either this or the old align table 199 * either this or the old align table
188 */ 200 */
189void TableView::removeEvent( int ) { 201void TableView::removeEvent( int ) {
190 updateView(); 202 updateView();
191} 203}
192void TableView::setShowCompleted( bool b) { 204void TableView::setShowCompleted( bool b) {
193 qWarning("Show Completed %d" + b ); 205 qWarning("Show Completed %d" + b );
194 updateView(); 206 updateView();
195} 207}
196void TableView::setShowDeadline( bool b) { 208void TableView::setShowDeadline( bool b) {
197 qWarning("Show DeadLine %d" + b ); 209 qWarning("Show DeadLine %d" + b );
198 if (b) 210 if (b)
199 showColumn(3 ); 211 showColumn(3 );
200 else 212 else
201 hideColumn(3 ); 213 hideColumn(3 );
202} 214}
203void TableView::setShowCategory( const QString& str) { 215void TableView::setShowCategory( const QString& str) {
204 qWarning("setShowCategory"); 216 qWarning("setShowCategory");
205 if ( str != m_oleCat || m_first ) 217 if ( str != m_oleCat || m_first )
206 updateView(); 218 updateView();
207 219
208 m_oleCat = str; 220 m_oleCat = str;
209 m_first = false; 221 m_first = false;
210 222
211} 223}
212void TableView::clear() { 224void TableView::clear() {
213 setNumRows(0); 225 setNumRows(0);
214} 226}
215void TableView::slotClicked(int row, int col, int, 227void TableView::slotClicked(int row, int col, int,
216 const QPoint& point) { 228 const QPoint& point) {
217 if ( !cellGeometry(row, col ).contains(point ) ) 229 if ( !cellGeometry(row, col ).contains(point ) )
218 return; 230 return;
219 231
220 int ui= sorted().uidAt( row ); 232 int ui= sorted().uidAt( row );
221 233
222 234
223 switch( col ) { 235 switch( col ) {
224 case 0:{ 236 case 0:{
225 int x = point.x() -columnPos( col ); 237 int x = point.x() -columnPos( col );
226 int y = point.y() -rowPos( row ); 238 int y = point.y() -rowPos( row );
227 int w = columnWidth( col ); 239 int w = columnWidth( col );
228 int h = rowHeight( row ); 240 int h = rowHeight( row );
229 if ( x >= ( w - BoxSize ) / 2 && 241 if ( x >= ( w - BoxSize ) / 2 &&
230 x <= ( w - BoxSize ) / 2 + BoxSize && 242 x <= ( w - BoxSize ) / 2 + BoxSize &&
231 y >= ( h - BoxSize ) / 2 && 243 y >= ( h - BoxSize ) / 2 &&
232 y <= ( h - BoxSize ) / 2 + BoxSize ) { 244 y <= ( h - BoxSize ) / 2 + BoxSize ) {
233 OTodo todo = sorted()[row]; 245 OTodo todo = sorted()[row];
234 todo.setCompleted( !todo.isCompleted() ); 246 todo.setCompleted( !todo.isCompleted() );
235 TodoView::update( todo.uid(), todo ); 247 TodoView::update( todo.uid(), todo );
236 updateView(); 248 updateView();
237 } 249 }
238 } 250 }
239 break; 251 break;
240 252
241 case 1: 253 case 1:
242 break; 254 break;
243 255
244 case 2: { 256 case 2: {
245 m_menuTimer->stop(); 257 m_menuTimer->stop();
246 showTodo( ui ); 258 showTodo( ui );
247 break; 259 break;
248 } 260 }
249 case 3: { 261 case 3: {
250 m_menuTimer->stop(); 262 m_menuTimer->stop();
251 TodoView::edit( ui ); 263 TodoView::edit( ui );
252 break; 264 break;
253 } 265 }
254 } 266 }
255 267
256 268
257} 269}
258void TableView::slotPressed(int row, int col, int, 270void TableView::slotPressed(int row, int col, int,
259 const QPoint& point) { 271 const QPoint& point) {
260 272
261 m_prevP = point; 273 m_prevP = point;
262 /* TextColumn column */ 274 /* TextColumn column */
263 if ( col == 2 && cellGeometry( row, col ).contains( point ) ) 275 if ( col == 2 && cellGeometry( row, col ).contains( point ) )
264 m_menuTimer->start( 750, TRUE ); 276 m_menuTimer->start( 750, TRUE );
265} 277}
266void TableView::slotValueChanged( int, int ) { 278void TableView::slotValueChanged( int, int ) {
267 qWarning("Value Changed"); 279 qWarning("Value Changed");
268} 280}
269void TableView::slotCurrentChanged(int, int ) { 281void TableView::slotCurrentChanged(int, int ) {
270 m_menuTimer->stop(); 282 m_menuTimer->stop();
271} 283}
272QWidget* TableView::widget() { 284QWidget* TableView::widget() {
273 return this; 285 return this;
274} 286}
275/* 287/*
276 * We need to overwrite sortColumn 288 * We need to overwrite sortColumn
277 * because we want to sort whole row 289 * because we want to sort whole row
278 * based 290 * based
279 * We event want to set the setOrder 291 * We event want to set the setOrder
280 * to a sort() and update() 292 * to a sort() and update()
281 */ 293 */
282void TableView::sortColumn( int col, bool asc, bool ) { 294void TableView::sortColumn( int col, bool asc, bool ) {
283 qWarning("bool %d", asc ); 295 qWarning("bool %d", asc );
284 setSortOrder( col ); 296 setSortOrder( col );
285 setAscending( asc ); 297 setAscending( asc );
286 updateView(); 298 updateView();
287} 299}
288void TableView::viewportPaintEvent( QPaintEvent* e) { 300void TableView::viewportPaintEvent( QPaintEvent* e) {
289 if (m_enablePaint ) 301 if (m_enablePaint )
290 QTable::viewportPaintEvent( e ); 302 QTable::viewportPaintEvent( e );
291} 303}
292/* 304/*
293 * This segment is copyrighted by TT 305 * This segment is copyrighted by TT
294 * it was taken from their todolist 306 * it was taken from their todolist
295 * application this code is GPL 307 * application this code is GPL
296 */ 308 */
297void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 309void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
298 const QColorGroup &cg = colorGroup(); 310 const QColorGroup &cg = colorGroup();
299 311
300 p->save(); 312 p->save();
301 313
302 OTodo task = sorted()[row]; 314 OTodo task = sorted()[row];
303 315
304 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 316 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
305 317
306 QPen op = p->pen(); 318 QPen op = p->pen();
307 p->setPen(cg.mid()); 319 p->setPen(cg.mid());
308 p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); 320 p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 );
309 p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); 321 p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 );
310 p->setPen(op); 322 p->setPen(op);
311 323
312 QFont f = p->font(); 324 QFont f = p->font();
313 QFontMetrics fm(f); 325 QFontMetrics fm(f);
314 326
315 switch(col) { 327 switch(col) {
316 case 0: 328 case 0:
317 { 329 {
318 // completed field 330 // completed field
319 int marg = ( cr.width() - BoxSize ) / 2; 331 int marg = ( cr.width() - BoxSize ) / 2;
320 int x = 0; 332 int x = 0;
321 int y = ( cr.height() - BoxSize ) / 2; 333 int y = ( cr.height() - BoxSize ) / 2;
322 p->setPen( QPen( cg.text() ) ); 334 p->setPen( QPen( cg.text() ) );
323 p->drawRect( x + marg, y, BoxSize, BoxSize ); 335 p->drawRect( x + marg, y, BoxSize, BoxSize );
324 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); 336 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
325 p->setPen( darkGreen ); 337 p->setPen( darkGreen );
326 x += 1; 338 x += 1;
327 y += 1; 339 y += 1;
328 if ( task.isCompleted() ) { 340 if ( task.isCompleted() ) {
329 QPointArray a( 9*2 ); 341 QPointArray a( 9*2 );
330 int i, xx, yy; 342 int i, xx, yy;
331 xx = x+2+marg; 343 xx = x+2+marg;
332 yy = y+4; 344 yy = y+4;
333 for ( i=0; i<4; i++ ) { 345 for ( i=0; i<4; i++ ) {
334 a.setPoint( 2*i, xx, yy ); 346 a.setPoint( 2*i, xx, yy );
335 a.setPoint( 2*i+1, xx, yy+2 ); 347 a.setPoint( 2*i+1, xx, yy+2 );
336 xx++; yy++; 348 xx++; yy++;
337 } 349 }
338 yy -= 2; 350 yy -= 2;
339 for ( i=4; i<9; i++ ) { 351 for ( i=4; i<9; i++ ) {
340 a.setPoint( 2*i, xx, yy ); 352 a.setPoint( 2*i, xx, yy );
341 a.setPoint( 2*i+1, xx, yy+2 ); 353 a.setPoint( 2*i+1, xx, yy+2 );
342 xx++; yy--; 354 xx++; yy--;
343 } 355 }
344 p->drawLineSegments( a ); 356 p->drawLineSegments( a );
345 } 357 }
346 } 358 }
347 break; 359 break;
348 case 1: 360 case 1:
349 // priority field 361 // priority field
350 { 362 {
351 QString text = QString::number(task.priority()); 363 QString text = QString::number(task.priority());
352 p->drawText(2,2 + fm.ascent(), text); 364 p->drawText(2,2 + fm.ascent(), text);
353 } 365 }
354 break; 366 break;
355 case 2: 367 case 2:
356 // description field 368 // description field
357 { 369 {
358 QString text = task.summary().isEmpty() ? 370 QString text = task.summary().isEmpty() ?
359 task.description() : 371 task.description() :
360 task.summary(); 372 task.summary();
361 p->drawText(2,2 + fm.ascent(), text); 373 p->drawText(2,2 + fm.ascent(), text);
362 } 374 }
363 break; 375 break;
364 case 3: 376 case 3:
365 { 377 {
366 QString text; 378 QString text;
367 if (task.hasDueDate()) { 379 if (task.hasDueDate()) {
368 int off = QDate::currentDate().daysTo( task.dueDate() ); 380 int off = QDate::currentDate().daysTo( task.dueDate() );
369 text = QString::number(off) + tr(" day(s)"); 381 text = QString::number(off) + tr(" day(s)");
370 /* 382 /*
371 * set color if not completed 383 * set color if not completed
372 */ 384 */
373 if (!task.isCompleted() ) { 385 if (!task.isCompleted() ) {
374 QColor color = Qt::black; 386 QColor color = Qt::black;
375 if ( off < 0 ) 387 if ( off < 0 )
376 color = Qt::red; 388 color = Qt::red;
377 else if ( off == 0 ) 389 else if ( off == 0 )
378 color = Qt::yellow; 390 color = Qt::yellow;
379 else if ( off > 0 ) 391 else if ( off > 0 )
380 color = Qt::green; 392 color = Qt::green;
381 p->setPen(color ); 393 p->setPen(color );
382 } 394 }
383 } else { 395 } else {
384 text = tr("None"); 396 text = tr("None");
385 } 397 }
386 p->drawText(2,2 + fm.ascent(), text); 398 p->drawText(2,2 + fm.ascent(), text);
387 } 399 }
388 break; 400 break;
389 } 401 }
390 p->restore(); 402 p->restore();
391} 403}
392QWidget* TableView::createEditor(int row, int col, bool )const { 404QWidget* TableView::createEditor(int row, int col, bool )const {
393 switch( col ) { 405 switch( col ) {
394 case 1: { 406 case 1: {
395 /* the priority stuff */ 407 /* the priority stuff */
396 QComboBox* combo = new QComboBox( viewport() ); 408 QComboBox* combo = new QComboBox( viewport() );
397 combo->insertItem( "1" ); 409 combo->insertItem( "1" );
398 combo->insertItem( "2" ); 410 combo->insertItem( "2" );
399 combo->insertItem( "3" ); 411 combo->insertItem( "3" );
400 combo->insertItem( "4" ); 412 combo->insertItem( "4" );
401 combo->insertItem( "5" ); 413 combo->insertItem( "5" );
402 combo->setCurrentItem( sorted()[row].priority()-1 ); 414 combo->setCurrentItem( sorted()[row].priority()-1 );
403 return combo; 415 return combo;
404 } 416 }
405 /* summary */ 417 /* summary */
406 case 2:{ 418 case 2:{
407 QLineEdit* edit = new QLineEdit( viewport() ); 419 QLineEdit* edit = new QLineEdit( viewport() );
408 edit->setText( sorted()[row].summary() ); 420 edit->setText( sorted()[row].summary() );
409 return edit; 421 return edit;
410 } 422 }
411 case 0: 423 case 0:
412 default: 424 default:
413 return 0l; 425 return 0l;
414 } 426 }
415} 427}
416void TableView::setCellContentFromEditor(int row, int col ) { 428void TableView::setCellContentFromEditor(int row, int col ) {
417 if ( col == 1 ) { 429 if ( col == 1 ) {
418 QWidget* wid = cellWidget(row, 1 ); 430 QWidget* wid = cellWidget(row, 1 );
419 if ( wid->inherits("QComboBox") ) { 431 if ( wid->inherits("QComboBox") ) {
420 int pri = ((QComboBox*)wid)->currentItem() + 1; 432 int pri = ((QComboBox*)wid)->currentItem() + 1;
421 OTodo todo = sorted()[row]; 433 OTodo todo = sorted()[row];
422 if ( todo.priority() != pri ) { 434 if ( todo.priority() != pri ) {
423 todo.setPriority( pri ); 435 todo.setPriority( pri );
424 TodoView::update( todo.uid(), todo ); 436 TodoView::update( todo.uid(), todo );
425 updateView(); 437 updateView();
426 } 438 }
427 } 439 }
428 }else if ( col == 2) { 440 }else if ( col == 2) {
429 QWidget* wid = cellWidget(row, 2); 441 QWidget* wid = cellWidget(row, 2);
430 if ( wid->inherits("QLineEdit") ) { 442 if ( wid->inherits("QLineEdit") ) {
431 QString text = ((QLineEdit*)wid)->text(); 443 QString text = ((QLineEdit*)wid)->text();
432 OTodo todo = sorted()[row]; 444 OTodo todo = sorted()[row];
433 if ( todo.summary() != text ) { 445 if ( todo.summary() != text ) {
434 todo.setSummary( text ); 446 todo.setSummary( text );
435 TodoView::update( todo.uid(), todo ); 447 TodoView::update( todo.uid(), todo );
436 updateView(); 448 updateView();
437 } 449 }
438 } 450 }
439 } 451 }
440} 452}
441void TableView::slotPriority() { 453void TableView::slotPriority() {
442 setCellContentFromEditor( currentRow(), currentColumn() ); 454 setCellContentFromEditor( currentRow(), currentColumn() );
443} 455}
444/* 456/*
445 * We'll use the TimerEvent to read ahead or to keep the cahce always 457 * We'll use the TimerEvent to read ahead or to keep the cahce always
446 * filled enough. 458 * filled enough.
447 * We will try to read ahead 4 items in both ways 459 * We will try to read ahead 4 items in both ways
448 * up and down. On odd or even we will currentRow()+-4 or +-9 460 * up and down. On odd or even we will currentRow()+-4 or +-9
449 * 461 *
450 */ 462 */
451void TableView::timerEvent( QTimerEvent* ev ) { 463void TableView::timerEvent( QTimerEvent* ev ) {
452 qWarning("sorted %d", sorted().count() ); 464 qWarning("sorted %d", sorted().count() );
453 if (sorted().count() == 0 ) 465 if (sorted().count() == 0 )
454 return; 466 return;
455 467
456 int row = currentRow(); 468 int row = currentRow();
457 if ( m_row ) { 469 if ( m_row ) {
458 int ro = row-4; 470 int ro = row-4;
459 if (ro < 0 ) ro = 0; 471 if (ro < 0 ) ro = 0;
460 sorted()[ro]; 472 sorted()[ro];
461 473
462 ro = row+4; 474 ro = row+4;
463 sorted()[ro]; 475 sorted()[ro];
464 } else { 476 } else {
465 int ro = row + 8; 477 int ro = row + 8;
466 sorted()[ro]; 478 sorted()[ro];
467 479
468 ro = row-8; 480 ro = row-8;
469 if (ro < 0 ) ro = 0; 481 if (ro < 0 ) ro = 0;
470 sorted()[ro]; 482 sorted()[ro];
471 } 483 }
472 484
473 m_row = !m_row; 485 m_row = !m_row;
474} 486}
475 487
476// We want a strike through completed ;) 488// We want a strike through completed ;)
477// durchstreichen to complete 489// durchstreichen to complete
478/* 490/*
479 * MouseTracking is off this mean we only receive 491 * MouseTracking is off this mean we only receive
480 * these events if the mouse button is pressed 492 * these events if the mouse button is pressed
481 * We've the previous point saved 493 * We've the previous point saved
482 * We check if the previous and current Point are 494 * We check if the previous and current Point are
483 * in the same row. 495 * in the same row.
484 * Then we check if they're some pixel horizontal away 496 * Then we check if they're some pixel horizontal away
485 * if the distance between the two points is greater than 497 * if the distance between the two points is greater than
486 * 8 we mark the underlying todo as completed and do a repaint 498 * 8 we mark the underlying todo as completed and do a repaint
487 */ 499 */
488void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { 500void TableView::contentsMouseReleaseEvent( QMouseEvent* e) {
489 int row = rowAt(m_prevP.y()); 501 int row = rowAt(m_prevP.y());
490 if ( row == rowAt( e->y() ) && row != -1 ) { 502 if ( row == rowAt( e->y() ) && row != -1 ) {
491 if ( abs( m_prevP.x() - e->x() ) >= 8 ) { 503 if ( ::abs( m_prevP.x() - e->x() ) >= m_completeStrokeWidth ) {
492 qWarning("current row %d", row ); 504 qWarning("current row %d", row );
493 OTodo todo = sorted()[row]; 505 OTodo todo = sorted()[row];
494 todo.setCompleted( !todo.isCompleted() ); 506 todo.setCompleted( !todo.isCompleted() );
495 TodoView::update( todo.uid(), todo ); 507 TodoView::update( todo.uid(), todo );
496 updateView(); 508 updateView();
497 return; 509 return;
498 } 510 }
499 } 511 }
500 QTable::contentsMouseReleaseEvent( e ); 512 QTable::contentsMouseReleaseEvent( e );
501} 513}
502void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { 514void TableView::contentsMouseMoveEvent( QMouseEvent* e ) {
503 m_menuTimer->stop(); 515 m_menuTimer->stop();
504 QTable::contentsMouseMoveEvent( e ); 516 QTable::contentsMouseMoveEvent( e );
505} 517}
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h
index 0c3e865..e47b38f 100644
--- a/core/pim/todo/tableview.h
+++ b/core/pim/todo/tableview.h
@@ -1,106 +1,108 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
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 28
29#ifndef OPIE_TABLE_VIEW_H 29#ifndef OPIE_TABLE_VIEW_H
30#define OPIE_TABLE_VIEW_H 30#define OPIE_TABLE_VIEW_H
31 31
32#include <qtable.h> 32#include <qtable.h>
33#include <qmap.h> 33#include <qmap.h>
34 34
35#include "tableitems.h" 35#include "tableitems.h"
36#include "todoview.h" 36#include "todoview.h"
37 37
38class QTimer; 38class QTimer;
39 39
40namespace Todo { 40namespace Todo {
41 class CheckItem; 41 class CheckItem;
42 class DueTextItem; 42 class DueTextItem;
43 class TableView : public QTable, public TodoView { 43 class TableView : public QTable, public TodoView {
44 Q_OBJECT 44 Q_OBJECT
45 public: 45 public:
46 TableView( MainWindow*, QWidget* parent ); 46 TableView( MainWindow*, QWidget* parent );
47 ~TableView(); 47 ~TableView();
48 48
49 49
50 QString type()const; 50 QString type()const;
51 int current(); 51 int current();
52 QString currentRepresentation(); 52 QString currentRepresentation();
53 53
54 void clear(); 54 void clear();
55 void showOverDue( bool ); 55 void showOverDue( bool );
56 void updateView(); 56 void updateView();
57 void setTodo( int uid, const OTodo& ); 57 void setTodo( int uid, const OTodo& );
58 void addEvent( const OTodo& event ); 58 void addEvent( const OTodo& event );
59 void replaceEvent( const OTodo& ); 59 void replaceEvent( const OTodo& );
60 void removeEvent( int uid ); 60 void removeEvent( int uid );
61 void setShowCompleted( bool ); 61 void setShowCompleted( bool );
62 void setShowDeadline( bool ); 62 void setShowDeadline( bool );
63 63
64 void setShowCategory(const QString& =QString::null ); 64 void setShowCategory(const QString& =QString::null );
65 void newDay(); 65 void newDay();
66 QWidget* widget(); 66 QWidget* widget();
67 void sortColumn(int, bool, bool ); 67 void sortColumn(int, bool, bool );
68 68
69 /* 69 /*
70 * we do our drawing ourselves 70 * we do our drawing ourselves
71 * because we don't want to have 71 * because we don't want to have
72 * 40.000 QTableItems for 10.000 72 * 40.000 QTableItems for 10.000
73 * OTodos where we only show 10 at a time! 73 * OTodos where we only show 10 at a time!
74 */ 74 */
75 void paintCell(QPainter* p, int row, int col, const QRect&, bool ); 75 void paintCell(QPainter* p, int row, int col, const QRect&, bool );
76 private: 76 private:
77 /* reimplented for internal reasons */ 77 /* reimplented for internal reasons */
78 void viewportPaintEvent( QPaintEvent* ); 78 void viewportPaintEvent( QPaintEvent* );
79 QTimer *m_menuTimer; 79 QTimer *m_menuTimer;
80 bool m_enablePaint:1; 80 bool m_enablePaint:1;
81 QString m_oleCat; 81 QString m_oleCat;
82 bool m_first : 1; 82 bool m_first : 1;
83 83
84 protected: 84 protected:
85 void contentsMouseReleaseEvent( QMouseEvent* ); 85 void contentsMouseReleaseEvent( QMouseEvent* );
86 void contentsMouseMoveEvent( QMouseEvent* ); 86 void contentsMouseMoveEvent( QMouseEvent* );
87 void timerEvent( QTimerEvent* e ); 87 void timerEvent( QTimerEvent* e );
88 QWidget* createEditor(int row, int col, bool initFromCell )const; 88 QWidget* createEditor(int row, int col, bool initFromCell )const;
89 void setCellContentFromEditor( int row, int col ); 89 void setCellContentFromEditor( int row, int col );
90 90
91private slots: 91private slots:
92 void slotShowMenu(); 92 void slotShowMenu();
93 void slotClicked(int, int, int, 93 void slotClicked(int, int, int,
94 const QPoint& ); 94 const QPoint& );
95 void slotPressed(int, int, int, 95 void slotPressed(int, int, int,
96 const QPoint& ); 96 const QPoint& );
97 void slotValueChanged(int, int); 97 void slotValueChanged(int, int);
98 void slotCurrentChanged(int, int ); 98 void slotCurrentChanged(int, int );
99 void slotPriority(); 99 void slotPriority();
100 private: 100 private:
101 void initConfig();
102 int m_completeStrokeWidth;
101 bool m_row : 1; 103 bool m_row : 1;
102 QPoint m_prevP; 104 QPoint m_prevP;
103 }; 105 };
104}; 106};
105 107
106#endif 108#endif
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp
index 639fa66..4cf7d30 100644
--- a/core/pim/todo/todoview.cpp
+++ b/core/pim/todo/todoview.cpp
@@ -1,79 +1,79 @@
1#include "mainwindow.h" 1#include "mainwindow.h"
2 2
3#include "todoview.h" 3#include "todoview.h"
4 4
5using namespace Todo; 5using namespace Todo;
6 6
7TodoView::TodoView( MainWindow* win ) 7TodoView::TodoView( MainWindow* win )
8 : m_main( win ) 8 : m_main( win )
9{ 9{
10 hack = new InternQtHack; 10 hack = new InternQtHack;
11 m_asc = false; 11 m_asc = false;
12 m_sortOrder = -1; 12 m_sortOrder = -1;
13} 13}
14TodoView::~TodoView() { 14TodoView::~TodoView() {
15 delete hack; 15 delete hack;
16}; 16};
17 17
18void TodoView::connectShow(QObject* obj, 18void TodoView::connectShow(QObject* obj,
19 const char* slot ) { 19 const char* slot ) {
20 QObject::connect( hack, SIGNAL(showTodo(int) ), 20 QObject::connect( hack, SIGNAL(showTodo(int) ),
21 obj, slot ); 21 obj, slot );
22} 22}
23void TodoView::connectEdit( QObject* obj, 23void TodoView::connectEdit( QObject* obj,
24 const char* slot ) { 24 const char* slot ) {
25 QObject::connect( hack, SIGNAL(edit(int) ), 25 QObject::connect( hack, SIGNAL(edit(int) ),
26 obj, slot ); 26 obj, slot );
27} 27}
28void TodoView::connectUpdateSmall( QObject* obj, 28void TodoView::connectUpdateSmall( QObject* obj,
29 const char* slot ) { 29 const char* slot ) {
30 QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ), 30 QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ),
31 obj, slot ); 31 obj, slot );
32} 32}
33void TodoView::connectUpdateBig( QObject* obj, 33void TodoView::connectUpdateBig( QObject* obj,
34 const char* slot ) { 34 const char* slot ) {
35 QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ), 35 QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ),
36 obj, slot ); 36 obj, slot );
37} 37}
38void TodoView::connectUpdateView( QObject* obj, 38void TodoView::connectUpdateView( QObject* obj,
39 const char* slot ) { 39 const char* slot ) {
40 QObject::connect( hack, SIGNAL(update(QWidget*) ), 40 QObject::connect( hack, SIGNAL(update(QWidget*) ),
41 obj, slot ); 41 obj, slot );
42} 42}
43void TodoView::connectRemove( QObject* obj, 43void TodoView::connectRemove( QObject* obj,
44 const char* slot ) { 44 const char* slot ) {
45 QObject::connect( hack, SIGNAL(remove(int) ), 45 QObject::connect( hack, SIGNAL(remove(int) ),
46 obj, slot ); 46 obj, slot );
47} 47}
48MainWindow* TodoView::todoWindow() { 48MainWindow* TodoView::todoWindow() {
49 return m_main; 49 return m_main;
50} 50}
51 51
52OTodo TodoView::event(int uid ) { return m_main->event( uid ); } 52OTodo TodoView::event(int uid ) { return m_main->event( uid ); }
53OTodoAccess::List TodoView::list(){ 53OTodoAccess::List TodoView::list(){
54 todoWindow()->updateList(); 54 todoWindow()->updateList();
55 return todoWindow()->list(); 55 return todoWindow()->list();
56} 56}
57OTodoAccess::List TodoView::sorted()const{ 57OTodoAccess::List TodoView::sorted()const{
58 return m_sort; 58 return m_sort;
59} 59}
60void TodoView::sort() { 60void TodoView::sort() {
61 m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); 61 m_sort = todoWindow()->sorted(m_asc,m_sortOrder );
62 qWarning("m_sort.count() = %d", m_sort.count() ); 62 qWarning("m_sort.count() = %d", m_sort.count() );
63} 63}
64void TodoView::sort(int sort) { 64void TodoView::sort(int sort) {
65 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort ); 65 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort );
66} 66}
67void TodoView::setSortOrder( int order ) { 67void TodoView::setSortOrder( int order ) {
68 m_sortOrder = order; 68 m_sortOrder = order;
69} 69}
70void TodoView::setAscending( bool b ) { 70void TodoView::setAscending( bool b ) {
71 qWarning("setAscending %d", b ); 71 qWarning("setAscending %d", b );
72 m_asc = b; 72 m_asc = b;
73} 73}
74void TodoView::update(int uid, const SmallTodo& to ) { 74void TodoView::update(int, const SmallTodo& ) {
75 //m_main->slotUpate1( uid, to ); 75 //m_main->slotUpate1( uid, to );
76} 76}
77void TodoView::update(int uid, const OTodo& ev ) { 77void TodoView::update(int , const OTodo& ev ) {
78 m_main->updateTodo( ev ); 78 m_main->updateTodo( ev );
79} 79}