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