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