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