summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-08-05 21:59:14 (UTC)
committer zautrix <zautrix>2005-08-05 21:59:14 (UTC)
commitcd215c243d0636cabbc73006652b9b6783319de1 (patch) (unidiff)
tree2b5021ac24ea77304991ebabac97cab9c8451202 /korganizer
parent90585d5946407bdb8783bcb369ef7483c869995d (diff)
downloadkdepimpi-cd215c243d0636cabbc73006652b9b6783319de1.zip
kdepimpi-cd215c243d0636cabbc73006652b9b6783319de1.tar.gz
kdepimpi-cd215c243d0636cabbc73006652b9b6783319de1.tar.bz2
fixxx
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 82c0f4c..00c2d97 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,929 +1,929 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31 31
32#include <qinputdialog.h> 32#include <qinputdialog.h>
33 33
34#include <qvbox.h> 34#include <qvbox.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include "koprefs.h" 36#include "koprefs.h"
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kdateedit.h> 39#include <kdateedit.h>
40#include "ktimeedit.h" 40#include "ktimeedit.h"
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kmessagebox.h> 42#include <kmessagebox.h>
43 43
44#include <libkcal/icaldrag.h> 44#include <libkcal/icaldrag.h>
45#include <libkcal/vcaldrag.h> 45#include <libkcal/vcaldrag.h>
46#include <libkcal/calfilter.h> 46#include <libkcal/calfilter.h>
47#include <libkcal/dndfactory.h> 47#include <libkcal/dndfactory.h>
48#include <libkcal/calendarresources.h> 48#include <libkcal/calendarresources.h>
49#include <libkcal/resourcecalendar.h> 49#include <libkcal/resourcecalendar.h>
50#include <kresources/resourceselectdialog.h> 50#include <kresources/resourceselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57#ifndef KORG_NOPRINTER 57#ifndef KORG_NOPRINTER
58#include "calprinter.h" 58#include "calprinter.h"
59#endif 59#endif
60#include "docprefs.h" 60#include "docprefs.h"
61 61
62#include "kotodoview.h" 62#include "kotodoview.h"
63using namespace KOrg; 63using namespace KOrg;
64 64
65 65
66KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : 66KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) :
67 QDialog( parent, name, true ) 67 QDialog( parent, name, true )
68{ 68{
69 mStopAll = true; 69 mStopAll = true;
70 setCaption( i18n("Start todo") ); 70 setCaption( i18n("Start todo") );
71 QVBoxLayout* lay = new QVBoxLayout( this ); 71 QVBoxLayout* lay = new QVBoxLayout( this );
72 lay->setSpacing( 3 ); 72 lay->setSpacing( 3 );
73 lay->setMargin( 3 ); 73 lay->setMargin( 3 );
74 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); 74 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this );
75 lay->addWidget( lab ); 75 lay->addWidget( lab );
76 lab->setAlignment( AlignCenter ); 76 lab->setAlignment( AlignCenter );
77 77
78 QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); 78 QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this );
79 lay->addWidget( ok ); 79 lay->addWidget( ok );
80 ok->setDefault( true ); 80 ok->setDefault( true );
81 QPushButton * start = new QPushButton( i18n("Start todo"), this ); 81 QPushButton * start = new QPushButton( i18n("Start todo"), this );
82 lay->addWidget( start ); 82 lay->addWidget( start );
83 QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); 83 QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this );
84 lay->addWidget( cancel ); 84 lay->addWidget( cancel );
85 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 85 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
86 connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); 86 connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) );
87 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 87 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
88 resize( sizeHint() ); 88 resize( sizeHint() );
89 89
90} 90}
91void KOStartTodoPrefs::doStop() 91void KOStartTodoPrefs::doStop()
92{ 92{
93 mStopAll = false; 93 mStopAll = false;
94 accept(); 94 accept();
95} 95}
96KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : 96KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) :
97 QDialog( parent, name, true ) 97 QDialog( parent, name, true )
98{ 98{
99 mTodo = todo; 99 mTodo = todo;
100 setCaption( i18n("Stop todo") ); 100 setCaption( i18n("Stop todo") );
101 QVBoxLayout* lay = new QVBoxLayout( this ); 101 QVBoxLayout* lay = new QVBoxLayout( this );
102 lay->setSpacing( 3 ); 102 lay->setSpacing( 3 );
103 lay->setMargin( 3 ); 103 lay->setMargin( 3 );
104 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); 104 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this );
105 lay->addWidget( lab ); 105 lay->addWidget( lab );
106 lab->setAlignment( AlignHCenter ); 106 lab->setAlignment( AlignHCenter );
107 lab = new QLabel( i18n("Additional Comment:"), this ); 107 lab = new QLabel( i18n("Additional Comment:"), this );
108 lay->addWidget( lab ); 108 lay->addWidget( lab );
109 mComment = new QLineEdit( this ); 109 mComment = new QLineEdit( this );
110 lay->addWidget( mComment ); 110 lay->addWidget( mComment );
111 QHBox * start = new QHBox ( this ); 111 QHBox * start = new QHBox ( this );
112 lay->addWidget( start ); 112 lay->addWidget( start );
113 lab = new QLabel( i18n("Start:"), start ); 113 lab = new QLabel( i18n("Start:"), start );
114 QHBox * end = new QHBox ( this ); 114 QHBox * end = new QHBox ( this );
115 lay->addWidget( end ); 115 lay->addWidget( end );
116 lab = new QLabel( i18n("End:"), end ); 116 lab = new QLabel( i18n("End:"), end );
117 sde = new KDateEdit( start ); 117 sde = new KDateEdit( start );
118 ste = new KOTimeEdit( start ); 118 ste = new KOTimeEdit( start );
119 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); 119 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) );
120 ede = new KDateEdit( end ); 120 ede = new KDateEdit( end );
121 ete = new KOTimeEdit(end ); 121 ete = new KOTimeEdit(end );
122 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); 122 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) );
123 sde->setDate( mTodo->runStart().date() ); 123 sde->setDate( mTodo->runStart().date() );
124 ste->setTime( mTodo->runStart().time() ); 124 ste->setTime( mTodo->runStart().time() );
125 ede->setDate( QDate::currentDate()); 125 ede->setDate( QDate::currentDate());
126 ete->setTime( QTime::currentTime() ); 126 ete->setTime( QTime::currentTime() );
127 QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); 127 QPushButton * ok = new QPushButton( i18n("Stop and save"), this );
128 lay->addWidget( ok ); 128 lay->addWidget( ok );
129 ok->setDefault( true ); 129 ok->setDefault( true );
130 QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); 130 QPushButton * cancel = new QPushButton( i18n("Continue running"), this );
131 lay->addWidget( cancel ); 131 lay->addWidget( cancel );
132 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 132 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
133 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 133 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
134 ok = new QPushButton( i18n("Stop - do not save"), this ); 134 ok = new QPushButton( i18n("Stop - do not save"), this );
135 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); 135 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) );
136 lay->addWidget( ok ); 136 lay->addWidget( ok );
137 if (QApplication::desktop()->width() < 320 ) 137 if (QApplication::desktop()->width() < 320 )
138 resize( 240, sizeHint().height() ); 138 resize( 240, sizeHint().height() );
139 else 139 else
140 resize( 320, sizeHint().height() ); 140 resize( 320, sizeHint().height() );
141 141
142} 142}
143 143
144void KOStopTodoPrefs::accept() 144void KOStopTodoPrefs::accept()
145{ 145{
146 QDateTime start = QDateTime( sde->date(), ste->getTime() ); 146 QDateTime start = QDateTime( sde->date(), ste->getTime() );
147 QDateTime stop = QDateTime( ede->date(), ete->getTime() ); 147 QDateTime stop = QDateTime( ede->date(), ete->getTime() );
148 if ( start > stop ) { 148 if ( start > stop ) {
149 KMessageBox::sorry(this, 149 KMessageBox::sorry(this,
150 i18n("The start time is\nafter the end time!"), 150 i18n("The start time is\nafter the end time!"),
151 i18n("Time mismatch!")); 151 i18n("Time mismatch!"));
152 return; 152 return;
153 } 153 }
154 mTodo->saveRunningInfo( mComment->text(), start, stop ); 154 mTodo->saveRunningInfo( mComment->text(), start, stop );
155 QDialog::accept(); 155 QDialog::accept();
156} 156}
157void KOStopTodoPrefs::doNotSave() 157void KOStopTodoPrefs::doNotSave()
158{ 158{
159 int result = KMessageBox::warningContinueCancel(this, 159 int result = KMessageBox::warningContinueCancel(this,
160 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); 160 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") );
161 if (result != KMessageBox::Continue) return; 161 if (result != KMessageBox::Continue) return;
162 mTodo->stopRunning(); 162 mTodo->stopRunning();
163 QDialog::accept(); 163 QDialog::accept();
164} 164}
165 165
166 166
167class KOTodoViewWhatsThis :public QWhatsThis 167class KOTodoViewWhatsThis :public QWhatsThis
168{ 168{
169public: 169public:
170 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 170 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
171 171
172protected: 172protected:
173 virtual QString text( const QPoint& p) 173 virtual QString text( const QPoint& p)
174 { 174 {
175 return _view->getWhatsThisText(p) ; 175 return _view->getWhatsThisText(p) ;
176 } 176 }
177private: 177private:
178 QWidget* _wid; 178 QWidget* _wid;
179 KOTodoView * _view; 179 KOTodoView * _view;
180}; 180};
181 181
182KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 182KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
183 const char *name) : 183 const char *name) :
184 KListView(parent,name) 184 KListView(parent,name)
185{ 185{
186 mName = QString ( name ); 186 mName = QString ( name );
187 mCalendar = calendar; 187 mCalendar = calendar;
188#ifndef DESKTOP_VERSION 188#ifndef DESKTOP_VERSION
189 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 189 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
190#endif 190#endif
191 mOldCurrent = 0; 191 mOldCurrent = 0;
192 mMousePressed = false; 192 mMousePressed = false;
193 193
194 setAcceptDrops(true); 194 setAcceptDrops(true);
195 viewport()->setAcceptDrops(true); 195 viewport()->setAcceptDrops(true);
196 int size = 16; 196 int size = 16;
197 if (qApp->desktop()->width() < 300 ) 197 if (qApp->desktop()->width() < 300 )
198 size = 12; 198 size = 12;
199 setTreeStepSize( size + 6 ); 199 setTreeStepSize( size + 6 );
200 200
201} 201}
202 202
203void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 203void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
204{ 204{
205#ifndef KORG_NODND 205#ifndef KORG_NODND
206// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 206// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
207 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 207 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
208 !QTextDrag::canDecode( e ) ) { 208 !QTextDrag::canDecode( e ) ) {
209 e->ignore(); 209 e->ignore();
210 return; 210 return;
211 } 211 }
212 212
213 mOldCurrent = currentItem(); 213 mOldCurrent = currentItem();
214#endif 214#endif
215} 215}
216 216
217 217
218void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 218void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
219{ 219{
220#ifndef KORG_NODND 220#ifndef KORG_NODND
221// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 221// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
222 222
223 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 223 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
224 !QTextDrag::canDecode( e ) ) { 224 !QTextDrag::canDecode( e ) ) {
225 e->ignore(); 225 e->ignore();
226 return; 226 return;
227 } 227 }
228 228
229 e->accept(); 229 e->accept();
230#endif 230#endif
231} 231}
232 232
233void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 233void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
234{ 234{
235#ifndef KORG_NODND 235#ifndef KORG_NODND
236// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 236// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
237 237
238 setCurrentItem(mOldCurrent); 238 setCurrentItem(mOldCurrent);
239 setSelected(mOldCurrent,true); 239 setSelected(mOldCurrent,true);
240#endif 240#endif
241} 241}
242 242
243void KOTodoListView::contentsDropEvent(QDropEvent *e) 243void KOTodoListView::contentsDropEvent(QDropEvent *e)
244{ 244{
245#ifndef KORG_NODND 245#ifndef KORG_NODND
246// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 246// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
247 247
248 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 248 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
249 !QTextDrag::canDecode( e ) ) { 249 !QTextDrag::canDecode( e ) ) {
250 e->ignore(); 250 e->ignore();
251 return; 251 return;
252 } 252 }
253 253
254 DndFactory factory( mCalendar ); 254 DndFactory factory( mCalendar );
255 Todo *todo = factory.createDropTodo(e); 255 Todo *todo = factory.createDropTodo(e);
256 256
257 if (todo) { 257 if (todo) {
258 e->acceptAction(); 258 e->acceptAction();
259 259
260 KOTodoViewItem *destination = 260 KOTodoViewItem *destination =
261 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 261 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
262 Todo *destinationEvent = 0; 262 Todo *destinationEvent = 0;
263 if (destination) destinationEvent = destination->todo(); 263 if (destination) destinationEvent = destination->todo();
264 264
265 Todo *existingTodo = mCalendar->todo(todo->uid()); 265 Todo *existingTodo = mCalendar->todo(todo->uid());
266 266
267 if(existingTodo) { 267 if(existingTodo) {
268 Incidence *to = destinationEvent; 268 Incidence *to = destinationEvent;
269 while(to) { 269 while(to) {
270 if (to->uid() == todo->uid()) { 270 if (to->uid() == todo->uid()) {
271 KMessageBox::sorry(this, 271 KMessageBox::sorry(this,
272 i18n("Cannot move Todo to itself\nor a child of itself"), 272 i18n("Cannot move Todo to itself\nor a child of itself"),
273 i18n("Drop Todo")); 273 i18n("Drop Todo"));
274 delete todo; 274 delete todo;
275 return; 275 return;
276 } 276 }
277 to = to->relatedTo(); 277 to = to->relatedTo();
278 } 278 }
279 internalDrop = true; 279 internalDrop = true;
280 if ( destinationEvent ) 280 if ( destinationEvent )
281 reparentTodoSignal( destinationEvent, existingTodo ); 281 reparentTodoSignal( destinationEvent, existingTodo );
282 else 282 else
283 unparentTodoSignal(existingTodo); 283 unparentTodoSignal(existingTodo);
284 delete todo; 284 delete todo;
285 } else { 285 } else {
286 mCalendar->addTodo(todo); 286 mCalendar->addTodo(todo);
287 emit todoDropped(todo, KOGlobals::EVENTADDED); 287 emit todoDropped(todo, KOGlobals::EVENTADDED);
288 if ( destinationEvent ) 288 if ( destinationEvent )
289 reparentTodoSignal( destinationEvent, todo ); 289 reparentTodoSignal( destinationEvent, todo );
290 } 290 }
291 } 291 }
292 else { 292 else {
293 QString text; 293 QString text;
294 if (QTextDrag::decode(e,text)) { 294 if (QTextDrag::decode(e,text)) {
295 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 295 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
296 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 296 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
297 qDebug("Dropped : " + text); 297 qDebug("Dropped : " + text);
298 QStringList emails = QStringList::split(",",text); 298 QStringList emails = QStringList::split(",",text);
299 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 299 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
300 int pos = (*it).find("<"); 300 int pos = (*it).find("<");
301 QString name = (*it).left(pos); 301 QString name = (*it).left(pos);
302 QString email = (*it).mid(pos); 302 QString email = (*it).mid(pos);
303 if (!email.isEmpty() && todoi) { 303 if (!email.isEmpty() && todoi) {
304 todoi->todo()->addAttendee(new Attendee(name,email)); 304 todoi->todo()->addAttendee(new Attendee(name,email));
305 } 305 }
306 } 306 }
307 } 307 }
308 else { 308 else {
309 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 309 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
310 e->ignore(); 310 e->ignore();
311 } 311 }
312 } 312 }
313#endif 313#endif
314} 314}
315void KOTodoListView::wheelEvent (QWheelEvent *e) 315void KOTodoListView::wheelEvent (QWheelEvent *e)
316{ 316{
317 QListView::wheelEvent (e); 317 QListView::wheelEvent (e);
318} 318}
319 319
320void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 320void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
321{ 321{
322 322
323 QPoint p(contentsToViewport(e->pos())); 323 QPoint p(contentsToViewport(e->pos()));
324 QListViewItem *i = itemAt(p); 324 QListViewItem *i = itemAt(p);
325 bool rootClicked = true; 325 bool rootClicked = true;
326 if (i) { 326 if (i) {
327 // if the user clicked into the root decoration of the item, don't 327 // if the user clicked into the root decoration of the item, don't
328 // try to start a drag! 328 // try to start a drag!
329 int X = p.x(); 329 int X = p.x();
330 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 330 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
331 if (X > header()->sectionPos(0) + 331 if (X > header()->sectionPos(0) +
332 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 332 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
333 itemMargin() +i->height()|| 333 itemMargin() +i->height()||
334 X < header()->sectionPos(0)) { 334 X < header()->sectionPos(0)) {
335 rootClicked = false; 335 rootClicked = false;
336 } 336 }
337 } else { 337 } else {
338 rootClicked = false; 338 rootClicked = false;
339 } 339 }
340#ifndef KORG_NODND 340#ifndef KORG_NODND
341 mMousePressed = false; 341 mMousePressed = false;
342 if (! rootClicked && !( e->button() == RightButton) ) { 342 if (! rootClicked && !( e->button() == RightButton) ) {
343 mPressPos = e->pos(); 343 mPressPos = e->pos();
344 mMousePressed = true; 344 mMousePressed = true;
345 } else { 345 } else {
346 mMousePressed = false; 346 mMousePressed = false;
347 } 347 }
348#endif 348#endif
349 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 349 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
350#ifndef DESKTOP_VERSION 350#ifndef DESKTOP_VERSION
351 if (!( e->button() == RightButton && rootClicked) ) 351 if (!( e->button() == RightButton && rootClicked) )
352 QListView::contentsMousePressEvent(e); 352 QListView::contentsMousePressEvent(e);
353#else 353#else
354 QListView::contentsMousePressEvent(e); 354 QListView::contentsMousePressEvent(e);
355#endif 355#endif
356} 356}
357void KOTodoListView::paintEvent(QPaintEvent* e) 357void KOTodoListView::paintEvent(QPaintEvent* e)
358{ 358{
359 emit paintNeeded(); 359 emit paintNeeded();
360 QListView::paintEvent( e); 360 QListView::paintEvent( e);
361} 361}
362void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 362void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
363{ 363{
364 364
365#ifndef KORG_NODND 365#ifndef KORG_NODND
366 //QListView::contentsMouseMoveEvent(e); 366 //QListView::contentsMouseMoveEvent(e);
367 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 367 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
368 QApplication::startDragDistance()*3) { 368 QApplication::startDragDistance()*3) {
369 mMousePressed = false; 369 mMousePressed = false;
370 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 370 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
371 if (item) { 371 if (item) {
372 DndFactory factory( mCalendar ); 372 DndFactory factory( mCalendar );
373 ICalDrag *vd = factory.createDrag( 373 ICalDrag *vd = factory.createDrag(
374 ((KOTodoViewItem *)item)->todo(),viewport()); 374 ((KOTodoViewItem *)item)->todo(),viewport());
375 internalDrop = false; 375 internalDrop = false;
376 // we cannot do any senseful here, because the DnD is still broken in Qt 376 // we cannot do any senseful here, because the DnD is still broken in Qt
377 if (vd->drag()) { 377 if (vd->drag()) {
378 if ( !internalDrop ) { 378 if ( !internalDrop ) {
379 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 379 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
380 qDebug("Dnd: External move: Delete drag source "); 380 qDebug("Dnd: External move: Delete drag source ");
381 } else 381 } else
382 qDebug("Dnd: Internal move "); 382 qDebug("Dnd: Internal move ");
383 383
384 } else { 384 } else {
385 if ( !internalDrop ) { 385 if ( !internalDrop ) {
386 qDebug("Dnd: External Copy"); 386 qDebug("Dnd: External Copy");
387 } else 387 } else
388 qDebug("DnD: Internal copy: Copy pending"); 388 qDebug("DnD: Internal copy: Copy pending");
389 } 389 }
390 } 390 }
391 } 391 }
392#endif 392#endif
393} 393}
394void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 394void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
395{ 395{
396 if ( !e->isAutoRepeat() ) { 396 if ( !e->isAutoRepeat() ) {
397 mFlagKeyPressed = false; 397 mFlagKeyPressed = false;
398 } 398 }
399} 399}
400 400
401 401
402void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 402void KOTodoListView::keyPressEvent ( QKeyEvent * e )
403{ 403{
404 qApp->processEvents(); 404 qApp->processEvents();
405 if ( !isVisible() ) { 405 if ( !isVisible() ) {
406 e->ignore(); 406 e->ignore();
407 return; 407 return;
408 } 408 }
409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
410 e->ignore(); 410 e->ignore();
411 // qDebug(" ignore %d",e->isAutoRepeat() ); 411 // qDebug(" ignore %d",e->isAutoRepeat() );
412 return; 412 return;
413 } 413 }
414 if (! e->isAutoRepeat() ) 414 if (! e->isAutoRepeat() )
415 mFlagKeyPressed = true; 415 mFlagKeyPressed = true;
416 QListViewItem* cn; 416 QListViewItem* cn;
417 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 417 if ( (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && mName != "todolistsmall") {
418 cn = currentItem(); 418 cn = currentItem();
419 if ( cn ) { 419 if ( cn ) {
420 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 420 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
421 if ( ci ){ 421 if ( ci ){
422 if ( e->state() == ShiftButton ) 422 if ( e->state() == ShiftButton )
423 ci->setOn( false ); 423 ci->setOn( false );
424 else 424 else
425 ci->setOn( true ); 425 ci->setOn( true );
426 cn = cn->itemBelow(); 426 cn = cn->itemBelow();
427 if ( cn ) { 427 if ( cn ) {
428 setCurrentItem ( cn ); 428 setCurrentItem ( cn );
429 ensureItemVisible ( cn ); 429 ensureItemVisible ( cn );
430 } 430 }
431 431
432 } 432 }
433 } 433 }
434 434
435 e->accept(); 435 e->accept();
436 return; 436 return;
437 } 437 }
438 438
439 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 439 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
440 switch ( e->key() ) { 440 switch ( e->key() ) {
441 case Qt::Key_Down: 441 case Qt::Key_Down:
442 case Qt::Key_Up: 442 case Qt::Key_Up:
443 QListView::keyPressEvent ( e ); 443 QListView::keyPressEvent ( e );
444 e->accept(); 444 e->accept();
445 break; 445 break;
446 case Qt::Key_Left: 446 case Qt::Key_Left:
447 case Qt::Key_Right: 447 case Qt::Key_Right:
448 QListView::keyPressEvent ( e ); 448 QListView::keyPressEvent ( e );
449 e->accept(); 449 e->accept();
450 return; 450 return;
451 break; 451 break;
452 default: 452 default:
453 e->ignore(); 453 e->ignore();
454 break; 454 break;
455 } 455 }
456 return; 456 return;
457 } 457 }
458 e->ignore(); 458 e->ignore();
459} 459}
460void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 460void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
461{ 461{
462 QListView::contentsMouseReleaseEvent(e); 462 QListView::contentsMouseReleaseEvent(e);
463 mMousePressed = false; 463 mMousePressed = false;
464} 464}
465 465
466void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 466void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
467{ 467{
468 if (!e) return; 468 if (!e) return;
469 469
470 QPoint vp = contentsToViewport(e->pos()); 470 QPoint vp = contentsToViewport(e->pos());
471 471
472 QListViewItem *item = itemAt(vp); 472 QListViewItem *item = itemAt(vp);
473 473
474 emit double_Clicked(item); 474 emit double_Clicked(item);
475 if (!item) return; 475 if (!item) return;
476 476
477 emit doubleClicked(item,vp,0); 477 emit doubleClicked(item,vp,0);
478} 478}
479 479
480///////////////////////////////////////////////////////////////////////////// 480/////////////////////////////////////////////////////////////////////////////
481 481
482KOQuickTodo::KOQuickTodo(QWidget *parent) : 482KOQuickTodo::KOQuickTodo(QWidget *parent) :
483 QLineEdit(parent) 483 QLineEdit(parent)
484{ 484{
485 setText(i18n("Click to add new Todo")); 485 setText(i18n("Click to add new Todo"));
486} 486}
487 487
488void KOQuickTodo::focusInEvent(QFocusEvent *ev) 488void KOQuickTodo::focusInEvent(QFocusEvent *ev)
489{ 489{
490 if ( text()==i18n("Click to add new Todo") ) 490 if ( text()==i18n("Click to add new Todo") )
491 setText(""); 491 setText("");
492 QLineEdit::focusInEvent(ev); 492 QLineEdit::focusInEvent(ev);
493} 493}
494 494
495void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 495void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
496{ 496{
497 setText(i18n("Click to add new Todo")); 497 setText(i18n("Click to add new Todo"));
498 QLineEdit::focusOutEvent(ev); 498 QLineEdit::focusOutEvent(ev);
499} 499}
500 500
501///////////////////////////////////////////////////////////////////////////// 501/////////////////////////////////////////////////////////////////////////////
502 502
503KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 503KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
504 KOrg::BaseView(calendar,parent,name) 504 KOrg::BaseView(calendar,parent,name)
505{ 505{
506 mCategoryPopupMenu = 0; 506 mCategoryPopupMenu = 0;
507 mPendingUpdateBeforeRepaint = false; 507 mPendingUpdateBeforeRepaint = false;
508 isFlatDisplay = false; 508 isFlatDisplay = false;
509 mNavigator = 0; 509 mNavigator = 0;
510 QBoxLayout *topLayout = new QVBoxLayout(this); 510 QBoxLayout *topLayout = new QVBoxLayout(this);
511 mName = QString ( name ); 511 mName = QString ( name );
512 mBlockUpdate = false; 512 mBlockUpdate = false;
513 mQuickBar = new QWidget( this ); 513 mQuickBar = new QWidget( this );
514 topLayout->addWidget(mQuickBar); 514 topLayout->addWidget(mQuickBar);
515 515
516 mQuickAdd = new KOQuickTodo(mQuickBar); 516 mQuickAdd = new KOQuickTodo(mQuickBar);
517 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); 517 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar);
518 quickLayout->addWidget( mQuickAdd ); 518 quickLayout->addWidget( mQuickAdd );
519 mNewSubBut = new QPushButton( "sub",mQuickBar ); 519 mNewSubBut = new QPushButton( "sub",mQuickBar );
520 QPushButton * s_done = new QPushButton( "D",mQuickBar ); 520 QPushButton * s_done = new QPushButton( "D",mQuickBar );
521 QPushButton * s_run = new QPushButton( "R",mQuickBar ); 521 QPushButton * s_run = new QPushButton( "R",mQuickBar );
522 QPushButton * allopen = new QPushButton( "O",mQuickBar ); 522 QPushButton * allopen = new QPushButton( "O",mQuickBar );
523 QPushButton * allclose = new QPushButton( "C",mQuickBar ); 523 QPushButton * allclose = new QPushButton( "C",mQuickBar );
524 QPushButton * flat = new QPushButton( "F",mQuickBar ); 524 QPushButton * flat = new QPushButton( "F",mQuickBar );
525 525
526 int fixwid = mQuickAdd->sizeHint().height(); 526 int fixwid = mQuickAdd->sizeHint().height();
527 int fixhei = fixwid; 527 int fixhei = fixwid;
528 if ( QApplication::desktop()->width() > 800 ) 528 if ( QApplication::desktop()->width() > 800 )
529 fixwid = (fixwid*3)/2; 529 fixwid = (fixwid*3)/2;
530 connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); 530 connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat()));
531 connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); 531 connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen()));
532 connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); 532 connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose()));
533 s_done->setPixmap( SmallIcon("greenhook16")); 533 s_done->setPixmap( SmallIcon("greenhook16"));
534 connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); 534 connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted()));
535 s_run->setPixmap( SmallIcon("ko16old")); 535 s_run->setPixmap( SmallIcon("ko16old"));
536 connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); 536 connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning()));
537 537
538 connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); 538 connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo()));
539 539
540 mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); 540 mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() );
541 mNewSubBut->setEnabled( false ); 541 mNewSubBut->setEnabled( false );
542 flat->setFixedWidth( fixwid ); 542 flat->setFixedWidth( fixwid );
543 s_done->setFixedWidth( fixwid ); 543 s_done->setFixedWidth( fixwid );
544 allopen->setFixedWidth( fixwid ); 544 allopen->setFixedWidth( fixwid );
545 allclose->setFixedWidth( fixwid ); 545 allclose->setFixedWidth( fixwid );
546 s_run->setFixedWidth( fixwid ); 546 s_run->setFixedWidth( fixwid );
547 547
548 flat->setFixedHeight(fixhei ); 548 flat->setFixedHeight(fixhei );
549 s_done->setFixedHeight(fixhei ); 549 s_done->setFixedHeight(fixhei );
550 allopen->setFixedHeight(fixhei ); 550 allopen->setFixedHeight(fixhei );
551 allclose->setFixedHeight(fixhei ); 551 allclose->setFixedHeight(fixhei );
552 s_run->setFixedHeight(fixhei ); 552 s_run->setFixedHeight(fixhei );
553 mNewSubBut->setFixedHeight(fixhei ); 553 mNewSubBut->setFixedHeight(fixhei );
554 554
555 quickLayout->addWidget( mNewSubBut ); 555 quickLayout->addWidget( mNewSubBut );
556 quickLayout->addWidget( s_done ); 556 quickLayout->addWidget( s_done );
557 quickLayout->addWidget( s_run ); 557 quickLayout->addWidget( s_run );
558 quickLayout->addWidget( allopen ); 558 quickLayout->addWidget( allopen );
559 quickLayout->addWidget( allclose ); 559 quickLayout->addWidget( allclose );
560 quickLayout->addWidget( flat ); 560 quickLayout->addWidget( flat );
561 561
562 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); 562 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide();
563 563
564 mTodoListView = new KOTodoListView(calendar,this, name ); 564 mTodoListView = new KOTodoListView(calendar,this, name );
565 topLayout->addWidget(mTodoListView); 565 topLayout->addWidget(mTodoListView);
566 //mTodoListView->header()->setMaximumHeight(30); 566 //mTodoListView->header()->setMaximumHeight(30);
567 mTodoListView->setRootIsDecorated(true); 567 mTodoListView->setRootIsDecorated(true);
568 mTodoListView->setAllColumnsShowFocus(true); 568 mTodoListView->setAllColumnsShowFocus(true);
569 569
570 mTodoListView->setShowSortIndicator(true); 570 mTodoListView->setShowSortIndicator(true);
571 571
572 mTodoListView->addColumn(i18n("Todo")); 572 mTodoListView->addColumn(i18n("Todo"));
573 mTodoListView->addColumn(i18n("Prio")); 573 mTodoListView->addColumn(i18n("Prio"));
574 mTodoListView->setColumnAlignment(1,AlignHCenter); 574 mTodoListView->setColumnAlignment(1,AlignHCenter);
575 mTodoListView->addColumn(i18n("Complete")); 575 mTodoListView->addColumn(i18n("Complete"));
576 mTodoListView->setColumnAlignment(2,AlignCenter); 576 mTodoListView->setColumnAlignment(2,AlignCenter);
577 577
578 mTodoListView->addColumn(i18n("Due Date")); 578 mTodoListView->addColumn(i18n("Due Date"));
579 mTodoListView->setColumnAlignment(3,AlignLeft); 579 mTodoListView->setColumnAlignment(3,AlignLeft);
580 mTodoListView->addColumn(i18n("Due Time")); 580 mTodoListView->addColumn(i18n("Due Time"));
581 mTodoListView->setColumnAlignment(4,AlignHCenter); 581 mTodoListView->setColumnAlignment(4,AlignHCenter);
582 582
583 mTodoListView->addColumn(i18n("Start Date")); 583 mTodoListView->addColumn(i18n("Start Date"));
584 mTodoListView->setColumnAlignment(5,AlignLeft); 584 mTodoListView->setColumnAlignment(5,AlignLeft);
585 mTodoListView->addColumn(i18n("Start Time")); 585 mTodoListView->addColumn(i18n("Start Time"));
586 mTodoListView->setColumnAlignment(6,AlignHCenter); 586 mTodoListView->setColumnAlignment(6,AlignHCenter);
587 587
588 //mTodoListView->addColumn(i18n("Cancelled")); 588 //mTodoListView->addColumn(i18n("Cancelled"));
589 mTodoListView->addColumn(i18n("Categories")); 589 mTodoListView->addColumn(i18n("Categories"));
590 mTodoListView->addColumn(i18n("Calendar")); 590 mTodoListView->addColumn(i18n("Calendar"));
591 mTodoListView->addColumn(i18n("Last Modified")); 591 mTodoListView->addColumn(i18n("Last Modified"));
592 mTodoListView->addColumn(i18n("Created")); 592 mTodoListView->addColumn(i18n("Created"));
593 mTodoListView->addColumn(i18n("Last Modified Sub")); 593 mTodoListView->addColumn(i18n("Last Modified Sub"));
594#if 0 594#if 0
595 mTodoListView->addColumn(i18n("Sort Id")); 595 mTodoListView->addColumn(i18n("Sort Id"));
596 mTodoListView->setColumnAlignment(4,AlignHCenter); 596 mTodoListView->setColumnAlignment(4,AlignHCenter);
597#endif 597#endif
598 598
599 mTodoListView->setMinimumHeight( 60 ); 599 mTodoListView->setMinimumHeight( 60 );
600 mTodoListView->setItemsRenameable( true ); 600 mTodoListView->setItemsRenameable( true );
601 mTodoListView->setRenameable( 0 ); 601 mTodoListView->setRenameable( 0 );
602 mTodoListView->setColumnWidth( 0, 120 ); 602 mTodoListView->setColumnWidth( 0, 120 );
603 int iii = 0; 603 int iii = 0;
604 for ( iii = 0; iii< 12 ; ++iii ) 604 for ( iii = 0; iii< 12 ; ++iii )
605 mTodoListView->setColumnWidthMode( iii, QListView::Manual ); 605 mTodoListView->setColumnWidthMode( iii, QListView::Manual );
606 606
607 607
608 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 608 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
609 609
610 mPriorityPopupMenu = new QPopupMenu(this); 610 mPriorityPopupMenu = new QPopupMenu(this);
611 for (int i = 1; i <= 5; i++) { 611 for (int i = 1; i <= 5; i++) {
612 QString label = QString ("%1").arg (i); 612 QString label = QString ("%1").arg (i);
613 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 613 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
614 } 614 }
615 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 615 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
616 616
617 mPercentageCompletedPopupMenu = new QPopupMenu(this); 617 mPercentageCompletedPopupMenu = new QPopupMenu(this);
618 for (int i = 0; i <= 100; i+=20) { 618 for (int i = 0; i <= 100; i+=20) {
619 QString label = QString ("%1 %").arg (i); 619 QString label = QString ("%1 %").arg (i);
620 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 620 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
621 } 621 }
622 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 622 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
623 623
624 624
625 mCategoryPopupMenu = new QPopupMenu (this); 625 mCategoryPopupMenu = new QPopupMenu (this);
626 mCategoryPopupMenu->setCheckable (true); 626 mCategoryPopupMenu->setCheckable (true);
627 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 627 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
628 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); 628 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ()));
629 629
630 mCalPopupMenu = new QPopupMenu (this); 630 mCalPopupMenu = new QPopupMenu (this);
631 mCalPopupMenu->setCheckable (true); 631 mCalPopupMenu->setCheckable (true);
632 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); 632 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int)));
633 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); 633 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ()));
634 634
635 635
636 636
637 637
638 mItemPopupMenu = new QPopupMenu(this); 638 mItemPopupMenu = new QPopupMenu(this);
639 mItemPopupMenu->insertItem(i18n("Show"), this, 639 mItemPopupMenu->insertItem(i18n("Show"), this,
640 SLOT (showTodo())); 640 SLOT (showTodo()));
641 mItemPopupMenu->insertItem(i18n("Edit..."), this, 641 mItemPopupMenu->insertItem(i18n("Edit..."), this,
642 SLOT (editTodo())); 642 SLOT (editTodo()));
643 mItemPopupMenu->insertItem( i18n("Delete..."), this, 643 mItemPopupMenu->insertItem( i18n("Delete..."), this,
644 SLOT (deleteTodo())); 644 SLOT (deleteTodo()));
645 mItemPopupMenu->insertItem( i18n("Clone..."), this, 645 mItemPopupMenu->insertItem( i18n("Clone..."), this,
646 SLOT (cloneTodo())); 646 SLOT (cloneTodo()));
647 mItemPopupMenu->insertItem( i18n("Move..."), this, 647 mItemPopupMenu->insertItem( i18n("Move..."), this,
648 SLOT (moveTodo())); 648 SLOT (moveTodo()));
649#ifndef DESKTOP_VERSION 649#ifndef DESKTOP_VERSION
650 mItemPopupMenu->insertItem( i18n("Beam..."), this, 650 mItemPopupMenu->insertItem( i18n("Beam..."), this,
651 SLOT (beamTodo())); 651 SLOT (beamTodo()));
652#endif 652#endif
653 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 653 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
654 SLOT (cancelTodo())); 654 SLOT (cancelTodo()));
655 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); 655 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu);
656 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); 656 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu);
657 mItemPopupMenu->insertSeparator(); 657 mItemPopupMenu->insertSeparator();
658 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 658 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
659 SLOT (toggleRunningItem())); 659 SLOT (toggleRunningItem()));
660 mItemPopupMenu->insertSeparator(); 660 mItemPopupMenu->insertSeparator();
661 /* 661 /*
662 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 662 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
663 SLOT (newTodo())); 663 SLOT (newTodo()));
664 */ 664 */
665 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 665 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
666 SLOT (newSubTodo())); 666 SLOT (newSubTodo()));
667 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 667 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
668 SLOT (unparentTodo()),0,21); 668 SLOT (unparentTodo()),0,21);
669 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 669 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
670 SLOT (reparentTodo()),0,22); 670 SLOT (reparentTodo()),0,22);
671 mItemPopupMenu->insertSeparator(); 671 mItemPopupMenu->insertSeparator();
672#if 0 672#if 0
673 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), 673 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."),
674 this, SLOT( purgeCompleted() ) ); 674 this, SLOT( purgeCompleted() ) );
675 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 675 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
676 this, SLOT( toggleCompleted() ),0, 33 ); 676 this, SLOT( toggleCompleted() ),0, 33 );
677 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 677 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
678 this, SLOT( toggleQuickTodo() ),0, 34 ); 678 this, SLOT( toggleQuickTodo() ),0, 34 );
679 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 679 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
680 this, SLOT( toggleRunning() ),0, 35 ); 680 this, SLOT( toggleRunning() ),0, 35 );
681 681
682#endif 682#endif
683 mPopupMenu = new QPopupMenu(this); 683 mPopupMenu = new QPopupMenu(this);
684 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 684 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
685 SLOT (newTodo()),0,1); 685 SLOT (newTodo()),0,1);
686 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), 686 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."),
687 this, SLOT(purgeCompleted()),0,2); 687 this, SLOT(purgeCompleted()),0,2);
688 mPopupMenu->insertItem(i18n("Show Completed"), 688 mPopupMenu->insertItem(i18n("Show Completed"),
689 this, SLOT( toggleCompleted() ),0,3 ); 689 this, SLOT( toggleCompleted() ),0,3 );
690 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 690 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
691 this, SLOT( toggleRunning() ),0,5 ); 691 this, SLOT( toggleRunning() ),0,5 );
692 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 692 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
693 this, SLOT( setAllOpen() ),0,6 ); 693 this, SLOT( setAllOpen() ),0,6 );
694 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 694 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
695 this, SLOT( setAllClose() ),0,7 ); 695 this, SLOT( setAllClose() ),0,7 );
696 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 696 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
697 this, SLOT( setAllFlat() ),0,8 ); 697 this, SLOT( setAllFlat() ),0,8 );
698 mPopupMenu->insertSeparator(); 698 mPopupMenu->insertSeparator();
699 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 699 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
700 this, SLOT( toggleQuickTodo() ),0,4 ); 700 this, SLOT( toggleQuickTodo() ),0,4 );
701 mDocPrefs = new DocPrefs( name ); 701 mDocPrefs = new DocPrefs( name );
702 702
703 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 703 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
704 mPopupMenu->setCheckable( true ); 704 mPopupMenu->setCheckable( true );
705 mItemPopupMenu->setCheckable( true ); 705 mItemPopupMenu->setCheckable( true );
706 706
707 707
708 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 708 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
709 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 709 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
710 710
711 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 711 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
712 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 712 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
713 713
714 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 714 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
715 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 715 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
716 716
717 717
718 // Double clicking conflicts with opening/closing the subtree 718 // Double clicking conflicts with opening/closing the subtree
719 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 719 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
720 SLOT( editItem( QListViewItem *) ) ); 720 SLOT( editItem( QListViewItem *) ) );
721 /* 721 /*
722 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 722 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
723 const QPoint &,int ) ), 723 const QPoint &,int ) ),
724 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 724 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
725 */ 725 */
726 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 726 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
727 const QPoint &,int ) ), 727 const QPoint &,int ) ),
728 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 728 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
729 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 729 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
730 SLOT( itemClicked( QListViewItem * ) ) ); 730 SLOT( itemClicked( QListViewItem * ) ) );
731 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 731 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
732 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 732 SLOT( itemDoubleClicked( QListViewItem * ) ) );
733 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 733 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
734 SLOT( updateView() ) ); 734 SLOT( updateView() ) );
735 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 735 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
736 SLOT( todoModified(Todo *, int) ) ); 736 SLOT( todoModified(Todo *, int) ) );
737 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 737 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
738 SLOT( itemStateChanged( QListViewItem * ) ) ); 738 SLOT( itemStateChanged( QListViewItem * ) ) );
739 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 739 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
740 SLOT( itemStateChanged( QListViewItem * ) ) ); 740 SLOT( itemStateChanged( QListViewItem * ) ) );
741 connect( mTodoListView, SIGNAL( paintNeeded() ), 741 connect( mTodoListView, SIGNAL( paintNeeded() ),
742 SLOT( paintNeeded()) ); 742 SLOT( paintNeeded()) );
743 743
744#if 0 744#if 0
745 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 745 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
746 SLOT(selectionChanged(QListViewItem *))); 746 SLOT(selectionChanged(QListViewItem *)));
747 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 747 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
748 SLOT(selectionChanged(QListViewItem *))); 748 SLOT(selectionChanged(QListViewItem *)));
749 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 749 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
750 SLOT(selectionChanged(QListViewItem *))); 750 SLOT(selectionChanged(QListViewItem *)));
751#endif 751#endif
752 752
753 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 753 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
754 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 754 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
755 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 755 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
756 756
757 connect( mTodoListView, SIGNAL(selectionChanged() ), 757 connect( mTodoListView, SIGNAL(selectionChanged() ),
758 SLOT( processSelectionChange() ) ); 758 SLOT( processSelectionChange() ) );
759 connect( mQuickAdd, SIGNAL( returnPressed () ), 759 connect( mQuickAdd, SIGNAL( returnPressed () ),
760 SLOT( addQuickTodo() ) ); 760 SLOT( addQuickTodo() ) );
761 761
762} 762}
763 763
764KOTodoView::~KOTodoView() 764KOTodoView::~KOTodoView()
765{ 765{
766 766
767#if QT_VERSION >= 0x030000 767#if QT_VERSION >= 0x030000
768 768
769#else 769#else
770 delete mKOTodoViewWhatsThis; 770 delete mKOTodoViewWhatsThis;
771#endif 771#endif
772 772
773 delete mDocPrefs; 773 delete mDocPrefs;
774} 774}
775QString KOTodoView::getWhatsThisText(QPoint p) 775QString KOTodoView::getWhatsThisText(QPoint p)
776{ 776{
777 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 777 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
778 if ( item ) 778 if ( item )
779 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 779 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
780 KOPrefs::instance()->mWTshowDetails, 780 KOPrefs::instance()->mWTshowDetails,
781 KOPrefs::instance()->mWTshowCreated, 781 KOPrefs::instance()->mWTshowCreated,
782 KOPrefs::instance()->mWTshowChanged); 782 KOPrefs::instance()->mWTshowChanged);
783 return i18n("That is the todo view" ); 783 return i18n("That is the todo view" );
784 784
785} 785}
786 786
787void KOTodoView::jumpToDate () 787void KOTodoView::jumpToDate ()
788{ 788{
789 // if (mActiveItem) { 789 // if (mActiveItem) {
790// mActiveItem->todo()); 790// mActiveItem->todo());
791// if ( mActiveItem->todo()->hasDueDate() ) 791// if ( mActiveItem->todo()->hasDueDate() )
792// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 792// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
793} 793}
794void KOTodoView::paintNeeded() 794void KOTodoView::paintNeeded()
795{ 795{
796 if ( mPendingUpdateBeforeRepaint ) { 796 if ( mPendingUpdateBeforeRepaint ) {
797 updateView(); 797 updateView();
798 mPendingUpdateBeforeRepaint = false; 798 mPendingUpdateBeforeRepaint = false;
799 } 799 }
800} 800}
801void KOTodoView::paintEvent(QPaintEvent * pevent) 801void KOTodoView::paintEvent(QPaintEvent * pevent)
802{ 802{
803 if ( mPendingUpdateBeforeRepaint ) { 803 if ( mPendingUpdateBeforeRepaint ) {
804 updateView(); 804 updateView();
805 mPendingUpdateBeforeRepaint = false; 805 mPendingUpdateBeforeRepaint = false;
806 } 806 }
807 KOrg::BaseView::paintEvent( pevent); 807 KOrg::BaseView::paintEvent( pevent);
808} 808}
809 809
810void KOTodoView::updateView() 810void KOTodoView::updateView()
811{ 811{
812 pendingSubtodo = 0; 812 pendingSubtodo = 0;
813 if ( mBlockUpdate ) { 813 if ( mBlockUpdate ) {
814 return; 814 return;
815 } 815 }
816 if ( !isVisible() ) { 816 if ( !isVisible() ) {
817 mPendingUpdateBeforeRepaint = true; 817 mPendingUpdateBeforeRepaint = true;
818 return; 818 return;
819 } 819 }
820 //qDebug("KOTodoView::updateView() %x", this); 820 //qDebug("KOTodoView::updateView() %x", this);
821 if ( isFlatDisplay ) { 821 if ( isFlatDisplay ) {
822 displayAllFlat(); 822 displayAllFlat();
823 return; 823 return;
824 } 824 }
825 storeCurrentItem(); 825 storeCurrentItem();
826 //qDebug("update "); 826 //qDebug("update ");
827// kdDebug() << "KOTodoView::updateView()" << endl; 827// kdDebug() << "KOTodoView::updateView()" << endl;
828 QFont fo = KOPrefs::instance()->mTodoViewFont; 828 QFont fo = KOPrefs::instance()->mTodoViewFont;
829 829
830 830
831 mTodoListView->clear(); 831 mTodoListView->clear();
832 if ( mName == "todolistsmall" ) { 832 if ( mName == "todolistsmall" ) {
833 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 833 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
834 int ps = fo.pointSize() -2; 834 int ps = fo.pointSize() -2;
835 if ( ps > 12 ) 835 if ( ps > 12 )
836 ps -= 2; 836 ps -= 2;
837 fo.setPointSize( ps ); 837 fo.setPointSize( ps );
838 } 838 }
839 } 839 }
840 840
841 mTodoListView->setFont( fo ); 841 mTodoListView->setFont( fo );
842 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 842 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
843 //mTodoListView->header()->setMaximumHeight(fm.height()); 843 //mTodoListView->header()->setMaximumHeight(fm.height());
844 QPtrList<Todo> todoList = calendar()->todos(); 844 QPtrList<Todo> todoList = calendar()->todos();
845 845
846/* 846/*
847 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 847 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
848 Event *t; 848 Event *t;
849 for(t = todoList.first(); t; t = todoList.next()) { 849 for(t = todoList.first(); t; t = todoList.next()) {
850 kdDebug() << " " << t->getSummary() << endl; 850 kdDebug() << " " << t->getSummary() << endl;
851 851
852 if (t->getRelatedTo()) { 852 if (t->getRelatedTo()) {
853 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 853 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
854 } 854 }
855 855
856 QPtrList<Event> l = t->getRelations(); 856 QPtrList<Event> l = t->getRelations();
857 Event *c; 857 Event *c;
858 for(c=l.first();c;c=l.next()) { 858 for(c=l.first();c;c=l.next()) {
859 kdDebug() << " - relation: " << c->getSummary() << endl; 859 kdDebug() << " - relation: " << c->getSummary() << endl;
860 } 860 }
861 } 861 }
862*/ 862*/
863 863
864 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 864 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
865 // specific order of events. That means that we have to generate parent items 865 // specific order of events. That means that we have to generate parent items
866 // recursively for proper hierarchical display of Todos. 866 // recursively for proper hierarchical display of Todos.
867 mTodoMap.clear(); 867 mTodoMap.clear();
868 Todo *todo; 868 Todo *todo;
869 todo = todoList.first();// todo; todo = todoList.next()) { 869 todo = todoList.first();// todo; todo = todoList.next()) {
870 while ( todo ) { 870 while ( todo ) {
871 bool next = true; 871 bool next = true;
872 // qDebug("todo %s ", todo->summary().latin1()); 872 // qDebug("todo %s ", todo->summary().latin1());
873 Incidence *incidence = todo->relatedTo(); 873 Incidence *incidence = todo->relatedTo();
874 while ( incidence ) { 874 while ( incidence ) {
875 if ( incidence->typeID() == todoID ) { 875 if ( incidence->typeID() == todoID ) {
876 //qDebug("related %s ",incidence->summary().latin1() ); 876 //qDebug("related %s ",incidence->summary().latin1() );
877 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { 877 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) {
878 //qDebug("related not found "); 878 //qDebug("related not found ");
879 todoList.remove( ); 879 todoList.remove( );
880 todo = todoList.current(); 880 todo = todoList.current();
881 next = false; 881 next = false;
882 incidence = 0; 882 incidence = 0;
883 883
884 } else { 884 } else {
885 //qDebug("related found "); 885 //qDebug("related found ");
886 incidence = incidence->relatedTo(); 886 incidence = incidence->relatedTo();
887 } 887 }
888 } else 888 } else
889 incidence = 0; 889 incidence = 0;
890 } 890 }
891 if ( next ) 891 if ( next )
892 todo = todoList.next(); 892 todo = todoList.next();
893 } 893 }
894 894
895 for(todo = todoList.first(); todo; todo = todoList.next()) { 895 for(todo = todoList.first(); todo; todo = todoList.next()) {
896 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 896 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
897 { 897 {
898 insertTodoItem(todo); 898 insertTodoItem(todo);
899 } 899 }
900 } 900 }
901 // Restore opened/closed state 901 // Restore opened/closed state
902 mTodoListView->blockSignals( true ); 902 mTodoListView->blockSignals( true );
903 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 903 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
904 mTodoListView->blockSignals( false ); 904 mTodoListView->blockSignals( false );
905 resetCurrentItem(); 905 resetCurrentItem();
906} 906}
907 907
908void KOTodoView::storeCurrentItem() 908void KOTodoView::storeCurrentItem()
909{ 909{
910 mCurItem = 0; 910 mCurItem = 0;
911 mCurItemRootParent = 0; 911 mCurItemRootParent = 0;
912 mCurItemParent = 0; 912 mCurItemParent = 0;
913 mCurItemAbove = 0; 913 mCurItemAbove = 0;
914 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 914 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
915 if (mActiveItem) { 915 if (mActiveItem) {
916 mCurItem = mActiveItem->todo(); 916 mCurItem = mActiveItem->todo();
917 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 917 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
918 if ( activeItemAbove ) 918 if ( activeItemAbove )
919 mCurItemAbove = activeItemAbove->todo(); 919 mCurItemAbove = activeItemAbove->todo();
920 mCurItemRootParent = mCurItem; 920 mCurItemRootParent = mCurItem;
921 mCurItemParent = mCurItemRootParent->relatedTo(); 921 mCurItemParent = mCurItemRootParent->relatedTo();
922 while ( mCurItemRootParent->relatedTo() != 0 ) 922 while ( mCurItemRootParent->relatedTo() != 0 )
923 mCurItemRootParent = mCurItemRootParent->relatedTo(); 923 mCurItemRootParent = mCurItemRootParent->relatedTo();
924 } 924 }
925 mActiveItem = 0; 925 mActiveItem = 0;
926} 926}
927 927
928void KOTodoView::resetCurrentItem() 928void KOTodoView::resetCurrentItem()
929{ 929{
@@ -1183,542 +1183,539 @@ void KOTodoView::moveTodo()
1183 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 1183 emit moveTodoSignal((Incidence*)mActiveItem->todo());
1184 } 1184 }
1185} 1185}
1186void KOTodoView::beamTodo() 1186void KOTodoView::beamTodo()
1187{ 1187{
1188 if (mActiveItem) { 1188 if (mActiveItem) {
1189 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 1189 emit beamTodoSignal((Incidence*)mActiveItem->todo());
1190 } 1190 }
1191} 1191}
1192 1192
1193 1193
1194void KOTodoView::showTodo() 1194void KOTodoView::showTodo()
1195{ 1195{
1196 if (mActiveItem) { 1196 if (mActiveItem) {
1197 emit showTodoSignal(mActiveItem->todo()); 1197 emit showTodoSignal(mActiveItem->todo());
1198 } 1198 }
1199} 1199}
1200 1200
1201void KOTodoView::deleteTodo() 1201void KOTodoView::deleteTodo()
1202{ 1202{
1203 if (mActiveItem) { 1203 if (mActiveItem) {
1204 emit deleteTodoSignal(mActiveItem->todo()); 1204 emit deleteTodoSignal(mActiveItem->todo());
1205 } 1205 }
1206} 1206}
1207 1207
1208void KOTodoView::setNewPriority(int index) 1208void KOTodoView::setNewPriority(int index)
1209{ 1209{
1210 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1210 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1211 mActiveItem->todo()->setPriority(mPriority[index]); 1211 mActiveItem->todo()->setPriority(mPriority[index]);
1212 mActiveItem->construct(); 1212 mActiveItem->construct();
1213 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1213 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1214 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1214 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1215 } 1215 }
1216 processSelectionChange(); 1216 processSelectionChange();
1217} 1217}
1218 1218
1219void KOTodoView::setNewPercentage(int index) 1219void KOTodoView::setNewPercentage(int index)
1220{ 1220{
1221 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1221 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1222 1222
1223 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1223 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1224 mActiveItem->setOn( true ); 1224 mActiveItem->setOn( true );
1225 processSelectionChange(); 1225 processSelectionChange();
1226 return; 1226 return;
1227 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1227 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1228 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1228 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1229 if ( par && par->isOn() ) 1229 if ( par && par->isOn() )
1230 par->setOn( false ); 1230 par->setOn( false );
1231 } 1231 }
1232 if (mPercentage[index] == 100) { 1232 if (mPercentage[index] == 100) {
1233 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1233 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1234 } else { 1234 } else {
1235 mActiveItem->todo()->setCompleted(false); 1235 mActiveItem->todo()->setCompleted(false);
1236 } 1236 }
1237 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1237 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1238 mActiveItem->construct(); 1238 mActiveItem->construct();
1239 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1239 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1240 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1240 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1241 } 1241 }
1242 processSelectionChange(); 1242 processSelectionChange();
1243} 1243}
1244 1244
1245void KOTodoView::fillCategories () 1245void KOTodoView::fillCategories ()
1246{ 1246{
1247 mCategoryPopupMenu->clear(); 1247 mCategoryPopupMenu->clear();
1248 if ( ! mActiveItem ) return; 1248 if ( ! mActiveItem ) return;
1249 QStringList checkedCategories = mActiveItem->todo()->categories (); 1249 QStringList checkedCategories = mActiveItem->todo()->categories ();
1250 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1250 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1251 it != KOPrefs::instance()->mCustomCategories.end (); 1251 it != KOPrefs::instance()->mCustomCategories.end ();
1252 ++it) { 1252 ++it) {
1253 int index = mCategoryPopupMenu->insertItem (*it); 1253 int index = mCategoryPopupMenu->insertItem (*it);
1254 mCategory[index] = *it; 1254 mCategory[index] = *it;
1255 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); 1255 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true);
1256 } 1256 }
1257} 1257}
1258void KOTodoView::fillCal () 1258void KOTodoView::fillCal ()
1259{ 1259{
1260 mCalPopupMenu->clear(); 1260 mCalPopupMenu->clear();
1261 if (!mActiveItem) return; 1261 if (!mActiveItem) return;
1262 bool readO = mActiveItem->todo()->isReadOnly(); 1262 bool readO = mActiveItem->todo()->isReadOnly();
1263 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 1263 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
1264 while ( kkf ) { 1264 while ( kkf ) {
1265 int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); 1265 int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber);
1266 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) 1266 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO )
1267 mCalPopupMenu->setItemEnabled( index, false ); 1267 mCalPopupMenu->setItemEnabled( index, false );
1268 mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); 1268 mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID());
1269 kkf = KOPrefs::instance()->mCalendars.next(); 1269 kkf = KOPrefs::instance()->mCalendars.next();
1270 } 1270 }
1271} 1271}
1272void KOTodoView::changedCal (int index ) 1272void KOTodoView::changedCal (int index )
1273{ 1273{
1274 if (!mActiveItem) return; 1274 if (!mActiveItem) return;
1275 mActiveItem->todo()->setCalID( index ); 1275 mActiveItem->todo()->setCalID( index );
1276 mActiveItem->construct(); 1276 mActiveItem->construct();
1277} 1277}
1278void KOTodoView::changedCategories(int index) 1278void KOTodoView::changedCategories(int index)
1279{ 1279{
1280 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1280 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1281 QStringList categories = mActiveItem->todo()->categories (); 1281 QStringList categories = mActiveItem->todo()->categories ();
1282 QString colcat = categories.first(); 1282 QString colcat = categories.first();
1283 if (categories.find (mCategory[index]) != categories.end ()) 1283 if (categories.find (mCategory[index]) != categories.end ())
1284 categories.remove (mCategory[index]); 1284 categories.remove (mCategory[index]);
1285 else 1285 else
1286 categories.insert (categories.end(), mCategory[index]); 1286 categories.insert (categories.end(), mCategory[index]);
1287 categories.sort (); 1287 categories.sort ();
1288 if ( !colcat.isEmpty() ) { 1288 if ( !colcat.isEmpty() ) {
1289 if ( categories.find ( colcat ) != categories.end () ) { 1289 if ( categories.find ( colcat ) != categories.end () ) {
1290 categories.remove( colcat ); 1290 categories.remove( colcat );
1291 categories.prepend( colcat ); 1291 categories.prepend( colcat );
1292 } 1292 }
1293 } 1293 }
1294 mActiveItem->todo()->setCategories (categories); 1294 mActiveItem->todo()->setCategories (categories);
1295 mActiveItem->construct(); 1295 mActiveItem->construct();
1296 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1296 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1297 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1297 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1298 } 1298 }
1299} 1299}
1300void KOTodoView::itemDoubleClicked(QListViewItem *item) 1300void KOTodoView::itemDoubleClicked(QListViewItem *item)
1301{ 1301{
1302 if ( pendingSubtodo != 0 ) { 1302 if ( pendingSubtodo != 0 ) {
1303 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1303 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1304 } 1304 }
1305 pendingSubtodo = 0; 1305 pendingSubtodo = 0;
1306 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1306 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1307 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1307 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1308 //qDebug("ROW %d ", row); 1308 //qDebug("ROW %d ", row);
1309 if (!item) { 1309 if (!item) {
1310 newTodo(); 1310 newTodo();
1311 return; 1311 return;
1312 } else { 1312 } else {
1313 if ( row == 1 ) { 1313 if ( row == 1 ) {
1314 mActiveItem = (KOTodoViewItem *) item; 1314 mActiveItem = (KOTodoViewItem *) item;
1315 newSubTodo(); 1315 newSubTodo();
1316 return; 1316 return;
1317 } 1317 }
1318 if ( row == 5 || row == 6 || row == 2) { 1318 if ( row == 5 || row == 6 || row == 2) {
1319 mActiveItem = (KOTodoViewItem *) item; 1319 mActiveItem = (KOTodoViewItem *) item;
1320 Todo * t = mActiveItem->todo(); 1320 Todo * t = mActiveItem->todo();
1321 if ( t->isRunning() ) { 1321 if ( t->isRunning() ) {
1322 if ( t->runTime() < 15) { 1322 if ( t->runTime() < 15) {
1323 t->stopRunning(); 1323 t->stopRunning();
1324 mActiveItem->construct(); 1324 mActiveItem->construct();
1325 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); 1325 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!"));
1326 return; 1326 return;
1327 } 1327 }
1328 else 1328 else
1329 toggleRunningItem(); 1329 toggleRunningItem();
1330 return; 1330 return;
1331 } else { 1331 } else {
1332 t->setRunning( true ); 1332 t->setRunning( true );
1333 mActiveItem->construct(); 1333 mActiveItem->construct();
1334 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); 1334 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!"));
1335 return; 1335 return;
1336 } 1336 }
1337 } 1337 }
1338 } 1338 }
1339 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1339 if ( KOPrefs::instance()->mEditOnDoubleClick )
1340 editItem( item ); 1340 editItem( item );
1341 else 1341 else
1342 showItem( item , QPoint(), 0 ); 1342 showItem( item , QPoint(), 0 );
1343} 1343}
1344void KOTodoView::toggleRunningItem() 1344void KOTodoView::toggleRunningItem()
1345{ 1345{
1346 // qDebug("KOTodoView::toggleRunning() "); 1346 // qDebug("KOTodoView::toggleRunning() ");
1347 if ( ! mActiveItem ) 1347 if ( ! mActiveItem )
1348 return; 1348 return;
1349 Todo * t = mActiveItem->todo(); 1349 Todo * t = mActiveItem->todo();
1350 if ( t->isRunning() ) { 1350 if ( t->isRunning() ) {
1351 KOStopTodoPrefs tp ( t, this ); 1351 KOStopTodoPrefs tp ( t, this );
1352 if (QApplication::desktop()->width() <= 800 ){ 1352 if (QApplication::desktop()->width() <= 800 ){
1353 int wid = tp.width(); 1353 int wid = tp.width();
1354 int hei = tp.height(); 1354 int hei = tp.height();
1355 int xx = (QApplication::desktop()->width()-wid)/2; 1355 int xx = (QApplication::desktop()->width()-wid)/2;
1356 int yy = (QApplication::desktop()->height()-hei)/2; 1356 int yy = (QApplication::desktop()->height()-hei)/2;
1357 tp.setGeometry( xx,yy,wid,hei ); 1357 tp.setGeometry( xx,yy,wid,hei );
1358 } 1358 }
1359 tp.exec(); 1359 tp.exec();
1360 updateTodo ( t, 0 ); 1360 updateTodo ( t, 0 );
1361 } else { 1361 } else {
1362 KOStartTodoPrefs tp ( t->summary(), this ); 1362 KOStartTodoPrefs tp ( t->summary(), this );
1363 if (QApplication::desktop()->width() <= 800 ){ 1363 if (QApplication::desktop()->width() <= 800 ){
1364 int wid = tp.width(); 1364 int wid = tp.width();
1365 int hei = tp.height(); 1365 int hei = tp.height();
1366 int xx = (QApplication::desktop()->width()-wid)/2; 1366 int xx = (QApplication::desktop()->width()-wid)/2;
1367 int yy = (QApplication::desktop()->height()-hei)/2; 1367 int yy = (QApplication::desktop()->height()-hei)/2;
1368 tp.setGeometry( xx,yy,wid,hei ); 1368 tp.setGeometry( xx,yy,wid,hei );
1369 } 1369 }
1370 if ( !tp.exec() ) return; 1370 if ( !tp.exec() ) return;
1371 if ( tp.stopAll() ) { 1371 if ( tp.stopAll() ) {
1372 mCalendar->stopAllTodos(); 1372 mCalendar->stopAllTodos();
1373 t->setRunning( true ); 1373 t->setRunning( true );
1374 updateView(); 1374 updateView();
1375 } else { 1375 } else {
1376 t->setRunning( true ); 1376 t->setRunning( true );
1377 updateTodo ( t, 0 ); 1377 updateTodo ( t, 0 );
1378 } 1378 }
1379 } 1379 }
1380} 1380}
1381 1381
1382void KOTodoView::itemClicked(QListViewItem *item) 1382void KOTodoView::itemClicked(QListViewItem *item)
1383{ 1383{
1384 //qDebug("KOTodoView::itemClicked %d", item); 1384 //qDebug("KOTodoView::itemClicked %d", item);
1385 if (!item) { 1385 if (!item) {
1386 if ( pendingSubtodo != 0 ) { 1386 if ( pendingSubtodo != 0 ) {
1387 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1387 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1388 } 1388 }
1389 pendingSubtodo = 0; 1389 pendingSubtodo = 0;
1390 return; 1390 return;
1391 } 1391 }
1392 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1392 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1393 if ( pendingSubtodo != 0 ) { 1393 if ( pendingSubtodo != 0 ) {
1394 bool allowReparent = true; 1394 bool allowReparent = true;
1395 QListViewItem *par = item; 1395 QListViewItem *par = item;
1396 while ( par ) { 1396 while ( par ) {
1397 if ( par == pendingSubtodo ) { 1397 if ( par == pendingSubtodo ) {
1398 allowReparent = false; 1398 allowReparent = false;
1399 break; 1399 break;
1400 } 1400 }
1401 par = par->parent(); 1401 par = par->parent();
1402 } 1402 }
1403 if ( !allowReparent ) { 1403 if ( !allowReparent ) {
1404 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1404 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1405 pendingSubtodo = 0; 1405 pendingSubtodo = 0;
1406 } else { 1406 } else {
1407 Todo* newParent = todoItem->todo(); 1407 Todo* newParent = todoItem->todo();
1408 Todo* newSub = pendingSubtodo->todo(); 1408 Todo* newSub = pendingSubtodo->todo();
1409 pendingSubtodo = 0; 1409 pendingSubtodo = 0;
1410 emit reparentTodoSignal( newParent,newSub ); 1410 emit reparentTodoSignal( newParent,newSub );
1411 return; 1411 return;
1412 } 1412 }
1413 } 1413 }
1414 1414
1415} 1415}
1416 1416
1417void KOTodoView::setDocumentId( const QString &id ) 1417void KOTodoView::setDocumentId( const QString &id )
1418{ 1418{
1419 1419
1420 mDocPrefs->setDoc( id ); 1420 mDocPrefs->setDoc( id );
1421} 1421}
1422 1422
1423void KOTodoView::itemStateChanged( QListViewItem *item ) 1423void KOTodoView::itemStateChanged( QListViewItem *item )
1424{ 1424{
1425 if (!item) return; 1425 if (!item) return;
1426 1426
1427 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1427 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1428 1428
1429// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1429// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1430 1430
1431 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1431 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1432} 1432}
1433 1433
1434void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1434void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1435{ 1435{
1436 mTodoListView->saveLayout(config,group); 1436 mTodoListView->saveLayout(config,group);
1437} 1437}
1438 1438
1439void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1439void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1440{ 1440{
1441 mTodoListView->restoreLayout(config,group); 1441 mTodoListView->restoreLayout(config,group);
1442} 1442}
1443 1443
1444void KOTodoView::processSelectionChange() 1444void KOTodoView::processSelectionChange()
1445{ 1445{
1446// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1446// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1447 1447
1448 KOTodoViewItem *item = 1448 KOTodoViewItem *item =
1449 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1449 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1450 1450
1451 if ( !item ) { 1451 if ( !item ) {
1452 emit incidenceSelected( 0 ); 1452 emit incidenceSelected( 0 );
1453 mNewSubBut->setEnabled( false ); 1453 mNewSubBut->setEnabled( false );
1454 } else { 1454 } else {
1455 emit incidenceSelected( item->todo() ); 1455 emit incidenceSelected( item->todo() );
1456 mNewSubBut->setEnabled( true ); 1456 mNewSubBut->setEnabled( true );
1457 } 1457 }
1458} 1458}
1459 1459
1460void KOTodoView::modified(bool b) 1460void KOTodoView::modified(bool b)
1461{ 1461{
1462 emit isModified(b); 1462 emit isModified(b);
1463} 1463}
1464void KOTodoView::setTodoModified( Todo* todo ) 1464void KOTodoView::setTodoModified( Todo* todo )
1465{ 1465{
1466 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1466 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1467} 1467}
1468void KOTodoView::clearSelection() 1468void KOTodoView::clearSelection()
1469{ 1469{
1470 mTodoListView->selectAll( false ); 1470 mTodoListView->selectAll( false );
1471} 1471}
1472void KOTodoView::setAllOpen() 1472void KOTodoView::setAllOpen()
1473{ 1473{
1474 if ( isFlatDisplay ) { 1474 if ( isFlatDisplay ) {
1475 isFlatDisplay = false; 1475 isFlatDisplay = false;
1476 mPopupMenu->setItemChecked( 8,false ); 1476 mPopupMenu->setItemChecked( 8,false );
1477 updateView(); 1477 updateView();
1478 } else { 1478 } else {
1479 storeCurrentItem(); 1479 storeCurrentItem();
1480 } 1480 }
1481 setOpen(mTodoListView->firstChild(), true); 1481 setOpen(mTodoListView->firstChild(), true);
1482 resetCurrentItem(); 1482 resetCurrentItem();
1483} 1483}
1484void KOTodoView::setAllClose() 1484void KOTodoView::setAllClose()
1485{ 1485{
1486 if ( isFlatDisplay ) { 1486 if ( isFlatDisplay ) {
1487 isFlatDisplay = false; 1487 isFlatDisplay = false;
1488 mPopupMenu->setItemChecked( 8,false ); 1488 mPopupMenu->setItemChecked( 8,false );
1489 updateView(); 1489 updateView();
1490 } else { 1490 } else {
1491 storeCurrentItem(); 1491 storeCurrentItem();
1492 } 1492 }
1493 setOpen(mTodoListView->firstChild(), false); 1493 setOpen(mTodoListView->firstChild(), false);
1494 resetCurrentItem(); 1494 resetCurrentItem();
1495} 1495}
1496void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1496void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1497{ 1497{
1498 1498
1499 while ( item ) { 1499 while ( item ) {
1500 setOpen( item->firstChild(), setOpenI ); 1500 setOpen( item->firstChild(), setOpenI );
1501 item->setOpen( setOpenI ); 1501 item->setOpen( setOpenI );
1502 item = item->nextSibling(); 1502 item = item->nextSibling();
1503 } 1503 }
1504} 1504}
1505 1505
1506void KOTodoView::displayAllFlat() 1506void KOTodoView::displayAllFlat()
1507{ 1507{
1508 storeCurrentItem(); 1508 storeCurrentItem();
1509 pendingSubtodo = 0; 1509 pendingSubtodo = 0;
1510 if ( mBlockUpdate ) { 1510 if ( mBlockUpdate ) {
1511 return; 1511 return;
1512 } 1512 }
1513 mPopupMenu->setItemChecked( 8,true ); 1513 mPopupMenu->setItemChecked( 8,true );
1514 isFlatDisplay = true; 1514 isFlatDisplay = true;
1515 QPtrList<Todo> todoList = calendar()->todos(); 1515 QPtrList<Todo> todoList = calendar()->todos();
1516 mTodoMap.clear(); 1516 mTodoMap.clear();
1517 mTodoListView->clear(); 1517 mTodoListView->clear();
1518 Todo *todo; 1518 Todo *todo;
1519 for(todo = todoList.first(); todo; todo = todoList.next()) { 1519 for(todo = todoList.first(); todo; todo = todoList.next()) {
1520 if ( checkTodo( todo ) ) { 1520 if ( checkTodo( todo ) ) {
1521 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1521 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1522 mTodoMap.insert(todo,todoItem); 1522 mTodoMap.insert(todo,todoItem);
1523 } 1523 }
1524 } 1524 }
1525 resetCurrentItem(); 1525 resetCurrentItem();
1526} 1526}
1527 1527
1528void KOTodoView::setAllFlat() 1528void KOTodoView::setAllFlat()
1529{ 1529{
1530 if ( isFlatDisplay ) { 1530 if ( isFlatDisplay ) {
1531 isFlatDisplay = false; 1531 isFlatDisplay = false;
1532 mPopupMenu->setItemChecked( 8,false ); 1532 mPopupMenu->setItemChecked( 8,false );
1533 updateView(); 1533 updateView();
1534 return; 1534 return;
1535 } 1535 }
1536 displayAllFlat(); 1536 displayAllFlat();
1537} 1537}
1538 1538
1539void KOTodoView::purgeCompleted() 1539void KOTodoView::purgeCompleted()
1540{ 1540{
1541 emit purgeCompletedSignal(); 1541 emit purgeCompletedSignal();
1542 1542
1543} 1543}
1544void KOTodoView::toggleQuickTodo() 1544void KOTodoView::toggleQuickTodo()
1545{ 1545{
1546 if ( mQuickBar->isVisible() ) { 1546 if ( mQuickBar->isVisible() ) {
1547 mQuickBar->hide(); 1547 mQuickBar->hide();
1548 KOPrefs::instance()->mEnableQuickTodo = false; 1548 KOPrefs::instance()->mEnableQuickTodo = false;
1549 } 1549 }
1550 else { 1550 else {
1551 mQuickBar->show(); 1551 mQuickBar->show();
1552 KOPrefs::instance()->mEnableQuickTodo = true; 1552 KOPrefs::instance()->mEnableQuickTodo = true;
1553 } 1553 }
1554 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1554 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1555 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1555 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1556} 1556}
1557 1557
1558void KOTodoView::toggleRunning() 1558void KOTodoView::toggleRunning()
1559{ 1559{
1560 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1560 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1561 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1561 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1562 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1562 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1563 updateView(); 1563 updateView();
1564 if ( KOPrefs::instance()->mHideNonStartedTodos ) 1564 if ( KOPrefs::instance()->mHideNonStartedTodos )
1565 topLevelWidget()->setCaption(i18n("Hide not Running")); 1565 topLevelWidget()->setCaption(i18n("Hide not Running"));
1566 else 1566 else
1567 topLevelWidget()->setCaption(i18n("Show not Running")); 1567 topLevelWidget()->setCaption(i18n("Show not Running"));
1568} 1568}
1569 1569
1570void KOTodoView::toggleCompleted() 1570void KOTodoView::toggleCompleted()
1571{ 1571{
1572 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1572 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1573 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1573 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1574 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1574 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1575 updateView(); 1575 updateView();
1576 if ( KOPrefs::instance()->mShowCompletedTodo ) 1576 if ( KOPrefs::instance()->mShowCompletedTodo )
1577 topLevelWidget()->setCaption(i18n("Show Completed")); 1577 topLevelWidget()->setCaption(i18n("Show Completed"));
1578 else 1578 else
1579 topLevelWidget()->setCaption(i18n("Hide Completed")); 1579 topLevelWidget()->setCaption(i18n("Hide Completed"));
1580} 1580}
1581 1581
1582void KOTodoView::addQuickTodo() 1582void KOTodoView::addQuickTodo()
1583{ 1583{
1584 addQuickTodoPar( 0 ); 1584 addQuickTodoPar( 0 );
1585} 1585}
1586void KOTodoView::addQuickTodoPar( Todo * parentTodo) 1586void KOTodoView::addQuickTodoPar( Todo * parentTodo)
1587{ 1587{
1588 Todo *todo = new Todo(); 1588 Todo *todo = new Todo();
1589 todo->setSummary(mQuickAdd->text()); 1589 todo->setSummary(mQuickAdd->text());
1590 todo->setOrganizer(KOPrefs::instance()->email()); 1590 todo->setOrganizer(KOPrefs::instance()->email());
1591 if ( parentTodo ) { 1591 if ( parentTodo ) {
1592 todo->setRelatedTo(parentTodo); 1592 todo->setRelatedTo(parentTodo);
1593 1593
1594 todo->setCategories (parentTodo->categoriesStr ()); 1594 todo->setCategories (parentTodo->categoriesStr ());
1595 todo->setSecrecy (parentTodo->secrecy ()); 1595 todo->setSecrecy (parentTodo->secrecy ());
1596 if ( parentTodo->priority() < 3 ) 1596 if ( parentTodo->priority() < 3 )
1597 todo->setPriority( parentTodo->priority() ); 1597 todo->setPriority( parentTodo->priority() );
1598 todo->setCalID( parentTodo->calID() ); 1598 todo->setCalID( parentTodo->calID() );
1599 } else { 1599 } else {
1600 CalFilter * cf = mCalendar->filter(); 1600 CalFilter * cf = mCalendar->filter();
1601 if ( cf ) { 1601 if ( cf ) {
1602 if ( cf->isEnabled()&& cf->showCategories()) { 1602 if ( cf->isEnabled()&& cf->showCategories()) {
1603 todo->setCategories(cf->categoryList()); 1603 todo->setCategories(cf->categoryList());
1604 } 1604 }
1605 if ( cf->isEnabled() ) 1605 if ( cf->isEnabled() )
1606 todo->setSecrecy( cf->getSecrecy()); 1606 todo->setSecrecy( cf->getSecrecy());
1607 } 1607 }
1608 } 1608 }
1609 mCalendar->addTodo(todo); 1609 mCalendar->addTodo(todo);
1610 mQuickAdd->setText(""); 1610 mQuickAdd->setText("");
1611 todoModified (todo, KOGlobals::EVENTADDED ); 1611 todoModified (todo, KOGlobals::EVENTADDED );
1612 updateView(); 1612 updateView();
1613 1613
1614} 1614}
1615void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1615void KOTodoView::keyPressEvent ( QKeyEvent * e )
1616{ 1616{
1617 // e->ignore(); 1617 // e->ignore();
1618 //return; 1618 //return;
1619 if ( !isVisible() ) { 1619 if ( !isVisible() ) {
1620 e->ignore(); 1620 e->ignore();
1621 return; 1621 return;
1622 } 1622 }
1623 switch ( e->key() ) { 1623 switch ( e->key() ) {
1624 case Qt::Key_Down: 1624 case Qt::Key_Down:
1625 case Qt::Key_Up: 1625 case Qt::Key_Up:
1626 // KOrg::BaseView::keyPressEvent ( e ); 1626 // KOrg::BaseView::keyPressEvent ( e );
1627 e->ignore(); 1627 e->ignore();
1628 break; 1628 break;
1629 1629
1630 case Qt::Key_Q: 1630 case Qt::Key_Q:
1631 1631
1632 1632
1633 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { 1633 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) {
1634 e->ignore(); 1634 e->ignore();
1635 break; 1635 break;
1636 } 1636 }
1637 toggleQuickTodo(); 1637 toggleQuickTodo();
1638 break; 1638 break;
1639 case Qt::Key_U: 1639 case Qt::Key_U:
1640 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1640 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1641 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1641 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1642 unparentTodo(); 1642 unparentTodo();
1643 e->accept(); 1643 e->accept();
1644 } else 1644 } else
1645 e->ignore(); 1645 e->ignore();
1646 break; 1646 break;
1647 case Qt::Key_S: 1647 case Qt::Key_S:
1648 if ( e->state() == Qt::ControlButton ) { 1648 if ( e->state() == Qt::ControlButton ) {
1649 e->ignore(); 1649 e->ignore();
1650 break; 1650 break;
1651 } 1651 }
1652 if ( e->state() == Qt::ShiftButton ) { 1652 if ( e->state() == Qt::ShiftButton ) {
1653 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1653 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1654 reparentTodo(); 1654 reparentTodo();
1655 e->accept(); 1655 e->accept();
1656 } else 1656 } else
1657 e->ignore(); 1657 e->ignore();
1658 break; 1658 break;
1659 case Qt::Key_P: 1659 case Qt::Key_P:
1660 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1660 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1661 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1661 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1662 if ( pendingSubtodo ) 1662 if ( pendingSubtodo )
1663 itemClicked(mActiveItem); 1663 itemClicked(mActiveItem);
1664 e->accept(); 1664 e->accept();
1665 } else 1665 } else
1666 e->ignore(); 1666 e->ignore();
1667 break; 1667 break;
1668 case Qt::Key_Escape: 1668 case Qt::Key_Escape:
1669 if ( pendingSubtodo ) { 1669 if ( pendingSubtodo ) {
1670 itemClicked(0); 1670 itemClicked(0);
1671 e->accept(); 1671 e->accept();
1672 } else 1672 } else
1673 e->ignore(); 1673 e->ignore();
1674 break; 1674 break;
1675 default: 1675 default:
1676 e->ignore(); 1676 e->ignore();
1677 } 1677 }
1678 1678
1679 if ( true ) { 1679 if ( true ) {
1680 if ( e->key() == Qt::Key_I ) { 1680 if ( e->key() == Qt::Key_I ) {
1681 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1681 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1682 if ( cn ) { 1682 if ( cn ) {
1683 mActiveItem = cn; 1683 mActiveItem = cn;
1684 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1684 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1685 if ( ci ){ 1685 if ( ci ){
1686 showTodo(); 1686 showTodo();
1687 cn = (KOTodoViewItem*)cn->itemBelow(); 1687 cn = (KOTodoViewItem*)cn->itemBelow();
1688 if ( cn ) { 1688 if ( cn ) {
1689 mTodoListView->setCurrentItem ( cn ); 1689 mTodoListView->setCurrentItem ( cn );
1690 mTodoListView->ensureItemVisible ( cn ); 1690 mTodoListView->ensureItemVisible ( cn );
1691 } 1691 }
1692 1692
1693 } 1693 }
1694 } 1694 }
1695 e->accept(); 1695 e->accept();
1696
1697 } 1696 }
1698
1699 } 1697 }
1700
1701} 1698}
1702void KOTodoView::updateTodo( Todo * t, int type ) 1699void KOTodoView::updateTodo( Todo * t, int type )
1703{ 1700{
1704 if ( mBlockUpdate) 1701 if ( mBlockUpdate)
1705 return; 1702 return;
1706 1703
1707 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1704 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1708 itemIterator = mTodoMap.find(t); 1705 itemIterator = mTodoMap.find(t);
1709 if (itemIterator != mTodoMap.end()) { 1706 if (itemIterator != mTodoMap.end()) {
1710 (*itemIterator)->construct(); 1707 (*itemIterator)->construct();
1711 } else { 1708 } else {
1712 if ( type == KOGlobals::EVENTADDED ) { 1709 if ( type == KOGlobals::EVENTADDED ) {
1713 insertTodoItem( t ); 1710 insertTodoItem( t );
1714 } 1711 }
1715 } 1712 }
1716 1713
1717} 1714}
1718 1715
1719void KOTodoView::todoModified(Todo * t , int p ) 1716void KOTodoView::todoModified(Todo * t , int p )
1720{ 1717{
1721 mBlockUpdate = true; 1718 mBlockUpdate = true;
1722 emit todoModifiedSignal ( t, p ); 1719 emit todoModifiedSignal ( t, p );
1723 mBlockUpdate = false; 1720 mBlockUpdate = false;
1724} 1721}