summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp49
-rw-r--r--korganizer/kotodoview.h5
-rw-r--r--libkcal/todo.cpp2
-rw-r--r--libkcal/todo.h2
4 files changed, 45 insertions, 13 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index c5fae17..13e88ef 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,610 +1,635 @@
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#include <qdialog.h> 28#include <qdialog.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31 31
32#include <qinputdialog.h> 32#include <qinputdialog.h>
33 33
34#include <qvbox.h> 34#include <qvbox.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include "koprefs.h" 36#include "koprefs.h"
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kdateedit.h>
40#include "ktimeedit.h"
39#include <kiconloader.h> 41#include <kiconloader.h>
40#include <kmessagebox.h> 42#include <kmessagebox.h>
41 43
42#include <libkcal/icaldrag.h> 44#include <libkcal/icaldrag.h>
43#include <libkcal/vcaldrag.h> 45#include <libkcal/vcaldrag.h>
44#include <libkcal/calfilter.h> 46#include <libkcal/calfilter.h>
45#include <libkcal/dndfactory.h> 47#include <libkcal/dndfactory.h>
46#include <libkcal/calendarresources.h> 48#include <libkcal/calendarresources.h>
47#include <libkcal/resourcecalendar.h> 49#include <libkcal/resourcecalendar.h>
48#include <kresources/resourceselectdialog.h> 50#include <kresources/resourceselectdialog.h>
49#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
50#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
51#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
52#else 54#else
53#include <qapplication.h> 55#include <qapplication.h>
54#endif 56#endif
55#ifndef KORG_NOPRINTER 57#ifndef KORG_NOPRINTER
56#include "calprinter.h" 58#include "calprinter.h"
57#endif 59#endif
58#include "docprefs.h" 60#include "docprefs.h"
59 61
60#include "kotodoview.h" 62#include "kotodoview.h"
61using namespace KOrg; 63using namespace KOrg;
62 64
63 65
64KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : 66KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) :
65 QDialog( parent, name, true ) 67 QDialog( parent, name, true )
66{ 68{
67 mTodo = todo; 69 mTodo = todo;
68 setCaption( i18n("Stop todo") ); 70 setCaption( i18n("Stop todo") );
69 QVBoxLayout* lay = new QVBoxLayout( this ); 71 QVBoxLayout* lay = new QVBoxLayout( this );
70 lay->setSpacing( 3 ); 72 lay->setSpacing( 3 );
71 lay->setMargin( 3 ); 73 lay->setMargin( 3 );
72 QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this ); 74 QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this );
73 lay->addWidget( lab ); 75 lay->addWidget( lab );
74 lab->setAlignment( AlignHCenter ); 76 lab->setAlignment( AlignHCenter );
75 77 lab = new QLabel( i18n("Additional Comment:"), this );
78 lay->addWidget( lab );
79 mComment = new QLineEdit( this );
80 lay->addWidget( mComment );
81 QHBox * start = new QHBox ( this );
82 lay->addWidget( start );
83 lab = new QLabel( i18n("Start:"), start );
84 QHBox * end = new QHBox ( this );
85 lay->addWidget( end );
86 lab = new QLabel( i18n("End:"), end );
87 sde = new KDateEdit( start );
88 ste = new KOTimeEdit( start );
89 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) );
90 ede = new KDateEdit( end );
91 ete = new KOTimeEdit(end );
92 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) );
93 sde->setDate( mTodo->runStart().date() );
94 ste->setTime( mTodo->runStart().time() );
95 ede->setDate( QDate::currentDate());
96 ete->setTime( QTime::currentTime() );
76 QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); 97 QPushButton * ok = new QPushButton( i18n("Stop and save"), this );
77 lay->addWidget( ok ); 98 lay->addWidget( ok );
78 QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); 99 QPushButton * cancel = new QPushButton( i18n("Continue running"), this );
79 lay->addWidget( cancel ); 100 lay->addWidget( cancel );
80 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 101 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
81 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 102 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
82 ok = new QPushButton( i18n("Stop - do not save"), this ); 103 ok = new QPushButton( i18n("Stop - do not save"), this );
83 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); 104 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) );
84 lay->addWidget( ok ); 105 lay->addWidget( ok );
85 resize( 200, 200 ); 106 if (QApplication::desktop()->width() < 320 )
107 resize( 240, 200 );
108 else
109 resize( 320, 200 );
110
86} 111}
87 112
88void KOStopTodoPrefs::accept() 113void KOStopTodoPrefs::accept()
89{ 114{
90 qDebug("KOStopTodoPrefs::accept() "); 115 QDateTime start = QDateTime( sde->date(), ste->getTime() );
91 116 QDateTime stop = QDateTime( ede->date(), ete->getTime() );
92 117 if ( start > stop ) {
93#if 0 118 KMessageBox::sorry(this,
94 t->setRunningFalse( comment ); 119 i18n("The start time is\nafter the end time!"),
95 120 i18n("Time mismatch!"));
96 t->setRunning( false ); 121 return;
97#endif 122 }
98 123 mTodo->saveRunningInfo( mComment->text(), start, stop );
99 QDialog::accept(); 124 QDialog::accept();
100} 125}
101void KOStopTodoPrefs::doNotSave() 126void KOStopTodoPrefs::doNotSave()
102{ 127{
103 int result = KMessageBox::warningContinueCancel(this, 128 int result = KMessageBox::warningContinueCancel(this,
104 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() ); 129 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() );
105 if (result != KMessageBox::Continue) return; 130 if (result != KMessageBox::Continue) return;
106 mTodo->stopRunning(); 131 mTodo->stopRunning();
107 QDialog::accept(); 132 QDialog::accept();
108} 133}
109 134
110 135
111class KOTodoViewWhatsThis :public QWhatsThis 136class KOTodoViewWhatsThis :public QWhatsThis
112{ 137{
113public: 138public:
114 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 139 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
115 140
116protected: 141protected:
117 virtual QString text( const QPoint& p) 142 virtual QString text( const QPoint& p)
118 { 143 {
119 return _view->getWhatsThisText(p) ; 144 return _view->getWhatsThisText(p) ;
120 } 145 }
121private: 146private:
122 QWidget* _wid; 147 QWidget* _wid;
123 KOTodoView * _view; 148 KOTodoView * _view;
124}; 149};
125 150
126KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 151KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
127 const char *name) : 152 const char *name) :
128 KListView(parent,name) 153 KListView(parent,name)
129{ 154{
130 mName = QString ( name ); 155 mName = QString ( name );
131 mCalendar = calendar; 156 mCalendar = calendar;
132#ifndef DESKTOP_VERSION 157#ifndef DESKTOP_VERSION
133 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 158 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
134#endif 159#endif
135 mOldCurrent = 0; 160 mOldCurrent = 0;
136 mMousePressed = false; 161 mMousePressed = false;
137 162
138 setAcceptDrops(true); 163 setAcceptDrops(true);
139 viewport()->setAcceptDrops(true); 164 viewport()->setAcceptDrops(true);
140 int size = 16; 165 int size = 16;
141 if (qApp->desktop()->width() < 300 ) 166 if (qApp->desktop()->width() < 300 )
142 size = 12; 167 size = 12;
143 setTreeStepSize( size + 6 ); 168 setTreeStepSize( size + 6 );
144 169
145} 170}
146 171
147void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 172void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
148{ 173{
149#ifndef KORG_NODND 174#ifndef KORG_NODND
150// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 175// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
151 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 176 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
152 !QTextDrag::canDecode( e ) ) { 177 !QTextDrag::canDecode( e ) ) {
153 e->ignore(); 178 e->ignore();
154 return; 179 return;
155 } 180 }
156 181
157 mOldCurrent = currentItem(); 182 mOldCurrent = currentItem();
158#endif 183#endif
159} 184}
160 185
161 186
162void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 187void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
163{ 188{
164#ifndef KORG_NODND 189#ifndef KORG_NODND
165// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 190// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
166 191
167 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 192 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
168 !QTextDrag::canDecode( e ) ) { 193 !QTextDrag::canDecode( e ) ) {
169 e->ignore(); 194 e->ignore();
170 return; 195 return;
171 } 196 }
172 197
173 e->accept(); 198 e->accept();
174#endif 199#endif
175} 200}
176 201
177void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 202void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
178{ 203{
179#ifndef KORG_NODND 204#ifndef KORG_NODND
180// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 205// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
181 206
182 setCurrentItem(mOldCurrent); 207 setCurrentItem(mOldCurrent);
183 setSelected(mOldCurrent,true); 208 setSelected(mOldCurrent,true);
184#endif 209#endif
185} 210}
186 211
187void KOTodoListView::contentsDropEvent(QDropEvent *e) 212void KOTodoListView::contentsDropEvent(QDropEvent *e)
188{ 213{
189#ifndef KORG_NODND 214#ifndef KORG_NODND
190// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 215// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
191 216
192 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 217 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
193 !QTextDrag::canDecode( e ) ) { 218 !QTextDrag::canDecode( e ) ) {
194 e->ignore(); 219 e->ignore();
195 return; 220 return;
196 } 221 }
197 222
198 DndFactory factory( mCalendar ); 223 DndFactory factory( mCalendar );
199 Todo *todo = factory.createDropTodo(e); 224 Todo *todo = factory.createDropTodo(e);
200 225
201 if (todo) { 226 if (todo) {
202 e->acceptAction(); 227 e->acceptAction();
203 228
204 KOTodoViewItem *destination = 229 KOTodoViewItem *destination =
205 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 230 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
206 Todo *destinationEvent = 0; 231 Todo *destinationEvent = 0;
207 if (destination) destinationEvent = destination->todo(); 232 if (destination) destinationEvent = destination->todo();
208 233
209 Todo *existingTodo = mCalendar->todo(todo->uid()); 234 Todo *existingTodo = mCalendar->todo(todo->uid());
210 235
211 if(existingTodo) { 236 if(existingTodo) {
212 Incidence *to = destinationEvent; 237 Incidence *to = destinationEvent;
213 while(to) { 238 while(to) {
214 if (to->uid() == todo->uid()) { 239 if (to->uid() == todo->uid()) {
215 KMessageBox::sorry(this, 240 KMessageBox::sorry(this,
216 i18n("Cannot move Todo to itself\nor a child of itself"), 241 i18n("Cannot move Todo to itself\nor a child of itself"),
217 i18n("Drop Todo")); 242 i18n("Drop Todo"));
218 delete todo; 243 delete todo;
219 return; 244 return;
220 } 245 }
221 to = to->relatedTo(); 246 to = to->relatedTo();
222 } 247 }
223 internalDrop = true; 248 internalDrop = true;
224 if ( destinationEvent ) 249 if ( destinationEvent )
225 reparentTodoSignal( destinationEvent, existingTodo ); 250 reparentTodoSignal( destinationEvent, existingTodo );
226 else 251 else
227 unparentTodoSignal(existingTodo); 252 unparentTodoSignal(existingTodo);
228 delete todo; 253 delete todo;
229 } else { 254 } else {
230 mCalendar->addTodo(todo); 255 mCalendar->addTodo(todo);
231 emit todoDropped(todo, KOGlobals::EVENTADDED); 256 emit todoDropped(todo, KOGlobals::EVENTADDED);
232 if ( destinationEvent ) 257 if ( destinationEvent )
233 reparentTodoSignal( destinationEvent, todo ); 258 reparentTodoSignal( destinationEvent, todo );
234 } 259 }
235 } 260 }
236 else { 261 else {
237 QString text; 262 QString text;
238 if (QTextDrag::decode(e,text)) { 263 if (QTextDrag::decode(e,text)) {
239 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 264 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
240 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 265 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
241 qDebug("Dropped : " + text); 266 qDebug("Dropped : " + text);
242 QStringList emails = QStringList::split(",",text); 267 QStringList emails = QStringList::split(",",text);
243 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 268 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
244 int pos = (*it).find("<"); 269 int pos = (*it).find("<");
245 QString name = (*it).left(pos); 270 QString name = (*it).left(pos);
246 QString email = (*it).mid(pos); 271 QString email = (*it).mid(pos);
247 if (!email.isEmpty() && todoi) { 272 if (!email.isEmpty() && todoi) {
248 todoi->todo()->addAttendee(new Attendee(name,email)); 273 todoi->todo()->addAttendee(new Attendee(name,email));
249 } 274 }
250 } 275 }
251 } 276 }
252 else { 277 else {
253 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 278 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
254 e->ignore(); 279 e->ignore();
255 } 280 }
256 } 281 }
257#endif 282#endif
258} 283}
259void KOTodoListView::wheelEvent (QWheelEvent *e) 284void KOTodoListView::wheelEvent (QWheelEvent *e)
260{ 285{
261 QListView::wheelEvent (e); 286 QListView::wheelEvent (e);
262} 287}
263 288
264void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 289void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
265{ 290{
266 291
267 QPoint p(contentsToViewport(e->pos())); 292 QPoint p(contentsToViewport(e->pos()));
268 QListViewItem *i = itemAt(p); 293 QListViewItem *i = itemAt(p);
269 bool rootClicked = true; 294 bool rootClicked = true;
270 if (i) { 295 if (i) {
271 // if the user clicked into the root decoration of the item, don't 296 // if the user clicked into the root decoration of the item, don't
272 // try to start a drag! 297 // try to start a drag!
273 int X = p.x(); 298 int X = p.x();
274 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 299 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
275 if (X > header()->sectionPos(0) + 300 if (X > header()->sectionPos(0) +
276 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 301 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
277 itemMargin() +i->height()|| 302 itemMargin() +i->height()||
278 X < header()->sectionPos(0)) { 303 X < header()->sectionPos(0)) {
279 rootClicked = false; 304 rootClicked = false;
280 } 305 }
281 } else { 306 } else {
282 rootClicked = false; 307 rootClicked = false;
283 } 308 }
284#ifndef KORG_NODND 309#ifndef KORG_NODND
285 mMousePressed = false; 310 mMousePressed = false;
286 if (! rootClicked && !( e->button() == RightButton) ) { 311 if (! rootClicked && !( e->button() == RightButton) ) {
287 mPressPos = e->pos(); 312 mPressPos = e->pos();
288 mMousePressed = true; 313 mMousePressed = true;
289 } else { 314 } else {
290 mMousePressed = false; 315 mMousePressed = false;
291 } 316 }
292#endif 317#endif
293 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 318 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
294#ifndef DESKTOP_VERSION 319#ifndef DESKTOP_VERSION
295 if (!( e->button() == RightButton && rootClicked) ) 320 if (!( e->button() == RightButton && rootClicked) )
296 QListView::contentsMousePressEvent(e); 321 QListView::contentsMousePressEvent(e);
297#else 322#else
298 QListView::contentsMousePressEvent(e); 323 QListView::contentsMousePressEvent(e);
299#endif 324#endif
300} 325}
301void KOTodoListView::paintEvent(QPaintEvent* e) 326void KOTodoListView::paintEvent(QPaintEvent* e)
302{ 327{
303 emit paintNeeded(); 328 emit paintNeeded();
304 QListView::paintEvent( e); 329 QListView::paintEvent( e);
305} 330}
306void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 331void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
307{ 332{
308 333
309#ifndef KORG_NODND 334#ifndef KORG_NODND
310 //QListView::contentsMouseMoveEvent(e); 335 //QListView::contentsMouseMoveEvent(e);
311 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 336 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
312 QApplication::startDragDistance()*3) { 337 QApplication::startDragDistance()*3) {
313 mMousePressed = false; 338 mMousePressed = false;
314 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 339 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
315 if (item) { 340 if (item) {
316 DndFactory factory( mCalendar ); 341 DndFactory factory( mCalendar );
317 ICalDrag *vd = factory.createDrag( 342 ICalDrag *vd = factory.createDrag(
318 ((KOTodoViewItem *)item)->todo(),viewport()); 343 ((KOTodoViewItem *)item)->todo(),viewport());
319 internalDrop = false; 344 internalDrop = false;
320 // we cannot do any senseful here, because the DnD is still broken in Qt 345 // we cannot do any senseful here, because the DnD is still broken in Qt
321 if (vd->drag()) { 346 if (vd->drag()) {
322 if ( !internalDrop ) { 347 if ( !internalDrop ) {
323 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 348 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
324 qDebug("Dnd: External move: Delete drag source "); 349 qDebug("Dnd: External move: Delete drag source ");
325 } else 350 } else
326 qDebug("Dnd: Internal move "); 351 qDebug("Dnd: Internal move ");
327 352
328 } else { 353 } else {
329 if ( !internalDrop ) { 354 if ( !internalDrop ) {
330 qDebug("Dnd: External Copy"); 355 qDebug("Dnd: External Copy");
331 } else 356 } else
332 qDebug("DnD: Internal copy: Copy pending"); 357 qDebug("DnD: Internal copy: Copy pending");
333 } 358 }
334 } 359 }
335 } 360 }
336#endif 361#endif
337} 362}
338void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 363void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
339{ 364{
340 if ( !e->isAutoRepeat() ) { 365 if ( !e->isAutoRepeat() ) {
341 mFlagKeyPressed = false; 366 mFlagKeyPressed = false;
342 } 367 }
343} 368}
344 369
345 370
346void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 371void KOTodoListView::keyPressEvent ( QKeyEvent * e )
347{ 372{
348 qApp->processEvents(); 373 qApp->processEvents();
349 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 374 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
350 e->ignore(); 375 e->ignore();
351 // qDebug(" ignore %d",e->isAutoRepeat() ); 376 // qDebug(" ignore %d",e->isAutoRepeat() );
352 return; 377 return;
353 } 378 }
354 if (! e->isAutoRepeat() ) 379 if (! e->isAutoRepeat() )
355 mFlagKeyPressed = true; 380 mFlagKeyPressed = true;
356 QListViewItem* cn; 381 QListViewItem* cn;
357 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 382 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
358 cn = currentItem(); 383 cn = currentItem();
359 if ( cn ) { 384 if ( cn ) {
360 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 385 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
361 if ( ci ){ 386 if ( ci ){
362 if ( e->state() == ShiftButton ) 387 if ( e->state() == ShiftButton )
363 ci->setOn( false ); 388 ci->setOn( false );
364 else 389 else
365 ci->setOn( true ); 390 ci->setOn( true );
366 cn = cn->itemBelow(); 391 cn = cn->itemBelow();
367 if ( cn ) { 392 if ( cn ) {
368 setCurrentItem ( cn ); 393 setCurrentItem ( cn );
369 ensureItemVisible ( cn ); 394 ensureItemVisible ( cn );
370 } 395 }
371 396
372 } 397 }
373 } 398 }
374 399
375 return; 400 return;
376 } 401 }
377 402
378 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 403 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
379 switch ( e->key() ) { 404 switch ( e->key() ) {
380 case Qt::Key_Down: 405 case Qt::Key_Down:
381 case Qt::Key_Up: 406 case Qt::Key_Up:
382 QListView::keyPressEvent ( e ); 407 QListView::keyPressEvent ( e );
383 break; 408 break;
384 case Qt::Key_Left: 409 case Qt::Key_Left:
385 case Qt::Key_Right: 410 case Qt::Key_Right:
386 QListView::keyPressEvent ( e ); 411 QListView::keyPressEvent ( e );
387 e->accept(); 412 e->accept();
388 return; 413 return;
389 break; 414 break;
390 default: 415 default:
391 e->ignore(); 416 e->ignore();
392 break; 417 break;
393 } 418 }
394 return; 419 return;
395 } 420 }
396 e->ignore(); 421 e->ignore();
397} 422}
398void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 423void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
399{ 424{
400 QListView::contentsMouseReleaseEvent(e); 425 QListView::contentsMouseReleaseEvent(e);
401 mMousePressed = false; 426 mMousePressed = false;
402} 427}
403 428
404void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 429void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
405{ 430{
406 if (!e) return; 431 if (!e) return;
407 432
408 QPoint vp = contentsToViewport(e->pos()); 433 QPoint vp = contentsToViewport(e->pos());
409 434
410 QListViewItem *item = itemAt(vp); 435 QListViewItem *item = itemAt(vp);
411 436
412 emit double_Clicked(item); 437 emit double_Clicked(item);
413 if (!item) return; 438 if (!item) return;
414 439
415 emit doubleClicked(item,vp,0); 440 emit doubleClicked(item,vp,0);
416} 441}
417 442
418///////////////////////////////////////////////////////////////////////////// 443/////////////////////////////////////////////////////////////////////////////
419 444
420KOQuickTodo::KOQuickTodo(QWidget *parent) : 445KOQuickTodo::KOQuickTodo(QWidget *parent) :
421 QLineEdit(parent) 446 QLineEdit(parent)
422{ 447{
423 setText(i18n("Click to add a new Todo")); 448 setText(i18n("Click to add a new Todo"));
424} 449}
425 450
426void KOQuickTodo::focusInEvent(QFocusEvent *ev) 451void KOQuickTodo::focusInEvent(QFocusEvent *ev)
427{ 452{
428 if ( text()==i18n("Click to add a new Todo") ) 453 if ( text()==i18n("Click to add a new Todo") )
429 setText(""); 454 setText("");
430 QLineEdit::focusInEvent(ev); 455 QLineEdit::focusInEvent(ev);
431} 456}
432 457
433void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 458void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
434{ 459{
435 setText(i18n("Click to add a new Todo")); 460 setText(i18n("Click to add a new Todo"));
436 QLineEdit::focusOutEvent(ev); 461 QLineEdit::focusOutEvent(ev);
437} 462}
438 463
439///////////////////////////////////////////////////////////////////////////// 464/////////////////////////////////////////////////////////////////////////////
440 465
441KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 466KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
442 KOrg::BaseView(calendar,parent,name) 467 KOrg::BaseView(calendar,parent,name)
443{ 468{
444 mPendingUpdateBeforeRepaint = false; 469 mPendingUpdateBeforeRepaint = false;
445 isFlatDisplay = false; 470 isFlatDisplay = false;
446 mNavigator = 0; 471 mNavigator = 0;
447 QBoxLayout *topLayout = new QVBoxLayout(this); 472 QBoxLayout *topLayout = new QVBoxLayout(this);
448 mName = QString ( name ); 473 mName = QString ( name );
449 mBlockUpdate = false; 474 mBlockUpdate = false;
450 mQuickAdd = new KOQuickTodo(this); 475 mQuickAdd = new KOQuickTodo(this);
451 topLayout->addWidget(mQuickAdd); 476 topLayout->addWidget(mQuickAdd);
452 477
453 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 478 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
454 479
455 mTodoListView = new KOTodoListView(calendar,this, name ); 480 mTodoListView = new KOTodoListView(calendar,this, name );
456 topLayout->addWidget(mTodoListView); 481 topLayout->addWidget(mTodoListView);
457 //mTodoListView->header()->setMaximumHeight(30); 482 //mTodoListView->header()->setMaximumHeight(30);
458 mTodoListView->setRootIsDecorated(true); 483 mTodoListView->setRootIsDecorated(true);
459 mTodoListView->setAllColumnsShowFocus(true); 484 mTodoListView->setAllColumnsShowFocus(true);
460 485
461 mTodoListView->setShowSortIndicator(true); 486 mTodoListView->setShowSortIndicator(true);
462 487
463 mTodoListView->addColumn(i18n("Todo")); 488 mTodoListView->addColumn(i18n("Todo"));
464 mTodoListView->addColumn(i18n("Prio")); 489 mTodoListView->addColumn(i18n("Prio"));
465 mTodoListView->setColumnAlignment(1,AlignHCenter); 490 mTodoListView->setColumnAlignment(1,AlignHCenter);
466 mTodoListView->addColumn(i18n("Complete")); 491 mTodoListView->addColumn(i18n("Complete"));
467 mTodoListView->setColumnAlignment(2,AlignCenter); 492 mTodoListView->setColumnAlignment(2,AlignCenter);
468 493
469 mTodoListView->addColumn(i18n("Due Date")); 494 mTodoListView->addColumn(i18n("Due Date"));
470 mTodoListView->setColumnAlignment(3,AlignLeft); 495 mTodoListView->setColumnAlignment(3,AlignLeft);
471 mTodoListView->addColumn(i18n("Due Time")); 496 mTodoListView->addColumn(i18n("Due Time"));
472 mTodoListView->setColumnAlignment(4,AlignHCenter); 497 mTodoListView->setColumnAlignment(4,AlignHCenter);
473 498
474 mTodoListView->addColumn(i18n("Start Date")); 499 mTodoListView->addColumn(i18n("Start Date"));
475 mTodoListView->setColumnAlignment(5,AlignLeft); 500 mTodoListView->setColumnAlignment(5,AlignLeft);
476 mTodoListView->addColumn(i18n("Start Time")); 501 mTodoListView->addColumn(i18n("Start Time"));
477 mTodoListView->setColumnAlignment(6,AlignHCenter); 502 mTodoListView->setColumnAlignment(6,AlignHCenter);
478 503
479 mTodoListView->addColumn(i18n("Cancelled")); 504 mTodoListView->addColumn(i18n("Cancelled"));
480 mTodoListView->addColumn(i18n("Categories")); 505 mTodoListView->addColumn(i18n("Categories"));
481 mTodoListView->addColumn(i18n("Calendar")); 506 mTodoListView->addColumn(i18n("Calendar"));
482#if 0 507#if 0
483 mTodoListView->addColumn(i18n("Sort Id")); 508 mTodoListView->addColumn(i18n("Sort Id"));
484 mTodoListView->setColumnAlignment(4,AlignHCenter); 509 mTodoListView->setColumnAlignment(4,AlignHCenter);
485#endif 510#endif
486 511
487 mTodoListView->setMinimumHeight( 60 ); 512 mTodoListView->setMinimumHeight( 60 );
488 mTodoListView->setItemsRenameable( true ); 513 mTodoListView->setItemsRenameable( true );
489 mTodoListView->setRenameable( 0 ); 514 mTodoListView->setRenameable( 0 );
490 mTodoListView->setColumnWidth( 0, 120 ); 515 mTodoListView->setColumnWidth( 0, 120 );
491 int iii = 0; 516 int iii = 0;
492 for ( iii = 0; iii< 10 ; ++iii ) 517 for ( iii = 0; iii< 10 ; ++iii )
493 mTodoListView->setColumnWidthMode( iii, QListView::Manual ); 518 mTodoListView->setColumnWidthMode( iii, QListView::Manual );
494 519
495 520
496 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 521 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
497 522
498 mPriorityPopupMenu = new QPopupMenu(this); 523 mPriorityPopupMenu = new QPopupMenu(this);
499 for (int i = 1; i <= 5; i++) { 524 for (int i = 1; i <= 5; i++) {
500 QString label = QString ("%1").arg (i); 525 QString label = QString ("%1").arg (i);
501 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 526 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
502 } 527 }
503 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 528 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
504 529
505 mPercentageCompletedPopupMenu = new QPopupMenu(this); 530 mPercentageCompletedPopupMenu = new QPopupMenu(this);
506 for (int i = 0; i <= 100; i+=20) { 531 for (int i = 0; i <= 100; i+=20) {
507 QString label = QString ("%1 %").arg (i); 532 QString label = QString ("%1 %").arg (i);
508 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 533 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
509 } 534 }
510 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 535 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
511 536
512 537
513 538
514 mItemPopupMenu = new QPopupMenu(this); 539 mItemPopupMenu = new QPopupMenu(this);
515 mItemPopupMenu->insertItem(i18n("Show..."), this, 540 mItemPopupMenu->insertItem(i18n("Show..."), this,
516 SLOT (showTodo())); 541 SLOT (showTodo()));
517 mItemPopupMenu->insertItem(i18n("Edit..."), this, 542 mItemPopupMenu->insertItem(i18n("Edit..."), this,
518 SLOT (editTodo())); 543 SLOT (editTodo()));
519 mItemPopupMenu->insertItem( i18n("Delete"), this, 544 mItemPopupMenu->insertItem( i18n("Delete"), this,
520 SLOT (deleteTodo())); 545 SLOT (deleteTodo()));
521 mItemPopupMenu->insertItem( i18n("Clone..."), this, 546 mItemPopupMenu->insertItem( i18n("Clone..."), this,
522 SLOT (cloneTodo())); 547 SLOT (cloneTodo()));
523 mItemPopupMenu->insertItem( i18n("Move..."), this, 548 mItemPopupMenu->insertItem( i18n("Move..."), this,
524 SLOT (moveTodo())); 549 SLOT (moveTodo()));
525#ifndef DESKTOP_VERSION 550#ifndef DESKTOP_VERSION
526 mItemPopupMenu->insertItem( i18n("Beam..."), this, 551 mItemPopupMenu->insertItem( i18n("Beam..."), this,
527 SLOT (beamTodo())); 552 SLOT (beamTodo()));
528#endif 553#endif
529 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 554 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
530 SLOT (cancelTodo())); 555 SLOT (cancelTodo()));
531 mItemPopupMenu->insertSeparator(); 556 mItemPopupMenu->insertSeparator();
532 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 557 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
533 SLOT (toggleRunningItem())); 558 SLOT (toggleRunningItem()));
534 mItemPopupMenu->insertSeparator(); 559 mItemPopupMenu->insertSeparator();
535 /* 560 /*
536 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 561 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
537 SLOT (newTodo())); 562 SLOT (newTodo()));
538 */ 563 */
539 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 564 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
540 SLOT (newSubTodo())); 565 SLOT (newSubTodo()));
541 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 566 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
542 SLOT (unparentTodo()),0,21); 567 SLOT (unparentTodo()),0,21);
543 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 568 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
544 SLOT (reparentTodo()),0,22); 569 SLOT (reparentTodo()),0,22);
545 mItemPopupMenu->insertSeparator(); 570 mItemPopupMenu->insertSeparator();
546#if 0 571#if 0
547 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 572 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
548 this, SLOT( purgeCompleted() ) ); 573 this, SLOT( purgeCompleted() ) );
549 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 574 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
550 this, SLOT( toggleCompleted() ),0, 33 ); 575 this, SLOT( toggleCompleted() ),0, 33 );
551 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 576 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
552 this, SLOT( toggleQuickTodo() ),0, 34 ); 577 this, SLOT( toggleQuickTodo() ),0, 34 );
553 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 578 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
554 this, SLOT( toggleRunning() ),0, 35 ); 579 this, SLOT( toggleRunning() ),0, 35 );
555 580
556#endif 581#endif
557 mPopupMenu = new QPopupMenu(this); 582 mPopupMenu = new QPopupMenu(this);
558 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 583 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
559 SLOT (newTodo()),0,1); 584 SLOT (newTodo()),0,1);
560 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 585 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
561 this, SLOT(purgeCompleted()),0,2); 586 this, SLOT(purgeCompleted()),0,2);
562 mPopupMenu->insertItem(i18n("Show Completed"), 587 mPopupMenu->insertItem(i18n("Show Completed"),
563 this, SLOT( toggleCompleted() ),0,3 ); 588 this, SLOT( toggleCompleted() ),0,3 );
564 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 589 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
565 this, SLOT( toggleRunning() ),0,5 ); 590 this, SLOT( toggleRunning() ),0,5 );
566 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 591 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
567 this, SLOT( setAllOpen() ),0,6 ); 592 this, SLOT( setAllOpen() ),0,6 );
568 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 593 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
569 this, SLOT( setAllClose() ),0,7 ); 594 this, SLOT( setAllClose() ),0,7 );
570 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 595 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
571 this, SLOT( setAllFlat() ),0,8 ); 596 this, SLOT( setAllFlat() ),0,8 );
572 mPopupMenu->insertSeparator(); 597 mPopupMenu->insertSeparator();
573 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 598 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
574 this, SLOT( toggleQuickTodo() ),0,4 ); 599 this, SLOT( toggleQuickTodo() ),0,4 );
575 mDocPrefs = new DocPrefs( name ); 600 mDocPrefs = new DocPrefs( name );
576 601
577 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 602 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
578 mPopupMenu->setCheckable( true ); 603 mPopupMenu->setCheckable( true );
579 mItemPopupMenu->setCheckable( true ); 604 mItemPopupMenu->setCheckable( true );
580 605
581 606
582 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 607 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
583 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 608 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
584 609
585 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 610 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
586 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 611 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
587 612
588 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 613 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
589 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 614 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
590 615
591 616
592 // Double clicking conflicts with opening/closing the subtree 617 // Double clicking conflicts with opening/closing the subtree
593 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 618 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
594 SLOT( editItem( QListViewItem *) ) ); 619 SLOT( editItem( QListViewItem *) ) );
595 /* 620 /*
596 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 621 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
597 const QPoint &,int ) ), 622 const QPoint &,int ) ),
598 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 623 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
599 */ 624 */
600 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 625 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
601 const QPoint &,int ) ), 626 const QPoint &,int ) ),
602 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 627 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
603 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 628 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
604 SLOT( itemClicked( QListViewItem * ) ) ); 629 SLOT( itemClicked( QListViewItem * ) ) );
605 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 630 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
606 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 631 SLOT( itemDoubleClicked( QListViewItem * ) ) );
607 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 632 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
608 SLOT( updateView() ) ); 633 SLOT( updateView() ) );
609 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 634 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
610 SLOT( todoModified(Todo *, int) ) ); 635 SLOT( todoModified(Todo *, int) ) );
@@ -690,828 +715,828 @@ void KOTodoView::updateView()
690 if ( !isVisible() ) { 715 if ( !isVisible() ) {
691 mPendingUpdateBeforeRepaint = true; 716 mPendingUpdateBeforeRepaint = true;
692 return; 717 return;
693 } 718 }
694 storeCurrentItem(); 719 storeCurrentItem();
695 //qDebug("KOTodoView::updateView() %x", this); 720 //qDebug("KOTodoView::updateView() %x", this);
696 if ( isFlatDisplay ) { 721 if ( isFlatDisplay ) {
697 displayAllFlat(); 722 displayAllFlat();
698 resetCurrentItem(); 723 resetCurrentItem();
699 return; 724 return;
700 } 725 }
701 //qDebug("update "); 726 //qDebug("update ");
702// kdDebug() << "KOTodoView::updateView()" << endl; 727// kdDebug() << "KOTodoView::updateView()" << endl;
703 QFont fo = KOPrefs::instance()->mTodoViewFont; 728 QFont fo = KOPrefs::instance()->mTodoViewFont;
704 729
705 730
706 mTodoListView->clear(); 731 mTodoListView->clear();
707 if ( mName == "todolistsmall" ) { 732 if ( mName == "todolistsmall" ) {
708 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 733 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
709 int ps = fo.pointSize() -2; 734 int ps = fo.pointSize() -2;
710 if ( ps > 12 ) 735 if ( ps > 12 )
711 ps -= 2; 736 ps -= 2;
712 fo.setPointSize( ps ); 737 fo.setPointSize( ps );
713 } 738 }
714 } 739 }
715 740
716 mTodoListView->setFont( fo ); 741 mTodoListView->setFont( fo );
717 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 742 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
718 //mTodoListView->header()->setMaximumHeight(fm.height()); 743 //mTodoListView->header()->setMaximumHeight(fm.height());
719 QPtrList<Todo> todoList = calendar()->todos(); 744 QPtrList<Todo> todoList = calendar()->todos();
720 745
721/* 746/*
722 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 747 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
723 Event *t; 748 Event *t;
724 for(t = todoList.first(); t; t = todoList.next()) { 749 for(t = todoList.first(); t; t = todoList.next()) {
725 kdDebug() << " " << t->getSummary() << endl; 750 kdDebug() << " " << t->getSummary() << endl;
726 751
727 if (t->getRelatedTo()) { 752 if (t->getRelatedTo()) {
728 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 753 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
729 } 754 }
730 755
731 QPtrList<Event> l = t->getRelations(); 756 QPtrList<Event> l = t->getRelations();
732 Event *c; 757 Event *c;
733 for(c=l.first();c;c=l.next()) { 758 for(c=l.first();c;c=l.next()) {
734 kdDebug() << " - relation: " << c->getSummary() << endl; 759 kdDebug() << " - relation: " << c->getSummary() << endl;
735 } 760 }
736 } 761 }
737*/ 762*/
738 763
739 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 764 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
740 // specific order of events. That means that we have to generate parent items 765 // specific order of events. That means that we have to generate parent items
741 // recursively for proper hierarchical display of Todos. 766 // recursively for proper hierarchical display of Todos.
742 mTodoMap.clear(); 767 mTodoMap.clear();
743 Todo *todo; 768 Todo *todo;
744 todo = todoList.first();// todo; todo = todoList.next()) { 769 todo = todoList.first();// todo; todo = todoList.next()) {
745 while ( todo ) { 770 while ( todo ) {
746 bool next = true; 771 bool next = true;
747 // qDebug("todo %s ", todo->summary().latin1()); 772 // qDebug("todo %s ", todo->summary().latin1());
748 Incidence *incidence = todo->relatedTo(); 773 Incidence *incidence = todo->relatedTo();
749 while ( incidence ) { 774 while ( incidence ) {
750 if ( incidence->typeID() == todoID ) { 775 if ( incidence->typeID() == todoID ) {
751 //qDebug("related %s ",incidence->summary().latin1() ); 776 //qDebug("related %s ",incidence->summary().latin1() );
752 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { 777 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) {
753 //qDebug("related not found "); 778 //qDebug("related not found ");
754 todoList.remove( ); 779 todoList.remove( );
755 todo = todoList.current(); 780 todo = todoList.current();
756 next = false; 781 next = false;
757 incidence = 0; 782 incidence = 0;
758 783
759 } else { 784 } else {
760 //qDebug("related found "); 785 //qDebug("related found ");
761 incidence = incidence->relatedTo(); 786 incidence = incidence->relatedTo();
762 } 787 }
763 } else 788 } else
764 incidence = 0; 789 incidence = 0;
765 } 790 }
766 if ( next ) 791 if ( next )
767 todo = todoList.next(); 792 todo = todoList.next();
768 } 793 }
769 794
770 for(todo = todoList.first(); todo; todo = todoList.next()) { 795 for(todo = todoList.first(); todo; todo = todoList.next()) {
771 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 796 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
772 { 797 {
773 insertTodoItem(todo); 798 insertTodoItem(todo);
774 } 799 }
775 } 800 }
776 // Restore opened/closed state 801 // Restore opened/closed state
777 mTodoListView->blockSignals( true ); 802 mTodoListView->blockSignals( true );
778 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 803 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
779 mTodoListView->blockSignals( false ); 804 mTodoListView->blockSignals( false );
780 resetCurrentItem(); 805 resetCurrentItem();
781 processSelectionChange(); 806 processSelectionChange();
782} 807}
783 808
784void KOTodoView::storeCurrentItem() 809void KOTodoView::storeCurrentItem()
785{ 810{
786 mCurItem = 0; 811 mCurItem = 0;
787 mCurItemRootParent = 0; 812 mCurItemRootParent = 0;
788 mCurItemParent = 0; 813 mCurItemParent = 0;
789 mCurItemAbove = 0; 814 mCurItemAbove = 0;
790 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 815 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
791 if (mActiveItem) { 816 if (mActiveItem) {
792 mCurItem = mActiveItem->todo(); 817 mCurItem = mActiveItem->todo();
793 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 818 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
794 if ( activeItemAbove ) 819 if ( activeItemAbove )
795 mCurItemAbove = activeItemAbove->todo(); 820 mCurItemAbove = activeItemAbove->todo();
796 mCurItemRootParent = mCurItem; 821 mCurItemRootParent = mCurItem;
797 mCurItemParent = mCurItemRootParent->relatedTo(); 822 mCurItemParent = mCurItemRootParent->relatedTo();
798 while ( mCurItemRootParent->relatedTo() != 0 ) 823 while ( mCurItemRootParent->relatedTo() != 0 )
799 mCurItemRootParent = mCurItemRootParent->relatedTo(); 824 mCurItemRootParent = mCurItemRootParent->relatedTo();
800 } 825 }
801 mActiveItem = 0; 826 mActiveItem = 0;
802} 827}
803 828
804void KOTodoView::resetCurrentItem() 829void KOTodoView::resetCurrentItem()
805{ 830{
806 mTodoListView->setFocus(); 831 mTodoListView->setFocus();
807 KOTodoViewItem* foundItem = 0; 832 KOTodoViewItem* foundItem = 0;
808 KOTodoViewItem* foundItemRoot = 0; 833 KOTodoViewItem* foundItemRoot = 0;
809 KOTodoViewItem* foundItemParent = 0; 834 KOTodoViewItem* foundItemParent = 0;
810 KOTodoViewItem* foundItemAbove = 0; 835 KOTodoViewItem* foundItemAbove = 0;
811 if ( mTodoListView->firstChild () ) { 836 if ( mTodoListView->firstChild () ) {
812 if ( mCurItem ) { 837 if ( mCurItem ) {
813 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 838 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
814 while ( item ) { 839 while ( item ) {
815 if ( item->todo() == mCurItem ) { 840 if ( item->todo() == mCurItem ) {
816 foundItem = item; 841 foundItem = item;
817 break; 842 break;
818 } else if ( item->todo() == mCurItemAbove ) { 843 } else if ( item->todo() == mCurItemAbove ) {
819 foundItemAbove = item; 844 foundItemAbove = item;
820 845
821 } 846 }
822 if ( item->todo() == mCurItemRootParent ) { 847 if ( item->todo() == mCurItemRootParent ) {
823 foundItemRoot = item; 848 foundItemRoot = item;
824 } 849 }
825 if ( item->todo() == mCurItemParent ) { 850 if ( item->todo() == mCurItemParent ) {
826 foundItemParent = item; 851 foundItemParent = item;
827 } 852 }
828 item = (KOTodoViewItem*)item->itemBelow(); 853 item = (KOTodoViewItem*)item->itemBelow();
829 } 854 }
830 if ( ! foundItem ) { 855 if ( ! foundItem ) {
831 if ( foundItemParent ) { 856 if ( foundItemParent ) {
832 foundItem = foundItemParent; 857 foundItem = foundItemParent;
833 } else { 858 } else {
834 if ( foundItemRoot ) 859 if ( foundItemRoot )
835 foundItem = foundItemRoot; 860 foundItem = foundItemRoot;
836 else 861 else
837 foundItem = foundItemAbove; 862 foundItem = foundItemAbove;
838 } 863 }
839 } 864 }
840 } 865 }
841 if ( foundItem ) { 866 if ( foundItem ) {
842 mTodoListView->setCurrentItem( foundItem ); 867 mTodoListView->setCurrentItem( foundItem );
843 mTodoListView->ensureItemVisible( foundItem ); 868 mTodoListView->ensureItemVisible( foundItem );
844 } else { 869 } else {
845 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 870 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
846 } 871 }
847 } 872 }
848 mTodoListView->setFocus(); 873 mTodoListView->setFocus();
849} 874}
850//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 875//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
851bool KOTodoView::checkTodo( Todo * todo ) 876bool KOTodoView::checkTodo( Todo * todo )
852{ 877{
853 878
854 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 879 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
855 return false; 880 return false;
856 if ( !todo->isCompleted() ) { 881 if ( !todo->isCompleted() ) {
857 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 882 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
858 return true; 883 return true;
859 } 884 }
860 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 885 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
861 if ( todo->hasStartDate() ) 886 if ( todo->hasStartDate() )
862 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 887 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
863 return false; 888 return false;
864 if ( todo->hasDueDate() ) 889 if ( todo->hasDueDate() )
865 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 890 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
866 return false; 891 return false;
867 } 892 }
868 return true; 893 return true;
869} 894}
870 895
871void KOTodoView::restoreItemState( QListViewItem *item ) 896void KOTodoView::restoreItemState( QListViewItem *item )
872{ 897{
873 pendingSubtodo = 0; 898 pendingSubtodo = 0;
874 while( item ) { 899 while( item ) {
875 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 900 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
876 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 901 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
877 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 902 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
878 item = item->nextSibling(); 903 item = item->nextSibling();
879 } 904 }
880} 905}
881 906
882 907
883QMap<Todo *,KOTodoViewItem *>::ConstIterator 908QMap<Todo *,KOTodoViewItem *>::ConstIterator
884KOTodoView::insertTodoItem(Todo *todo) 909KOTodoView::insertTodoItem(Todo *todo)
885{ 910{
886 911
887 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 912 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
888 // TODO: Check, if dynmaic cast is necessary 913 // TODO: Check, if dynmaic cast is necessary
889 914
890 pendingSubtodo = 0; 915 pendingSubtodo = 0;
891 Incidence *incidence = todo->relatedTo(); 916 Incidence *incidence = todo->relatedTo();
892 while ( incidence && !incidence->calEnabled() ) 917 while ( incidence && !incidence->calEnabled() )
893 incidence = incidence->relatedTo(); 918 incidence = incidence->relatedTo();
894 if (incidence && incidence->typeID() == todoID ) { 919 if (incidence && incidence->typeID() == todoID ) {
895 Todo *relatedTodo = static_cast<Todo *>(incidence); 920 Todo *relatedTodo = static_cast<Todo *>(incidence);
896 921
897 // kdDebug() << " has Related" << endl; 922 // kdDebug() << " has Related" << endl;
898 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 923 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
899 itemIterator = mTodoMap.find(relatedTodo); 924 itemIterator = mTodoMap.find(relatedTodo);
900 if (itemIterator == mTodoMap.end()) { 925 if (itemIterator == mTodoMap.end()) {
901 // kdDebug() << " related not yet in list" << endl; 926 // kdDebug() << " related not yet in list" << endl;
902 itemIterator = insertTodoItem (relatedTodo); 927 itemIterator = insertTodoItem (relatedTodo);
903 } 928 }
904 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 929 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
905 // and one into the map. Sure finding is more easy but why? -zecke 930 // and one into the map. Sure finding is more easy but why? -zecke
906 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 931 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
907 return mTodoMap.insert(todo,todoItem); 932 return mTodoMap.insert(todo,todoItem);
908 } else { 933 } else {
909 // kdDebug() << " no Related" << endl; 934 // kdDebug() << " no Related" << endl;
910 // see above -zecke 935 // see above -zecke
911 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 936 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
912 return mTodoMap.insert(todo,todoItem); 937 return mTodoMap.insert(todo,todoItem);
913 } 938 }
914} 939}
915 940
916 941
917void KOTodoView::updateConfig() 942void KOTodoView::updateConfig()
918{ 943{
919 updateView(); 944 updateView();
920 mTodoListView->repaintContents(); 945 mTodoListView->repaintContents();
921} 946}
922 947
923QPtrList<Incidence> KOTodoView::selectedIncidences() 948QPtrList<Incidence> KOTodoView::selectedIncidences()
924{ 949{
925 QPtrList<Incidence> selected; 950 QPtrList<Incidence> selected;
926 951
927 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 952 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
928// if (!item) item = mActiveItem; 953// if (!item) item = mActiveItem;
929 if (item) selected.append(item->todo()); 954 if (item) selected.append(item->todo());
930 955
931 return selected; 956 return selected;
932} 957}
933 958
934QPtrList<Todo> KOTodoView::selectedTodos() 959QPtrList<Todo> KOTodoView::selectedTodos()
935{ 960{
936 QPtrList<Todo> selected; 961 QPtrList<Todo> selected;
937 962
938 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 963 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
939// if (!item) item = mActiveItem; 964// if (!item) item = mActiveItem;
940 if (item) selected.append(item->todo()); 965 if (item) selected.append(item->todo());
941 966
942 return selected; 967 return selected;
943} 968}
944 969
945void KOTodoView::changeEventDisplay(Event *, int) 970void KOTodoView::changeEventDisplay(Event *, int)
946{ 971{
947 updateView(); 972 updateView();
948} 973}
949 974
950void KOTodoView::showDates(const QDate &, const QDate &) 975void KOTodoView::showDates(const QDate &, const QDate &)
951{ 976{
952} 977}
953 978
954void KOTodoView::showEvents(QPtrList<Event>) 979void KOTodoView::showEvents(QPtrList<Event>)
955{ 980{
956 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 981 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
957} 982}
958 983
959void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 984void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
960 const QDate &td) 985 const QDate &td)
961{ 986{
962#ifndef KORG_NOPRINTER 987#ifndef KORG_NOPRINTER
963 calPrinter->preview(CalPrinter::Todolist, fd, td); 988 calPrinter->preview(CalPrinter::Todolist, fd, td);
964#endif 989#endif
965} 990}
966 991
967void KOTodoView::editItem(QListViewItem *item ) 992void KOTodoView::editItem(QListViewItem *item )
968{ 993{
969 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 994 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
970} 995}
971 996
972void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 997void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
973{ 998{
974 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 999 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
975} 1000}
976 1001
977void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 1002void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
978{ 1003{
979 pendingSubtodo = 0; 1004 pendingSubtodo = 0;
980 mActiveItem = (KOTodoViewItem *)item; 1005 mActiveItem = (KOTodoViewItem *)item;
981 if (item) { 1006 if (item) {
982 switch (column){ 1007 switch (column){
983 case 1: 1008 case 1:
984 mPriorityPopupMenu->popup(QCursor::pos ()); break; 1009 mPriorityPopupMenu->popup(QCursor::pos ()); break;
985 case 2: 1010 case 2:
986 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 1011 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
987 case 3: 1012 case 3:
988 moveTodo(); 1013 moveTodo();
989 break; 1014 break;
990 case 8: 1015 case 8:
991 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 1016 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
992 default: 1017 default:
993 mItemPopupMenu->popup(QCursor::pos()); 1018 mItemPopupMenu->popup(QCursor::pos());
994 } 1019 }
995 } else mPopupMenu->popup(QCursor::pos()); 1020 } else mPopupMenu->popup(QCursor::pos());
996} 1021}
997void KOTodoView::newTodo() 1022void KOTodoView::newTodo()
998{ 1023{
999 emit newTodoSignal(); 1024 emit newTodoSignal();
1000} 1025}
1001 1026
1002void KOTodoView::newSubTodo() 1027void KOTodoView::newSubTodo()
1003{ 1028{
1004 if (mActiveItem) { 1029 if (mActiveItem) {
1005 emit newSubTodoSignal(mActiveItem->todo()); 1030 emit newSubTodoSignal(mActiveItem->todo());
1006 } 1031 }
1007} 1032}
1008void KOTodoView::unparentTodo() 1033void KOTodoView::unparentTodo()
1009{ 1034{
1010 if (mActiveItem) { 1035 if (mActiveItem) {
1011 emit unparentTodoSignal(mActiveItem->todo()); 1036 emit unparentTodoSignal(mActiveItem->todo());
1012 } 1037 }
1013} 1038}
1014 1039
1015void KOTodoView::reparentTodo() 1040void KOTodoView::reparentTodo()
1016{ 1041{
1017 if (mActiveItem) { 1042 if (mActiveItem) {
1018 topLevelWidget()->setCaption(i18n("Click on new parent item")); 1043 topLevelWidget()->setCaption(i18n("Click on new parent item"));
1019 pendingSubtodo = mActiveItem; 1044 pendingSubtodo = mActiveItem;
1020 } 1045 }
1021} 1046}
1022void KOTodoView::editTodo() 1047void KOTodoView::editTodo()
1023{ 1048{
1024 if (mActiveItem) { 1049 if (mActiveItem) {
1025 emit editTodoSignal(mActiveItem->todo()); 1050 emit editTodoSignal(mActiveItem->todo());
1026 } 1051 }
1027} 1052}
1028void KOTodoView::cloneTodo() 1053void KOTodoView::cloneTodo()
1029{ 1054{
1030 if (mActiveItem) { 1055 if (mActiveItem) {
1031 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 1056 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
1032 } 1057 }
1033} 1058}
1034void KOTodoView::cancelTodo() 1059void KOTodoView::cancelTodo()
1035{ 1060{
1036 if (mActiveItem) { 1061 if (mActiveItem) {
1037 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 1062 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
1038 } 1063 }
1039} 1064}
1040void KOTodoView::moveTodo() 1065void KOTodoView::moveTodo()
1041{ 1066{
1042 if (mActiveItem) { 1067 if (mActiveItem) {
1043 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 1068 emit moveTodoSignal((Incidence*)mActiveItem->todo());
1044 } 1069 }
1045} 1070}
1046void KOTodoView::beamTodo() 1071void KOTodoView::beamTodo()
1047{ 1072{
1048 if (mActiveItem) { 1073 if (mActiveItem) {
1049 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 1074 emit beamTodoSignal((Incidence*)mActiveItem->todo());
1050 } 1075 }
1051} 1076}
1052 1077
1053 1078
1054void KOTodoView::showTodo() 1079void KOTodoView::showTodo()
1055{ 1080{
1056 if (mActiveItem) { 1081 if (mActiveItem) {
1057 emit showTodoSignal(mActiveItem->todo()); 1082 emit showTodoSignal(mActiveItem->todo());
1058 } 1083 }
1059} 1084}
1060 1085
1061void KOTodoView::deleteTodo() 1086void KOTodoView::deleteTodo()
1062{ 1087{
1063 if (mActiveItem) { 1088 if (mActiveItem) {
1064 emit deleteTodoSignal(mActiveItem->todo()); 1089 emit deleteTodoSignal(mActiveItem->todo());
1065 } 1090 }
1066} 1091}
1067 1092
1068void KOTodoView::setNewPriority(int index) 1093void KOTodoView::setNewPriority(int index)
1069{ 1094{
1070 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1095 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1071 mActiveItem->todo()->setPriority(mPriority[index]); 1096 mActiveItem->todo()->setPriority(mPriority[index]);
1072 mActiveItem->construct(); 1097 mActiveItem->construct();
1073 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1098 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1074 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1099 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1075 } 1100 }
1076} 1101}
1077 1102
1078void KOTodoView::setNewPercentage(int index) 1103void KOTodoView::setNewPercentage(int index)
1079{ 1104{
1080 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1105 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1081 1106
1082 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1107 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1083 mActiveItem->setOn( true ); 1108 mActiveItem->setOn( true );
1084 return; 1109 return;
1085 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1110 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1086 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1111 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1087 if ( par && par->isOn() ) 1112 if ( par && par->isOn() )
1088 par->setOn( false ); 1113 par->setOn( false );
1089 } 1114 }
1090 if (mPercentage[index] == 100) { 1115 if (mPercentage[index] == 100) {
1091 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1116 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1092 } else { 1117 } else {
1093 mActiveItem->todo()->setCompleted(false); 1118 mActiveItem->todo()->setCompleted(false);
1094 } 1119 }
1095 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1120 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1096 mActiveItem->construct(); 1121 mActiveItem->construct();
1097 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1122 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1098 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1123 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1099 } 1124 }
1100} 1125}
1101 1126
1102 1127
1103QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 1128QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
1104{ 1129{
1105 QPopupMenu* tempMenu = new QPopupMenu (this); 1130 QPopupMenu* tempMenu = new QPopupMenu (this);
1106 QStringList checkedCategories = todoItem->todo()->categories (); 1131 QStringList checkedCategories = todoItem->todo()->categories ();
1107 1132
1108 tempMenu->setCheckable (true); 1133 tempMenu->setCheckable (true);
1109 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1134 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1110 it != KOPrefs::instance()->mCustomCategories.end (); 1135 it != KOPrefs::instance()->mCustomCategories.end ();
1111 ++it) { 1136 ++it) {
1112 int index = tempMenu->insertItem (*it); 1137 int index = tempMenu->insertItem (*it);
1113 mCategory[index] = *it; 1138 mCategory[index] = *it;
1114 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 1139 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
1115 } 1140 }
1116 1141
1117 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 1142 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
1118 return tempMenu; 1143 return tempMenu;
1119 1144
1120 1145
1121} 1146}
1122void KOTodoView::changedCategories(int index) 1147void KOTodoView::changedCategories(int index)
1123{ 1148{
1124 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1149 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1125 QStringList categories = mActiveItem->todo()->categories (); 1150 QStringList categories = mActiveItem->todo()->categories ();
1126 QString colcat = categories.first(); 1151 QString colcat = categories.first();
1127 if (categories.find (mCategory[index]) != categories.end ()) 1152 if (categories.find (mCategory[index]) != categories.end ())
1128 categories.remove (mCategory[index]); 1153 categories.remove (mCategory[index]);
1129 else 1154 else
1130 categories.insert (categories.end(), mCategory[index]); 1155 categories.insert (categories.end(), mCategory[index]);
1131 categories.sort (); 1156 categories.sort ();
1132 if ( !colcat.isEmpty() ) { 1157 if ( !colcat.isEmpty() ) {
1133 if ( categories.find ( colcat ) != categories.end () ) { 1158 if ( categories.find ( colcat ) != categories.end () ) {
1134 categories.remove( colcat ); 1159 categories.remove( colcat );
1135 categories.prepend( colcat ); 1160 categories.prepend( colcat );
1136 } 1161 }
1137 } 1162 }
1138 mActiveItem->todo()->setCategories (categories); 1163 mActiveItem->todo()->setCategories (categories);
1139 mActiveItem->construct(); 1164 mActiveItem->construct();
1140 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1165 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1141 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1166 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1142 } 1167 }
1143} 1168}
1144void KOTodoView::itemDoubleClicked(QListViewItem *item) 1169void KOTodoView::itemDoubleClicked(QListViewItem *item)
1145{ 1170{
1146 if ( pendingSubtodo != 0 ) { 1171 if ( pendingSubtodo != 0 ) {
1147 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1172 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1148 } 1173 }
1149 pendingSubtodo = 0; 1174 pendingSubtodo = 0;
1150 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1175 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1151 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1176 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1152 //qDebug("ROW %d ", row); 1177 //qDebug("ROW %d ", row);
1153 if (!item) { 1178 if (!item) {
1154 newTodo(); 1179 newTodo();
1155 return; 1180 return;
1156 } else { 1181 } else {
1157 if ( row == 2 || row == 1 ) { 1182 if ( row == 2 || row == 1 ) {
1158 mActiveItem = (KOTodoViewItem *) item; 1183 mActiveItem = (KOTodoViewItem *) item;
1159 newSubTodo(); 1184 newSubTodo();
1160 return; 1185 return;
1161 } 1186 }
1162 if ( row == 5 || row == 6 ) { 1187 if ( row == 5 || row == 6 ) {
1163 mActiveItem = (KOTodoViewItem *) item; 1188 mActiveItem = (KOTodoViewItem *) item;
1164 toggleRunningItem(); 1189 toggleRunningItem();
1165 return; 1190 return;
1166 } 1191 }
1167 } 1192 }
1168 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1193 if ( KOPrefs::instance()->mEditOnDoubleClick )
1169 editItem( item ); 1194 editItem( item );
1170 else 1195 else
1171 showItem( item , QPoint(), 0 ); 1196 showItem( item , QPoint(), 0 );
1172} 1197}
1173void KOTodoView::toggleRunningItem() 1198void KOTodoView::toggleRunningItem()
1174{ 1199{
1175 // qDebug("KOTodoView::toggleRunning() "); 1200 // qDebug("KOTodoView::toggleRunning() ");
1176 if ( ! mActiveItem ) 1201 if ( ! mActiveItem )
1177 return; 1202 return;
1178 Todo * t = mActiveItem->todo(); 1203 Todo * t = mActiveItem->todo();
1179 if ( t->isRunning() ) { 1204 if ( t->isRunning() ) {
1180 1205
1181 1206
1182 KOStopTodoPrefs tp ( t, this ); 1207 KOStopTodoPrefs tp ( t, this );
1183 tp.exec(); 1208 tp.exec();
1184 1209
1185 1210
1186#if 0 1211#if 0
1187 int result = KMessageBox::warningYesNoCancel(this, 1212 int result = KMessageBox::warningYesNoCancel(this,
1188 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")); 1213 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"));
1189 if (result == KMessageBox::Cancel) return; 1214 if (result == KMessageBox::Cancel) return;
1190 if ( result == KMessageBox::No ) { 1215 if ( result == KMessageBox::No ) {
1191 QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") ); 1216 QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") );
1192 t->setRunningFalse( comment ); 1217 t->setRunningFalse( comment );
1193 } else { 1218 } else {
1194 t->setRunning( false ); 1219 t->setRunning( false );
1195 } 1220 }
1196 mActiveItem->construct(); 1221 mActiveItem->construct();
1197 1222
1198 1223
1199#endif 1224#endif
1200 } else { 1225 } else {
1201 int result = KMessageBox::warningContinueCancel(this, 1226 int result = KMessageBox::warningContinueCancel(this,
1202 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); 1227 i18n("<center>%1</center> <center>is not running. Do you want to set\nthe state to running?</center>").arg(mActiveItem->text(0).left( 25 ) ),i18n("Start todo"),i18n("Start todo"),i18n("Cancel"), true);
1203 if (result != KMessageBox::Continue) return; 1228 if (result != KMessageBox::Continue) return;
1204 t->setRunning( true ); 1229 t->setRunning( true );
1205 mActiveItem->construct(); 1230 mActiveItem->construct();
1206 } 1231 }
1207} 1232}
1208 1233
1209void KOTodoView::itemClicked(QListViewItem *item) 1234void KOTodoView::itemClicked(QListViewItem *item)
1210{ 1235{
1211 //qDebug("KOTodoView::itemClicked %d", item); 1236 //qDebug("KOTodoView::itemClicked %d", item);
1212 if (!item) { 1237 if (!item) {
1213 if ( pendingSubtodo != 0 ) { 1238 if ( pendingSubtodo != 0 ) {
1214 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1239 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1215 } 1240 }
1216 pendingSubtodo = 0; 1241 pendingSubtodo = 0;
1217 return; 1242 return;
1218 } 1243 }
1219 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1244 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1220 if ( pendingSubtodo != 0 ) { 1245 if ( pendingSubtodo != 0 ) {
1221 bool allowReparent = true; 1246 bool allowReparent = true;
1222 QListViewItem *par = item; 1247 QListViewItem *par = item;
1223 while ( par ) { 1248 while ( par ) {
1224 if ( par == pendingSubtodo ) { 1249 if ( par == pendingSubtodo ) {
1225 allowReparent = false; 1250 allowReparent = false;
1226 break; 1251 break;
1227 } 1252 }
1228 par = par->parent(); 1253 par = par->parent();
1229 } 1254 }
1230 if ( !allowReparent ) { 1255 if ( !allowReparent ) {
1231 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1256 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1232 pendingSubtodo = 0; 1257 pendingSubtodo = 0;
1233 } else { 1258 } else {
1234 Todo* newParent = todoItem->todo(); 1259 Todo* newParent = todoItem->todo();
1235 Todo* newSub = pendingSubtodo->todo(); 1260 Todo* newSub = pendingSubtodo->todo();
1236 pendingSubtodo = 0; 1261 pendingSubtodo = 0;
1237 emit reparentTodoSignal( newParent,newSub ); 1262 emit reparentTodoSignal( newParent,newSub );
1238 return; 1263 return;
1239 } 1264 }
1240 } 1265 }
1241 1266
1242} 1267}
1243 1268
1244void KOTodoView::setDocumentId( const QString &id ) 1269void KOTodoView::setDocumentId( const QString &id )
1245{ 1270{
1246 1271
1247 mDocPrefs->setDoc( id ); 1272 mDocPrefs->setDoc( id );
1248} 1273}
1249 1274
1250void KOTodoView::itemStateChanged( QListViewItem *item ) 1275void KOTodoView::itemStateChanged( QListViewItem *item )
1251{ 1276{
1252 if (!item) return; 1277 if (!item) return;
1253 1278
1254 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1279 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1255 1280
1256// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1281// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1257 1282
1258 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1283 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1259} 1284}
1260 1285
1261void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1286void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1262{ 1287{
1263 mTodoListView->saveLayout(config,group); 1288 mTodoListView->saveLayout(config,group);
1264} 1289}
1265 1290
1266void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1291void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1267{ 1292{
1268 mTodoListView->restoreLayout(config,group); 1293 mTodoListView->restoreLayout(config,group);
1269} 1294}
1270 1295
1271void KOTodoView::processSelectionChange() 1296void KOTodoView::processSelectionChange()
1272{ 1297{
1273// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1298// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1274 1299
1275 KOTodoViewItem *item = 1300 KOTodoViewItem *item =
1276 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1301 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1277 1302
1278 if ( !item ) { 1303 if ( !item ) {
1279 emit incidenceSelected( 0 ); 1304 emit incidenceSelected( 0 );
1280 } else { 1305 } else {
1281 emit incidenceSelected( item->todo() ); 1306 emit incidenceSelected( item->todo() );
1282 } 1307 }
1283} 1308}
1284 1309
1285void KOTodoView::modified(bool b) 1310void KOTodoView::modified(bool b)
1286{ 1311{
1287 emit isModified(b); 1312 emit isModified(b);
1288} 1313}
1289void KOTodoView::setTodoModified( Todo* todo ) 1314void KOTodoView::setTodoModified( Todo* todo )
1290{ 1315{
1291 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1316 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1292} 1317}
1293void KOTodoView::clearSelection() 1318void KOTodoView::clearSelection()
1294{ 1319{
1295 mTodoListView->selectAll( false ); 1320 mTodoListView->selectAll( false );
1296} 1321}
1297void KOTodoView::setAllOpen() 1322void KOTodoView::setAllOpen()
1298{ 1323{
1299 if ( isFlatDisplay ) { 1324 if ( isFlatDisplay ) {
1300 isFlatDisplay = false; 1325 isFlatDisplay = false;
1301 mPopupMenu->setItemChecked( 8,false ); 1326 mPopupMenu->setItemChecked( 8,false );
1302 updateView(); 1327 updateView();
1303 } else { 1328 } else {
1304 storeCurrentItem(); 1329 storeCurrentItem();
1305 } 1330 }
1306 setOpen(mTodoListView->firstChild(), true); 1331 setOpen(mTodoListView->firstChild(), true);
1307 resetCurrentItem(); 1332 resetCurrentItem();
1308} 1333}
1309void KOTodoView::setAllClose() 1334void KOTodoView::setAllClose()
1310{ 1335{
1311 if ( isFlatDisplay ) { 1336 if ( isFlatDisplay ) {
1312 isFlatDisplay = false; 1337 isFlatDisplay = false;
1313 mPopupMenu->setItemChecked( 8,false ); 1338 mPopupMenu->setItemChecked( 8,false );
1314 updateView(); 1339 updateView();
1315 } else { 1340 } else {
1316 storeCurrentItem(); 1341 storeCurrentItem();
1317 } 1342 }
1318 setOpen(mTodoListView->firstChild(), false); 1343 setOpen(mTodoListView->firstChild(), false);
1319 resetCurrentItem(); 1344 resetCurrentItem();
1320} 1345}
1321void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1346void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1322{ 1347{
1323 1348
1324 while ( item ) { 1349 while ( item ) {
1325 setOpen( item->firstChild(), setOpenI ); 1350 setOpen( item->firstChild(), setOpenI );
1326 item->setOpen( setOpenI ); 1351 item->setOpen( setOpenI );
1327 item = item->nextSibling(); 1352 item = item->nextSibling();
1328 } 1353 }
1329} 1354}
1330 1355
1331void KOTodoView::displayAllFlat() 1356void KOTodoView::displayAllFlat()
1332{ 1357{
1333 pendingSubtodo = 0; 1358 pendingSubtodo = 0;
1334 if ( mBlockUpdate ) { 1359 if ( mBlockUpdate ) {
1335 return; 1360 return;
1336 } 1361 }
1337 mPopupMenu->setItemChecked( 8,true ); 1362 mPopupMenu->setItemChecked( 8,true );
1338 isFlatDisplay = true; 1363 isFlatDisplay = true;
1339 QPtrList<Todo> todoList = calendar()->todos(); 1364 QPtrList<Todo> todoList = calendar()->todos();
1340 mTodoMap.clear(); 1365 mTodoMap.clear();
1341 mTodoListView->clear(); 1366 mTodoListView->clear();
1342 Todo *todo; 1367 Todo *todo;
1343 for(todo = todoList.first(); todo; todo = todoList.next()) { 1368 for(todo = todoList.first(); todo; todo = todoList.next()) {
1344 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1369 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1345 mTodoMap.insert(todo,todoItem); 1370 mTodoMap.insert(todo,todoItem);
1346 } 1371 }
1347 mTodoListView->setFocus(); 1372 mTodoListView->setFocus();
1348 processSelectionChange(); 1373 processSelectionChange();
1349} 1374}
1350 1375
1351void KOTodoView::setAllFlat() 1376void KOTodoView::setAllFlat()
1352{ 1377{
1353 if ( isFlatDisplay ) { 1378 if ( isFlatDisplay ) {
1354 isFlatDisplay = false; 1379 isFlatDisplay = false;
1355 mPopupMenu->setItemChecked( 8,false ); 1380 mPopupMenu->setItemChecked( 8,false );
1356 updateView(); 1381 updateView();
1357 return; 1382 return;
1358 } 1383 }
1359 storeCurrentItem(); 1384 storeCurrentItem();
1360 displayAllFlat(); 1385 displayAllFlat();
1361 resetCurrentItem(); 1386 resetCurrentItem();
1362} 1387}
1363 1388
1364void KOTodoView::purgeCompleted() 1389void KOTodoView::purgeCompleted()
1365{ 1390{
1366 emit purgeCompletedSignal(); 1391 emit purgeCompletedSignal();
1367 1392
1368} 1393}
1369void KOTodoView::toggleQuickTodo() 1394void KOTodoView::toggleQuickTodo()
1370{ 1395{
1371 if ( mQuickAdd->isVisible() ) { 1396 if ( mQuickAdd->isVisible() ) {
1372 mQuickAdd->hide(); 1397 mQuickAdd->hide();
1373 KOPrefs::instance()->mEnableQuickTodo = false; 1398 KOPrefs::instance()->mEnableQuickTodo = false;
1374 } 1399 }
1375 else { 1400 else {
1376 mQuickAdd->show(); 1401 mQuickAdd->show();
1377 KOPrefs::instance()->mEnableQuickTodo = true; 1402 KOPrefs::instance()->mEnableQuickTodo = true;
1378 } 1403 }
1379 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1404 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1380 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1405 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1381} 1406}
1382 1407
1383void KOTodoView::toggleRunning() 1408void KOTodoView::toggleRunning()
1384{ 1409{
1385 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1410 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1386 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1411 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1387 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1412 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1388 updateView(); 1413 updateView();
1389} 1414}
1390 1415
1391void KOTodoView::toggleCompleted() 1416void KOTodoView::toggleCompleted()
1392{ 1417{
1393 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1418 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1394 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1419 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1395 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1420 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1396 updateView(); 1421 updateView();
1397} 1422}
1398 1423
1399void KOTodoView::addQuickTodo() 1424void KOTodoView::addQuickTodo()
1400{ 1425{
1401 Todo *todo = new Todo(); 1426 Todo *todo = new Todo();
1402 todo->setSummary(mQuickAdd->text()); 1427 todo->setSummary(mQuickAdd->text());
1403 todo->setOrganizer(KOPrefs::instance()->email()); 1428 todo->setOrganizer(KOPrefs::instance()->email());
1404 CalFilter * cf = mCalendar->filter(); 1429 CalFilter * cf = mCalendar->filter();
1405 if ( cf ) { 1430 if ( cf ) {
1406 if ( cf->isEnabled()&& cf->showCategories()) { 1431 if ( cf->isEnabled()&& cf->showCategories()) {
1407 todo->setCategories(cf->categoryList()); 1432 todo->setCategories(cf->categoryList());
1408 } 1433 }
1409 if ( cf->isEnabled() ) 1434 if ( cf->isEnabled() )
1410 todo->setSecrecy( cf->getSecrecy()); 1435 todo->setSecrecy( cf->getSecrecy());
1411 } 1436 }
1412 mCalendar->addTodo(todo); 1437 mCalendar->addTodo(todo);
1413 mQuickAdd->setText(""); 1438 mQuickAdd->setText("");
1414 todoModified (todo, KOGlobals::EVENTADDED ); 1439 todoModified (todo, KOGlobals::EVENTADDED );
1415 updateView(); 1440 updateView();
1416} 1441}
1417 1442
1418void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1443void KOTodoView::keyPressEvent ( QKeyEvent * e )
1419{ 1444{
1420 // e->ignore(); 1445 // e->ignore();
1421 //return; 1446 //return;
1422 //qDebug("KOTodoView::keyPressEvent "); 1447 //qDebug("KOTodoView::keyPressEvent ");
1423 switch ( e->key() ) { 1448 switch ( e->key() ) {
1424 case Qt::Key_Down: 1449 case Qt::Key_Down:
1425 case Qt::Key_Up: 1450 case Qt::Key_Up:
1426 QWidget::keyPressEvent ( e ); 1451 QWidget::keyPressEvent ( e );
1427 break; 1452 break;
1428 1453
1429 case Qt::Key_Q: 1454 case Qt::Key_Q:
1430 toggleQuickTodo(); 1455 toggleQuickTodo();
1431 break; 1456 break;
1432 case Qt::Key_U: 1457 case Qt::Key_U:
1433 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1458 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1434 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1459 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1435 unparentTodo(); 1460 unparentTodo();
1436 e->accept(); 1461 e->accept();
1437 } else 1462 } else
1438 e->ignore(); 1463 e->ignore();
1439 break; 1464 break;
1440 case Qt::Key_S: 1465 case Qt::Key_S:
1441 if ( e->state() == Qt::ControlButton ) { 1466 if ( e->state() == Qt::ControlButton ) {
1442 e->ignore(); 1467 e->ignore();
1443 break; 1468 break;
1444 } 1469 }
1445 if ( e->state() == Qt::ShiftButton ) { 1470 if ( e->state() == Qt::ShiftButton ) {
1446 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1471 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1447 reparentTodo(); 1472 reparentTodo();
1448 e->accept(); 1473 e->accept();
1449 } else 1474 } else
1450 e->ignore(); 1475 e->ignore();
1451 break; 1476 break;
1452 case Qt::Key_P: 1477 case Qt::Key_P:
1453 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1478 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1454 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1479 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1455 if ( pendingSubtodo ) 1480 if ( pendingSubtodo )
1456 itemClicked(mActiveItem); 1481 itemClicked(mActiveItem);
1457 e->accept(); 1482 e->accept();
1458 } else 1483 } else
1459 e->ignore(); 1484 e->ignore();
1460 break; 1485 break;
1461 case Qt::Key_Escape: 1486 case Qt::Key_Escape:
1462 if ( pendingSubtodo ) { 1487 if ( pendingSubtodo ) {
1463 itemClicked(0); 1488 itemClicked(0);
1464 e->accept(); 1489 e->accept();
1465 } else 1490 } else
1466 e->ignore(); 1491 e->ignore();
1467 break; 1492 break;
1468 default: 1493 default:
1469 e->ignore(); 1494 e->ignore();
1470 } 1495 }
1471 1496
1472 if ( true ) { 1497 if ( true ) {
1473 if ( e->key() == Qt::Key_I ) { 1498 if ( e->key() == Qt::Key_I ) {
1474 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1499 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1475 if ( cn ) { 1500 if ( cn ) {
1476 mActiveItem = cn; 1501 mActiveItem = cn;
1477 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1502 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1478 if ( ci ){ 1503 if ( ci ){
1479 showTodo(); 1504 showTodo();
1480 cn = (KOTodoViewItem*)cn->itemBelow(); 1505 cn = (KOTodoViewItem*)cn->itemBelow();
1481 if ( cn ) { 1506 if ( cn ) {
1482 mTodoListView->setCurrentItem ( cn ); 1507 mTodoListView->setCurrentItem ( cn );
1483 mTodoListView->ensureItemVisible ( cn ); 1508 mTodoListView->ensureItemVisible ( cn );
1484 } 1509 }
1485 1510
1486 } 1511 }
1487 } 1512 }
1488 e->accept(); 1513 e->accept();
1489 1514
1490 } 1515 }
1491 1516
1492 } 1517 }
1493 1518
1494} 1519}
1495void KOTodoView::updateTodo( Todo * t, int type ) 1520void KOTodoView::updateTodo( Todo * t, int type )
1496{ 1521{
1497 if ( mBlockUpdate) 1522 if ( mBlockUpdate)
1498 return; 1523 return;
1499 1524
1500 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1525 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1501 itemIterator = mTodoMap.find(t); 1526 itemIterator = mTodoMap.find(t);
1502 if (itemIterator != mTodoMap.end()) { 1527 if (itemIterator != mTodoMap.end()) {
1503 (*itemIterator)->construct(); 1528 (*itemIterator)->construct();
1504 } else { 1529 } else {
1505 if ( type == KOGlobals::EVENTADDED ) { 1530 if ( type == KOGlobals::EVENTADDED ) {
1506 insertTodoItem( t ); 1531 insertTodoItem( t );
1507 } 1532 }
1508 } 1533 }
1509 1534
1510} 1535}
1511 1536
1512void KOTodoView::todoModified(Todo * t , int p ) 1537void KOTodoView::todoModified(Todo * t , int p )
1513{ 1538{
1514 mBlockUpdate = true; 1539 mBlockUpdate = true;
1515 emit todoModifiedSignal ( t, p ); 1540 emit todoModifiedSignal ( t, p );
1516 mBlockUpdate = false; 1541 mBlockUpdate = false;
1517} 1542}
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index ceabdba..8f0c99e 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -1,283 +1,288 @@
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#ifndef KOTODOVIEW_H 23#ifndef KOTODOVIEW_H
24#define KOTODOVIEW_H 24#define KOTODOVIEW_H
25 25
26#include <qfont.h> 26#include <qfont.h>
27#include <qfontmetrics.h> 27#include <qfontmetrics.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30#include <qstrlist.h> 30#include <qstrlist.h>
31#include <qlistbox.h> 31#include <qlistbox.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qdialog.h> 35#include <qdialog.h>
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qlistview.h> 37#include <qlistview.h>
38#include <klistview.h> 38#include <klistview.h>
39 39
40#include <libkcal/calendar.h> 40#include <libkcal/calendar.h>
41#include <libkcal/todo.h> 41#include <libkcal/todo.h>
42 42
43#include <korganizer/baseview.h> 43#include <korganizer/baseview.h>
44 44
45#include "kotodoviewitem.h" 45#include "kotodoviewitem.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "koglobals.h" 47#include "koglobals.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49 49
50class QDragEnterEvent; 50class QDragEnterEvent;
51class QDragMoveEvent; 51class QDragMoveEvent;
52class QDragLeaveEvent; 52class QDragLeaveEvent;
53class QDropEvent; 53class QDropEvent;
54class KOTodoViewWhatsThis; 54class KOTodoViewWhatsThis;
55class KDateEdit;
56class KOTimeEdit;
55 57
56class DocPrefs; 58class DocPrefs;
57 59
58 60
59class KOStopTodoPrefs : public QDialog 61class KOStopTodoPrefs : public QDialog
60{ 62{
61 Q_OBJECT 63 Q_OBJECT
62 public: 64 public:
63 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ; 65 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ;
64 66
65 67
66private slots: 68private slots:
67 void doNotSave(); 69 void doNotSave();
68 void accept(); 70 void accept();
69private: 71private:
70 Todo* mTodo; 72 Todo* mTodo;
73 QLineEdit* mComment;
74 KDateEdit *sde, *ede;
75 KOTimeEdit *ste, *ete;
71 76
72}; 77};
73 78
74class KOTodoListView : public KListView 79class KOTodoListView : public KListView
75{ 80{
76 Q_OBJECT 81 Q_OBJECT
77 public: 82 public:
78 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); 83 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
79 virtual ~KOTodoListView() {} 84 virtual ~KOTodoListView() {}
80 85
81 signals: 86 signals:
82 void paintNeeded(); 87 void paintNeeded();
83 void todoDropped(Todo *, int); 88 void todoDropped(Todo *, int);
84 void double_Clicked(QListViewItem *item); 89 void double_Clicked(QListViewItem *item);
85 void reparentTodoSignal( Todo *,Todo * ); 90 void reparentTodoSignal( Todo *,Todo * );
86 void unparentTodoSignal(Todo *); 91 void unparentTodoSignal(Todo *);
87 void deleteTodo( Todo * ); 92 void deleteTodo( Todo * );
88 protected: 93 protected:
89 void wheelEvent (QWheelEvent *e); 94 void wheelEvent (QWheelEvent *e);
90 void contentsDragEnterEvent(QDragEnterEvent *); 95 void contentsDragEnterEvent(QDragEnterEvent *);
91 void contentsDragMoveEvent(QDragMoveEvent *); 96 void contentsDragMoveEvent(QDragMoveEvent *);
92 void contentsDragLeaveEvent(QDragLeaveEvent *); 97 void contentsDragLeaveEvent(QDragLeaveEvent *);
93 void contentsDropEvent(QDropEvent *); 98 void contentsDropEvent(QDropEvent *);
94 99
95 void contentsMousePressEvent(QMouseEvent *); 100 void contentsMousePressEvent(QMouseEvent *);
96 void contentsMouseMoveEvent(QMouseEvent *); 101 void contentsMouseMoveEvent(QMouseEvent *);
97 void contentsMouseReleaseEvent(QMouseEvent *); 102 void contentsMouseReleaseEvent(QMouseEvent *);
98 void contentsMouseDoubleClickEvent(QMouseEvent *); 103 void contentsMouseDoubleClickEvent(QMouseEvent *);
99 104
100 private: 105 private:
101 void paintEvent(QPaintEvent * pevent); 106 void paintEvent(QPaintEvent * pevent);
102 bool internalDrop; 107 bool internalDrop;
103 QString mName; 108 QString mName;
104 Calendar *mCalendar; 109 Calendar *mCalendar;
105 QPoint mPressPos; 110 QPoint mPressPos;
106 bool mMousePressed; 111 bool mMousePressed;
107 QListViewItem *mOldCurrent; 112 QListViewItem *mOldCurrent;
108 bool mFlagKeyPressed; 113 bool mFlagKeyPressed;
109 void keyPressEvent ( QKeyEvent * ) ; 114 void keyPressEvent ( QKeyEvent * ) ;
110 void keyReleaseEvent ( QKeyEvent * ) ; 115 void keyReleaseEvent ( QKeyEvent * ) ;
111}; 116};
112 117
113 118
114/** 119/**
115 This is the line-edit on top of the todoview for fast addition of new todos 120 This is the line-edit on top of the todoview for fast addition of new todos
116*/ 121*/
117class KOQuickTodo : public QLineEdit 122class KOQuickTodo : public QLineEdit
118{ 123{
119 public: 124 public:
120 KOQuickTodo(QWidget *parent=0); 125 KOQuickTodo(QWidget *parent=0);
121 protected: 126 protected:
122 void focusInEvent(QFocusEvent *ev); 127 void focusInEvent(QFocusEvent *ev);
123 void focusOutEvent(QFocusEvent *ev); 128 void focusOutEvent(QFocusEvent *ev);
124}; 129};
125 130
126 131
127/** 132/**
128 This class provides a multi-column list view of todo events. 133 This class provides a multi-column list view of todo events.
129 134
130 @short multi-column list view of todo events. 135 @short multi-column list view of todo events.
131 @author Cornelius Schumacher <schumacher@kde.org> 136 @author Cornelius Schumacher <schumacher@kde.org>
132*/ 137*/
133class KOTodoView : public KOrg::BaseView 138class KOTodoView : public KOrg::BaseView
134{ 139{
135 Q_OBJECT 140 Q_OBJECT
136 public: 141 public:
137 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); 142 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 );
138 ~KOTodoView(); 143 ~KOTodoView();
139 144
140 QPtrList<Incidence> selectedIncidences(); 145 QPtrList<Incidence> selectedIncidences();
141 QPtrList<Todo> selectedTodos(); 146 QPtrList<Todo> selectedTodos();
142 147
143 DateList selectedDates() 148 DateList selectedDates()
144 {DateList q; 149 {DateList q;
145 return q;} 150 return q;}
146 151
147 /** Return number of shown dates. TodoView does not show dates, */ 152 /** Return number of shown dates. TodoView does not show dates, */
148 int currentDateCount() { return 0; } 153 int currentDateCount() { return 0; }
149 154
150 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); 155 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td);
151 156
152 void setDocumentId( const QString & ); 157 void setDocumentId( const QString & );
153 158
154 void saveLayout(KConfig *config, const QString &group) const; 159 void saveLayout(KConfig *config, const QString &group) const;
155 void restoreLayout(KConfig *config, const QString &group); 160 void restoreLayout(KConfig *config, const QString &group);
156 /** Create a popup menu to set categories */ 161 /** Create a popup menu to set categories */
157 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); 162 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem);
158 void setNavigator( DateNavigator* nav ) {mNavigator = nav;} 163 void setNavigator( DateNavigator* nav ) {mNavigator = nav;}
159 QString getWhatsThisText(QPoint p); 164 QString getWhatsThisText(QPoint p);
160 void clearList() {mTodoListView->clear(); } 165 void clearList() {mTodoListView->clear(); }
161 166
162 public slots: 167 public slots:
163 void updateView(); 168 void updateView();
164 void updateConfig(); 169 void updateConfig();
165 170
166 void changeEventDisplay(Event *, int); 171 void changeEventDisplay(Event *, int);
167 172
168 void showDates(const QDate &start, const QDate &end); 173 void showDates(const QDate &start, const QDate &end);
169 void showEvents(QPtrList<Event> eventList); 174 void showEvents(QPtrList<Event> eventList);
170 175
171 void clearSelection(); 176 void clearSelection();
172 void jumpToDate (); 177 void jumpToDate ();
173 178
174 void editItem(QListViewItem *item); 179 void editItem(QListViewItem *item);
175 void showItem(QListViewItem *item,const QPoint &,int); 180 void showItem(QListViewItem *item,const QPoint &,int);
176 void popupMenu(QListViewItem *item,const QPoint &,int); 181 void popupMenu(QListViewItem *item,const QPoint &,int);
177 void newTodo(); 182 void newTodo();
178 void newSubTodo(); 183 void newSubTodo();
179 void unparentTodo(); 184 void unparentTodo();
180 void reparentTodo(); 185 void reparentTodo();
181 void showTodo(); 186 void showTodo();
182 void editTodo(); 187 void editTodo();
183 void cloneTodo(); 188 void cloneTodo();
184 void cancelTodo(); 189 void cancelTodo();
185 void moveTodo(); 190 void moveTodo();
186 void beamTodo(); 191 void beamTodo();
187 void deleteTodo(); 192 void deleteTodo();
188 193
189 void setNewPriority(int); 194 void setNewPriority(int);
190 void setNewPercentage(int); 195 void setNewPercentage(int);
191 void changedCategories(int); 196 void changedCategories(int);
192 197
193 void setAllOpen(); 198 void setAllOpen();
194 void setAllClose(); 199 void setAllClose();
195 void setAllFlat(); 200 void setAllFlat();
196 void displayAllFlat(); 201 void displayAllFlat();
197 202
198 void purgeCompleted(); 203 void purgeCompleted();
199 void toggleCompleted(); 204 void toggleCompleted();
200 void toggleRunning(); 205 void toggleRunning();
201 void toggleQuickTodo(); 206 void toggleQuickTodo();
202 void updateTodo( Todo *, int ); 207 void updateTodo( Todo *, int );
203 208
204 void itemClicked(QListViewItem *); 209 void itemClicked(QListViewItem *);
205 void itemStateChanged(QListViewItem *); 210 void itemStateChanged(QListViewItem *);
206 void modified(bool); 211 void modified(bool);
207 void itemDoubleClicked(QListViewItem *item); 212 void itemDoubleClicked(QListViewItem *item);
208 213
209 signals: 214 signals:
210 void newTodoSignal(); 215 void newTodoSignal();
211 void newSubTodoSignal(Todo *); 216 void newSubTodoSignal(Todo *);
212 void unparentTodoSignal(Todo *); 217 void unparentTodoSignal(Todo *);
213 void reparentTodoSignal( Todo *,Todo * ); 218 void reparentTodoSignal( Todo *,Todo * );
214 void showTodoSignal(Todo *); 219 void showTodoSignal(Todo *);
215 220
216 void editTodoSignal(Todo *); 221 void editTodoSignal(Todo *);
217 void deleteTodoSignal(Todo *); 222 void deleteTodoSignal(Todo *);
218 void todoModifiedSignal (Todo *, int); 223 void todoModifiedSignal (Todo *, int);
219 224
220 void isModified(bool); 225 void isModified(bool);
221 void cloneTodoSignal( Incidence * ); 226 void cloneTodoSignal( Incidence * );
222 void cancelTodoSignal( Incidence * ); 227 void cancelTodoSignal( Incidence * );
223 void moveTodoSignal( Incidence * ); 228 void moveTodoSignal( Incidence * );
224 void beamTodoSignal( Incidence * ); 229 void beamTodoSignal( Incidence * );
225 void purgeCompletedSignal(); 230 void purgeCompletedSignal();
226 231
227 protected slots: 232 protected slots:
228 void toggleRunningItem(); 233 void toggleRunningItem();
229 void paintNeeded(); 234 void paintNeeded();
230 void processSelectionChange(); 235 void processSelectionChange();
231 void addQuickTodo(); 236 void addQuickTodo();
232 void setTodoModified( Todo* ); 237 void setTodoModified( Todo* );
233 void todoModified(Todo *, int ); 238 void todoModified(Todo *, int );
234 239
235 private: 240 private:
236 /* 241 /*
237 * the TodoEditor approach is rather unscaling in the long 242 * the TodoEditor approach is rather unscaling in the long
238 * run. 243 * run.
239 * Korganizer keeps it in memory and we need to update 244 * Korganizer keeps it in memory and we need to update
240 * 1. make KOTodoViewItem a QObject again? 245 * 1. make KOTodoViewItem a QObject again?
241 * 2. add a public method for setting one todo modified? 246 * 2. add a public method for setting one todo modified?
242 * 3. add a private method for setting a todo modified + friend here? 247 * 3. add a private method for setting a todo modified + friend here?
243 * -- zecke 2002-07-08 248 * -- zecke 2002-07-08
244 */ 249 */
245 KOTodoViewWhatsThis* mKOTodoViewWhatsThis; 250 KOTodoViewWhatsThis* mKOTodoViewWhatsThis;
246 friend class KOTodoListView; 251 friend class KOTodoListView;
247 void paintEvent(QPaintEvent * pevent); 252 void paintEvent(QPaintEvent * pevent);
248 bool mPendingUpdateBeforeRepaint; 253 bool mPendingUpdateBeforeRepaint;
249 friend class KOTodoViewItem; 254 friend class KOTodoViewItem;
250 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); 255 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo);
251 void restoreItemState( QListViewItem * ); 256 void restoreItemState( QListViewItem * );
252 257
253 bool checkTodo( Todo * ); 258 bool checkTodo( Todo * );
254 bool isFlatDisplay; 259 bool isFlatDisplay;
255 void setOpen( QListViewItem*, bool setOpen); 260 void setOpen( QListViewItem*, bool setOpen);
256 KOTodoListView *mTodoListView; 261 KOTodoListView *mTodoListView;
257 QPopupMenu *mItemPopupMenu; 262 QPopupMenu *mItemPopupMenu;
258 QPopupMenu *mPopupMenu; 263 QPopupMenu *mPopupMenu;
259 QPopupMenu *mPriorityPopupMenu; 264 QPopupMenu *mPriorityPopupMenu;
260 QPopupMenu *mPercentageCompletedPopupMenu; 265 QPopupMenu *mPercentageCompletedPopupMenu;
261 QPopupMenu *mCategoryPopupMenu; 266 QPopupMenu *mCategoryPopupMenu;
262 267
263 QMap<int, int> mPercentage; 268 QMap<int, int> mPercentage;
264 QMap<int, int> mPriority; 269 QMap<int, int> mPriority;
265 QMap<int, QString> mCategory; 270 QMap<int, QString> mCategory;
266 KOTodoViewItem *mActiveItem; 271 KOTodoViewItem *mActiveItem;
267 272
268 QMap<Todo *,KOTodoViewItem *> mTodoMap; 273 QMap<Todo *,KOTodoViewItem *> mTodoMap;
269 QString mName; 274 QString mName;
270 275
271 DocPrefs *mDocPrefs; 276 DocPrefs *mDocPrefs;
272 QString mCurrentDoc; 277 QString mCurrentDoc;
273 KOQuickTodo *mQuickAdd; 278 KOQuickTodo *mQuickAdd;
274 bool mBlockUpdate; 279 bool mBlockUpdate;
275 void keyPressEvent ( QKeyEvent * ) ; 280 void keyPressEvent ( QKeyEvent * ) ;
276 KOTodoViewItem * pendingSubtodo; 281 KOTodoViewItem * pendingSubtodo;
277 DateNavigator* mNavigator; 282 DateNavigator* mNavigator;
278 void storeCurrentItem(); 283 void storeCurrentItem();
279 void resetCurrentItem(); 284 void resetCurrentItem();
280 Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove; 285 Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove;
281}; 286};
282 287
283#endif 288#endif
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 62b74f1..9a8b6e4 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -1,599 +1,601 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <kglobalsettings.h> 22#include <kglobalsettings.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kdebug.h> 24#include <kdebug.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qfileinfo.h> 26#include <qfileinfo.h>
27 27
28#include "calendarlocal.h" 28#include "calendarlocal.h"
29#include "icalformat.h" 29#include "icalformat.h"
30#include "todo.h" 30#include "todo.h"
31 31
32using namespace KCal; 32using namespace KCal;
33 33
34Todo::Todo(): QObject(), Incidence() 34Todo::Todo(): QObject(), Incidence()
35{ 35{
36// mStatus = TENTATIVE; 36// mStatus = TENTATIVE;
37 37
38 mHasDueDate = false; 38 mHasDueDate = false;
39 setHasStartDate( false ); 39 setHasStartDate( false );
40 mCompleted = getEvenTime(QDateTime::currentDateTime()); 40 mCompleted = getEvenTime(QDateTime::currentDateTime());
41 mHasCompletedDate = false; 41 mHasCompletedDate = false;
42 mPercentComplete = 0; 42 mPercentComplete = 0;
43 mRunning = false; 43 mRunning = false;
44 mRunSaveTimer = 0; 44 mRunSaveTimer = 0;
45} 45}
46 46
47Todo::Todo(const Todo &t) : QObject(),Incidence(t) 47Todo::Todo(const Todo &t) : QObject(),Incidence(t)
48{ 48{
49 mDtDue = t.mDtDue; 49 mDtDue = t.mDtDue;
50 mHasDueDate = t.mHasDueDate; 50 mHasDueDate = t.mHasDueDate;
51 mCompleted = t.mCompleted; 51 mCompleted = t.mCompleted;
52 mHasCompletedDate = t.mHasCompletedDate; 52 mHasCompletedDate = t.mHasCompletedDate;
53 mPercentComplete = t.mPercentComplete; 53 mPercentComplete = t.mPercentComplete;
54 mRunning = false; 54 mRunning = false;
55 mRunSaveTimer = 0; 55 mRunSaveTimer = 0;
56} 56}
57 57
58Todo::~Todo() 58Todo::~Todo()
59{ 59{
60 setRunning( false ); 60 setRunning( false );
61 //qDebug("Todo::~Todo() "); 61 //qDebug("Todo::~Todo() ");
62} 62}
63 63
64void Todo::setRunningFalse( QString s ) 64void Todo::setRunningFalse( QString s )
65{ 65{
66 if ( ! mRunning ) 66 if ( ! mRunning )
67 return; 67 return;
68 mRunning = false; 68 mRunning = false;
69 mRunSaveTimer->stop(); 69 mRunSaveTimer->stop();
70 saveRunningInfoToFile( s ); 70 saveRunningInfoToFile( s );
71} 71}
72void Todo::stopRunning() 72void Todo::stopRunning()
73{ 73{
74 if ( !mRunning ) 74 if ( !mRunning )
75 return; 75 return;
76 if ( mRunSaveTimer ) 76 if ( mRunSaveTimer )
77 mRunSaveTimer->stop(); 77 mRunSaveTimer->stop();
78 mRunning = false; 78 mRunning = false;
79} 79}
80void Todo::setRunning( bool run ) 80void Todo::setRunning( bool run )
81{ 81{
82 if ( run == mRunning ) 82 if ( run == mRunning )
83 return; 83 return;
84 //qDebug("Todo::setRunning %d ", run); 84 //qDebug("Todo::setRunning %d ", run);
85 if ( !mRunSaveTimer ) { 85 if ( !mRunSaveTimer ) {
86 mRunSaveTimer = new QTimer ( this ); 86 mRunSaveTimer = new QTimer ( this );
87 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 87 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
88 } 88 }
89 mRunning = run; 89 mRunning = run;
90 if ( mRunning ) { 90 if ( mRunning ) {
91 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 91 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
92 mRunStart = QDateTime::currentDateTime(); 92 mRunStart = QDateTime::currentDateTime();
93 } else { 93 } else {
94 mRunSaveTimer->stop(); 94 mRunSaveTimer->stop();
95 saveRunningInfoToFile(); 95 saveRunningInfoToFile();
96 } 96 }
97} 97}
98void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) 98void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end )
99{ 99{
100 if ( !mRunning) return;
101 mRunning = false;
100 mRunStart = start; 102 mRunStart = start;
101 mRunEnd = end; 103 mRunEnd = end;
102 saveRunningInfoToFile( comment ); 104 saveRunningInfoToFile( comment );
103} 105}
104void Todo::saveRunningInfoToFile() 106void Todo::saveRunningInfoToFile()
105{ 107{
106 mRunEnd = QDateTime::currentDateTime(); 108 mRunEnd = QDateTime::currentDateTime();
107 saveRunningInfoToFile( QString::null ); 109 saveRunningInfoToFile( QString::null );
108} 110}
109void Todo::saveRunningInfoToFile( QString comment ) 111void Todo::saveRunningInfoToFile( QString comment )
110{ 112{
111 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 113 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
112 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 10 ) { 114 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 10 ) {
113 qDebug("Running time < 30 seconds. Skipped. "); 115 qDebug("Running time < 30 seconds. Skipped. ");
114 return; 116 return;
115 } 117 }
116 QString dir = KGlobalSettings::timeTrackerDir(); 118 QString dir = KGlobalSettings::timeTrackerDir();
117 //qDebug("%s ", dir.latin1()); 119 //qDebug("%s ", dir.latin1());
118 QString file = "%1%2%3-%4%5%6-"; 120 QString file = "%1%2%3-%4%5%6-";
119 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); 121 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 );
120 file.replace ( QRegExp (" "), "0" ); 122 file.replace ( QRegExp (" "), "0" );
121 file += uid(); 123 file += uid();
122 //qDebug("File %s ",file.latin1() ); 124 //qDebug("File %s ",file.latin1() );
123 CalendarLocal cal; 125 CalendarLocal cal;
124 cal.setLocalTime(); 126 cal.setLocalTime();
125 Todo * to = (Todo*) clone(); 127 Todo * to = (Todo*) clone();
126 to->setFloats( false ); 128 to->setFloats( false );
127 to->setDtStart( mRunStart ); 129 to->setDtStart( mRunStart );
128 to->setHasStartDate( true ); 130 to->setHasStartDate( true );
129 to->setDtDue( mRunEnd ); 131 to->setDtDue( mRunEnd );
130 to->setHasDueDate( true ); 132 to->setHasDueDate( true );
131 to->setUid( file ); 133 to->setUid( file );
132 if ( !comment.isEmpty() ) { 134 if ( !comment.isEmpty() ) {
133 QString des = to->description(); 135 QString des = to->description();
134 if ( des.isEmpty () ) 136 if ( des.isEmpty () )
135 to->setDescription( "TT-Note: " + comment ); 137 to->setDescription( "TT-Note: " + comment );
136 else 138 else
137 to->setDescription( "TT-Note: " + comment +"\n" + des ); 139 to->setDescription( "TT-Note: " + comment +"\n" + des );
138 } 140 }
139 cal.addIncidence( to ); 141 cal.addIncidence( to );
140 ICalFormat format; 142 ICalFormat format;
141 file = dir +"/" +file +".ics"; 143 file = dir +"/" +file +".ics";
142 format.save( &cal, file ); 144 format.save( &cal, file );
143 saveParents(); 145 saveParents();
144 146
145} 147}
146void Todo::saveParents() 148void Todo::saveParents()
147{ 149{
148 if (!relatedTo() ) 150 if (!relatedTo() )
149 return; 151 return;
150 Incidence * inc = relatedTo(); 152 Incidence * inc = relatedTo();
151 if ( inc->typeID() != todoID ) 153 if ( inc->typeID() != todoID )
152 return; 154 return;
153 Todo* to = (Todo*)inc; 155 Todo* to = (Todo*)inc;
154 bool saveTodo = false; 156 bool saveTodo = false;
155 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; 157 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics";
156 QFileInfo fi ( file ); 158 QFileInfo fi ( file );
157 if ( fi.exists() ) { 159 if ( fi.exists() ) {
158 if ( fi.lastModified () < to->lastModified ()) 160 if ( fi.lastModified () < to->lastModified ())
159 saveTodo = true; 161 saveTodo = true;
160 } else { 162 } else {
161 saveTodo = true; 163 saveTodo = true;
162 } 164 }
163 if ( saveTodo ) { 165 if ( saveTodo ) {
164 CalendarLocal cal; 166 CalendarLocal cal;
165 cal.setLocalTime(); 167 cal.setLocalTime();
166 Todo * par = (Todo *) to->clone(); 168 Todo * par = (Todo *) to->clone();
167 cal.addIncidence( par ); 169 cal.addIncidence( par );
168 ICalFormat format; 170 ICalFormat format;
169 format.save( &cal, file ); 171 format.save( &cal, file );
170 } 172 }
171 to->saveParents(); 173 to->saveParents();
172} 174}
173 175
174int Todo::runTime() 176int Todo::runTime()
175{ 177{
176 if ( !mRunning ) 178 if ( !mRunning )
177 return 0; 179 return 0;
178 return mRunStart.secsTo( QDateTime::currentDateTime() ); 180 return mRunStart.secsTo( QDateTime::currentDateTime() );
179} 181}
180bool Todo::hasRunningSub() 182bool Todo::hasRunningSub()
181{ 183{
182 if ( mRunning ) 184 if ( mRunning )
183 return true; 185 return true;
184 Incidence *aTodo; 186 Incidence *aTodo;
185 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 187 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
186 if ( ((Todo*)aTodo)->hasRunningSub() ) 188 if ( ((Todo*)aTodo)->hasRunningSub() )
187 return true; 189 return true;
188 } 190 }
189 return false; 191 return false;
190} 192}
191Incidence *Todo::clone() 193Incidence *Todo::clone()
192{ 194{
193 return new Todo(*this); 195 return new Todo(*this);
194} 196}
195 197
196bool Todo::contains ( Todo* from ) 198bool Todo::contains ( Todo* from )
197{ 199{
198 200
199 if ( !from->summary().isEmpty() ) 201 if ( !from->summary().isEmpty() )
200 if ( !summary().startsWith( from->summary() )) 202 if ( !summary().startsWith( from->summary() ))
201 return false; 203 return false;
202 if ( from->hasStartDate() ) { 204 if ( from->hasStartDate() ) {
203 if ( !hasStartDate() ) 205 if ( !hasStartDate() )
204 return false; 206 return false;
205 if ( from->dtStart() != dtStart()) 207 if ( from->dtStart() != dtStart())
206 return false; 208 return false;
207 } 209 }
208 if ( from->hasDueDate() ){ 210 if ( from->hasDueDate() ){
209 if ( !hasDueDate() ) 211 if ( !hasDueDate() )
210 return false; 212 return false;
211 if ( from->dtDue() != dtDue()) 213 if ( from->dtDue() != dtDue())
212 return false; 214 return false;
213 } 215 }
214 if ( !from->location().isEmpty() ) 216 if ( !from->location().isEmpty() )
215 if ( !location().startsWith( from->location() ) ) 217 if ( !location().startsWith( from->location() ) )
216 return false; 218 return false;
217 if ( !from->description().isEmpty() ) 219 if ( !from->description().isEmpty() )
218 if ( !description().startsWith( from->description() )) 220 if ( !description().startsWith( from->description() ))
219 return false; 221 return false;
220 if ( from->alarms().count() ) { 222 if ( from->alarms().count() ) {
221 Alarm *a = from->alarms().first(); 223 Alarm *a = from->alarms().first();
222 if ( a->enabled() ){ 224 if ( a->enabled() ){
223 if ( !alarms().count() ) 225 if ( !alarms().count() )
224 return false; 226 return false;
225 Alarm *b = alarms().first(); 227 Alarm *b = alarms().first();
226 if( ! b->enabled() ) 228 if( ! b->enabled() )
227 return false; 229 return false;
228 if ( ! (a->offset() == b->offset() )) 230 if ( ! (a->offset() == b->offset() ))
229 return false; 231 return false;
230 } 232 }
231 } 233 }
232 234
233 QStringList cat = categories(); 235 QStringList cat = categories();
234 QStringList catFrom = from->categories(); 236 QStringList catFrom = from->categories();
235 QString nCat; 237 QString nCat;
236 unsigned int iii; 238 unsigned int iii;
237 for ( iii = 0; iii < catFrom.count();++iii ) { 239 for ( iii = 0; iii < catFrom.count();++iii ) {
238 nCat = catFrom[iii]; 240 nCat = catFrom[iii];
239 if ( !nCat.isEmpty() ) 241 if ( !nCat.isEmpty() )
240 if ( !cat.contains( nCat )) { 242 if ( !cat.contains( nCat )) {
241 return false; 243 return false;
242 } 244 }
243 } 245 }
244 if ( from->isCompleted() ) { 246 if ( from->isCompleted() ) {
245 if ( !isCompleted() ) 247 if ( !isCompleted() )
246 return false; 248 return false;
247 } 249 }
248 if( priority() != from->priority() ) 250 if( priority() != from->priority() )
249 return false; 251 return false;
250 252
251 253
252 return true; 254 return true;
253 255
254} 256}
255bool KCal::operator==( const Todo& t1, const Todo& t2 ) 257bool KCal::operator==( const Todo& t1, const Todo& t2 )
256{ 258{
257 259
258 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); 260 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 );
259 if ( ! ret ) 261 if ( ! ret )
260 return false; 262 return false;
261 if ( t1.hasDueDate() == t2.hasDueDate() ) { 263 if ( t1.hasDueDate() == t2.hasDueDate() ) {
262 if ( t1.hasDueDate() ) { 264 if ( t1.hasDueDate() ) {
263 if ( t1.doesFloat() == t2.doesFloat() ) { 265 if ( t1.doesFloat() == t2.doesFloat() ) {
264 if ( t1.doesFloat() ) { 266 if ( t1.doesFloat() ) {
265 if ( t1.dtDue().date() != t2.dtDue().date() ) 267 if ( t1.dtDue().date() != t2.dtDue().date() )
266 return false; 268 return false;
267 } else 269 } else
268 if ( t1.dtDue() != t2.dtDue() ) 270 if ( t1.dtDue() != t2.dtDue() )
269 return false; 271 return false;
270 } else 272 } else
271 return false;// float != 273 return false;// float !=
272 } 274 }
273 275
274 } else 276 } else
275 return false; 277 return false;
276 if ( t1.percentComplete() != t2.percentComplete() ) 278 if ( t1.percentComplete() != t2.percentComplete() )
277 return false; 279 return false;
278 if ( t1.isCompleted() ) { 280 if ( t1.isCompleted() ) {
279 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { 281 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) {
280 if ( t1.hasCompletedDate() ) { 282 if ( t1.hasCompletedDate() ) {
281 if ( t1.completed() != t2.completed() ) 283 if ( t1.completed() != t2.completed() )
282 return false; 284 return false;
283 } 285 }
284 286
285 } else 287 } else
286 return false; 288 return false;
287 } 289 }
288 return true; 290 return true;
289 291
290} 292}
291 293
292void Todo::setDtDue(const QDateTime &dtDue) 294void Todo::setDtDue(const QDateTime &dtDue)
293{ 295{
294 //int diffsecs = mDtDue.secsTo(dtDue); 296 //int diffsecs = mDtDue.secsTo(dtDue);
295 297
296 /*if (mReadOnly) return; 298 /*if (mReadOnly) return;
297 const QPtrList<Alarm>& alarms = alarms(); 299 const QPtrList<Alarm>& alarms = alarms();
298 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { 300 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) {
299 if (alarm->enabled()) { 301 if (alarm->enabled()) {
300 alarm->setTime(alarm->time().addSecs(diffsecs)); 302 alarm->setTime(alarm->time().addSecs(diffsecs));
301 } 303 }
302 }*/ 304 }*/
303 mDtDue = getEvenTime(dtDue); 305 mDtDue = getEvenTime(dtDue);
304 306
305 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; 307 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl;
306 308
307 /*const QPtrList<Alarm>& alarms = alarms(); 309 /*const QPtrList<Alarm>& alarms = alarms();
308 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) 310 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next())
309 alarm->setAlarmStart(mDtDue);*/ 311 alarm->setAlarmStart(mDtDue);*/
310 updated(); 312 updated();
311} 313}
312 314
313QDateTime Todo::dtDue() const 315QDateTime Todo::dtDue() const
314{ 316{
315 return mDtDue; 317 return mDtDue;
316} 318}
317 319
318QString Todo::dtDueTimeStr() const 320QString Todo::dtDueTimeStr() const
319{ 321{
320 return KGlobal::locale()->formatTime(mDtDue.time()); 322 return KGlobal::locale()->formatTime(mDtDue.time());
321} 323}
322 324
323QString Todo::dtDueDateStr(bool shortfmt) const 325QString Todo::dtDueDateStr(bool shortfmt) const
324{ 326{
325 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); 327 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
326} 328}
327 329
328QString Todo::dtDueStr(bool shortfmt) const 330QString Todo::dtDueStr(bool shortfmt) const
329{ 331{
330 if ( doesFloat() ) 332 if ( doesFloat() )
331 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); 333 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
332 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); 334 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt);
333} 335}
334// retval 0 : no found 336// retval 0 : no found
335// 1 : due for date found 337// 1 : due for date found
336// 2 : overdue for date found 338// 2 : overdue for date found
337int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) 339int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos )
338{ 340{
339 int retval = 0; 341 int retval = 0;
340 if ( isCompleted() ) 342 if ( isCompleted() )
341 return 0; 343 return 0;
342 if ( hasDueDate() ) { 344 if ( hasDueDate() ) {
343 if ( dtDue().date() < date ) 345 if ( dtDue().date() < date )
344 return 2; 346 return 2;
345 // we do not return, because we may find an overdue sub todo 347 // we do not return, because we may find an overdue sub todo
346 if ( dtDue().date() == date ) 348 if ( dtDue().date() == date )
347 retval = 1; 349 retval = 1;
348 } 350 }
349 if ( checkSubtodos ) { 351 if ( checkSubtodos ) {
350 Incidence *aTodo; 352 Incidence *aTodo;
351 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 353 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
352 int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); 354 int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos );
353 if ( ret == 2 ) 355 if ( ret == 2 )
354 return 2; 356 return 2;
355 if ( ret == 1) 357 if ( ret == 1)
356 retval = 1; 358 retval = 1;
357 } 359 }
358 } 360 }
359 return retval; 361 return retval;
360} 362}
361int Todo::hasDueSubTodo( bool checkSubtodos ) //= true 363int Todo::hasDueSubTodo( bool checkSubtodos ) //= true
362{ 364{
363 return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); 365 return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos );
364} 366}
365bool Todo::hasDueDate() const 367bool Todo::hasDueDate() const
366{ 368{
367 return mHasDueDate; 369 return mHasDueDate;
368} 370}
369 371
370void Todo::setHasDueDate(bool f) 372void Todo::setHasDueDate(bool f)
371{ 373{
372 if (mReadOnly) return; 374 if (mReadOnly) return;
373 mHasDueDate = f; 375 mHasDueDate = f;
374 updated(); 376 updated();
375} 377}
376 378
377 379
378#if 0 380#if 0
379void Todo::setStatus(const QString &statStr) 381void Todo::setStatus(const QString &statStr)
380{ 382{
381 if (mReadOnly) return; 383 if (mReadOnly) return;
382 QString ss(statStr.upper()); 384 QString ss(statStr.upper());
383 385
384 if (ss == "X-ACTION") 386 if (ss == "X-ACTION")
385 mStatus = NEEDS_ACTION; 387 mStatus = NEEDS_ACTION;
386 else if (ss == "NEEDS ACTION") 388 else if (ss == "NEEDS ACTION")
387 mStatus = NEEDS_ACTION; 389 mStatus = NEEDS_ACTION;
388 else if (ss == "ACCEPTED") 390 else if (ss == "ACCEPTED")
389 mStatus = ACCEPTED; 391 mStatus = ACCEPTED;
390 else if (ss == "SENT") 392 else if (ss == "SENT")
391 mStatus = SENT; 393 mStatus = SENT;
392 else if (ss == "TENTATIVE") 394 else if (ss == "TENTATIVE")
393 mStatus = TENTATIVE; 395 mStatus = TENTATIVE;
394 else if (ss == "CONFIRMED") 396 else if (ss == "CONFIRMED")
395 mStatus = CONFIRMED; 397 mStatus = CONFIRMED;
396 else if (ss == "DECLINED") 398 else if (ss == "DECLINED")
397 mStatus = DECLINED; 399 mStatus = DECLINED;
398 else if (ss == "COMPLETED") 400 else if (ss == "COMPLETED")
399 mStatus = COMPLETED; 401 mStatus = COMPLETED;
400 else if (ss == "DELEGATED") 402 else if (ss == "DELEGATED")
401 mStatus = DELEGATED; 403 mStatus = DELEGATED;
402 404
403 updated(); 405 updated();
404} 406}
405 407
406void Todo::setStatus(int status) 408void Todo::setStatus(int status)
407{ 409{
408 if (mReadOnly) return; 410 if (mReadOnly) return;
409 mStatus = status; 411 mStatus = status;
410 updated(); 412 updated();
411} 413}
412 414
413int Todo::status() const 415int Todo::status() const
414{ 416{
415 return mStatus; 417 return mStatus;
416} 418}
417 419
418QString Todo::statusStr() const 420QString Todo::statusStr() const
419{ 421{
420 switch(mStatus) { 422 switch(mStatus) {
421 case NEEDS_ACTION: 423 case NEEDS_ACTION:
422 return QString("NEEDS ACTION"); 424 return QString("NEEDS ACTION");
423 break; 425 break;
424 case ACCEPTED: 426 case ACCEPTED:
425 return QString("ACCEPTED"); 427 return QString("ACCEPTED");
426 break; 428 break;
427 case SENT: 429 case SENT:
428 return QString("SENT"); 430 return QString("SENT");
429 break; 431 break;
430 case TENTATIVE: 432 case TENTATIVE:
431 return QString("TENTATIVE"); 433 return QString("TENTATIVE");
432 break; 434 break;
433 case CONFIRMED: 435 case CONFIRMED:
434 return QString("CONFIRMED"); 436 return QString("CONFIRMED");
435 break; 437 break;
436 case DECLINED: 438 case DECLINED:
437 return QString("DECLINED"); 439 return QString("DECLINED");
438 break; 440 break;
439 case COMPLETED: 441 case COMPLETED:
440 return QString("COMPLETED"); 442 return QString("COMPLETED");
441 break; 443 break;
442 case DELEGATED: 444 case DELEGATED:
443 return QString("DELEGATED"); 445 return QString("DELEGATED");
444 break; 446 break;
445 } 447 }
446 return QString(""); 448 return QString("");
447} 449}
448#endif 450#endif
449 451
450bool Todo::isCompleted() const 452bool Todo::isCompleted() const
451{ 453{
452 if (mPercentComplete == 100) { 454 if (mPercentComplete == 100) {
453 return true; 455 return true;
454 } 456 }
455 else return false; 457 else return false;
456} 458}
457 459
458void Todo::setCompleted(bool completed) 460void Todo::setCompleted(bool completed)
459{ 461{
460 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { 462 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) {
461 if ( !setRecurDates() ) 463 if ( !setRecurDates() )
462 completed = false; 464 completed = false;
463 } 465 }
464 if (completed) mPercentComplete = 100; 466 if (completed) mPercentComplete = 100;
465 else { 467 else {
466 mPercentComplete = 0; 468 mPercentComplete = 0;
467 mHasCompletedDate = false; 469 mHasCompletedDate = false;
468 } 470 }
469 updated(); 471 updated();
470} 472}
471 473
472QDateTime Todo::completed() const 474QDateTime Todo::completed() const
473{ 475{
474 return mCompleted; 476 return mCompleted;
475} 477}
476 478
477QString Todo::completedStr( bool shortF ) const 479QString Todo::completedStr( bool shortF ) const
478{ 480{
479 return KGlobal::locale()->formatDateTime(mCompleted, shortF); 481 return KGlobal::locale()->formatDateTime(mCompleted, shortF);
480} 482}
481 483
482void Todo::setCompleted(const QDateTime &completed) 484void Todo::setCompleted(const QDateTime &completed)
483{ 485{
484 //qDebug("Todo::setCompleted "); 486 //qDebug("Todo::setCompleted ");
485 if ( mHasCompletedDate ) { 487 if ( mHasCompletedDate ) {
486 // qDebug("has completed data - return "); 488 // qDebug("has completed data - return ");
487 return; 489 return;
488 } 490 }
489 mHasCompletedDate = true; 491 mHasCompletedDate = true;
490 mPercentComplete = 100; 492 mPercentComplete = 100;
491 mCompleted = getEvenTime(completed); 493 mCompleted = getEvenTime(completed);
492 updated(); 494 updated();
493} 495}
494 496
495bool Todo::hasCompletedDate() const 497bool Todo::hasCompletedDate() const
496{ 498{
497 return mHasCompletedDate; 499 return mHasCompletedDate;
498} 500}
499 501
500int Todo::percentComplete() const 502int Todo::percentComplete() const
501{ 503{
502 return mPercentComplete; 504 return mPercentComplete;
503} 505}
504bool Todo::setRecurDates() 506bool Todo::setRecurDates()
505{ 507{
506 if ( !mHasRecurrenceID ) 508 if ( !mHasRecurrenceID )
507 return true; 509 return true;
508 int secs = mDtStart.secsTo( dtDue() ); 510 int secs = mDtStart.secsTo( dtDue() );
509 bool ok; 511 bool ok;
510 qDebug("T:setRecurDates() "); 512 qDebug("T:setRecurDates() ");
511 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 513 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
512 QDateTime next = getNextOccurence( mRecurrenceID, &ok ); 514 QDateTime next = getNextOccurence( mRecurrenceID, &ok );
513 if ( ok ) { 515 if ( ok ) {
514 mRecurrenceID = next; 516 mRecurrenceID = next;
515 mDtStart = next; 517 mDtStart = next;
516 setDtDue( next.addSecs( secs ) ); 518 setDtDue( next.addSecs( secs ) );
517 if ( QDateTime::currentDateTime() > next) 519 if ( QDateTime::currentDateTime() > next)
518 return false; 520 return false;
519 } else { 521 } else {
520 setHasRecurrenceID( false ); 522 setHasRecurrenceID( false );
521 recurrence()->unsetRecurs(); 523 recurrence()->unsetRecurs();
522 } 524 }
523 return true; 525 return true;
524} 526}
525void Todo::setPercentComplete(int v) 527void Todo::setPercentComplete(int v)
526{ 528{
527 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { 529 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) {
528 if ( !setRecurDates() ) 530 if ( !setRecurDates() )
529 v = 0; 531 v = 0;
530 } 532 }
531 mPercentComplete = v; 533 mPercentComplete = v;
532 if ( v != 100 ) 534 if ( v != 100 )
533 mHasCompletedDate = false; 535 mHasCompletedDate = false;
534 updated(); 536 updated();
535} 537}
536QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const 538QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
537{ 539{
538 if ( isCompleted() || ! hasDueDate() || cancelled() || !alarmEnabled() ) { 540 if ( isCompleted() || ! hasDueDate() || cancelled() || !alarmEnabled() ) {
539 *ok = false; 541 *ok = false;
540 return QDateTime (); 542 return QDateTime ();
541 } 543 }
542 QDateTime incidenceStart; 544 QDateTime incidenceStart;
543 incidenceStart = dtDue(); 545 incidenceStart = dtDue();
544 bool enabled = false; 546 bool enabled = false;
545 Alarm* alarm; 547 Alarm* alarm;
546 int off = 0; 548 int off = 0;
547 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 549 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
548 // if ( QDateTime::currentDateTime() > incidenceStart ){ 550 // if ( QDateTime::currentDateTime() > incidenceStart ){
549// *ok = false; 551// *ok = false;
550// return incidenceStart; 552// return incidenceStart;
551// } 553// }
552 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 554 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
553 if (alarm->enabled()) { 555 if (alarm->enabled()) {
554 if ( alarm->hasTime () ) { 556 if ( alarm->hasTime () ) {
555 if ( alarm->time() < alarmStart ) { 557 if ( alarm->time() < alarmStart ) {
556 alarmStart = alarm->time(); 558 alarmStart = alarm->time();
557 enabled = true; 559 enabled = true;
558 off = alarmStart.secsTo( incidenceStart ); 560 off = alarmStart.secsTo( incidenceStart );
559 } 561 }
560 562
561 } else { 563 } else {
562 int secs = alarm->startOffset().asSeconds(); 564 int secs = alarm->startOffset().asSeconds();
563 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 565 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
564 alarmStart = incidenceStart.addSecs( secs ); 566 alarmStart = incidenceStart.addSecs( secs );
565 enabled = true; 567 enabled = true;
566 off = -secs; 568 off = -secs;
567 } 569 }
568 } 570 }
569 } 571 }
570 } 572 }
571 if ( enabled ) { 573 if ( enabled ) {
572 if ( alarmStart > start_dt ) { 574 if ( alarmStart > start_dt ) {
573 *ok = true; 575 *ok = true;
574 * offset = off; 576 * offset = off;
575 return alarmStart; 577 return alarmStart;
576 } 578 }
577 } 579 }
578 *ok = false; 580 *ok = false;
579 return QDateTime (); 581 return QDateTime ();
580 582
581} 583}
582 584
583void Todo::checkSetCompletedFalse() 585void Todo::checkSetCompletedFalse()
584{ 586{
585 if ( !mHasRecurrenceID ) { 587 if ( !mHasRecurrenceID ) {
586 qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); 588 qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
587 return; 589 return;
588 } 590 }
589 // qDebug("Todo::checkSetCompletedFalse()"); 591 // qDebug("Todo::checkSetCompletedFalse()");
590 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 592 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
591 if ( mPercentComplete == 100 ) { 593 if ( mPercentComplete == 100 ) {
592 QDateTime dt = QDateTime::currentDateTime(); 594 QDateTime dt = QDateTime::currentDateTime();
593 if ( dt > mDtStart && dt > mRecurrenceID ) { 595 if ( dt > mDtStart && dt > mRecurrenceID ) {
594 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 596 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
595 setCompleted( false ); 597 setCompleted( false );
596 qDebug("Todo::checkSetCompletedFalse "); 598 qDebug("Todo::checkSetCompletedFalse ");
597 } 599 }
598 } 600 }
599} 601}
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 11f848e..425dfad 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -1,155 +1,155 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef TODO_H 20#ifndef TODO_H
21#define TODO_H 21#define TODO_H
22// 22//
23// Todo component, representing a VTODO object 23// Todo component, representing a VTODO object
24// 24//
25 25
26#include "incidence.h" 26#include "incidence.h"
27 27
28#include <qtimer.h> 28#include <qtimer.h>
29 29
30namespace KCal { 30namespace KCal {
31 31
32/** 32/**
33 This class provides a Todo in the sense of RFC2445. 33 This class provides a Todo in the sense of RFC2445.
34*/ 34*/
35 class Todo : public QObject,public Incidence 35 class Todo : public QObject,public Incidence
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 Todo(); 39 Todo();
40 Todo(const Todo &); 40 Todo(const Todo &);
41 ~Todo(); 41 ~Todo();
42 typedef ListBase<Todo> List; 42 typedef ListBase<Todo> List;
43 QCString type() const { return "Todo"; } 43 QCString type() const { return "Todo"; }
44 IncTypeID typeID() const { return todoID; } 44 IncTypeID typeID() const { return todoID; }
45 void saveRunningInfo( QString comment, QDateTime start, QDateTime end );
46 45
47 /** Return an exact copy of this todo. */ 46 /** Return an exact copy of this todo. */
48 Incidence *clone(); 47 Incidence *clone();
49 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; 48 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const;
50 49
51 /** for setting the todo's due date/time with a QDateTime. */ 50 /** for setting the todo's due date/time with a QDateTime. */
52 void setDtDue(const QDateTime &dtDue); 51 void setDtDue(const QDateTime &dtDue);
53 /** returns an event's Due date/time as a QDateTime. */ 52 /** returns an event's Due date/time as a QDateTime. */
54 QDateTime dtDue() const; 53 QDateTime dtDue() const;
55 /** returns an event's due time as a string formatted according to the 54 /** returns an event's due time as a string formatted according to the
56 users locale settings */ 55 users locale settings */
57 QString dtDueTimeStr() const; 56 QString dtDueTimeStr() const;
58 /** returns an event's due date as a string formatted according to the 57 /** returns an event's due date as a string formatted according to the
59 users locale settings */ 58 users locale settings */
60 QString dtDueDateStr(bool shortfmt=true) const; 59 QString dtDueDateStr(bool shortfmt=true) const;
61 /** returns an event's due date and time as a string formatted according 60 /** returns an event's due date and time as a string formatted according
62 to the users locale settings */ 61 to the users locale settings */
63 QString dtDueStr(bool shortfmt=true) const; 62 QString dtDueStr(bool shortfmt=true) const;
64 63
65 /** returns TRUE or FALSE depending on whether the todo has a due date */ 64 /** returns TRUE or FALSE depending on whether the todo has a due date */
66 bool hasDueDate() const; 65 bool hasDueDate() const;
67 /** sets the event's hasDueDate value. */ 66 /** sets the event's hasDueDate value. */
68 void setHasDueDate(bool f); 67 void setHasDueDate(bool f);
69 68
70 /* 69 /*
71 Looks for a subtodo (including itself ) which is not complete and is 70 Looks for a subtodo (including itself ) which is not complete and is
72 - overdue, or 71 - overdue, or
73 - due today. 72 - due today.
74 It returns 0 for nothing found, 73 It returns 0 for nothing found,
75 1 for found a todo which is due today and no overdue found 74 1 for found a todo which is due today and no overdue found
76 2 for found a overdue todo 75 2 for found a overdue todo
77 */ 76 */
78 int hasDueSubTodo( bool checkSubtodos = true ); 77 int hasDueSubTodo( bool checkSubtodos = true );
79 /* same as above, but a specific date can be specified*/ 78 /* same as above, but a specific date can be specified*/
80 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ); 79 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos );
81 80
82 81
83 /** sets the event's status to the string specified. The string 82 /** sets the event's status to the string specified. The string
84 * must be a recognized value for the status field, i.e. a string 83 * must be a recognized value for the status field, i.e. a string
85 * equivalent of the possible status enumerations previously described. */ 84 * equivalent of the possible status enumerations previously described. */
86// void setStatus(const QString &statStr); 85// void setStatus(const QString &statStr);
87 /** sets the event's status to the value specified. See the enumeration 86 /** sets the event's status to the value specified. See the enumeration
88 * above for possible values. */ 87 * above for possible values. */
89// void setStatus(int); 88// void setStatus(int);
90 /** return the event's status. */ 89 /** return the event's status. */
91// int status() const; 90// int status() const;
92 /** return the event's status in string format. */ 91 /** return the event's status in string format. */
93// QString statusStr() const; 92// QString statusStr() const;
94 93
95 /** return, if this todo is completed */ 94 /** return, if this todo is completed */
96 bool isCompleted() const; 95 bool isCompleted() const;
97 /** set completed state of this todo */ 96 /** set completed state of this todo */
98 void setCompleted(bool); 97 void setCompleted(bool);
99 98
100 /** 99 /**
101 Return how many percent of the task are completed. Returns a value 100 Return how many percent of the task are completed. Returns a value
102 between 0 and 100. 101 between 0 and 100.
103 */ 102 */
104 int percentComplete() const; 103 int percentComplete() const;
105 /** 104 /**
106 Set how many percent of the task are completed. Valid values are in the 105 Set how many percent of the task are completed. Valid values are in the
107 range from 0 to 100. 106 range from 0 to 100.
108 */ 107 */
109 void setPercentComplete(int); 108 void setPercentComplete(int);
110 109
111 /** return date and time when todo was completed */ 110 /** return date and time when todo was completed */
112 QDateTime completed() const; 111 QDateTime completed() const;
113 QString completedStr(bool shortF = true) const; 112 QString completedStr(bool shortF = true) const;
114 /** set date and time of completion */ 113 /** set date and time of completion */
115 void setCompleted(const QDateTime &completed); 114 void setCompleted(const QDateTime &completed);
116 115
117 /** Return true, if todo has a date associated with completion */ 116 /** Return true, if todo has a date associated with completion */
118 bool hasCompletedDate() const; 117 bool hasCompletedDate() const;
119 bool contains ( Todo*); 118 bool contains ( Todo*);
120 void checkSetCompletedFalse(); 119 void checkSetCompletedFalse();
121 bool setRecurDates(); 120 bool setRecurDates();
122 bool isRunning() {return mRunning;} 121 bool isRunning() {return mRunning;}
123 bool hasRunningSub(); 122 bool hasRunningSub();
124 void setRunning( bool ); 123 void setRunning( bool );
125 void setRunningFalse( QString ); 124 void setRunningFalse( QString );
126 void stopRunning(); 125 void stopRunning();
127 int runTime(); 126 int runTime();
128 QDateTime runStart () const { return mRunStart;} 127 QDateTime runStart () const { return mRunStart;}
128 void saveRunningInfo( QString comment, QDateTime start, QDateTime end );
129 public slots: 129 public slots:
130 void saveRunningInfoToFile( QString st ); 130 void saveRunningInfoToFile( QString st );
131 void saveRunningInfoToFile( ); 131 void saveRunningInfoToFile( );
132 void saveParents(); 132 void saveParents();
133 private: 133 private:
134 bool mRunning; 134 bool mRunning;
135 QTimer * mRunSaveTimer; 135 QTimer * mRunSaveTimer;
136 QDateTime mRunStart; 136 QDateTime mRunStart;
137 QDateTime mRunEnd; 137 QDateTime mRunEnd;
138 bool accept(Visitor &v) { return v.visit(this); } 138 bool accept(Visitor &v) { return v.visit(this); }
139 139
140 QDateTime mDtDue; // due date of todo 140 QDateTime mDtDue; // due date of todo
141 141
142 bool mHasDueDate; // if todo has associated due date 142 bool mHasDueDate; // if todo has associated due date
143 143
144// int mStatus; // confirmed/delegated/tentative/etc 144// int mStatus; // confirmed/delegated/tentative/etc
145 145
146 QDateTime mCompleted; 146 QDateTime mCompleted;
147 bool mHasCompletedDate; 147 bool mHasCompletedDate;
148 148
149 int mPercentComplete; 149 int mPercentComplete;
150}; 150};
151 151
152 bool operator==( const Todo&, const Todo& ); 152 bool operator==( const Todo&, const Todo& );
153} 153}
154 154
155#endif 155#endif