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