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