summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-15 21:00:30 (UTC)
committer zautrix <zautrix>2005-06-15 21:00:30 (UTC)
commit4a9b5ad578e991f6216dc0556022a76223165f15 (patch) (unidiff)
tree41017358760a4db4b47e38a0364c219ed4760411
parente74483434835ad799b1a6880ae4576aacb14624a (diff)
downloadkdepimpi-4a9b5ad578e991f6216dc0556022a76223165f15.zip
kdepimpi-4a9b5ad578e991f6216dc0556022a76223165f15.tar.gz
kdepimpi-4a9b5ad578e991f6216dc0556022a76223165f15.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp15
-rw-r--r--korganizer/kotodoviewitem.cpp1
2 files changed, 6 insertions, 10 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 35c2a9f..b2ff33b 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1467 +1,1462 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28 28
29#include <qinputdialog.h> 29#include <qinputdialog.h>
30 30
31#include <qvbox.h> 31#include <qvbox.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include "koprefs.h" 33#include "koprefs.h"
34#include <klocale.h> 34#include <klocale.h>
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kiconloader.h> 36#include <kiconloader.h>
37#include <kmessagebox.h> 37#include <kmessagebox.h>
38 38
39#include <libkcal/icaldrag.h> 39#include <libkcal/icaldrag.h>
40#include <libkcal/vcaldrag.h> 40#include <libkcal/vcaldrag.h>
41#include <libkcal/calfilter.h> 41#include <libkcal/calfilter.h>
42#include <libkcal/dndfactory.h> 42#include <libkcal/dndfactory.h>
43#include <libkcal/calendarresources.h> 43#include <libkcal/calendarresources.h>
44#include <libkcal/resourcecalendar.h> 44#include <libkcal/resourcecalendar.h>
45#include <kresources/resourceselectdialog.h> 45#include <kresources/resourceselectdialog.h>
46#include <libkcal/kincidenceformatter.h> 46#include <libkcal/kincidenceformatter.h>
47#ifndef DESKTOP_VERSION 47#ifndef DESKTOP_VERSION
48#include <qpe/qpeapplication.h> 48#include <qpe/qpeapplication.h>
49#else 49#else
50#include <qapplication.h> 50#include <qapplication.h>
51#endif 51#endif
52#ifndef KORG_NOPRINTER 52#ifndef KORG_NOPRINTER
53#include "calprinter.h" 53#include "calprinter.h"
54#endif 54#endif
55#include "docprefs.h" 55#include "docprefs.h"
56 56
57#include "kotodoview.h" 57#include "kotodoview.h"
58using namespace KOrg; 58using namespace KOrg;
59 59
60 60
61class KOTodoViewWhatsThis :public QWhatsThis 61class KOTodoViewWhatsThis :public QWhatsThis
62{ 62{
63public: 63public:
64 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 64 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
65 65
66protected: 66protected:
67 virtual QString text( const QPoint& p) 67 virtual QString text( const QPoint& p)
68 { 68 {
69 return _view->getWhatsThisText(p) ; 69 return _view->getWhatsThisText(p) ;
70 } 70 }
71private: 71private:
72 QWidget* _wid; 72 QWidget* _wid;
73 KOTodoView * _view; 73 KOTodoView * _view;
74}; 74};
75 75
76KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 76KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
77 const char *name) : 77 const char *name) :
78 KListView(parent,name) 78 KListView(parent,name)
79{ 79{
80 mName = QString ( name ); 80 mName = QString ( name );
81 mCalendar = calendar; 81 mCalendar = calendar;
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mOldCurrent = 0; 85 mOldCurrent = 0;
86 mMousePressed = false; 86 mMousePressed = false;
87 87
88 setAcceptDrops(true); 88 setAcceptDrops(true);
89 viewport()->setAcceptDrops(true); 89 viewport()->setAcceptDrops(true);
90 int size = 16; 90 int size = 16;
91 if (qApp->desktop()->width() < 300 ) 91 if (qApp->desktop()->width() < 300 )
92 size = 12; 92 size = 12;
93 setTreeStepSize( size + 6 ); 93 setTreeStepSize( size + 6 );
94 94
95} 95}
96 96
97void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 97void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
98{ 98{
99#ifndef KORG_NODND 99#ifndef KORG_NODND
100// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 100// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
101 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 101 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
102 !QTextDrag::canDecode( e ) ) { 102 !QTextDrag::canDecode( e ) ) {
103 e->ignore(); 103 e->ignore();
104 return; 104 return;
105 } 105 }
106 106
107 mOldCurrent = currentItem(); 107 mOldCurrent = currentItem();
108#endif 108#endif
109} 109}
110 110
111 111
112void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 112void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
113{ 113{
114#ifndef KORG_NODND 114#ifndef KORG_NODND
115// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 115// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
116 116
117 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 117 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
118 !QTextDrag::canDecode( e ) ) { 118 !QTextDrag::canDecode( e ) ) {
119 e->ignore(); 119 e->ignore();
120 return; 120 return;
121 } 121 }
122 122
123 e->accept(); 123 e->accept();
124#endif 124#endif
125} 125}
126 126
127void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 127void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
128{ 128{
129#ifndef KORG_NODND 129#ifndef KORG_NODND
130// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 130// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
131 131
132 setCurrentItem(mOldCurrent); 132 setCurrentItem(mOldCurrent);
133 setSelected(mOldCurrent,true); 133 setSelected(mOldCurrent,true);
134#endif 134#endif
135} 135}
136 136
137void KOTodoListView::contentsDropEvent(QDropEvent *e) 137void KOTodoListView::contentsDropEvent(QDropEvent *e)
138{ 138{
139#ifndef KORG_NODND 139#ifndef KORG_NODND
140// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 140// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
141 141
142 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 142 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
143 !QTextDrag::canDecode( e ) ) { 143 !QTextDrag::canDecode( e ) ) {
144 e->ignore(); 144 e->ignore();
145 return; 145 return;
146 } 146 }
147 147
148 DndFactory factory( mCalendar ); 148 DndFactory factory( mCalendar );
149 Todo *todo = factory.createDropTodo(e); 149 Todo *todo = factory.createDropTodo(e);
150 150
151 if (todo) { 151 if (todo) {
152 e->acceptAction(); 152 e->acceptAction();
153 153
154 KOTodoViewItem *destination = 154 KOTodoViewItem *destination =
155 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 155 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
156 Todo *destinationEvent = 0; 156 Todo *destinationEvent = 0;
157 if (destination) destinationEvent = destination->todo(); 157 if (destination) destinationEvent = destination->todo();
158 158
159 Todo *existingTodo = mCalendar->todo(todo->uid()); 159 Todo *existingTodo = mCalendar->todo(todo->uid());
160 160
161 if(existingTodo) { 161 if(existingTodo) {
162 Incidence *to = destinationEvent; 162 Incidence *to = destinationEvent;
163 while(to) { 163 while(to) {
164 if (to->uid() == todo->uid()) { 164 if (to->uid() == todo->uid()) {
165 KMessageBox::sorry(this, 165 KMessageBox::sorry(this,
166 i18n("Cannot move Todo to itself\nor a child of itself"), 166 i18n("Cannot move Todo to itself\nor a child of itself"),
167 i18n("Drop Todo")); 167 i18n("Drop Todo"));
168 delete todo; 168 delete todo;
169 return; 169 return;
170 } 170 }
171 to = to->relatedTo(); 171 to = to->relatedTo();
172 } 172 }
173 internalDrop = true; 173 internalDrop = true;
174 if ( destinationEvent ) 174 if ( destinationEvent )
175 reparentTodoSignal( destinationEvent, existingTodo ); 175 reparentTodoSignal( destinationEvent, existingTodo );
176 else 176 else
177 unparentTodoSignal(existingTodo); 177 unparentTodoSignal(existingTodo);
178 delete todo; 178 delete todo;
179 } else { 179 } else {
180 mCalendar->addTodo(todo); 180 mCalendar->addTodo(todo);
181 emit todoDropped(todo, KOGlobals::EVENTADDED); 181 emit todoDropped(todo, KOGlobals::EVENTADDED);
182 if ( destinationEvent ) 182 if ( destinationEvent )
183 reparentTodoSignal( destinationEvent, todo ); 183 reparentTodoSignal( destinationEvent, todo );
184 } 184 }
185 } 185 }
186 else { 186 else {
187 QString text; 187 QString text;
188 if (QTextDrag::decode(e,text)) { 188 if (QTextDrag::decode(e,text)) {
189 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 189 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
190 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 190 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
191 qDebug("Dropped : " + text); 191 qDebug("Dropped : " + text);
192 QStringList emails = QStringList::split(",",text); 192 QStringList emails = QStringList::split(",",text);
193 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 193 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
194 int pos = (*it).find("<"); 194 int pos = (*it).find("<");
195 QString name = (*it).left(pos); 195 QString name = (*it).left(pos);
196 QString email = (*it).mid(pos); 196 QString email = (*it).mid(pos);
197 if (!email.isEmpty() && todoi) { 197 if (!email.isEmpty() && todoi) {
198 todoi->todo()->addAttendee(new Attendee(name,email)); 198 todoi->todo()->addAttendee(new Attendee(name,email));
199 } 199 }
200 } 200 }
201 } 201 }
202 else { 202 else {
203 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 203 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
204 e->ignore(); 204 e->ignore();
205 } 205 }
206 } 206 }
207#endif 207#endif
208} 208}
209void KOTodoListView::wheelEvent (QWheelEvent *e) 209void KOTodoListView::wheelEvent (QWheelEvent *e)
210{ 210{
211 QListView::wheelEvent (e); 211 QListView::wheelEvent (e);
212} 212}
213 213
214void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 214void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
215{ 215{
216 216
217 QPoint p(contentsToViewport(e->pos())); 217 QPoint p(contentsToViewport(e->pos()));
218 QListViewItem *i = itemAt(p); 218 QListViewItem *i = itemAt(p);
219 bool rootClicked = true; 219 bool rootClicked = true;
220 if (i) { 220 if (i) {
221 // if the user clicked into the root decoration of the item, don't 221 // if the user clicked into the root decoration of the item, don't
222 // try to start a drag! 222 // try to start a drag!
223 int X = p.x(); 223 int X = p.x();
224 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 224 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
225 if (X > header()->sectionPos(0) + 225 if (X > header()->sectionPos(0) +
226 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 226 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
227 itemMargin() +i->height()|| 227 itemMargin() +i->height()||
228 X < header()->sectionPos(0)) { 228 X < header()->sectionPos(0)) {
229 rootClicked = false; 229 rootClicked = false;
230 } 230 }
231 } else { 231 } else {
232 rootClicked = false; 232 rootClicked = false;
233 } 233 }
234#ifndef KORG_NODND 234#ifndef KORG_NODND
235 mMousePressed = false; 235 mMousePressed = false;
236 if (! rootClicked && !( e->button() == RightButton) ) { 236 if (! rootClicked && !( e->button() == RightButton) ) {
237 mPressPos = e->pos(); 237 mPressPos = e->pos();
238 mMousePressed = true; 238 mMousePressed = true;
239 } else { 239 } else {
240 mMousePressed = false; 240 mMousePressed = false;
241 } 241 }
242#endif 242#endif
243 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 243 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
244#ifndef DESKTOP_VERSION 244#ifndef DESKTOP_VERSION
245 if (!( e->button() == RightButton && rootClicked) ) 245 if (!( e->button() == RightButton && rootClicked) )
246 QListView::contentsMousePressEvent(e); 246 QListView::contentsMousePressEvent(e);
247#else 247#else
248 QListView::contentsMousePressEvent(e); 248 QListView::contentsMousePressEvent(e);
249#endif 249#endif
250} 250}
251void KOTodoListView::paintEvent(QPaintEvent* e) 251void KOTodoListView::paintEvent(QPaintEvent* e)
252{ 252{
253 emit paintNeeded(); 253 emit paintNeeded();
254 QListView::paintEvent( e); 254 QListView::paintEvent( e);
255} 255}
256void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 256void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
257{ 257{
258 258
259#ifndef KORG_NODND 259#ifndef KORG_NODND
260 //QListView::contentsMouseMoveEvent(e); 260 //QListView::contentsMouseMoveEvent(e);
261 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 261 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
262 QApplication::startDragDistance()*3) { 262 QApplication::startDragDistance()*3) {
263 mMousePressed = false; 263 mMousePressed = false;
264 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 264 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
265 if (item) { 265 if (item) {
266 DndFactory factory( mCalendar ); 266 DndFactory factory( mCalendar );
267 ICalDrag *vd = factory.createDrag( 267 ICalDrag *vd = factory.createDrag(
268 ((KOTodoViewItem *)item)->todo(),viewport()); 268 ((KOTodoViewItem *)item)->todo(),viewport());
269 internalDrop = false; 269 internalDrop = false;
270 // we cannot do any senseful here, because the DnD is still broken in Qt 270 // we cannot do any senseful here, because the DnD is still broken in Qt
271 if (vd->drag()) { 271 if (vd->drag()) {
272 if ( !internalDrop ) { 272 if ( !internalDrop ) {
273 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 273 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
274 qDebug("Dnd: External move: Delete drag source "); 274 qDebug("Dnd: External move: Delete drag source ");
275 } else 275 } else
276 qDebug("Dnd: Internal move "); 276 qDebug("Dnd: Internal move ");
277 277
278 } else { 278 } else {
279 if ( !internalDrop ) { 279 if ( !internalDrop ) {
280 qDebug("Dnd: External Copy"); 280 qDebug("Dnd: External Copy");
281 } else 281 } else
282 qDebug("DnD: Internal copy: Copy pending"); 282 qDebug("DnD: Internal copy: Copy pending");
283 } 283 }
284 } 284 }
285 } 285 }
286#endif 286#endif
287} 287}
288void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 288void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
289{ 289{
290 if ( !e->isAutoRepeat() ) { 290 if ( !e->isAutoRepeat() ) {
291 mFlagKeyPressed = false; 291 mFlagKeyPressed = false;
292 } 292 }
293} 293}
294 294
295 295
296void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 296void KOTodoListView::keyPressEvent ( QKeyEvent * e )
297{ 297{
298 qApp->processEvents(); 298 qApp->processEvents();
299 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 299 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
300 e->ignore(); 300 e->ignore();
301 // qDebug(" ignore %d",e->isAutoRepeat() ); 301 // qDebug(" ignore %d",e->isAutoRepeat() );
302 return; 302 return;
303 } 303 }
304 if (! e->isAutoRepeat() ) 304 if (! e->isAutoRepeat() )
305 mFlagKeyPressed = true; 305 mFlagKeyPressed = true;
306 QListViewItem* cn; 306 QListViewItem* cn;
307 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 307 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
308 cn = currentItem(); 308 cn = currentItem();
309 if ( cn ) { 309 if ( cn ) {
310 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 310 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
311 if ( ci ){ 311 if ( ci ){
312 if ( e->state() == ShiftButton ) 312 if ( e->state() == ShiftButton )
313 ci->setOn( false ); 313 ci->setOn( false );
314 else 314 else
315 ci->setOn( true ); 315 ci->setOn( true );
316 cn = cn->itemBelow(); 316 cn = cn->itemBelow();
317 if ( cn ) { 317 if ( cn ) {
318 setCurrentItem ( cn ); 318 setCurrentItem ( cn );
319 ensureItemVisible ( cn ); 319 ensureItemVisible ( cn );
320 } 320 }
321 321
322 } 322 }
323 } 323 }
324 324
325 return; 325 return;
326 } 326 }
327 327
328 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 328 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
329 switch ( e->key() ) { 329 switch ( e->key() ) {
330 case Qt::Key_Down: 330 case Qt::Key_Down:
331 case Qt::Key_Up: 331 case Qt::Key_Up:
332 QListView::keyPressEvent ( e ); 332 QListView::keyPressEvent ( e );
333 break; 333 break;
334 case Qt::Key_Left: 334 case Qt::Key_Left:
335 case Qt::Key_Right: 335 case Qt::Key_Right:
336 QListView::keyPressEvent ( e ); 336 QListView::keyPressEvent ( e );
337 e->accept(); 337 e->accept();
338 return; 338 return;
339 break; 339 break;
340 default: 340 default:
341 e->ignore(); 341 e->ignore();
342 break; 342 break;
343 } 343 }
344 return; 344 return;
345 } 345 }
346 e->ignore(); 346 e->ignore();
347} 347}
348void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 348void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
349{ 349{
350 QListView::contentsMouseReleaseEvent(e); 350 QListView::contentsMouseReleaseEvent(e);
351 mMousePressed = false; 351 mMousePressed = false;
352} 352}
353 353
354void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 354void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
355{ 355{
356 if (!e) return; 356 if (!e) return;
357 357
358 QPoint vp = contentsToViewport(e->pos()); 358 QPoint vp = contentsToViewport(e->pos());
359 359
360 QListViewItem *item = itemAt(vp); 360 QListViewItem *item = itemAt(vp);
361 361
362 emit double_Clicked(item); 362 emit double_Clicked(item);
363 if (!item) return; 363 if (!item) return;
364 364
365 emit doubleClicked(item,vp,0); 365 emit doubleClicked(item,vp,0);
366} 366}
367 367
368///////////////////////////////////////////////////////////////////////////// 368/////////////////////////////////////////////////////////////////////////////
369 369
370KOQuickTodo::KOQuickTodo(QWidget *parent) : 370KOQuickTodo::KOQuickTodo(QWidget *parent) :
371 QLineEdit(parent) 371 QLineEdit(parent)
372{ 372{
373 setText(i18n("Click to add a new Todo")); 373 setText(i18n("Click to add a new Todo"));
374} 374}
375 375
376void KOQuickTodo::focusInEvent(QFocusEvent *ev) 376void KOQuickTodo::focusInEvent(QFocusEvent *ev)
377{ 377{
378 if ( text()==i18n("Click to add a new Todo") ) 378 if ( text()==i18n("Click to add a new Todo") )
379 setText(""); 379 setText("");
380 QLineEdit::focusInEvent(ev); 380 QLineEdit::focusInEvent(ev);
381} 381}
382 382
383void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 383void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
384{ 384{
385 setText(i18n("Click to add a new Todo")); 385 setText(i18n("Click to add a new Todo"));
386 QLineEdit::focusOutEvent(ev); 386 QLineEdit::focusOutEvent(ev);
387} 387}
388 388
389///////////////////////////////////////////////////////////////////////////// 389/////////////////////////////////////////////////////////////////////////////
390 390
391KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 391KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
392 KOrg::BaseView(calendar,parent,name) 392 KOrg::BaseView(calendar,parent,name)
393{ 393{
394 mPendingUpdateBeforeRepaint = false; 394 mPendingUpdateBeforeRepaint = false;
395 isFlatDisplay = false; 395 isFlatDisplay = false;
396 mNavigator = 0; 396 mNavigator = 0;
397 QBoxLayout *topLayout = new QVBoxLayout(this); 397 QBoxLayout *topLayout = new QVBoxLayout(this);
398 mName = QString ( name ); 398 mName = QString ( name );
399 mBlockUpdate = false; 399 mBlockUpdate = false;
400 mQuickAdd = new KOQuickTodo(this); 400 mQuickAdd = new KOQuickTodo(this);
401 topLayout->addWidget(mQuickAdd); 401 topLayout->addWidget(mQuickAdd);
402 402
403 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 403 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
404 404
405 mTodoListView = new KOTodoListView(calendar,this, name ); 405 mTodoListView = new KOTodoListView(calendar,this, name );
406 topLayout->addWidget(mTodoListView); 406 topLayout->addWidget(mTodoListView);
407 //mTodoListView->header()->setMaximumHeight(30); 407 //mTodoListView->header()->setMaximumHeight(30);
408 mTodoListView->setRootIsDecorated(true); 408 mTodoListView->setRootIsDecorated(true);
409 mTodoListView->setAllColumnsShowFocus(true); 409 mTodoListView->setAllColumnsShowFocus(true);
410 410
411 mTodoListView->setShowSortIndicator(true); 411 mTodoListView->setShowSortIndicator(true);
412 412
413 mTodoListView->addColumn(i18n("Todo")); 413 mTodoListView->addColumn(i18n("Todo"));
414 mTodoListView->addColumn(i18n("Prio")); 414 mTodoListView->addColumn(i18n("Prio"));
415 mTodoListView->setColumnAlignment(1,AlignHCenter); 415 mTodoListView->setColumnAlignment(1,AlignHCenter);
416 mTodoListView->addColumn(i18n("Complete")); 416 mTodoListView->addColumn(i18n("Complete"));
417 mTodoListView->setColumnAlignment(2,AlignCenter); 417 mTodoListView->setColumnAlignment(2,AlignCenter);
418 418
419 mTodoListView->addColumn(i18n("Due Date")); 419 mTodoListView->addColumn(i18n("Due Date"));
420 mTodoListView->setColumnAlignment(3,AlignLeft); 420 mTodoListView->setColumnAlignment(3,AlignLeft);
421 mTodoListView->addColumn(i18n("Due Time")); 421 mTodoListView->addColumn(i18n("Due Time"));
422 mTodoListView->setColumnAlignment(4,AlignHCenter); 422 mTodoListView->setColumnAlignment(4,AlignHCenter);
423 423
424 mTodoListView->addColumn(i18n("Start Date")); 424 mTodoListView->addColumn(i18n("Start Date"));
425 mTodoListView->setColumnAlignment(5,AlignLeft); 425 mTodoListView->setColumnAlignment(5,AlignLeft);
426 mTodoListView->addColumn(i18n("Start Time")); 426 mTodoListView->addColumn(i18n("Start Time"));
427 mTodoListView->setColumnAlignment(6,AlignHCenter); 427 mTodoListView->setColumnAlignment(6,AlignHCenter);
428 428
429 mTodoListView->addColumn(i18n("Cancelled")); 429 mTodoListView->addColumn(i18n("Cancelled"));
430 mTodoListView->addColumn(i18n("Categories")); 430 mTodoListView->addColumn(i18n("Categories"));
431 mTodoListView->addColumn(i18n("Calendar"));
431#if 0 432#if 0
432 mTodoListView->addColumn(i18n("Sort Id")); 433 mTodoListView->addColumn(i18n("Sort Id"));
433 mTodoListView->setColumnAlignment(4,AlignHCenter); 434 mTodoListView->setColumnAlignment(4,AlignHCenter);
434#endif 435#endif
435 436
436 mTodoListView->setMinimumHeight( 60 ); 437 mTodoListView->setMinimumHeight( 60 );
437 mTodoListView->setItemsRenameable( true ); 438 mTodoListView->setItemsRenameable( true );
438 mTodoListView->setRenameable( 0 ); 439 mTodoListView->setRenameable( 0 );
439 mTodoListView->setColumnWidth( 0, 120 ); 440 mTodoListView->setColumnWidth( 0, 120 );
440 mTodoListView->setColumnWidthMode(0, QListView::Manual); 441 int iii = 0;
441 mTodoListView->setColumnWidthMode(1, QListView::Manual); 442 for ( iii = 0; iii< 10 ; ++iii )
442 mTodoListView->setColumnWidthMode(2, QListView::Manual); 443 mTodoListView->setColumnWidthMode( iii, QListView::Manual );
443 mTodoListView->setColumnWidthMode(3, QListView::Manual); 444
444 mTodoListView->setColumnWidthMode(4, QListView::Manual);
445 mTodoListView->setColumnWidthMode(5, QListView::Manual);
446 mTodoListView->setColumnWidthMode(6, QListView::Manual);
447 mTodoListView->setColumnWidthMode(7, QListView::Manual);
448 mTodoListView->setColumnWidthMode(8, QListView::Manual);
449
450 445
451 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 446 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
452 447
453 mPriorityPopupMenu = new QPopupMenu(this); 448 mPriorityPopupMenu = new QPopupMenu(this);
454 for (int i = 1; i <= 5; i++) { 449 for (int i = 1; i <= 5; i++) {
455 QString label = QString ("%1").arg (i); 450 QString label = QString ("%1").arg (i);
456 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 451 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
457 } 452 }
458 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 453 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
459 454
460 mPercentageCompletedPopupMenu = new QPopupMenu(this); 455 mPercentageCompletedPopupMenu = new QPopupMenu(this);
461 for (int i = 0; i <= 100; i+=20) { 456 for (int i = 0; i <= 100; i+=20) {
462 QString label = QString ("%1 %").arg (i); 457 QString label = QString ("%1 %").arg (i);
463 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 458 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
464 } 459 }
465 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 460 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
466 461
467 462
468 463
469 mItemPopupMenu = new QPopupMenu(this); 464 mItemPopupMenu = new QPopupMenu(this);
470 mItemPopupMenu->insertItem(i18n("Show..."), this, 465 mItemPopupMenu->insertItem(i18n("Show..."), this,
471 SLOT (showTodo())); 466 SLOT (showTodo()));
472 mItemPopupMenu->insertItem(i18n("Edit..."), this, 467 mItemPopupMenu->insertItem(i18n("Edit..."), this,
473 SLOT (editTodo())); 468 SLOT (editTodo()));
474 mItemPopupMenu->insertItem( i18n("Delete"), this, 469 mItemPopupMenu->insertItem( i18n("Delete"), this,
475 SLOT (deleteTodo())); 470 SLOT (deleteTodo()));
476 mItemPopupMenu->insertItem( i18n("Clone..."), this, 471 mItemPopupMenu->insertItem( i18n("Clone..."), this,
477 SLOT (cloneTodo())); 472 SLOT (cloneTodo()));
478 mItemPopupMenu->insertItem( i18n("Move..."), this, 473 mItemPopupMenu->insertItem( i18n("Move..."), this,
479 SLOT (moveTodo())); 474 SLOT (moveTodo()));
480#ifndef DESKTOP_VERSION 475#ifndef DESKTOP_VERSION
481 mItemPopupMenu->insertItem( i18n("Beam..."), this, 476 mItemPopupMenu->insertItem( i18n("Beam..."), this,
482 SLOT (beamTodo())); 477 SLOT (beamTodo()));
483#endif 478#endif
484 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 479 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
485 SLOT (cancelTodo())); 480 SLOT (cancelTodo()));
486 mItemPopupMenu->insertSeparator(); 481 mItemPopupMenu->insertSeparator();
487 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 482 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
488 SLOT (toggleRunningItem())); 483 SLOT (toggleRunningItem()));
489 mItemPopupMenu->insertSeparator(); 484 mItemPopupMenu->insertSeparator();
490 /* 485 /*
491 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 486 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
492 SLOT (newTodo())); 487 SLOT (newTodo()));
493 */ 488 */
494 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 489 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
495 SLOT (newSubTodo())); 490 SLOT (newSubTodo()));
496 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 491 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
497 SLOT (unparentTodo()),0,21); 492 SLOT (unparentTodo()),0,21);
498 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 493 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
499 SLOT (reparentTodo()),0,22); 494 SLOT (reparentTodo()),0,22);
500 mItemPopupMenu->insertSeparator(); 495 mItemPopupMenu->insertSeparator();
501#if 0 496#if 0
502 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 497 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
503 this, SLOT( purgeCompleted() ) ); 498 this, SLOT( purgeCompleted() ) );
504 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 499 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
505 this, SLOT( toggleCompleted() ),0, 33 ); 500 this, SLOT( toggleCompleted() ),0, 33 );
506 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 501 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
507 this, SLOT( toggleQuickTodo() ),0, 34 ); 502 this, SLOT( toggleQuickTodo() ),0, 34 );
508 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 503 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
509 this, SLOT( toggleRunning() ),0, 35 ); 504 this, SLOT( toggleRunning() ),0, 35 );
510 505
511#endif 506#endif
512 mPopupMenu = new QPopupMenu(this); 507 mPopupMenu = new QPopupMenu(this);
513 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 508 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
514 SLOT (newTodo()),0,1); 509 SLOT (newTodo()),0,1);
515 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 510 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
516 this, SLOT(purgeCompleted()),0,2); 511 this, SLOT(purgeCompleted()),0,2);
517 mPopupMenu->insertItem(i18n("Show Completed"), 512 mPopupMenu->insertItem(i18n("Show Completed"),
518 this, SLOT( toggleCompleted() ),0,3 ); 513 this, SLOT( toggleCompleted() ),0,3 );
519 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 514 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
520 this, SLOT( toggleRunning() ),0,5 ); 515 this, SLOT( toggleRunning() ),0,5 );
521 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 516 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
522 this, SLOT( setAllOpen() ),0,6 ); 517 this, SLOT( setAllOpen() ),0,6 );
523 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 518 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
524 this, SLOT( setAllClose() ),0,7 ); 519 this, SLOT( setAllClose() ),0,7 );
525 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 520 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
526 this, SLOT( setAllFlat() ),0,8 ); 521 this, SLOT( setAllFlat() ),0,8 );
527 mPopupMenu->insertSeparator(); 522 mPopupMenu->insertSeparator();
528 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 523 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
529 this, SLOT( toggleQuickTodo() ),0,4 ); 524 this, SLOT( toggleQuickTodo() ),0,4 );
530 mDocPrefs = new DocPrefs( name ); 525 mDocPrefs = new DocPrefs( name );
531 526
532 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 527 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
533 mPopupMenu->setCheckable( true ); 528 mPopupMenu->setCheckable( true );
534 mItemPopupMenu->setCheckable( true ); 529 mItemPopupMenu->setCheckable( true );
535 530
536 531
537 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 532 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
538 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 533 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
539 534
540 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 535 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
541 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 536 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
542 537
543 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 538 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
544 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 539 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
545 540
546 541
547 // Double clicking conflicts with opening/closing the subtree 542 // Double clicking conflicts with opening/closing the subtree
548 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 543 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
549 SLOT( editItem( QListViewItem *) ) ); 544 SLOT( editItem( QListViewItem *) ) );
550 /* 545 /*
551 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 546 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
552 const QPoint &,int ) ), 547 const QPoint &,int ) ),
553 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 548 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
554 */ 549 */
555 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 550 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
556 const QPoint &,int ) ), 551 const QPoint &,int ) ),
557 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 552 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
558 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 553 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
559 SLOT( itemClicked( QListViewItem * ) ) ); 554 SLOT( itemClicked( QListViewItem * ) ) );
560 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 555 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
561 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 556 SLOT( itemDoubleClicked( QListViewItem * ) ) );
562 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 557 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
563 SLOT( updateView() ) ); 558 SLOT( updateView() ) );
564 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 559 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
565 SLOT( todoModified(Todo *, int) ) ); 560 SLOT( todoModified(Todo *, int) ) );
566 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 561 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
567 SLOT( itemStateChanged( QListViewItem * ) ) ); 562 SLOT( itemStateChanged( QListViewItem * ) ) );
568 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 563 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
569 SLOT( itemStateChanged( QListViewItem * ) ) ); 564 SLOT( itemStateChanged( QListViewItem * ) ) );
570 connect( mTodoListView, SIGNAL( paintNeeded() ), 565 connect( mTodoListView, SIGNAL( paintNeeded() ),
571 SLOT( paintNeeded()) ); 566 SLOT( paintNeeded()) );
572 567
573#if 0 568#if 0
574 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 569 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
575 SLOT(selectionChanged(QListViewItem *))); 570 SLOT(selectionChanged(QListViewItem *)));
576 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 571 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
577 SLOT(selectionChanged(QListViewItem *))); 572 SLOT(selectionChanged(QListViewItem *)));
578 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 573 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
579 SLOT(selectionChanged(QListViewItem *))); 574 SLOT(selectionChanged(QListViewItem *)));
580#endif 575#endif
581 576
582 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 577 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
583 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 578 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
584 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 579 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
585 580
586 connect( mTodoListView, SIGNAL(selectionChanged() ), 581 connect( mTodoListView, SIGNAL(selectionChanged() ),
587 SLOT( processSelectionChange() ) ); 582 SLOT( processSelectionChange() ) );
588 connect( mQuickAdd, SIGNAL( returnPressed () ), 583 connect( mQuickAdd, SIGNAL( returnPressed () ),
589 SLOT( addQuickTodo() ) ); 584 SLOT( addQuickTodo() ) );
590 585
591} 586}
592 587
593KOTodoView::~KOTodoView() 588KOTodoView::~KOTodoView()
594{ 589{
595 590
596#if QT_VERSION >= 0x030000 591#if QT_VERSION >= 0x030000
597 592
598#else 593#else
599 delete mKOTodoViewWhatsThis; 594 delete mKOTodoViewWhatsThis;
600#endif 595#endif
601 596
602 delete mDocPrefs; 597 delete mDocPrefs;
603} 598}
604QString KOTodoView::getWhatsThisText(QPoint p) 599QString KOTodoView::getWhatsThisText(QPoint p)
605{ 600{
606 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 601 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
607 if ( item ) 602 if ( item )
608 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 603 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
609 KOPrefs::instance()->mWTshowDetails, 604 KOPrefs::instance()->mWTshowDetails,
610 KOPrefs::instance()->mWTshowCreated, 605 KOPrefs::instance()->mWTshowCreated,
611 KOPrefs::instance()->mWTshowChanged); 606 KOPrefs::instance()->mWTshowChanged);
612 return i18n("That is the todo view" ); 607 return i18n("That is the todo view" );
613 608
614} 609}
615 610
616void KOTodoView::jumpToDate () 611void KOTodoView::jumpToDate ()
617{ 612{
618 // if (mActiveItem) { 613 // if (mActiveItem) {
619// mActiveItem->todo()); 614// mActiveItem->todo());
620// if ( mActiveItem->todo()->hasDueDate() ) 615// if ( mActiveItem->todo()->hasDueDate() )
621// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 616// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
622} 617}
623void KOTodoView::paintNeeded() 618void KOTodoView::paintNeeded()
624{ 619{
625 if ( mPendingUpdateBeforeRepaint ) { 620 if ( mPendingUpdateBeforeRepaint ) {
626 updateView(); 621 updateView();
627 mPendingUpdateBeforeRepaint = false; 622 mPendingUpdateBeforeRepaint = false;
628 } 623 }
629} 624}
630void KOTodoView::paintEvent(QPaintEvent * pevent) 625void KOTodoView::paintEvent(QPaintEvent * pevent)
631{ 626{
632 if ( mPendingUpdateBeforeRepaint ) { 627 if ( mPendingUpdateBeforeRepaint ) {
633 updateView(); 628 updateView();
634 mPendingUpdateBeforeRepaint = false; 629 mPendingUpdateBeforeRepaint = false;
635 } 630 }
636 KOrg::BaseView::paintEvent( pevent); 631 KOrg::BaseView::paintEvent( pevent);
637} 632}
638 633
639void KOTodoView::updateView() 634void KOTodoView::updateView()
640{ 635{
641 pendingSubtodo = 0; 636 pendingSubtodo = 0;
642 if ( mBlockUpdate ) { 637 if ( mBlockUpdate ) {
643 return; 638 return;
644 } 639 }
645 if ( !isVisible() ) { 640 if ( !isVisible() ) {
646 mPendingUpdateBeforeRepaint = true; 641 mPendingUpdateBeforeRepaint = true;
647 return; 642 return;
648 } 643 }
649 storeCurrentItem(); 644 storeCurrentItem();
650 //qDebug("KOTodoView::updateView() %x", this); 645 //qDebug("KOTodoView::updateView() %x", this);
651 if ( isFlatDisplay ) { 646 if ( isFlatDisplay ) {
652 displayAllFlat(); 647 displayAllFlat();
653 resetCurrentItem(); 648 resetCurrentItem();
654 return; 649 return;
655 } 650 }
656 //qDebug("update "); 651 //qDebug("update ");
657// kdDebug() << "KOTodoView::updateView()" << endl; 652// kdDebug() << "KOTodoView::updateView()" << endl;
658 QFont fo = KOPrefs::instance()->mTodoViewFont; 653 QFont fo = KOPrefs::instance()->mTodoViewFont;
659 654
660 655
661 mTodoListView->clear(); 656 mTodoListView->clear();
662 if ( mName == "todolistsmall" ) { 657 if ( mName == "todolistsmall" ) {
663 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 658 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
664 int ps = fo.pointSize() -2; 659 int ps = fo.pointSize() -2;
665 if ( ps > 12 ) 660 if ( ps > 12 )
666 ps -= 2; 661 ps -= 2;
667 fo.setPointSize( ps ); 662 fo.setPointSize( ps );
668 } 663 }
669 } 664 }
670 665
671 mTodoListView->setFont( fo ); 666 mTodoListView->setFont( fo );
672 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 667 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
673 //mTodoListView->header()->setMaximumHeight(fm.height()); 668 //mTodoListView->header()->setMaximumHeight(fm.height());
674 QPtrList<Todo> todoList = calendar()->todos(); 669 QPtrList<Todo> todoList = calendar()->todos();
675 670
676/* 671/*
677 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 672 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
678 Event *t; 673 Event *t;
679 for(t = todoList.first(); t; t = todoList.next()) { 674 for(t = todoList.first(); t; t = todoList.next()) {
680 kdDebug() << " " << t->getSummary() << endl; 675 kdDebug() << " " << t->getSummary() << endl;
681 676
682 if (t->getRelatedTo()) { 677 if (t->getRelatedTo()) {
683 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 678 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
684 } 679 }
685 680
686 QPtrList<Event> l = t->getRelations(); 681 QPtrList<Event> l = t->getRelations();
687 Event *c; 682 Event *c;
688 for(c=l.first();c;c=l.next()) { 683 for(c=l.first();c;c=l.next()) {
689 kdDebug() << " - relation: " << c->getSummary() << endl; 684 kdDebug() << " - relation: " << c->getSummary() << endl;
690 } 685 }
691 } 686 }
692*/ 687*/
693 688
694 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 689 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
695 // specific order of events. That means that we have to generate parent items 690 // specific order of events. That means that we have to generate parent items
696 // recursively for proper hierarchical display of Todos. 691 // recursively for proper hierarchical display of Todos.
697 mTodoMap.clear(); 692 mTodoMap.clear();
698 Todo *todo; 693 Todo *todo;
699 todo = todoList.first();// todo; todo = todoList.next()) { 694 todo = todoList.first();// todo; todo = todoList.next()) {
700 while ( todo ) { 695 while ( todo ) {
701 bool next = true; 696 bool next = true;
702 // qDebug("todo %s ", todo->summary().latin1()); 697 // qDebug("todo %s ", todo->summary().latin1());
703 Incidence *incidence = todo->relatedTo(); 698 Incidence *incidence = todo->relatedTo();
704 while ( incidence ) { 699 while ( incidence ) {
705 if ( incidence->typeID() == todoID ) { 700 if ( incidence->typeID() == todoID ) {
706 //qDebug("related %s ",incidence->summary().latin1() ); 701 //qDebug("related %s ",incidence->summary().latin1() );
707 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { 702 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) {
708 //qDebug("related not found "); 703 //qDebug("related not found ");
709 todoList.remove( ); 704 todoList.remove( );
710 todo = todoList.current(); 705 todo = todoList.current();
711 next = false; 706 next = false;
712 incidence = 0; 707 incidence = 0;
713 708
714 } else { 709 } else {
715 //qDebug("related found "); 710 //qDebug("related found ");
716 incidence = incidence->relatedTo(); 711 incidence = incidence->relatedTo();
717 } 712 }
718 } else 713 } else
719 incidence = 0; 714 incidence = 0;
720 } 715 }
721 if ( next ) 716 if ( next )
722 todo = todoList.next(); 717 todo = todoList.next();
723 } 718 }
724 719
725 for(todo = todoList.first(); todo; todo = todoList.next()) { 720 for(todo = todoList.first(); todo; todo = todoList.next()) {
726 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 721 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
727 { 722 {
728 insertTodoItem(todo); 723 insertTodoItem(todo);
729 } 724 }
730 } 725 }
731 // Restore opened/closed state 726 // Restore opened/closed state
732 mTodoListView->blockSignals( true ); 727 mTodoListView->blockSignals( true );
733 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 728 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
734 mTodoListView->blockSignals( false ); 729 mTodoListView->blockSignals( false );
735 resetCurrentItem(); 730 resetCurrentItem();
736 processSelectionChange(); 731 processSelectionChange();
737} 732}
738 733
739void KOTodoView::storeCurrentItem() 734void KOTodoView::storeCurrentItem()
740{ 735{
741 mCurItem = 0; 736 mCurItem = 0;
742 mCurItemRootParent = 0; 737 mCurItemRootParent = 0;
743 mCurItemParent = 0; 738 mCurItemParent = 0;
744 mCurItemAbove = 0; 739 mCurItemAbove = 0;
745 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 740 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
746 if (mActiveItem) { 741 if (mActiveItem) {
747 mCurItem = mActiveItem->todo(); 742 mCurItem = mActiveItem->todo();
748 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 743 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
749 if ( activeItemAbove ) 744 if ( activeItemAbove )
750 mCurItemAbove = activeItemAbove->todo(); 745 mCurItemAbove = activeItemAbove->todo();
751 mCurItemRootParent = mCurItem; 746 mCurItemRootParent = mCurItem;
752 mCurItemParent = mCurItemRootParent->relatedTo(); 747 mCurItemParent = mCurItemRootParent->relatedTo();
753 while ( mCurItemRootParent->relatedTo() != 0 ) 748 while ( mCurItemRootParent->relatedTo() != 0 )
754 mCurItemRootParent = mCurItemRootParent->relatedTo(); 749 mCurItemRootParent = mCurItemRootParent->relatedTo();
755 } 750 }
756 mActiveItem = 0; 751 mActiveItem = 0;
757} 752}
758 753
759void KOTodoView::resetCurrentItem() 754void KOTodoView::resetCurrentItem()
760{ 755{
761 mTodoListView->setFocus(); 756 mTodoListView->setFocus();
762 KOTodoViewItem* foundItem = 0; 757 KOTodoViewItem* foundItem = 0;
763 KOTodoViewItem* foundItemRoot = 0; 758 KOTodoViewItem* foundItemRoot = 0;
764 KOTodoViewItem* foundItemParent = 0; 759 KOTodoViewItem* foundItemParent = 0;
765 KOTodoViewItem* foundItemAbove = 0; 760 KOTodoViewItem* foundItemAbove = 0;
766 if ( mTodoListView->firstChild () ) { 761 if ( mTodoListView->firstChild () ) {
767 if ( mCurItem ) { 762 if ( mCurItem ) {
768 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 763 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
769 while ( item ) { 764 while ( item ) {
770 if ( item->todo() == mCurItem ) { 765 if ( item->todo() == mCurItem ) {
771 foundItem = item; 766 foundItem = item;
772 break; 767 break;
773 } else if ( item->todo() == mCurItemAbove ) { 768 } else if ( item->todo() == mCurItemAbove ) {
774 foundItemAbove = item; 769 foundItemAbove = item;
775 770
776 } 771 }
777 if ( item->todo() == mCurItemRootParent ) { 772 if ( item->todo() == mCurItemRootParent ) {
778 foundItemRoot = item; 773 foundItemRoot = item;
779 } 774 }
780 if ( item->todo() == mCurItemParent ) { 775 if ( item->todo() == mCurItemParent ) {
781 foundItemParent = item; 776 foundItemParent = item;
782 } 777 }
783 item = (KOTodoViewItem*)item->itemBelow(); 778 item = (KOTodoViewItem*)item->itemBelow();
784 } 779 }
785 if ( ! foundItem ) { 780 if ( ! foundItem ) {
786 if ( foundItemParent ) { 781 if ( foundItemParent ) {
787 foundItem = foundItemParent; 782 foundItem = foundItemParent;
788 } else { 783 } else {
789 if ( foundItemRoot ) 784 if ( foundItemRoot )
790 foundItem = foundItemRoot; 785 foundItem = foundItemRoot;
791 else 786 else
792 foundItem = foundItemAbove; 787 foundItem = foundItemAbove;
793 } 788 }
794 } 789 }
795 } 790 }
796 if ( foundItem ) { 791 if ( foundItem ) {
797 mTodoListView->setCurrentItem( foundItem ); 792 mTodoListView->setCurrentItem( foundItem );
798 mTodoListView->ensureItemVisible( foundItem ); 793 mTodoListView->ensureItemVisible( foundItem );
799 } else { 794 } else {
800 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 795 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
801 } 796 }
802 } 797 }
803 mTodoListView->setFocus(); 798 mTodoListView->setFocus();
804} 799}
805//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 800//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
806bool KOTodoView::checkTodo( Todo * todo ) 801bool KOTodoView::checkTodo( Todo * todo )
807{ 802{
808 803
809 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 804 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
810 return false; 805 return false;
811 if ( !todo->isCompleted() ) { 806 if ( !todo->isCompleted() ) {
812 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 807 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
813 return true; 808 return true;
814 } 809 }
815 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 810 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
816 if ( todo->hasStartDate() ) 811 if ( todo->hasStartDate() )
817 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 812 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
818 return false; 813 return false;
819 if ( todo->hasDueDate() ) 814 if ( todo->hasDueDate() )
820 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 815 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
821 return false; 816 return false;
822 } 817 }
823 return true; 818 return true;
824} 819}
825 820
826void KOTodoView::restoreItemState( QListViewItem *item ) 821void KOTodoView::restoreItemState( QListViewItem *item )
827{ 822{
828 pendingSubtodo = 0; 823 pendingSubtodo = 0;
829 while( item ) { 824 while( item ) {
830 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 825 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
831 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 826 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
832 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 827 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
833 item = item->nextSibling(); 828 item = item->nextSibling();
834 } 829 }
835} 830}
836 831
837 832
838QMap<Todo *,KOTodoViewItem *>::ConstIterator 833QMap<Todo *,KOTodoViewItem *>::ConstIterator
839KOTodoView::insertTodoItem(Todo *todo) 834KOTodoView::insertTodoItem(Todo *todo)
840{ 835{
841 836
842 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 837 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
843 // TODO: Check, if dynmaic cast is necessary 838 // TODO: Check, if dynmaic cast is necessary
844 839
845 pendingSubtodo = 0; 840 pendingSubtodo = 0;
846 Incidence *incidence = todo->relatedTo(); 841 Incidence *incidence = todo->relatedTo();
847 while ( incidence && !incidence->calEnabled() ) 842 while ( incidence && !incidence->calEnabled() )
848 incidence = incidence->relatedTo(); 843 incidence = incidence->relatedTo();
849 if (incidence && incidence->typeID() == todoID ) { 844 if (incidence && incidence->typeID() == todoID ) {
850 Todo *relatedTodo = static_cast<Todo *>(incidence); 845 Todo *relatedTodo = static_cast<Todo *>(incidence);
851 846
852 // kdDebug() << " has Related" << endl; 847 // kdDebug() << " has Related" << endl;
853 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 848 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
854 itemIterator = mTodoMap.find(relatedTodo); 849 itemIterator = mTodoMap.find(relatedTodo);
855 if (itemIterator == mTodoMap.end()) { 850 if (itemIterator == mTodoMap.end()) {
856 // kdDebug() << " related not yet in list" << endl; 851 // kdDebug() << " related not yet in list" << endl;
857 itemIterator = insertTodoItem (relatedTodo); 852 itemIterator = insertTodoItem (relatedTodo);
858 } 853 }
859 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 854 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
860 // and one into the map. Sure finding is more easy but why? -zecke 855 // and one into the map. Sure finding is more easy but why? -zecke
861 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 856 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
862 return mTodoMap.insert(todo,todoItem); 857 return mTodoMap.insert(todo,todoItem);
863 } else { 858 } else {
864 // kdDebug() << " no Related" << endl; 859 // kdDebug() << " no Related" << endl;
865 // see above -zecke 860 // see above -zecke
866 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 861 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
867 return mTodoMap.insert(todo,todoItem); 862 return mTodoMap.insert(todo,todoItem);
868 } 863 }
869} 864}
870 865
871 866
872void KOTodoView::updateConfig() 867void KOTodoView::updateConfig()
873{ 868{
874 updateView(); 869 updateView();
875 mTodoListView->repaintContents(); 870 mTodoListView->repaintContents();
876} 871}
877 872
878QPtrList<Incidence> KOTodoView::selectedIncidences() 873QPtrList<Incidence> KOTodoView::selectedIncidences()
879{ 874{
880 QPtrList<Incidence> selected; 875 QPtrList<Incidence> selected;
881 876
882 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 877 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
883// if (!item) item = mActiveItem; 878// if (!item) item = mActiveItem;
884 if (item) selected.append(item->todo()); 879 if (item) selected.append(item->todo());
885 880
886 return selected; 881 return selected;
887} 882}
888 883
889QPtrList<Todo> KOTodoView::selectedTodos() 884QPtrList<Todo> KOTodoView::selectedTodos()
890{ 885{
891 QPtrList<Todo> selected; 886 QPtrList<Todo> selected;
892 887
893 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 888 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
894// if (!item) item = mActiveItem; 889// if (!item) item = mActiveItem;
895 if (item) selected.append(item->todo()); 890 if (item) selected.append(item->todo());
896 891
897 return selected; 892 return selected;
898} 893}
899 894
900void KOTodoView::changeEventDisplay(Event *, int) 895void KOTodoView::changeEventDisplay(Event *, int)
901{ 896{
902 updateView(); 897 updateView();
903} 898}
904 899
905void KOTodoView::showDates(const QDate &, const QDate &) 900void KOTodoView::showDates(const QDate &, const QDate &)
906{ 901{
907} 902}
908 903
909void KOTodoView::showEvents(QPtrList<Event>) 904void KOTodoView::showEvents(QPtrList<Event>)
910{ 905{
911 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 906 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
912} 907}
913 908
914void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 909void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
915 const QDate &td) 910 const QDate &td)
916{ 911{
917#ifndef KORG_NOPRINTER 912#ifndef KORG_NOPRINTER
918 calPrinter->preview(CalPrinter::Todolist, fd, td); 913 calPrinter->preview(CalPrinter::Todolist, fd, td);
919#endif 914#endif
920} 915}
921 916
922void KOTodoView::editItem(QListViewItem *item ) 917void KOTodoView::editItem(QListViewItem *item )
923{ 918{
924 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 919 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
925} 920}
926 921
927void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 922void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
928{ 923{
929 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 924 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
930} 925}
931 926
932void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 927void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
933{ 928{
934 pendingSubtodo = 0; 929 pendingSubtodo = 0;
935 mActiveItem = (KOTodoViewItem *)item; 930 mActiveItem = (KOTodoViewItem *)item;
936 if (item) { 931 if (item) {
937 switch (column){ 932 switch (column){
938 case 1: 933 case 1:
939 mPriorityPopupMenu->popup(QCursor::pos ()); break; 934 mPriorityPopupMenu->popup(QCursor::pos ()); break;
940 case 2: 935 case 2:
941 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 936 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
942 case 3: 937 case 3:
943 moveTodo(); 938 moveTodo();
944 break; 939 break;
945 case 8: 940 case 8:
946 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 941 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
947 default: 942 default:
948 mItemPopupMenu->popup(QCursor::pos()); 943 mItemPopupMenu->popup(QCursor::pos());
949 } 944 }
950 } else mPopupMenu->popup(QCursor::pos()); 945 } else mPopupMenu->popup(QCursor::pos());
951} 946}
952void KOTodoView::newTodo() 947void KOTodoView::newTodo()
953{ 948{
954 emit newTodoSignal(); 949 emit newTodoSignal();
955} 950}
956 951
957void KOTodoView::newSubTodo() 952void KOTodoView::newSubTodo()
958{ 953{
959 if (mActiveItem) { 954 if (mActiveItem) {
960 emit newSubTodoSignal(mActiveItem->todo()); 955 emit newSubTodoSignal(mActiveItem->todo());
961 } 956 }
962} 957}
963void KOTodoView::unparentTodo() 958void KOTodoView::unparentTodo()
964{ 959{
965 if (mActiveItem) { 960 if (mActiveItem) {
966 emit unparentTodoSignal(mActiveItem->todo()); 961 emit unparentTodoSignal(mActiveItem->todo());
967 } 962 }
968} 963}
969 964
970void KOTodoView::reparentTodo() 965void KOTodoView::reparentTodo()
971{ 966{
972 if (mActiveItem) { 967 if (mActiveItem) {
973 topLevelWidget()->setCaption(i18n("Click on new parent item")); 968 topLevelWidget()->setCaption(i18n("Click on new parent item"));
974 pendingSubtodo = mActiveItem; 969 pendingSubtodo = mActiveItem;
975 } 970 }
976} 971}
977void KOTodoView::editTodo() 972void KOTodoView::editTodo()
978{ 973{
979 if (mActiveItem) { 974 if (mActiveItem) {
980 emit editTodoSignal(mActiveItem->todo()); 975 emit editTodoSignal(mActiveItem->todo());
981 } 976 }
982} 977}
983void KOTodoView::cloneTodo() 978void KOTodoView::cloneTodo()
984{ 979{
985 if (mActiveItem) { 980 if (mActiveItem) {
986 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 981 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
987 } 982 }
988} 983}
989void KOTodoView::cancelTodo() 984void KOTodoView::cancelTodo()
990{ 985{
991 if (mActiveItem) { 986 if (mActiveItem) {
992 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 987 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
993 } 988 }
994} 989}
995void KOTodoView::moveTodo() 990void KOTodoView::moveTodo()
996{ 991{
997 if (mActiveItem) { 992 if (mActiveItem) {
998 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 993 emit moveTodoSignal((Incidence*)mActiveItem->todo());
999 } 994 }
1000} 995}
1001void KOTodoView::beamTodo() 996void KOTodoView::beamTodo()
1002{ 997{
1003 if (mActiveItem) { 998 if (mActiveItem) {
1004 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 999 emit beamTodoSignal((Incidence*)mActiveItem->todo());
1005 } 1000 }
1006} 1001}
1007 1002
1008 1003
1009void KOTodoView::showTodo() 1004void KOTodoView::showTodo()
1010{ 1005{
1011 if (mActiveItem) { 1006 if (mActiveItem) {
1012 emit showTodoSignal(mActiveItem->todo()); 1007 emit showTodoSignal(mActiveItem->todo());
1013 } 1008 }
1014} 1009}
1015 1010
1016void KOTodoView::deleteTodo() 1011void KOTodoView::deleteTodo()
1017{ 1012{
1018 if (mActiveItem) { 1013 if (mActiveItem) {
1019 emit deleteTodoSignal(mActiveItem->todo()); 1014 emit deleteTodoSignal(mActiveItem->todo());
1020 } 1015 }
1021} 1016}
1022 1017
1023void KOTodoView::setNewPriority(int index) 1018void KOTodoView::setNewPriority(int index)
1024{ 1019{
1025 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1020 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1026 mActiveItem->todo()->setPriority(mPriority[index]); 1021 mActiveItem->todo()->setPriority(mPriority[index]);
1027 mActiveItem->construct(); 1022 mActiveItem->construct();
1028 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1023 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1029 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1024 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1030 } 1025 }
1031} 1026}
1032 1027
1033void KOTodoView::setNewPercentage(int index) 1028void KOTodoView::setNewPercentage(int index)
1034{ 1029{
1035 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1030 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1036 1031
1037 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1032 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1038 mActiveItem->setOn( true ); 1033 mActiveItem->setOn( true );
1039 return; 1034 return;
1040 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1035 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1041 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1036 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1042 if ( par && par->isOn() ) 1037 if ( par && par->isOn() )
1043 par->setOn( false ); 1038 par->setOn( false );
1044 } 1039 }
1045 if (mPercentage[index] == 100) { 1040 if (mPercentage[index] == 100) {
1046 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1041 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1047 } else { 1042 } else {
1048 mActiveItem->todo()->setCompleted(false); 1043 mActiveItem->todo()->setCompleted(false);
1049 } 1044 }
1050 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1045 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1051 mActiveItem->construct(); 1046 mActiveItem->construct();
1052 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1047 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1053 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1048 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1054 } 1049 }
1055} 1050}
1056 1051
1057 1052
1058QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 1053QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
1059{ 1054{
1060 QPopupMenu* tempMenu = new QPopupMenu (this); 1055 QPopupMenu* tempMenu = new QPopupMenu (this);
1061 QStringList checkedCategories = todoItem->todo()->categories (); 1056 QStringList checkedCategories = todoItem->todo()->categories ();
1062 1057
1063 tempMenu->setCheckable (true); 1058 tempMenu->setCheckable (true);
1064 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1059 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1065 it != KOPrefs::instance()->mCustomCategories.end (); 1060 it != KOPrefs::instance()->mCustomCategories.end ();
1066 ++it) { 1061 ++it) {
1067 int index = tempMenu->insertItem (*it); 1062 int index = tempMenu->insertItem (*it);
1068 mCategory[index] = *it; 1063 mCategory[index] = *it;
1069 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 1064 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
1070 } 1065 }
1071 1066
1072 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 1067 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
1073 return tempMenu; 1068 return tempMenu;
1074 1069
1075 1070
1076} 1071}
1077void KOTodoView::changedCategories(int index) 1072void KOTodoView::changedCategories(int index)
1078{ 1073{
1079 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1074 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1080 QStringList categories = mActiveItem->todo()->categories (); 1075 QStringList categories = mActiveItem->todo()->categories ();
1081 QString colcat = categories.first(); 1076 QString colcat = categories.first();
1082 if (categories.find (mCategory[index]) != categories.end ()) 1077 if (categories.find (mCategory[index]) != categories.end ())
1083 categories.remove (mCategory[index]); 1078 categories.remove (mCategory[index]);
1084 else 1079 else
1085 categories.insert (categories.end(), mCategory[index]); 1080 categories.insert (categories.end(), mCategory[index]);
1086 categories.sort (); 1081 categories.sort ();
1087 if ( !colcat.isEmpty() ) { 1082 if ( !colcat.isEmpty() ) {
1088 if ( categories.find ( colcat ) != categories.end () ) { 1083 if ( categories.find ( colcat ) != categories.end () ) {
1089 categories.remove( colcat ); 1084 categories.remove( colcat );
1090 categories.prepend( colcat ); 1085 categories.prepend( colcat );
1091 } 1086 }
1092 } 1087 }
1093 mActiveItem->todo()->setCategories (categories); 1088 mActiveItem->todo()->setCategories (categories);
1094 mActiveItem->construct(); 1089 mActiveItem->construct();
1095 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1090 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1096 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1091 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1097 } 1092 }
1098} 1093}
1099void KOTodoView::itemDoubleClicked(QListViewItem *item) 1094void KOTodoView::itemDoubleClicked(QListViewItem *item)
1100{ 1095{
1101 if ( pendingSubtodo != 0 ) { 1096 if ( pendingSubtodo != 0 ) {
1102 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1097 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1103 } 1098 }
1104 pendingSubtodo = 0; 1099 pendingSubtodo = 0;
1105 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1100 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1106 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1101 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1107 //qDebug("ROW %d ", row); 1102 //qDebug("ROW %d ", row);
1108 if (!item) { 1103 if (!item) {
1109 newTodo(); 1104 newTodo();
1110 return; 1105 return;
1111 } else { 1106 } else {
1112 if ( row == 2 || row == 1 ) { 1107 if ( row == 2 || row == 1 ) {
1113 mActiveItem = (KOTodoViewItem *) item; 1108 mActiveItem = (KOTodoViewItem *) item;
1114 newSubTodo(); 1109 newSubTodo();
1115 return; 1110 return;
1116 } 1111 }
1117 if ( row == 5 || row == 6 ) { 1112 if ( row == 5 || row == 6 ) {
1118 mActiveItem = (KOTodoViewItem *) item; 1113 mActiveItem = (KOTodoViewItem *) item;
1119 toggleRunningItem(); 1114 toggleRunningItem();
1120 return; 1115 return;
1121 } 1116 }
1122 } 1117 }
1123 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1118 if ( KOPrefs::instance()->mEditOnDoubleClick )
1124 editItem( item ); 1119 editItem( item );
1125 else 1120 else
1126 showItem( item , QPoint(), 0 ); 1121 showItem( item , QPoint(), 0 );
1127} 1122}
1128void KOTodoView::toggleRunningItem() 1123void KOTodoView::toggleRunningItem()
1129{ 1124{
1130 // qDebug("KOTodoView::toggleRunning() "); 1125 // qDebug("KOTodoView::toggleRunning() ");
1131 if ( ! mActiveItem ) 1126 if ( ! mActiveItem )
1132 return; 1127 return;
1133 Todo * t = mActiveItem->todo(); 1128 Todo * t = mActiveItem->todo();
1134 if ( t->isRunning() ) { 1129 if ( t->isRunning() ) {
1135#if 0 1130#if 0
1136 int result = KMessageBox::warningContinueCancel(this, 1131 int result = KMessageBox::warningContinueCancel(this,
1137 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true); 1132 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true);
1138#endif 1133#endif
1139 1134
1140 int result = KMessageBox::warningYesNoCancel(this, 1135 int result = KMessageBox::warningYesNoCancel(this,
1141 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop"),i18n("Stop+note")); 1136 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop"),i18n("Stop+note"));
1142 if (result == KMessageBox::Cancel) return; 1137 if (result == KMessageBox::Cancel) return;
1143 if ( result == KMessageBox::No ) { 1138 if ( result == KMessageBox::No ) {
1144 QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") ); 1139 QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") );
1145 t->setRunningFalse( comment ); 1140 t->setRunningFalse( comment );
1146 } else { 1141 } else {
1147 t->setRunning( false ); 1142 t->setRunning( false );
1148 } 1143 }
1149 mActiveItem->construct(); 1144 mActiveItem->construct();
1150 } else { 1145 } else {
1151 int result = KMessageBox::warningContinueCancel(this, 1146 int result = KMessageBox::warningContinueCancel(this,
1152 i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); 1147 i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true);
1153 if (result != KMessageBox::Continue) return; 1148 if (result != KMessageBox::Continue) return;
1154 t->setRunning( true ); 1149 t->setRunning( true );
1155 mActiveItem->construct(); 1150 mActiveItem->construct();
1156 } 1151 }
1157} 1152}
1158 1153
1159void KOTodoView::itemClicked(QListViewItem *item) 1154void KOTodoView::itemClicked(QListViewItem *item)
1160{ 1155{
1161 //qDebug("KOTodoView::itemClicked %d", item); 1156 //qDebug("KOTodoView::itemClicked %d", item);
1162 if (!item) { 1157 if (!item) {
1163 if ( pendingSubtodo != 0 ) { 1158 if ( pendingSubtodo != 0 ) {
1164 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1159 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1165 } 1160 }
1166 pendingSubtodo = 0; 1161 pendingSubtodo = 0;
1167 return; 1162 return;
1168 } 1163 }
1169 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1164 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1170 if ( pendingSubtodo != 0 ) { 1165 if ( pendingSubtodo != 0 ) {
1171 bool allowReparent = true; 1166 bool allowReparent = true;
1172 QListViewItem *par = item; 1167 QListViewItem *par = item;
1173 while ( par ) { 1168 while ( par ) {
1174 if ( par == pendingSubtodo ) { 1169 if ( par == pendingSubtodo ) {
1175 allowReparent = false; 1170 allowReparent = false;
1176 break; 1171 break;
1177 } 1172 }
1178 par = par->parent(); 1173 par = par->parent();
1179 } 1174 }
1180 if ( !allowReparent ) { 1175 if ( !allowReparent ) {
1181 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1176 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1182 pendingSubtodo = 0; 1177 pendingSubtodo = 0;
1183 } else { 1178 } else {
1184 Todo* newParent = todoItem->todo(); 1179 Todo* newParent = todoItem->todo();
1185 Todo* newSub = pendingSubtodo->todo(); 1180 Todo* newSub = pendingSubtodo->todo();
1186 pendingSubtodo = 0; 1181 pendingSubtodo = 0;
1187 emit reparentTodoSignal( newParent,newSub ); 1182 emit reparentTodoSignal( newParent,newSub );
1188 return; 1183 return;
1189 } 1184 }
1190 } 1185 }
1191 1186
1192} 1187}
1193 1188
1194void KOTodoView::setDocumentId( const QString &id ) 1189void KOTodoView::setDocumentId( const QString &id )
1195{ 1190{
1196 1191
1197 mDocPrefs->setDoc( id ); 1192 mDocPrefs->setDoc( id );
1198} 1193}
1199 1194
1200void KOTodoView::itemStateChanged( QListViewItem *item ) 1195void KOTodoView::itemStateChanged( QListViewItem *item )
1201{ 1196{
1202 if (!item) return; 1197 if (!item) return;
1203 1198
1204 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1199 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1205 1200
1206// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1201// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1207 1202
1208 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1203 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1209} 1204}
1210 1205
1211void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1206void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1212{ 1207{
1213 mTodoListView->saveLayout(config,group); 1208 mTodoListView->saveLayout(config,group);
1214} 1209}
1215 1210
1216void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1211void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1217{ 1212{
1218 mTodoListView->restoreLayout(config,group); 1213 mTodoListView->restoreLayout(config,group);
1219} 1214}
1220 1215
1221void KOTodoView::processSelectionChange() 1216void KOTodoView::processSelectionChange()
1222{ 1217{
1223// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1218// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1224 1219
1225 KOTodoViewItem *item = 1220 KOTodoViewItem *item =
1226 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1221 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1227 1222
1228 if ( !item ) { 1223 if ( !item ) {
1229 emit incidenceSelected( 0 ); 1224 emit incidenceSelected( 0 );
1230 } else { 1225 } else {
1231 emit incidenceSelected( item->todo() ); 1226 emit incidenceSelected( item->todo() );
1232 } 1227 }
1233} 1228}
1234 1229
1235void KOTodoView::modified(bool b) 1230void KOTodoView::modified(bool b)
1236{ 1231{
1237 emit isModified(b); 1232 emit isModified(b);
1238} 1233}
1239void KOTodoView::setTodoModified( Todo* todo ) 1234void KOTodoView::setTodoModified( Todo* todo )
1240{ 1235{
1241 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1236 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1242} 1237}
1243void KOTodoView::clearSelection() 1238void KOTodoView::clearSelection()
1244{ 1239{
1245 mTodoListView->selectAll( false ); 1240 mTodoListView->selectAll( false );
1246} 1241}
1247void KOTodoView::setAllOpen() 1242void KOTodoView::setAllOpen()
1248{ 1243{
1249 if ( isFlatDisplay ) { 1244 if ( isFlatDisplay ) {
1250 isFlatDisplay = false; 1245 isFlatDisplay = false;
1251 mPopupMenu->setItemChecked( 8,false ); 1246 mPopupMenu->setItemChecked( 8,false );
1252 updateView(); 1247 updateView();
1253 } else { 1248 } else {
1254 storeCurrentItem(); 1249 storeCurrentItem();
1255 } 1250 }
1256 setOpen(mTodoListView->firstChild(), true); 1251 setOpen(mTodoListView->firstChild(), true);
1257 resetCurrentItem(); 1252 resetCurrentItem();
1258} 1253}
1259void KOTodoView::setAllClose() 1254void KOTodoView::setAllClose()
1260{ 1255{
1261 if ( isFlatDisplay ) { 1256 if ( isFlatDisplay ) {
1262 isFlatDisplay = false; 1257 isFlatDisplay = false;
1263 mPopupMenu->setItemChecked( 8,false ); 1258 mPopupMenu->setItemChecked( 8,false );
1264 updateView(); 1259 updateView();
1265 } else { 1260 } else {
1266 storeCurrentItem(); 1261 storeCurrentItem();
1267 } 1262 }
1268 setOpen(mTodoListView->firstChild(), false); 1263 setOpen(mTodoListView->firstChild(), false);
1269 resetCurrentItem(); 1264 resetCurrentItem();
1270} 1265}
1271void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1266void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1272{ 1267{
1273 1268
1274 while ( item ) { 1269 while ( item ) {
1275 setOpen( item->firstChild(), setOpenI ); 1270 setOpen( item->firstChild(), setOpenI );
1276 item->setOpen( setOpenI ); 1271 item->setOpen( setOpenI );
1277 item = item->nextSibling(); 1272 item = item->nextSibling();
1278 } 1273 }
1279} 1274}
1280 1275
1281void KOTodoView::displayAllFlat() 1276void KOTodoView::displayAllFlat()
1282{ 1277{
1283 pendingSubtodo = 0; 1278 pendingSubtodo = 0;
1284 if ( mBlockUpdate ) { 1279 if ( mBlockUpdate ) {
1285 return; 1280 return;
1286 } 1281 }
1287 mPopupMenu->setItemChecked( 8,true ); 1282 mPopupMenu->setItemChecked( 8,true );
1288 isFlatDisplay = true; 1283 isFlatDisplay = true;
1289 QPtrList<Todo> todoList = calendar()->todos(); 1284 QPtrList<Todo> todoList = calendar()->todos();
1290 mTodoMap.clear(); 1285 mTodoMap.clear();
1291 mTodoListView->clear(); 1286 mTodoListView->clear();
1292 Todo *todo; 1287 Todo *todo;
1293 for(todo = todoList.first(); todo; todo = todoList.next()) { 1288 for(todo = todoList.first(); todo; todo = todoList.next()) {
1294 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1289 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1295 mTodoMap.insert(todo,todoItem); 1290 mTodoMap.insert(todo,todoItem);
1296 } 1291 }
1297 mTodoListView->setFocus(); 1292 mTodoListView->setFocus();
1298 processSelectionChange(); 1293 processSelectionChange();
1299} 1294}
1300 1295
1301void KOTodoView::setAllFlat() 1296void KOTodoView::setAllFlat()
1302{ 1297{
1303 if ( isFlatDisplay ) { 1298 if ( isFlatDisplay ) {
1304 isFlatDisplay = false; 1299 isFlatDisplay = false;
1305 mPopupMenu->setItemChecked( 8,false ); 1300 mPopupMenu->setItemChecked( 8,false );
1306 updateView(); 1301 updateView();
1307 return; 1302 return;
1308 } 1303 }
1309 storeCurrentItem(); 1304 storeCurrentItem();
1310 displayAllFlat(); 1305 displayAllFlat();
1311 resetCurrentItem(); 1306 resetCurrentItem();
1312} 1307}
1313 1308
1314void KOTodoView::purgeCompleted() 1309void KOTodoView::purgeCompleted()
1315{ 1310{
1316 emit purgeCompletedSignal(); 1311 emit purgeCompletedSignal();
1317 1312
1318} 1313}
1319void KOTodoView::toggleQuickTodo() 1314void KOTodoView::toggleQuickTodo()
1320{ 1315{
1321 if ( mQuickAdd->isVisible() ) { 1316 if ( mQuickAdd->isVisible() ) {
1322 mQuickAdd->hide(); 1317 mQuickAdd->hide();
1323 KOPrefs::instance()->mEnableQuickTodo = false; 1318 KOPrefs::instance()->mEnableQuickTodo = false;
1324 } 1319 }
1325 else { 1320 else {
1326 mQuickAdd->show(); 1321 mQuickAdd->show();
1327 KOPrefs::instance()->mEnableQuickTodo = true; 1322 KOPrefs::instance()->mEnableQuickTodo = true;
1328 } 1323 }
1329 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1324 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1330 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1325 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1331} 1326}
1332 1327
1333void KOTodoView::toggleRunning() 1328void KOTodoView::toggleRunning()
1334{ 1329{
1335 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1330 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1336 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1331 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1337 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1332 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1338 updateView(); 1333 updateView();
1339} 1334}
1340 1335
1341void KOTodoView::toggleCompleted() 1336void KOTodoView::toggleCompleted()
1342{ 1337{
1343 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1338 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1344 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1339 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1345 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1340 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1346 updateView(); 1341 updateView();
1347} 1342}
1348 1343
1349void KOTodoView::addQuickTodo() 1344void KOTodoView::addQuickTodo()
1350{ 1345{
1351 Todo *todo = new Todo(); 1346 Todo *todo = new Todo();
1352 todo->setSummary(mQuickAdd->text()); 1347 todo->setSummary(mQuickAdd->text());
1353 todo->setOrganizer(KOPrefs::instance()->email()); 1348 todo->setOrganizer(KOPrefs::instance()->email());
1354 CalFilter * cf = mCalendar->filter(); 1349 CalFilter * cf = mCalendar->filter();
1355 if ( cf ) { 1350 if ( cf ) {
1356 if ( cf->isEnabled()&& cf->showCategories()) { 1351 if ( cf->isEnabled()&& cf->showCategories()) {
1357 todo->setCategories(cf->categoryList()); 1352 todo->setCategories(cf->categoryList());
1358 } 1353 }
1359 if ( cf->isEnabled() ) 1354 if ( cf->isEnabled() )
1360 todo->setSecrecy( cf->getSecrecy()); 1355 todo->setSecrecy( cf->getSecrecy());
1361 } 1356 }
1362 mCalendar->addTodo(todo); 1357 mCalendar->addTodo(todo);
1363 mQuickAdd->setText(""); 1358 mQuickAdd->setText("");
1364 todoModified (todo, KOGlobals::EVENTADDED ); 1359 todoModified (todo, KOGlobals::EVENTADDED );
1365 updateView(); 1360 updateView();
1366} 1361}
1367 1362
1368void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1363void KOTodoView::keyPressEvent ( QKeyEvent * e )
1369{ 1364{
1370 // e->ignore(); 1365 // e->ignore();
1371 //return; 1366 //return;
1372 //qDebug("KOTodoView::keyPressEvent "); 1367 //qDebug("KOTodoView::keyPressEvent ");
1373 switch ( e->key() ) { 1368 switch ( e->key() ) {
1374 case Qt::Key_Down: 1369 case Qt::Key_Down:
1375 case Qt::Key_Up: 1370 case Qt::Key_Up:
1376 QWidget::keyPressEvent ( e ); 1371 QWidget::keyPressEvent ( e );
1377 break; 1372 break;
1378 1373
1379 case Qt::Key_Q: 1374 case Qt::Key_Q:
1380 toggleQuickTodo(); 1375 toggleQuickTodo();
1381 break; 1376 break;
1382 case Qt::Key_U: 1377 case Qt::Key_U:
1383 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1378 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1384 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1379 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1385 unparentTodo(); 1380 unparentTodo();
1386 e->accept(); 1381 e->accept();
1387 } else 1382 } else
1388 e->ignore(); 1383 e->ignore();
1389 break; 1384 break;
1390 case Qt::Key_S: 1385 case Qt::Key_S:
1391 if ( e->state() == Qt::ControlButton ) { 1386 if ( e->state() == Qt::ControlButton ) {
1392 e->ignore(); 1387 e->ignore();
1393 break; 1388 break;
1394 } 1389 }
1395 if ( e->state() == Qt::ShiftButton ) { 1390 if ( e->state() == Qt::ShiftButton ) {
1396 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1391 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1397 reparentTodo(); 1392 reparentTodo();
1398 e->accept(); 1393 e->accept();
1399 } else 1394 } else
1400 e->ignore(); 1395 e->ignore();
1401 break; 1396 break;
1402 case Qt::Key_P: 1397 case Qt::Key_P:
1403 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1398 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1404 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1399 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1405 if ( pendingSubtodo ) 1400 if ( pendingSubtodo )
1406 itemClicked(mActiveItem); 1401 itemClicked(mActiveItem);
1407 e->accept(); 1402 e->accept();
1408 } else 1403 } else
1409 e->ignore(); 1404 e->ignore();
1410 break; 1405 break;
1411 case Qt::Key_Escape: 1406 case Qt::Key_Escape:
1412 if ( pendingSubtodo ) { 1407 if ( pendingSubtodo ) {
1413 itemClicked(0); 1408 itemClicked(0);
1414 e->accept(); 1409 e->accept();
1415 } else 1410 } else
1416 e->ignore(); 1411 e->ignore();
1417 break; 1412 break;
1418 default: 1413 default:
1419 e->ignore(); 1414 e->ignore();
1420 } 1415 }
1421 1416
1422 if ( true ) { 1417 if ( true ) {
1423 if ( e->key() == Qt::Key_I ) { 1418 if ( e->key() == Qt::Key_I ) {
1424 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1419 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1425 if ( cn ) { 1420 if ( cn ) {
1426 mActiveItem = cn; 1421 mActiveItem = cn;
1427 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1422 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1428 if ( ci ){ 1423 if ( ci ){
1429 showTodo(); 1424 showTodo();
1430 cn = (KOTodoViewItem*)cn->itemBelow(); 1425 cn = (KOTodoViewItem*)cn->itemBelow();
1431 if ( cn ) { 1426 if ( cn ) {
1432 mTodoListView->setCurrentItem ( cn ); 1427 mTodoListView->setCurrentItem ( cn );
1433 mTodoListView->ensureItemVisible ( cn ); 1428 mTodoListView->ensureItemVisible ( cn );
1434 } 1429 }
1435 1430
1436 } 1431 }
1437 } 1432 }
1438 e->accept(); 1433 e->accept();
1439 1434
1440 } 1435 }
1441 1436
1442 } 1437 }
1443 1438
1444} 1439}
1445void KOTodoView::updateTodo( Todo * t, int type ) 1440void KOTodoView::updateTodo( Todo * t, int type )
1446{ 1441{
1447 if ( mBlockUpdate) 1442 if ( mBlockUpdate)
1448 return; 1443 return;
1449 1444
1450 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1445 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1451 itemIterator = mTodoMap.find(t); 1446 itemIterator = mTodoMap.find(t);
1452 if (itemIterator != mTodoMap.end()) { 1447 if (itemIterator != mTodoMap.end()) {
1453 (*itemIterator)->construct(); 1448 (*itemIterator)->construct();
1454 } else { 1449 } else {
1455 if ( type == KOGlobals::EVENTADDED ) { 1450 if ( type == KOGlobals::EVENTADDED ) {
1456 insertTodoItem( t ); 1451 insertTodoItem( t );
1457 } 1452 }
1458 } 1453 }
1459 1454
1460} 1455}
1461 1456
1462void KOTodoView::todoModified(Todo * t , int p ) 1457void KOTodoView::todoModified(Todo * t , int p )
1463{ 1458{
1464 mBlockUpdate = true; 1459 mBlockUpdate = true;
1465 emit todoModifiedSignal ( t, p ); 1460 emit todoModifiedSignal ( t, p );
1466 mBlockUpdate = false; 1461 mBlockUpdate = false;
1467} 1462}
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 748f3e4..f62aab8 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -1,525 +1,526 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <klocale.h> 20#include <klocale.h>
21#include <kdebug.h> 21#include <kdebug.h>
22#include <qapp.h> 22#include <qapp.h>
23#include <kglobal.h> 23#include <kglobal.h>
24 24
25#include <kiconloader.h> 25#include <kiconloader.h>
26#include "kotodoviewitem.h" 26#include "kotodoviewitem.h"
27#include "kotodoview.h" 27#include "kotodoview.h"
28#include "koprefs.h" 28#include "koprefs.h"
29 29
30KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) 30KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo)
31 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 31 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
32{ 32{
33 construct(); 33 construct();
34} 34}
35 35
36KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) 36KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo )
37 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 37 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
38{ 38{
39 construct(); 39 construct();
40} 40}
41 41
42QString KOTodoViewItem::key(int column,bool) const 42QString KOTodoViewItem::key(int column,bool) const
43{ 43{
44 QMap<int,QString>::ConstIterator it = mKeyMap.find(column); 44 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
45 if (it == mKeyMap.end()) { 45 if (it == mKeyMap.end()) {
46 return text(column).lower(); 46 return text(column).lower();
47 } else { 47 } else {
48 return *it; 48 return *it;
49 } 49 }
50} 50}
51 51
52void KOTodoViewItem:: setup() 52void KOTodoViewItem:: setup()
53{ 53{
54 54
55 int h = 20; 55 int h = 20;
56 if ( listView () ) { 56 if ( listView () ) {
57 QFontMetrics fm ( listView ()->font () ); 57 QFontMetrics fm ( listView ()->font () );
58 h = fm.height(); 58 h = fm.height();
59 } 59 }
60 setHeight( h ); 60 setHeight( h );
61 61
62} 62}
63void KOTodoViewItem::setSortKey(int column,const QString &key) 63void KOTodoViewItem::setSortKey(int column,const QString &key)
64{ 64{
65 mKeyMap.insert(column,key); 65 mKeyMap.insert(column,key);
66} 66}
67 67
68#if QT_VERSION >= 0x030000 68#if QT_VERSION >= 0x030000
69void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, 69void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w,
70 int y,int h) 70 int y,int h)
71{ 71{
72 QListViewItem::paintBranches(p,cg,w,y,h); 72 QListViewItem::paintBranches(p,cg,w,y,h);
73} 73}
74#else 74#else
75#endif 75#endif
76 76
77void KOTodoViewItem::construct() 77void KOTodoViewItem::construct()
78{ 78{
79 // qDebug("KOTodoViewItem::construct() "); 79 // qDebug("KOTodoViewItem::construct() ");
80 m_init = true; 80 m_init = true;
81 QString keyd = "=="; 81 QString keyd = "==";
82 QString keyt = "=="; 82 QString keyt = "==";
83 QString skeyd = "=="; 83 QString skeyd = "==";
84 QString skeyt = "=="; 84 QString skeyt = "==";
85 85
86 setOn(mTodo->isCompleted()); 86 setOn(mTodo->isCompleted());
87 setText(0,mTodo->summary()); 87 setText(0,mTodo->summary());
88 setText(1,QString::number(mTodo->priority())); 88 setText(1,QString::number(mTodo->priority()));
89 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 89 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
90 if (mTodo->percentComplete()<100) { 90 if (mTodo->percentComplete()<100) {
91 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 91 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
92 else setSortKey(2,QString::number(mTodo->percentComplete())); 92 else setSortKey(2,QString::number(mTodo->percentComplete()));
93 } 93 }
94 else { 94 else {
95 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 95 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
96 else setSortKey(2,QString::number(99)); 96 else setSortKey(2,QString::number(99));
97 } 97 }
98 if (mTodo->hasDueDate()) { 98 if (mTodo->hasDueDate()) {
99 setText(3, mTodo->dtDueDateStr()); 99 setText(3, mTodo->dtDueDateStr());
100 QDate d = mTodo->dtDue().date(); 100 QDate d = mTodo->dtDue().date();
101 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 101 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
102 // setSortKey(3,keyd); 102 // setSortKey(3,keyd);
103 if (mTodo->doesFloat()) { 103 if (mTodo->doesFloat()) {
104 setText(4,""); 104 setText(4,"");
105 } 105 }
106 else { 106 else {
107 setText(4,mTodo->dtDueTimeStr()); 107 setText(4,mTodo->dtDueTimeStr());
108 QTime t = mTodo->dtDue().time(); 108 QTime t = mTodo->dtDue().time();
109 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 109 keyt.sprintf("%02d%02d",t.hour(),t.minute());
110 //setSortKey(4,keyt); 110 //setSortKey(4,keyt);
111 } 111 }
112 } else { 112 } else {
113 setText(3,""); 113 setText(3,"");
114 setText(4,""); 114 setText(4,"");
115 } 115 }
116 setSortKey(3,keyd); 116 setSortKey(3,keyd);
117 setSortKey(4,keyt); 117 setSortKey(4,keyt);
118 118
119 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); 119 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
120 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 120 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
121 121
122 122
123 123
124 keyd = ""; 124 keyd = "";
125 keyt = ""; 125 keyt = "";
126 126
127 if (mTodo->isRunning() ) { 127 if (mTodo->isRunning() ) {
128 QDate d = mTodo->runStart().date(); 128 QDate d = mTodo->runStart().date();
129 QTime t = mTodo->runStart().time(); 129 QTime t = mTodo->runStart().time();
130 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 130 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
131 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 131 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
132 keyd = KGlobal::locale()->formatDate( d , true); 132 keyd = KGlobal::locale()->formatDate( d , true);
133 keyt = KGlobal::locale()->formatTime( t ); 133 keyt = KGlobal::locale()->formatTime( t );
134 134
135 } else { 135 } else {
136 136
137 if (mTodo->hasStartDate()) { 137 if (mTodo->hasStartDate()) {
138 keyd = mTodo->dtStartDateStr(); 138 keyd = mTodo->dtStartDateStr();
139 QDate d = mTodo->dtStart().date(); 139 QDate d = mTodo->dtStart().date();
140 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 140 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
141 141
142 if ( !mTodo->doesFloat()) { 142 if ( !mTodo->doesFloat()) {
143 keyt = mTodo->dtStartTimeStr(); 143 keyt = mTodo->dtStartTimeStr();
144 QTime t = mTodo->dtStart().time(); 144 QTime t = mTodo->dtStart().time();
145 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 145 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
146 146
147 } 147 }
148 148
149 } 149 }
150 } 150 }
151 setText(5,keyd); 151 setText(5,keyd);
152 setText(6,keyt); 152 setText(6,keyt);
153 setSortKey(5,skeyd); 153 setSortKey(5,skeyd);
154 setSortKey(6,skeyt); 154 setSortKey(6,skeyt);
155 155
156 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); 156 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
157 setText(8,mTodo->categoriesStr()); 157 setText(8,mTodo->categoriesStr());
158 setText(9,KOPrefs::instance()->calName( mTodo->calID()));
158 159
159#if 0 160#if 0
160 // Find sort id in description. It's the text behind the last '#' character 161 // Find sort id in description. It's the text behind the last '#' character
161 // found in the description. White spaces are removed from beginning and end 162 // found in the description. White spaces are removed from beginning and end
162 // of sort id. 163 // of sort id.
163 int pos = mTodo->description().findRev('#'); 164 int pos = mTodo->description().findRev('#');
164 if (pos < 0) { 165 if (pos < 0) {
165 setText(6,""); 166 setText(6,"");
166 } else { 167 } else {
167 QString str = mTodo->description().mid(pos+1); 168 QString str = mTodo->description().mid(pos+1);
168 str.stripWhiteSpace(); 169 str.stripWhiteSpace();
169 setText(6,str); 170 setText(6,str);
170 } 171 }
171#endif 172#endif
172 173
173 m_known = false; 174 m_known = false;
174 m_init = false; 175 m_init = false;
175 176
176 setMyPixmap(); 177 setMyPixmap();
177 178
178} 179}
179void KOTodoViewItem::setMyPixmap() 180void KOTodoViewItem::setMyPixmap()
180{ 181{
181 int size = 5; 182 int size = 5;
182 QPixmap pixi = QPixmap( 1, 1 ); 183 QPixmap pixi = QPixmap( 1, 1 );
183 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { 184 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
184// pixi = SmallIcon("redcross16"); 185// pixi = SmallIcon("redcross16");
185// } else { 186// } else {
186 QPainter p; 187 QPainter p;
187 188
188 int pixSize = 0; 189 int pixSize = 0;
189 QPixmap pPix = QPixmap( size, size ); 190 QPixmap pPix = QPixmap( size, size );
190 if ( mTodo->description().length() > 0 ) { 191 if ( mTodo->description().length() > 0 ) {
191 pixi.resize(size, pixSize+size); 192 pixi.resize(size, pixSize+size);
192 pPix.fill( Qt::darkGreen ); 193 pPix.fill( Qt::darkGreen );
193 p.begin( &pixi ); 194 p.begin( &pixi );
194 p. drawPixmap ( 0, pixSize, pPix); 195 p. drawPixmap ( 0, pixSize, pPix);
195 p.end(); 196 p.end();
196 pixSize += size; 197 pixSize += size;
197 } 198 }
198 if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { 199 if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) {
199 pixi.resize(size, pixSize+size); 200 pixi.resize(size, pixSize+size);
200 pPix.fill( Qt::red ); 201 pPix.fill( Qt::red );
201 p.begin( &pixi ); 202 p.begin( &pixi );
202 p. drawPixmap ( 0, pixSize, pPix); 203 p. drawPixmap ( 0, pixSize, pPix);
203 p.end(); 204 p.end();
204 pixSize += size; 205 pixSize += size;
205 } 206 }
206 if ( mTodo->doesRecur() ) { 207 if ( mTodo->doesRecur() ) {
207 pixi.resize(size, pixSize+size); 208 pixi.resize(size, pixSize+size);
208 pPix.fill( Qt::blue ); 209 pPix.fill( Qt::blue );
209 p.begin( &pixi ); 210 p.begin( &pixi );
210 p. drawPixmap ( 0, pixSize, pPix); 211 p. drawPixmap ( 0, pixSize, pPix);
211 p.end(); 212 p.end();
212 pixSize += size; 213 pixSize += size;
213 } 214 }
214 // } 215 // }
215 if ( pixi.width() > 1 ) { 216 if ( pixi.width() > 1 ) {
216 setPixmap ( 0,pixi ) ; 217 setPixmap ( 0,pixi ) ;
217 } else { 218 } else {
218 setPixmap ( 0,QPixmap() ) ; 219 setPixmap ( 0,QPixmap() ) ;
219 } 220 }
220} 221}
221void KOTodoViewItem::stateChange(bool state) 222void KOTodoViewItem::stateChange(bool state)
222{ 223{
223 // qDebug("KOTodoViewItem::stateChange %d ", state); 224 // qDebug("KOTodoViewItem::stateChange %d ", state);
224 // do not change setting on startup 225 // do not change setting on startup
225 if ( m_init ) return; 226 if ( m_init ) return;
226 if (isOn()!=state) { 227 if (isOn()!=state) {
227 setOn(state); 228 setOn(state);
228 //qDebug("SETON "); 229 //qDebug("SETON ");
229 return; 230 return;
230 } 231 }
231 if ( mTodo->isCompleted() == state ) { 232 if ( mTodo->isCompleted() == state ) {
232 //qDebug("STATECHANGE:nothing to do "); 233 //qDebug("STATECHANGE:nothing to do ");
233 return; 234 return;
234 } 235 }
235 QString keyd = "=="; 236 QString keyd = "==";
236 QString keyt = "=="; 237 QString keyt = "==";
237 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); 238 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1());
238 if ( mTodo->doesRecur() ){ 239 if ( mTodo->doesRecur() ){
239 QDateTime start = mTodo->dtStart(); 240 QDateTime start = mTodo->dtStart();
240 mTodo->setCompleted(state); 241 mTodo->setCompleted(state);
241 if ( start != mTodo->dtStart() ) { 242 if ( start != mTodo->dtStart() ) {
242 if ( state && !mTodo->isCompleted() ) { 243 if ( state && !mTodo->isCompleted() ) {
243 setOn( false ); 244 setOn( false );
244 state = false; 245 state = false;
245 } 246 }
246 } 247 }
247 } else 248 } else
248 mTodo->setCompleted(state); 249 mTodo->setCompleted(state);
249 250
250 if (state) mTodo->setCompleted(QDateTime::currentDateTime()); 251 if (state) mTodo->setCompleted(QDateTime::currentDateTime());
251 252
252 if (mTodo->hasDueDate()) { 253 if (mTodo->hasDueDate()) {
253 setText(3, mTodo->dtDueDateStr()); 254 setText(3, mTodo->dtDueDateStr());
254 QDate d = mTodo->dtDue().date(); 255 QDate d = mTodo->dtDue().date();
255 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 256 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
256 setSortKey(3,keyd); 257 setSortKey(3,keyd);
257 if (mTodo->doesFloat()) { 258 if (mTodo->doesFloat()) {
258 setText(4,""); 259 setText(4,"");
259 } 260 }
260 else { 261 else {
261 setText(4,mTodo->dtDueTimeStr()); 262 setText(4,mTodo->dtDueTimeStr());
262 QTime t = mTodo->dtDue().time(); 263 QTime t = mTodo->dtDue().time();
263 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 264 keyt.sprintf("%02d%02d",t.hour(),t.minute());
264 setSortKey(4,keyt); 265 setSortKey(4,keyt);
265 } 266 }
266 } 267 }
267 if (mTodo->hasStartDate()) { 268 if (mTodo->hasStartDate()) {
268 QString skeyt = "=="; 269 QString skeyt = "==";
269 QString skeyd = "=="; 270 QString skeyd = "==";
270 setText(5, mTodo->dtStartDateStr()); 271 setText(5, mTodo->dtStartDateStr());
271 QDate d = mTodo->dtStart().date(); 272 QDate d = mTodo->dtStart().date();
272 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 273 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
273 274
274 if (mTodo->doesFloat()) { 275 if (mTodo->doesFloat()) {
275 setText(6,""); 276 setText(6,"");
276 } 277 }
277 else { 278 else {
278 setText(6,mTodo->dtStartTimeStr()); 279 setText(6,mTodo->dtStartTimeStr());
279 QTime t = mTodo->dtStart().time(); 280 QTime t = mTodo->dtStart().time();
280 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 281 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
281 282
282 } 283 }
283 setSortKey(5,skeyd); 284 setSortKey(5,skeyd);
284 setSortKey(6,skeyt); 285 setSortKey(6,skeyt);
285 } 286 }
286 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); 287 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
287 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 288 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
288 289
289 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 290 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
290 if (mTodo->percentComplete()<100) { 291 if (mTodo->percentComplete()<100) {
291 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 292 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
292 else setSortKey(2,QString::number(mTodo->percentComplete())); 293 else setSortKey(2,QString::number(mTodo->percentComplete()));
293 } 294 }
294 else { 295 else {
295 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 296 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
296 else setSortKey(2,QString::number(99)); 297 else setSortKey(2,QString::number(99));
297 } 298 }
298 if ( state ) { 299 if ( state ) {
299 QListViewItem * myChild = firstChild(); 300 QListViewItem * myChild = firstChild();
300 KOTodoViewItem *item; 301 KOTodoViewItem *item;
301 while( myChild ) { 302 while( myChild ) {
302 //qDebug("stateCH "); 303 //qDebug("stateCH ");
303 item = static_cast<KOTodoViewItem*>(myChild); 304 item = static_cast<KOTodoViewItem*>(myChild);
304 item->stateChange(state); 305 item->stateChange(state);
305 myChild = myChild->nextSibling(); 306 myChild = myChild->nextSibling();
306 } 307 }
307 } else { 308 } else {
308 QListViewItem * myChild = parent(); 309 QListViewItem * myChild = parent();
309 if ( myChild ) 310 if ( myChild )
310 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); 311 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state);
311 } 312 }
312 mTodoView->modified(true); 313 mTodoView->modified(true);
313 setMyPixmap(); 314 setMyPixmap();
314 mTodoView->setTodoModified( mTodo ); 315 mTodoView->setTodoModified( mTodo );
315} 316}
316 317
317bool KOTodoViewItem::isAlternate() 318bool KOTodoViewItem::isAlternate()
318{ 319{
319 320
320 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 321 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
321 if (lv && lv->alternateBackground().isValid()) 322 if (lv && lv->alternateBackground().isValid())
322 { 323 {
323 KOTodoViewItem *above = 0; 324 KOTodoViewItem *above = 0;
324 above = static_cast<KOTodoViewItem *>(itemAbove()); 325 above = static_cast<KOTodoViewItem *>(itemAbove());
325 m_known = above ? above->m_known : true; 326 m_known = above ? above->m_known : true;
326 if (m_known) 327 if (m_known)
327 { 328 {
328 m_odd = above ? !above->m_odd : false; 329 m_odd = above ? !above->m_odd : false;
329 } 330 }
330 else 331 else
331 { 332 {
332 KOTodoViewItem *item; 333 KOTodoViewItem *item;
333 bool previous = true; 334 bool previous = true;
334 if (QListViewItem::parent()) 335 if (QListViewItem::parent())
335 { 336 {
336 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); 337 item = static_cast<KOTodoViewItem *>(QListViewItem::parent());
337 if (item) 338 if (item)
338 previous = item->m_odd; 339 previous = item->m_odd;
339 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); 340 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
340 } 341 }
341 else 342 else
342 { 343 {
343 item = static_cast<KOTodoViewItem *>(lv->firstChild()); 344 item = static_cast<KOTodoViewItem *>(lv->firstChild());
344 } 345 }
345 346
346 while(item) 347 while(item)
347 { 348 {
348 item->m_odd = previous = !previous; 349 item->m_odd = previous = !previous;
349 item->m_known = true; 350 item->m_known = true;
350 item = static_cast<KOTodoViewItem *>(item->nextSibling()); 351 item = static_cast<KOTodoViewItem *>(item->nextSibling());
351 } 352 }
352 } 353 }
353 return m_odd; 354 return m_odd;
354 } 355 }
355 return false; 356 return false;
356} 357}
357 358
358void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 359void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
359{ 360{
360 QColorGroup _cg = cg; 361 QColorGroup _cg = cg;
361 QColorGroup::ColorRole role; 362 QColorGroup::ColorRole role;
362 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) 363 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor )
363 role = QColorGroup::Text; 364 role = QColorGroup::Text;
364 else 365 else
365 role = QColorGroup::Base; 366 role = QColorGroup::Base;
366 //#ifndef KORG_NOLVALTERNATION 367 //#ifndef KORG_NOLVALTERNATION
367 if (isAlternate()) 368 if (isAlternate())
368 _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); 369 _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
369 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; 370 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
370 QColor colorToSet; 371 QColor colorToSet;
371 if ( column == 0 && mTodo->calID() > 1 ) { 372 if ( column == 0 && mTodo->calID() > 1 ) {
372 setColor = true; 373 setColor = true;
373 colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() ); 374 colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() );
374 } else if ( setColor ) { 375 } else if ( setColor ) {
375 QStringList categories = mTodo->categories(); 376 QStringList categories = mTodo->categories();
376 QString cat = categories.first(); 377 QString cat = categories.first();
377 if ( !cat.isEmpty()) { 378 if ( !cat.isEmpty()) {
378 colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); 379 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
379 } else 380 } else
380 setColor = false; 381 setColor = false;
381 } 382 }
382 bool openMode = !isOpen(); 383 bool openMode = !isOpen();
383 // maybe we are in flat-display-mode 384 // maybe we are in flat-display-mode
384 if ( !firstChild() ) 385 if ( !firstChild() )
385 openMode = false; 386 openMode = false;
386 bool colorRunning = mTodo->isRunning(); 387 bool colorRunning = mTodo->isRunning();
387 if ( ! colorRunning && openMode ) 388 if ( ! colorRunning && openMode )
388 colorRunning = mTodo->hasRunningSub(); 389 colorRunning = mTodo->hasRunningSub();
389 if ( colorRunning ) { 390 if ( colorRunning ) {
390 setColor = true; 391 setColor = true;
391 colorToSet = KOPrefs::instance()->mTodoRunColor; 392 colorToSet = KOPrefs::instance()->mTodoRunColor;
392 } else { 393 } else {
393 int odue = mTodo->hasDueSubTodo( openMode ); 394 int odue = mTodo->hasDueSubTodo( openMode );
394 if (odue == 2) { 395 if (odue == 2) {
395 colorToSet = KOPrefs::instance()->mTodoOverdueColor; 396 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
396 setColor = true; 397 setColor = true;
397 } else if ( odue == 1 ) { 398 } else if ( odue == 1 ) {
398 colorToSet = KOPrefs::instance()->mTodoDueTodayColor; 399 colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
399 setColor = true; 400 setColor = true;
400 } 401 }
401 } 402 }
402 403
403 404
404 if ( setColor ) { 405 if ( setColor ) {
405 _cg.setColor(role,colorToSet ); 406 _cg.setColor(role,colorToSet );
406 if ( role == QColorGroup::Base) { 407 if ( role == QColorGroup::Base) {
407 int rgb = colorToSet.red(); 408 int rgb = colorToSet.red();
408 rgb += colorToSet.blue()/2; 409 rgb += colorToSet.blue()/2;
409 rgb += colorToSet.green(); 410 rgb += colorToSet.green();
410 if ( rgb < 200 ) 411 if ( rgb < 200 )
411 _cg.setColor(QColorGroup::Text,Qt::white ); 412 _cg.setColor(QColorGroup::Text,Qt::white );
412 } 413 }
413 } 414 }
414 //#endif 415 //#endif
415 if ( column > 0 ){ 416 if ( column > 0 ){
416 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { 417 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) {
417 p->save(); 418 p->save();
418 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); 419 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5);
419 420
420 p->fillRect( 0, 0, width, height(), _cg.base() ); // background 421 p->fillRect( 0, 0, width, height(), _cg.base() ); // background
421 // p->setPen(Qt::black ); //border 422 // p->setPen(Qt::black ); //border
422 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling 423 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling
423 QColor fc = KOPrefs::instance()->mHighlightColor; 424 QColor fc = KOPrefs::instance()->mHighlightColor;
424 if ( mTodo->percentComplete() == 100 ) 425 if ( mTodo->percentComplete() == 100 )
425 fc = darkGreen; 426 fc = darkGreen;
426 p->drawRect( 2, 2, width-4, height()-4); 427 p->drawRect( 2, 2, width-4, height()-4);
427 p->fillRect( 3, 3, progress, height()-6, 428 p->fillRect( 3, 3, progress, height()-6,
428 fc ); 429 fc );
429 p->restore(); 430 p->restore();
430 } else { 431 } else {
431 QCheckListItem::paintCell(p, _cg, column, width, alignment); 432 QCheckListItem::paintCell(p, _cg, column, width, alignment);
432 } 433 }
433 return; 434 return;
434 } 435 }
435 436
436 int align = alignment; 437 int align = alignment;
437 438
438 if ( !p ) 439 if ( !p )
439 return; 440 return;
440 441
441 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); 442 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) );
442 443
443 QListView *lv = listView(); 444 QListView *lv = listView();
444 if ( !lv ) 445 if ( !lv )
445 return; 446 return;
446 int marg = 2;//lv->itemMargin(); 447 int marg = 2;//lv->itemMargin();
447 int r = 0; 448 int r = 0;
448 QCheckListItem::Type myType = QCheckListItem::CheckBox; 449 QCheckListItem::Type myType = QCheckListItem::CheckBox;
449 int BoxSize = 20; 450 int BoxSize = 20;
450 int boxOffset = 2; 451 int boxOffset = 2;
451 int xOffset = 2; 452 int xOffset = 2;
452 if (qApp->desktop()->width() < 300 ) { 453 if (qApp->desktop()->width() < 300 ) {
453 BoxSize = 14; 454 BoxSize = 14;
454 boxOffset = -1; 455 boxOffset = -1;
455 xOffset = 1; 456 xOffset = 1;
456 // marg = 0; 457 // marg = 0;
457 } 458 }
458 if ( height() < BoxSize ) { 459 if ( height() < BoxSize ) {
459 boxOffset = boxOffset - ((BoxSize - height())/2) ; 460 boxOffset = boxOffset - ((BoxSize - height())/2) ;
460 // qDebug("boxOffset %d height %d", boxOffset, height() ); 461 // qDebug("boxOffset %d height %d", boxOffset, height() );
461 BoxSize = height(); 462 BoxSize = height();
462 463
463 } 464 }
464 //bool winStyle = lv->style() == WindowsStyle; 465 //bool winStyle = lv->style() == WindowsStyle;
465 466
466 int lineStart = 5; 467 int lineStart = 5;
467 if ( myType == Controller ) { 468 if ( myType == Controller ) {
468 if ( !pixmap( 0 ) ) 469 if ( !pixmap( 0 ) )
469 r += BoxSize + 4; 470 r += BoxSize + 4;
470 } else { 471 } else {
471 ASSERT( lv ); //### 472 ASSERT( lv ); //###
472 //QFontMetrics fm( lv->font() ); 473 //QFontMetrics fm( lv->font() );
473 //int d = fm.height(); 474 //int d = fm.height();
474 int x = 0; 475 int x = 0;
475 int y = (height() - BoxSize) / 2; 476 int y = (height() - BoxSize) / 2;
476 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); 477 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) );
477 if ( myType == CheckBox ) { 478 if ( myType == CheckBox ) {
478 if ( isEnabled() ) 479 if ( isEnabled() )
479 p->setPen( QPen( _cg.text(), 1 ) ); 480 p->setPen( QPen( _cg.text(), 1 ) );
480 else 481 else
481 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); 482 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) );
482 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); 483 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 );
483 lineStart = x+marg; 484 lineStart = x+marg;
484 ///////////////////// 485 /////////////////////
485 x++; 486 x++;
486 y++; 487 y++;
487 if ( isOn() ) { 488 if ( isOn() ) {
488 QPointArray a( 7*2 ); 489 QPointArray a( 7*2 );
489 int i, xx, yy; 490 int i, xx, yy;
490 xx = x+xOffset+marg+(boxOffset/2); 491 xx = x+xOffset+marg+(boxOffset/2);
491 yy = y+5+boxOffset; 492 yy = y+5+boxOffset;
492 for ( i=0; i<3; i++ ) { 493 for ( i=0; i<3; i++ ) {
493 a.setPoint( 2*i, xx, yy ); 494 a.setPoint( 2*i, xx, yy );
494 a.setPoint( 2*i+1, xx, yy+2 ); 495 a.setPoint( 2*i+1, xx, yy+2 );
495 // qDebug(" "); 496 // qDebug(" ");
496 xx++; yy++; 497 xx++; yy++;
497 } 498 }
498 yy -= 2; 499 yy -= 2;
499 for ( i=3; i<7; i++ ) { 500 for ( i=3; i<7; i++ ) {
500 a.setPoint( 2*i, xx, yy ); 501 a.setPoint( 2*i, xx, yy );
501 a.setPoint( 2*i+1, xx, yy+2 ); 502 a.setPoint( 2*i+1, xx, yy+2 );
502 xx++; yy--; 503 xx++; yy--;
503 } 504 }
504 p->setPen( darkGreen ); 505 p->setPen( darkGreen );
505 p->drawLineSegments( a ); 506 p->drawLineSegments( a );
506 } 507 }
507 //////////////////////// 508 ////////////////////////
508 } 509 }
509 r += BoxSize + 4; 510 r += BoxSize + 4;
510 } 511 }
511 512
512 p->translate( r, 0 ); 513 p->translate( r, 0 );
513 p->setPen( QPen( _cg.text() ) ); 514 p->setPen( QPen( _cg.text() ) );
514 QListViewItem::paintCell( p, _cg, column, width - r, align ); 515 QListViewItem::paintCell( p, _cg, column, width - r, align );
515 if ( mTodo->cancelled () ) { 516 if ( mTodo->cancelled () ) {
516 p->setPen( black ); 517 p->setPen( black );
517 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); 518 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() );
518 int wid = br.width() +lineStart; 519 int wid = br.width() +lineStart;
519 if ( wid > width-3 ) 520 if ( wid > width-3 )
520 wid = width-3; 521 wid = width-3;
521 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); 522 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 );
522 523
523 } 524 }
524 525
525} 526}