summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index a8143a0..a12acd1 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1116 +1,1118 @@
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 27
28#include <qvbox.h> 28#include <qvbox.h>
29#include <kdebug.h> 29#include <kdebug.h>
30#include "koprefs.h" 30#include "koprefs.h"
31#include <klocale.h> 31#include <klocale.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <kmessagebox.h> 34#include <kmessagebox.h>
35 35
36#include <libkcal/icaldrag.h> 36#include <libkcal/icaldrag.h>
37#include <libkcal/vcaldrag.h> 37#include <libkcal/vcaldrag.h>
38#include <libkcal/calfilter.h> 38#include <libkcal/calfilter.h>
39#include <libkcal/dndfactory.h> 39#include <libkcal/dndfactory.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42#include <kresources/resourceselectdialog.h> 42#include <kresources/resourceselectdialog.h>
43#ifndef DESKTOP_VERSION 43#ifndef DESKTOP_VERSION
44#include <qpe/qpeapplication.h> 44#include <qpe/qpeapplication.h>
45#else 45#else
46#include <qapplication.h> 46#include <qapplication.h>
47#endif 47#endif
48#ifndef KORG_NOPRINTER 48#ifndef KORG_NOPRINTER
49#include "calprinter.h" 49#include "calprinter.h"
50#endif 50#endif
51#include "docprefs.h" 51#include "docprefs.h"
52 52
53#include "kotodoview.h" 53#include "kotodoview.h"
54using namespace KOrg; 54using namespace KOrg;
55 55
56KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 56KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
57 const char *name) : 57 const char *name) :
58 KListView(parent,name) 58 KListView(parent,name)
59{ 59{
60 mName = QString ( name ); 60 mName = QString ( name );
61 mCalendar = calendar; 61 mCalendar = calendar;
62#ifndef DESKTOP_VERSION 62#ifndef DESKTOP_VERSION
63 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 63 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
64#endif 64#endif
65 mOldCurrent = 0; 65 mOldCurrent = 0;
66 mMousePressed = false; 66 mMousePressed = false;
67 67
68 setAcceptDrops(true); 68 setAcceptDrops(true);
69 viewport()->setAcceptDrops(true); 69 viewport()->setAcceptDrops(true);
70 int size = 16; 70 int size = 16;
71 if (qApp->desktop()->width() < 300 ) 71 if (qApp->desktop()->width() < 300 )
72 size = 12; 72 size = 12;
73 setTreeStepSize( size + 6 ); 73 setTreeStepSize( size + 6 );
74 74
75} 75}
76 76
77void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 77void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
78{ 78{
79#ifndef KORG_NODND 79#ifndef KORG_NODND
80// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 80// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
81 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 81 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
82 !QTextDrag::canDecode( e ) ) { 82 !QTextDrag::canDecode( e ) ) {
83 e->ignore(); 83 e->ignore();
84 return; 84 return;
85 } 85 }
86 86
87 mOldCurrent = currentItem(); 87 mOldCurrent = currentItem();
88#endif 88#endif
89} 89}
90 90
91 91
92void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 92void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
93{ 93{
94#ifndef KORG_NODND 94#ifndef KORG_NODND
95// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 95// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
96 96
97 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 97 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
98 !QTextDrag::canDecode( e ) ) { 98 !QTextDrag::canDecode( e ) ) {
99 e->ignore(); 99 e->ignore();
100 return; 100 return;
101 } 101 }
102 102
103 e->accept(); 103 e->accept();
104#endif 104#endif
105} 105}
106 106
107void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 107void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
108{ 108{
109#ifndef KORG_NODND 109#ifndef KORG_NODND
110// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 110// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
111 111
112 setCurrentItem(mOldCurrent); 112 setCurrentItem(mOldCurrent);
113 setSelected(mOldCurrent,true); 113 setSelected(mOldCurrent,true);
114#endif 114#endif
115} 115}
116 116
117void KOTodoListView::contentsDropEvent(QDropEvent *e) 117void KOTodoListView::contentsDropEvent(QDropEvent *e)
118{ 118{
119#ifndef KORG_NODND 119#ifndef KORG_NODND
120// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 120// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
121 121
122 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 122 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
123 !QTextDrag::canDecode( e ) ) { 123 !QTextDrag::canDecode( e ) ) {
124 e->ignore(); 124 e->ignore();
125 return; 125 return;
126 } 126 }
127 127
128 DndFactory factory( mCalendar ); 128 DndFactory factory( mCalendar );
129 Todo *todo = factory.createDropTodo(e); 129 Todo *todo = factory.createDropTodo(e);
130 130
131 if (todo) { 131 if (todo) {
132 e->acceptAction(); 132 e->acceptAction();
133 133
134 KOTodoViewItem *destination = 134 KOTodoViewItem *destination =
135 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 135 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
136 Todo *destinationEvent = 0; 136 Todo *destinationEvent = 0;
137 if (destination) destinationEvent = destination->todo(); 137 if (destination) destinationEvent = destination->todo();
138 138
139 Todo *existingTodo = mCalendar->todo(todo->uid()); 139 Todo *existingTodo = mCalendar->todo(todo->uid());
140 140
141 if(existingTodo) { 141 if(existingTodo) {
142// kdDebug() << "Drop existing Todo" << endl; 142// kdDebug() << "Drop existing Todo" << endl;
143 Incidence *to = destinationEvent; 143 Incidence *to = destinationEvent;
144 while(to) { 144 while(to) {
145 if (to->uid() == todo->uid()) { 145 if (to->uid() == todo->uid()) {
146 KMessageBox::sorry(this, 146 KMessageBox::sorry(this,
147 i18n("Cannot move To-Do to itself or a child of itself"), 147 i18n("Cannot move To-Do to itself or a child of itself"),
148 i18n("Drop To-Do")); 148 i18n("Drop To-Do"));
149 delete todo; 149 delete todo;
150 return; 150 return;
151 } 151 }
152 to = to->relatedTo(); 152 to = to->relatedTo();
153 } 153 }
154 existingTodo->setRelatedTo(destinationEvent); 154 existingTodo->setRelatedTo(destinationEvent);
155 emit todoDropped(todo); 155 emit todoDropped(todo);
156 delete todo; 156 delete todo;
157 } else { 157 } else {
158// kdDebug() << "Drop new Todo" << endl; 158// kdDebug() << "Drop new Todo" << endl;
159 todo->setRelatedTo(destinationEvent); 159 todo->setRelatedTo(destinationEvent);
160 mCalendar->addTodo(todo); 160 mCalendar->addTodo(todo);
161 161
162 emit todoDropped(todo); 162 emit todoDropped(todo);
163 } 163 }
164 } 164 }
165 else { 165 else {
166 QString text; 166 QString text;
167 if (QTextDrag::decode(e,text)) { 167 if (QTextDrag::decode(e,text)) {
168 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 168 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
169 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 169 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
170 kdDebug() << "Dropped : " << text << endl; 170 kdDebug() << "Dropped : " << text << endl;
171 QStringList emails = QStringList::split(",",text); 171 QStringList emails = QStringList::split(",",text);
172 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 172 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
173 kdDebug() << " Email: " << (*it) << endl; 173 kdDebug() << " Email: " << (*it) << endl;
174 int pos = (*it).find("<"); 174 int pos = (*it).find("<");
175 QString name = (*it).left(pos); 175 QString name = (*it).left(pos);
176 QString email = (*it).mid(pos); 176 QString email = (*it).mid(pos);
177 if (!email.isEmpty() && todoi) { 177 if (!email.isEmpty() && todoi) {
178 todoi->todo()->addAttendee(new Attendee(name,email)); 178 todoi->todo()->addAttendee(new Attendee(name,email));
179 } 179 }
180 } 180 }
181 } 181 }
182 else { 182 else {
183 kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; 183 kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl;
184 e->ignore(); 184 e->ignore();
185 } 185 }
186 } 186 }
187#endif 187#endif
188} 188}
189 189
190void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 190void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
191{ 191{
192 QListView::contentsMousePressEvent(e); 192 QListView::contentsMousePressEvent(e);
193#ifndef KORG_NODND 193#ifndef KORG_NODND
194 QPoint p(contentsToViewport(e->pos())); 194 QPoint p(contentsToViewport(e->pos()));
195 QListViewItem *i = itemAt(p); 195 QListViewItem *i = itemAt(p);
196 if (i) { 196 if (i) {
197 // if the user clicked into the root decoration of the item, don't 197 // if the user clicked into the root decoration of the item, don't
198 // try to start a drag! 198 // try to start a drag!
199 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + 199 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
200 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 200 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
201 itemMargin() || 201 itemMargin() ||
202 p.x() < header()->sectionPos(header()->mapToIndex(0))) { 202 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
203 if (e->button()==Qt::LeftButton) { 203 if (e->button()==Qt::LeftButton) {
204 mPressPos = e->pos(); 204 mPressPos = e->pos();
205 mMousePressed = true; 205 mMousePressed = true;
206 } 206 }
207 } 207 }
208 } 208 }
209#endif 209#endif
210} 210}
211 211
212void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 212void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
213{ 213{
214 214
215#ifndef KORG_NODND 215#ifndef KORG_NODND
216// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; 216// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl;
217 QListView::contentsMouseMoveEvent(e); 217 QListView::contentsMouseMoveEvent(e);
218 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 218 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
219 QApplication::startDragDistance()) { 219 QApplication::startDragDistance()) {
220 mMousePressed = false; 220 mMousePressed = false;
221 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 221 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
222 if (item) { 222 if (item) {
223// kdDebug() << "Start Drag for item " << item->text(0) << endl; 223// kdDebug() << "Start Drag for item " << item->text(0) << endl;
224 DndFactory factory( mCalendar ); 224 DndFactory factory( mCalendar );
225 ICalDrag *vd = factory.createDragTodo( 225 ICalDrag *vd = factory.createDragTodo(
226 ((KOTodoViewItem *)item)->todo(),viewport()); 226 ((KOTodoViewItem *)item)->todo(),viewport());
227 if (vd->drag()) { 227 if (vd->drag()) {
228 kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; 228 kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl;
229 } 229 }
230/* 230/*
231 QString source = fullPath(item); 231 QString source = fullPath(item);
232 if ( QFile::exists(source) ) { 232 if ( QFile::exists(source) ) {
233 QUriDrag* ud = new QUriDrag(viewport()); 233 QUriDrag* ud = new QUriDrag(viewport());
234 ud->setFilenames( source ); 234 ud->setFilenames( source );
235 if ( ud->drag() ) 235 if ( ud->drag() )
236 QMessageBox::information( this, "Drag source", 236 QMessageBox::information( this, "Drag source",
237 QString("Delete ")+source, "Not implemented" ); 237 QString("Delete ")+source, "Not implemented" );
238*/ 238*/
239 } 239 }
240 } 240 }
241#endif 241#endif
242} 242}
243void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 243void KOTodoListView::keyPressEvent ( QKeyEvent * e )
244{ 244{
245 245
246 QListViewItem* cn; 246 QListViewItem* cn;
247 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 247 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
248 cn = currentItem(); 248 cn = currentItem();
249 if ( cn ) { 249 if ( cn ) {
250 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 250 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
251 if ( ci ){ 251 if ( ci ){
252 if ( e->state() == ShiftButton ) 252 if ( e->state() == ShiftButton )
253 ci->setOn( false ); 253 ci->setOn( false );
254 else 254 else
255 ci->setOn( true ); 255 ci->setOn( true );
256 cn = cn->nextSibling(); 256 cn = cn->nextSibling();
257 if ( cn ) { 257 if ( cn ) {
258 setCurrentItem ( cn ); 258 setCurrentItem ( cn );
259 ensureItemVisible ( cn ); 259 ensureItemVisible ( cn );
260 } 260 }
261 261
262 } 262 }
263 } 263 }
264 264
265 return; 265 return;
266 } 266 }
267 267
268 // qDebug("KOTodoListView::keyPressEvent "); 268 // qDebug("KOTodoListView::keyPressEvent ");
269 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 269 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
270 switch ( e->key() ) { 270 switch ( e->key() ) {
271 case Qt::Key_Down: 271 case Qt::Key_Down:
272 case Qt::Key_Up: 272 case Qt::Key_Up:
273 QListView::keyPressEvent ( e ); 273 QListView::keyPressEvent ( e );
274 break; 274 break;
275 case Qt::Key_Left: 275 case Qt::Key_Left:
276 case Qt::Key_Right: 276 case Qt::Key_Right:
277 QListView::keyPressEvent ( e ); 277 QListView::keyPressEvent ( e );
278 e->accept(); 278 e->accept();
279 return; 279 return;
280 break; 280 break;
281 default: 281 default:
282 e->ignore(); 282 e->ignore();
283 break; 283 break;
284 } 284 }
285 return; 285 return;
286 } 286 }
287 e->ignore(); 287 e->ignore();
288} 288}
289void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 289void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
290{ 290{
291 QListView::contentsMouseReleaseEvent(e); 291 QListView::contentsMouseReleaseEvent(e);
292 mMousePressed = false; 292 mMousePressed = false;
293} 293}
294 294
295void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 295void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
296{ 296{
297 if (!e) return; 297 if (!e) return;
298 298
299 QPoint vp = contentsToViewport(e->pos()); 299 QPoint vp = contentsToViewport(e->pos());
300 300
301 QListViewItem *item = itemAt(vp); 301 QListViewItem *item = itemAt(vp);
302 302
303 emit double_Clicked(item); 303 emit double_Clicked(item);
304 if (!item) return; 304 if (!item) return;
305 305
306 emit doubleClicked(item,vp,0); 306 emit doubleClicked(item,vp,0);
307} 307}
308 308
309///////////////////////////////////////////////////////////////////////////// 309/////////////////////////////////////////////////////////////////////////////
310 310
311KOQuickTodo::KOQuickTodo(QWidget *parent) : 311KOQuickTodo::KOQuickTodo(QWidget *parent) :
312 QLineEdit(parent) 312 QLineEdit(parent)
313{ 313{
314 setText(i18n("Click to add a new Todo")); 314 setText(i18n("Click to add a new Todo"));
315} 315}
316 316
317void KOQuickTodo::focusInEvent(QFocusEvent *ev) 317void KOQuickTodo::focusInEvent(QFocusEvent *ev)
318{ 318{
319 if ( text()==i18n("Click to add a new Todo") ) 319 if ( text()==i18n("Click to add a new Todo") )
320 setText(""); 320 setText("");
321 QLineEdit::focusInEvent(ev); 321 QLineEdit::focusInEvent(ev);
322} 322}
323 323
324void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 324void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
325{ 325{
326 setText(i18n("Click to add a new Todo")); 326 setText(i18n("Click to add a new Todo"));
327 QLineEdit::focusOutEvent(ev); 327 QLineEdit::focusOutEvent(ev);
328} 328}
329 329
330///////////////////////////////////////////////////////////////////////////// 330/////////////////////////////////////////////////////////////////////////////
331 331
332KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 332KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
333 KOrg::BaseView(calendar,parent,name) 333 KOrg::BaseView(calendar,parent,name)
334{ 334{
335 QBoxLayout *topLayout = new QVBoxLayout(this); 335 QBoxLayout *topLayout = new QVBoxLayout(this);
336 mName = QString ( name ); 336 mName = QString ( name );
337 mBlockUpdate = false; 337 mBlockUpdate = false;
338 mQuickAdd = new KOQuickTodo(this); 338 mQuickAdd = new KOQuickTodo(this);
339 topLayout->addWidget(mQuickAdd); 339 topLayout->addWidget(mQuickAdd);
340 340
341 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 341 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
342 342
343 mTodoListView = new KOTodoListView(calendar,this, name ); 343 mTodoListView = new KOTodoListView(calendar,this, name );
344 topLayout->addWidget(mTodoListView); 344 topLayout->addWidget(mTodoListView);
345 //mTodoListView->header()->setMaximumHeight(30); 345 //mTodoListView->header()->setMaximumHeight(30);
346 mTodoListView->setRootIsDecorated(true); 346 mTodoListView->setRootIsDecorated(true);
347 mTodoListView->setAllColumnsShowFocus(true); 347 mTodoListView->setAllColumnsShowFocus(true);
348 348
349 mTodoListView->setShowSortIndicator(true); 349 mTodoListView->setShowSortIndicator(true);
350 350
351 mTodoListView->addColumn(i18n("Todo")); 351 mTodoListView->addColumn(i18n("Todo"));
352 mTodoListView->addColumn(i18n("Prio")); 352 mTodoListView->addColumn(i18n("Prio"));
353 mTodoListView->setColumnAlignment(1,AlignHCenter); 353 mTodoListView->setColumnAlignment(1,AlignHCenter);
354 mTodoListView->addColumn(i18n("Complete")); 354 mTodoListView->addColumn(i18n("Complete"));
355 mTodoListView->setColumnAlignment(2,AlignHCenter); 355 mTodoListView->setColumnAlignment(2,AlignHCenter);
356 mTodoListView->addColumn(i18n("Due Date")); 356 mTodoListView->addColumn(i18n("Due Date"));
357 mTodoListView->setColumnAlignment(3,AlignLeft); 357 mTodoListView->setColumnAlignment(3,AlignLeft);
358 mTodoListView->addColumn(i18n("Due Time")); 358 mTodoListView->addColumn(i18n("Due Time"));
359 mTodoListView->setColumnAlignment(4,AlignHCenter); 359 mTodoListView->setColumnAlignment(4,AlignHCenter);
360 mTodoListView->addColumn(i18n("Cancelled")); 360 mTodoListView->addColumn(i18n("Cancelled"));
361 mTodoListView->addColumn(i18n("Categories")); 361 mTodoListView->addColumn(i18n("Categories"));
362#if 0 362#if 0
363 mTodoListView->addColumn(i18n("Sort Id")); 363 mTodoListView->addColumn(i18n("Sort Id"));
364 mTodoListView->setColumnAlignment(4,AlignHCenter); 364 mTodoListView->setColumnAlignment(4,AlignHCenter);
365#endif 365#endif
366 366
367 mTodoListView->setMinimumHeight( 60 ); 367 mTodoListView->setMinimumHeight( 60 );
368 mTodoListView->setItemsRenameable( true ); 368 mTodoListView->setItemsRenameable( true );
369 mTodoListView->setRenameable( 0 ); 369 mTodoListView->setRenameable( 0 );
370 mTodoListView->setColumnWidth( 0, 120 ); 370 mTodoListView->setColumnWidth( 0, 120 );
371 mTodoListView->setColumnWidthMode(0, QListView::Manual); 371 mTodoListView->setColumnWidthMode(0, QListView::Manual);
372 mTodoListView->setColumnWidthMode(1, QListView::Manual); 372 mTodoListView->setColumnWidthMode(1, QListView::Manual);
373 mTodoListView->setColumnWidthMode(2, QListView::Manual); 373 mTodoListView->setColumnWidthMode(2, QListView::Manual);
374 mTodoListView->setColumnWidthMode(3, QListView::Manual); 374 mTodoListView->setColumnWidthMode(3, QListView::Manual);
375 mTodoListView->setColumnWidthMode(4, QListView::Manual); 375 mTodoListView->setColumnWidthMode(4, QListView::Manual);
376 mTodoListView->setColumnWidthMode(5, QListView::Manual); 376 mTodoListView->setColumnWidthMode(5, QListView::Manual);
377 mTodoListView->setColumnAlignment( 2, AlignCenter ); 377 mTodoListView->setColumnAlignment( 2, AlignCenter );
378#if 0 378#if 0
379 mTodoListView->setColumnWidthMode(6, QListView::Manual); 379 mTodoListView->setColumnWidthMode(6, QListView::Manual);
380#endif 380#endif
381 381
382 mPriorityPopupMenu = new QPopupMenu(this); 382 mPriorityPopupMenu = new QPopupMenu(this);
383 for (int i = 1; i <= 5; i++) { 383 for (int i = 1; i <= 5; i++) {
384 QString label = QString ("%1").arg (i); 384 QString label = QString ("%1").arg (i);
385 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 385 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
386 } 386 }
387 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 387 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
388 388
389 mPercentageCompletedPopupMenu = new QPopupMenu(this); 389 mPercentageCompletedPopupMenu = new QPopupMenu(this);
390 for (int i = 0; i <= 100; i+=20) { 390 for (int i = 0; i <= 100; i+=20) {
391 QString label = QString ("%1 %").arg (i); 391 QString label = QString ("%1 %").arg (i);
392 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 392 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
393 } 393 }
394 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 394 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
395 395
396 396
397 397
398 mItemPopupMenu = new QPopupMenu(this); 398 mItemPopupMenu = new QPopupMenu(this);
399 mItemPopupMenu->insertItem(i18n("Show..."), this, 399 mItemPopupMenu->insertItem(i18n("Show..."), this,
400 SLOT (showTodo())); 400 SLOT (showTodo()));
401 mItemPopupMenu->insertItem(i18n("Edit..."), this, 401 mItemPopupMenu->insertItem(i18n("Edit..."), this,
402 SLOT (editTodo())); 402 SLOT (editTodo()));
403 mItemPopupMenu->insertItem( i18n("Delete"), this, 403 mItemPopupMenu->insertItem( i18n("Delete"), this,
404 SLOT (deleteTodo())); 404 SLOT (deleteTodo()));
405 mItemPopupMenu->insertItem( i18n("Clone..."), this, 405 mItemPopupMenu->insertItem( i18n("Clone..."), this,
406 SLOT (cloneTodo())); 406 SLOT (cloneTodo()));
407 mItemPopupMenu->insertItem( i18n("Move..."), this, 407 mItemPopupMenu->insertItem( i18n("Move..."), this,
408 SLOT (moveTodo())); 408 SLOT (moveTodo()));
409 mItemPopupMenu->insertItem( i18n("Beam..."), this, 409 mItemPopupMenu->insertItem( i18n("Beam..."), this,
410 SLOT (beamTodo())); 410 SLOT (beamTodo()));
411 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 411 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
412 SLOT (cancelTodo())); 412 SLOT (cancelTodo()));
413 mItemPopupMenu->insertSeparator(); 413 mItemPopupMenu->insertSeparator();
414 414
415 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 415 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
416 SLOT (newTodo())); 416 SLOT (newTodo()));
417 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 417 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
418 SLOT (newSubTodo())); 418 SLOT (newSubTodo()));
419 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 419 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
420 SLOT (unparentTodo()),0,21); 420 SLOT (unparentTodo()),0,21);
421 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 421 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
422 SLOT (reparentTodo()),0,22); 422 SLOT (reparentTodo()),0,22);
423 mItemPopupMenu->insertSeparator(); 423 mItemPopupMenu->insertSeparator();
424 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 424 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
425 this, SLOT( purgeCompleted() ) ); 425 this, SLOT( purgeCompleted() ) );
426 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 426 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
427 this, SLOT( toggleCompleted() ),0, 33 ); 427 this, SLOT( toggleCompleted() ),0, 33 );
428 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 428 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
429 this, SLOT( toggleQuickTodo() ),0, 34 ); 429 this, SLOT( toggleQuickTodo() ),0, 34 );
430 430
431 mPopupMenu = new QPopupMenu(this); 431 mPopupMenu = new QPopupMenu(this);
432 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 432 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
433 SLOT (newTodo()),0,1); 433 SLOT (newTodo()),0,1);
434 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 434 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
435 this, SLOT(purgeCompleted()),0,2); 435 this, SLOT(purgeCompleted()),0,2);
436 mPopupMenu->insertItem(i18n("Show Completed"), 436 mPopupMenu->insertItem(i18n("Show Completed"),
437 this, SLOT( toggleCompleted() ),0,3 ); 437 this, SLOT( toggleCompleted() ),0,3 );
438 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 438 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
439 this, SLOT( toggleQuickTodo() ),0,4 ); 439 this, SLOT( toggleQuickTodo() ),0,4 );
440 mDocPrefs = new DocPrefs( name ); 440 mDocPrefs = new DocPrefs( name );
441 441
442 mPopupMenu->setCheckable( true ); 442 mPopupMenu->setCheckable( true );
443 mItemPopupMenu->setCheckable( true ); 443 mItemPopupMenu->setCheckable( true );
444 // Double clicking conflicts with opening/closing the subtree 444 // Double clicking conflicts with opening/closing the subtree
445 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 445 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
446 SLOT( editItem( QListViewItem *) ) ); 446 SLOT( editItem( QListViewItem *) ) );
447 /* 447 /*
448 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 448 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
449 const QPoint &,int ) ), 449 const QPoint &,int ) ),
450 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 450 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
451 */ 451 */
452 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 452 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
453 const QPoint &,int ) ), 453 const QPoint &,int ) ),
454 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 454 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
455 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 455 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
456 SLOT( itemClicked( QListViewItem * ) ) ); 456 SLOT( itemClicked( QListViewItem * ) ) );
457 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 457 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
458 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 458 SLOT( itemDoubleClicked( QListViewItem * ) ) );
459 connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), 459 connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ),
460 SLOT( updateView() ) ); 460 SLOT( updateView() ) );
461 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 461 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
462 SLOT( itemStateChanged( QListViewItem * ) ) ); 462 SLOT( itemStateChanged( QListViewItem * ) ) );
463 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 463 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
464 SLOT( itemStateChanged( QListViewItem * ) ) ); 464 SLOT( itemStateChanged( QListViewItem * ) ) );
465 465
466#if 0 466#if 0
467 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 467 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
468 SLOT(selectionChanged(QListViewItem *))); 468 SLOT(selectionChanged(QListViewItem *)));
469 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 469 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
470 SLOT(selectionChanged(QListViewItem *))); 470 SLOT(selectionChanged(QListViewItem *)));
471 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 471 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
472 SLOT(selectionChanged(QListViewItem *))); 472 SLOT(selectionChanged(QListViewItem *)));
473#endif 473#endif
474 connect( mTodoListView, SIGNAL(selectionChanged() ), 474 connect( mTodoListView, SIGNAL(selectionChanged() ),
475 SLOT( processSelectionChange() ) ); 475 SLOT( processSelectionChange() ) );
476 connect( mQuickAdd, SIGNAL( returnPressed () ), 476 connect( mQuickAdd, SIGNAL( returnPressed () ),
477 SLOT( addQuickTodo() ) ); 477 SLOT( addQuickTodo() ) );
478// if ( QApplication::desktop()->width() < 480 ) { 478// if ( QApplication::desktop()->width() < 480 ) {
479// setNarrow(); 479// setNarrow();
480 // mTodoListView->setColumnWidth( 0, 100 ); 480 // mTodoListView->setColumnWidth( 0, 100 );
481 481
482 // } 482 // }
483 483
484} 484}
485 485
486KOTodoView::~KOTodoView() 486KOTodoView::~KOTodoView()
487{ 487{
488 delete mDocPrefs; 488 delete mDocPrefs;
489} 489}
490 490
491void KOTodoView::jumpToDate () 491void KOTodoView::jumpToDate ()
492{ 492{
493 // if (mActiveItem) { 493 // if (mActiveItem) {
494// mActiveItem->todo()); 494// mActiveItem->todo());
495// if ( mActiveItem->todo()->hasDueDate() ) 495// if ( mActiveItem->todo()->hasDueDate() )
496// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 496// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
497} 497}
498 498
499void KOTodoView::setNarrow() 499void KOTodoView::setNarrow()
500{ 500{
501 //mTodoListView->setColumnWidth( 0, 120 ); 501 //mTodoListView->setColumnWidth( 0, 120 );
502 mTodoListView->setColumnWidth( 1, 35 ); 502 mTodoListView->setColumnWidth( 1, 35 );
503 mTodoListView->setColumnWidth( 2, 40 ); 503 mTodoListView->setColumnWidth( 2, 40 );
504 mTodoListView->setColumnWidth( 3, 80 ); 504 mTodoListView->setColumnWidth( 3, 80 );
505 mTodoListView->setColumnWidth( 4, 40 ); 505 mTodoListView->setColumnWidth( 4, 40 );
506 mTodoListView->setColumnWidth( 5, 90 ); 506 mTodoListView->setColumnWidth( 5, 90 );
507 507
508} 508}
509void KOTodoView::updateView() 509void KOTodoView::updateView()
510{ 510{
511 511 pendingSubtodo = 0;
512 if ( mBlockUpdate ) { 512 if ( mBlockUpdate ) {
513 //qDebug("blocked "); 513 //qDebug("blocked ");
514 return; 514 return;
515 } 515 }
516 //qDebug("update "); 516 //qDebug("update ");
517// kdDebug() << "KOTodoView::updateView()" << endl; 517// kdDebug() << "KOTodoView::updateView()" << endl;
518 QFont fo = KOPrefs::instance()->mTodoViewFont; 518 QFont fo = KOPrefs::instance()->mTodoViewFont;
519 mTodoListView->clear(); 519 mTodoListView->clear();
520 if ( mName == "todolistsmall" ) { 520 if ( mName == "todolistsmall" ) {
521 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 521 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
522 int ps = fo.pointSize() -2; 522 int ps = fo.pointSize() -2;
523 if ( ps > 12 ) 523 if ( ps > 12 )
524 ps -= 2; 524 ps -= 2;
525 fo.setPointSize( ps ); 525 fo.setPointSize( ps );
526 } 526 }
527 } 527 }
528 528
529 mTodoListView->setFont( fo ); 529 mTodoListView->setFont( fo );
530 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 530 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
531 //mTodoListView->header()->setMaximumHeight(fm.height()); 531 //mTodoListView->header()->setMaximumHeight(fm.height());
532 QPtrList<Todo> todoList = calendar()->todos(); 532 QPtrList<Todo> todoList = calendar()->todos();
533 533
534/* 534/*
535 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 535 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
536 Event *t; 536 Event *t;
537 for(t = todoList.first(); t; t = todoList.next()) { 537 for(t = todoList.first(); t; t = todoList.next()) {
538 kdDebug() << " " << t->getSummary() << endl; 538 kdDebug() << " " << t->getSummary() << endl;
539 539
540 if (t->getRelatedTo()) { 540 if (t->getRelatedTo()) {
541 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 541 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
542 } 542 }
543 543
544 QPtrList<Event> l = t->getRelations(); 544 QPtrList<Event> l = t->getRelations();
545 Event *c; 545 Event *c;
546 for(c=l.first();c;c=l.next()) { 546 for(c=l.first();c;c=l.next()) {
547 kdDebug() << " - relation: " << c->getSummary() << endl; 547 kdDebug() << " - relation: " << c->getSummary() << endl;
548 } 548 }
549 } 549 }
550*/ 550*/
551 551
552 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 552 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
553 // specific order of events. That means that we have to generate parent items 553 // specific order of events. That means that we have to generate parent items
554 // recursively for proper hierarchical display of Todos. 554 // recursively for proper hierarchical display of Todos.
555 mTodoMap.clear(); 555 mTodoMap.clear();
556 Todo *todo; 556 Todo *todo;
557 todo = todoList.first();// todo; todo = todoList.next()) { 557 todo = todoList.first();// todo; todo = todoList.next()) {
558 while ( todo ) { 558 while ( todo ) {
559 bool next = true; 559 bool next = true;
560 // qDebug("todo %s ", todo->summary().latin1()); 560 // qDebug("todo %s ", todo->summary().latin1());
561 Incidence *incidence = todo->relatedTo(); 561 Incidence *incidence = todo->relatedTo();
562 while ( incidence ) { 562 while ( incidence ) {
563 if ( incidence->type() == "Todo") { 563 if ( incidence->type() == "Todo") {
564 //qDebug("related %s ",incidence->summary().latin1() ); 564 //qDebug("related %s ",incidence->summary().latin1() );
565 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 565 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
566 //qDebug("related not found "); 566 //qDebug("related not found ");
567 todoList.remove( ); 567 todoList.remove( );
568 todo = todoList.current(); 568 todo = todoList.current();
569 next = false; 569 next = false;
570 incidence = 0; 570 incidence = 0;
571 571
572 } else { 572 } else {
573 //qDebug("related found "); 573 //qDebug("related found ");
574 incidence = incidence->relatedTo(); 574 incidence = incidence->relatedTo();
575 } 575 }
576 } else 576 } else
577 incidence = 0; 577 incidence = 0;
578 } 578 }
579 if ( next ) 579 if ( next )
580 todo = todoList.next(); 580 todo = todoList.next();
581 } 581 }
582// qDebug("again .... "); 582// qDebug("again .... ");
583// for(todo = todoList.first(); todo; todo = todoList.next()) { 583// for(todo = todoList.first(); todo; todo = todoList.next()) {
584 584
585// qDebug("yytodo %s ", todo->summary().latin1()); 585// qDebug("yytodo %s ", todo->summary().latin1());
586// } 586// }
587 //qDebug("for "); 587 //qDebug("for ");
588 for(todo = todoList.first(); todo; todo = todoList.next()) { 588 for(todo = todoList.first(); todo; todo = todoList.next()) {
589 if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) ) 589 if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) )
590 { 590 {
591 insertTodoItem(todo); 591 insertTodoItem(todo);
592 } 592 }
593 } 593 }
594 //qDebug("for end "); 594 //qDebug("for end ");
595 // Restore opened/closed state 595 // Restore opened/closed state
596 mTodoListView->blockSignals( true ); 596 mTodoListView->blockSignals( true );
597 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 597 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
598 mTodoListView->blockSignals( false ); 598 mTodoListView->blockSignals( false );
599 mTodoListView->setFocus(); 599 mTodoListView->setFocus();
600 processSelectionChange(); 600 processSelectionChange();
601} 601}
602 602
603void KOTodoView::restoreItemState( QListViewItem *item ) 603void KOTodoView::restoreItemState( QListViewItem *item )
604{ 604{
605 pendingSubtodo = 0;
605 while( item ) { 606 while( item ) {
606 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 607 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
607 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 608 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
608 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 609 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
609 item = item->nextSibling(); 610 item = item->nextSibling();
610 } 611 }
611} 612}
612 613
613 614
614QMap<Todo *,KOTodoViewItem *>::ConstIterator 615QMap<Todo *,KOTodoViewItem *>::ConstIterator
615 KOTodoView::insertTodoItem(Todo *todo) 616 KOTodoView::insertTodoItem(Todo *todo)
616{ 617{
617// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 618// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
618 // TODO: Check, if dynmaic cast is necessary 619 // TODO: Check, if dynmaic cast is necessary
619 620
620 621 pendingSubtodo = 0;
621 Incidence *incidence = todo->relatedTo(); 622 Incidence *incidence = todo->relatedTo();
622 if (incidence && incidence->type() == "Todo") { 623 if (incidence && incidence->type() == "Todo") {
623 Todo *relatedTodo = static_cast<Todo *>(incidence); 624 Todo *relatedTodo = static_cast<Todo *>(incidence);
624 625
625// kdDebug() << " has Related" << endl; 626// kdDebug() << " has Related" << endl;
626 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 627 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
627 itemIterator = mTodoMap.find(relatedTodo); 628 itemIterator = mTodoMap.find(relatedTodo);
628 if (itemIterator == mTodoMap.end()) { 629 if (itemIterator == mTodoMap.end()) {
629// kdDebug() << " related not yet in list" << endl; 630// kdDebug() << " related not yet in list" << endl;
630 itemIterator = insertTodoItem (relatedTodo); 631 itemIterator = insertTodoItem (relatedTodo);
631 } 632 }
632 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 633 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
633 // and one into the map. Sure finding is more easy but why? -zecke 634 // and one into the map. Sure finding is more easy but why? -zecke
634 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 635 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
635 return mTodoMap.insert(todo,todoItem); 636 return mTodoMap.insert(todo,todoItem);
636 } else { 637 } else {
637// kdDebug() << " no Related" << endl; 638// kdDebug() << " no Related" << endl;
638 // see above -zecke 639 // see above -zecke
639 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 640 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
640 return mTodoMap.insert(todo,todoItem); 641 return mTodoMap.insert(todo,todoItem);
641 } 642 }
642} 643}
643 644
644 645
645void KOTodoView::updateConfig() 646void KOTodoView::updateConfig()
646{ 647{
647 updateView(); 648 updateView();
648 mTodoListView->repaintContents(); 649 mTodoListView->repaintContents();
649} 650}
650 651
651QPtrList<Incidence> KOTodoView::selectedIncidences() 652QPtrList<Incidence> KOTodoView::selectedIncidences()
652{ 653{
653 QPtrList<Incidence> selected; 654 QPtrList<Incidence> selected;
654 655
655 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 656 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
656// if (!item) item = mActiveItem; 657// if (!item) item = mActiveItem;
657 if (item) selected.append(item->todo()); 658 if (item) selected.append(item->todo());
658 659
659 return selected; 660 return selected;
660} 661}
661 662
662QPtrList<Todo> KOTodoView::selectedTodos() 663QPtrList<Todo> KOTodoView::selectedTodos()
663{ 664{
664 QPtrList<Todo> selected; 665 QPtrList<Todo> selected;
665 666
666 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 667 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
667// if (!item) item = mActiveItem; 668// if (!item) item = mActiveItem;
668 if (item) selected.append(item->todo()); 669 if (item) selected.append(item->todo());
669 670
670 return selected; 671 return selected;
671} 672}
672 673
673void KOTodoView::changeEventDisplay(Event *, int) 674void KOTodoView::changeEventDisplay(Event *, int)
674{ 675{
675 updateView(); 676 updateView();
676} 677}
677 678
678void KOTodoView::showDates(const QDate &, const QDate &) 679void KOTodoView::showDates(const QDate &, const QDate &)
679{ 680{
680} 681}
681 682
682void KOTodoView::showEvents(QPtrList<Event>) 683void KOTodoView::showEvents(QPtrList<Event>)
683{ 684{
684 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 685 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
685} 686}
686 687
687void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 688void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
688 const QDate &td) 689 const QDate &td)
689{ 690{
690#ifndef KORG_NOPRINTER 691#ifndef KORG_NOPRINTER
691 calPrinter->preview(CalPrinter::Todolist, fd, td); 692 calPrinter->preview(CalPrinter::Todolist, fd, td);
692#endif 693#endif
693} 694}
694 695
695void KOTodoView::editItem(QListViewItem *item ) 696void KOTodoView::editItem(QListViewItem *item )
696{ 697{
697 // qDebug("editItem(QListViewItem *item ) "); 698 // qDebug("editItem(QListViewItem *item ) ");
698 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 699 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
699} 700}
700 701
701void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 702void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
702{ 703{
703 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 704 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
704} 705}
705 706
706void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) 707void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column)
707{ 708{
709 pendingSubtodo = 0;
708 mActiveItem = (KOTodoViewItem *)item; 710 mActiveItem = (KOTodoViewItem *)item;
709 if (item) { 711 if (item) {
710 switch (column){ 712 switch (column){
711 case 1: 713 case 1:
712 mPriorityPopupMenu->popup(QCursor::pos ()); break; 714 mPriorityPopupMenu->popup(QCursor::pos ()); break;
713 case 2: 715 case 2:
714 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 716 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
715 case 3: 717 case 3:
716 moveTodo(); 718 moveTodo();
717 break; 719 break;
718 case 6: 720 case 6:
719 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 721 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
720 default: 722 default:
721 mItemPopupMenu->popup(QCursor::pos()); 723 mItemPopupMenu->popup(QCursor::pos());
722 } 724 }
723 } else mPopupMenu->popup(QCursor::pos()); 725 } else mPopupMenu->popup(QCursor::pos());
724} 726}
725void KOTodoView::newTodo() 727void KOTodoView::newTodo()
726{ 728{
727 emit newTodoSignal(); 729 emit newTodoSignal();
728} 730}
729 731
730void KOTodoView::newSubTodo() 732void KOTodoView::newSubTodo()
731{ 733{
732 if (mActiveItem) { 734 if (mActiveItem) {
733 emit newSubTodoSignal(mActiveItem->todo()); 735 emit newSubTodoSignal(mActiveItem->todo());
734 } 736 }
735} 737}
736void KOTodoView::unparentTodo() 738void KOTodoView::unparentTodo()
737{ 739{
738 if (mActiveItem) { 740 if (mActiveItem) {
739 emit unparentTodoSignal(mActiveItem->todo()); 741 emit unparentTodoSignal(mActiveItem->todo());
740 } 742 }
741} 743}
742 744
743void KOTodoView::reparentTodo() 745void KOTodoView::reparentTodo()
744{ 746{
745 if (mActiveItem) { 747 if (mActiveItem) {
746 qDebug("KOTodoView::reparentTodo() "); 748 qDebug("KOTodoView::reparentTodo() ");
747 topLevelWidget()->setCaption(i18n("Click on new parent item")); 749 topLevelWidget()->setCaption(i18n("Click on new parent item"));
748 pendingSubtodo = mActiveItem; 750 pendingSubtodo = mActiveItem;
749 } 751 }
750} 752}
751void KOTodoView::editTodo() 753void KOTodoView::editTodo()
752{ 754{
753 if (mActiveItem) { 755 if (mActiveItem) {
754 emit editTodoSignal(mActiveItem->todo()); 756 emit editTodoSignal(mActiveItem->todo());
755 } 757 }
756} 758}
757void KOTodoView::cloneTodo() 759void KOTodoView::cloneTodo()
758{ 760{
759 if (mActiveItem) { 761 if (mActiveItem) {
760 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 762 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
761 } 763 }
762} 764}
763void KOTodoView::cancelTodo() 765void KOTodoView::cancelTodo()
764{ 766{
765 if (mActiveItem) { 767 if (mActiveItem) {
766 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 768 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
767 } 769 }
768} 770}
769void KOTodoView::moveTodo() 771void KOTodoView::moveTodo()
770{ 772{
771 if (mActiveItem) { 773 if (mActiveItem) {
772 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 774 emit moveTodoSignal((Incidence*)mActiveItem->todo());
773 } 775 }
774} 776}
775void KOTodoView::beamTodo() 777void KOTodoView::beamTodo()
776{ 778{
777 if (mActiveItem) { 779 if (mActiveItem) {
778 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 780 emit beamTodoSignal((Incidence*)mActiveItem->todo());
779 } 781 }
780} 782}
781 783
782 784
783void KOTodoView::showTodo() 785void KOTodoView::showTodo()
784{ 786{
785 if (mActiveItem) { 787 if (mActiveItem) {
786 emit showTodoSignal(mActiveItem->todo()); 788 emit showTodoSignal(mActiveItem->todo());
787 } 789 }
788} 790}
789 791
790void KOTodoView::deleteTodo() 792void KOTodoView::deleteTodo()
791{ 793{
792 if (mActiveItem) { 794 if (mActiveItem) {
793 if (mActiveItem->childCount()) { 795 if (mActiveItem->childCount()) {
794 KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."), 796 KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."),
795 i18n("Delete To-Do")); 797 i18n("Delete To-Do"));
796 } else { 798 } else {
797 emit deleteTodoSignal(mActiveItem->todo()); 799 emit deleteTodoSignal(mActiveItem->todo());
798 } 800 }
799 } 801 }
800} 802}
801 803
802void KOTodoView::setNewPriority(int index) 804void KOTodoView::setNewPriority(int index)
803{ 805{
804 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 806 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
805 mActiveItem->todo()->setPriority(mPriority[index]); 807 mActiveItem->todo()->setPriority(mPriority[index]);
806 mActiveItem->construct(); 808 mActiveItem->construct();
807 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 809 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
808 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 810 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
809 } 811 }
810} 812}
811 813
812void KOTodoView::setNewPercentage(int index) 814void KOTodoView::setNewPercentage(int index)
813{ 815{
814 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 816 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
815 if (mPercentage[index] == 100) { 817 if (mPercentage[index] == 100) {
816 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 818 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
817 } else { 819 } else {
818 mActiveItem->todo()->setCompleted(false); 820 mActiveItem->todo()->setCompleted(false);
819 } 821 }
820 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 822 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
821 mActiveItem->construct(); 823 mActiveItem->construct();
822 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 824 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
823 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 825 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
824 } 826 }
825} 827}
826 828
827 829
828QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 830QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
829{ 831{
830 QPopupMenu* tempMenu = new QPopupMenu (this); 832 QPopupMenu* tempMenu = new QPopupMenu (this);
831 QStringList checkedCategories = todoItem->todo()->categories (); 833 QStringList checkedCategories = todoItem->todo()->categories ();
832 834
833 tempMenu->setCheckable (true); 835 tempMenu->setCheckable (true);
834 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 836 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
835 it != KOPrefs::instance()->mCustomCategories.end (); 837 it != KOPrefs::instance()->mCustomCategories.end ();
836 ++it) { 838 ++it) {
837 int index = tempMenu->insertItem (*it); 839 int index = tempMenu->insertItem (*it);
838 mCategory[index] = *it; 840 mCategory[index] = *it;
839 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 841 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
840 } 842 }
841 843
842 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 844 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
843 return tempMenu; 845 return tempMenu;
844 846
845 847
846} 848}
847void KOTodoView::changedCategories(int index) 849void KOTodoView::changedCategories(int index)
848{ 850{
849 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 851 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
850 QStringList categories = mActiveItem->todo()->categories (); 852 QStringList categories = mActiveItem->todo()->categories ();
851 if (categories.find (mCategory[index]) != categories.end ()) 853 if (categories.find (mCategory[index]) != categories.end ())
852 categories.remove (mCategory[index]); 854 categories.remove (mCategory[index]);
853 else 855 else
854 categories.insert (categories.end(), mCategory[index]); 856 categories.insert (categories.end(), mCategory[index]);
855 categories.sort (); 857 categories.sort ();
856 mActiveItem->todo()->setCategories (categories); 858 mActiveItem->todo()->setCategories (categories);
857 mActiveItem->construct(); 859 mActiveItem->construct();
858 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 860 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
859 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 861 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
860 } 862 }
861} 863}
862void KOTodoView::itemDoubleClicked(QListViewItem *item) 864void KOTodoView::itemDoubleClicked(QListViewItem *item)
863{ 865{
864 if ( pendingSubtodo != 0 ) { 866 if ( pendingSubtodo != 0 ) {
865 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 867 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
866 } 868 }
867 pendingSubtodo = 0; 869 pendingSubtodo = 0;
868 if (!item) { 870 if (!item) {
869 newTodo(); 871 newTodo();
870 return; 872 return;
871 } 873 }
872 if ( KOPrefs::instance()->mEditOnDoubleClick ) 874 if ( KOPrefs::instance()->mEditOnDoubleClick )
873 editItem( item ); 875 editItem( item );
874 else 876 else
875 showItem( item , QPoint(), 0 ); 877 showItem( item , QPoint(), 0 );
876} 878}
877void KOTodoView::itemClicked(QListViewItem *item) 879void KOTodoView::itemClicked(QListViewItem *item)
878{ 880{
879 881
880 if (!item) { 882 if (!item) {
881 if ( pendingSubtodo != 0 ) { 883 if ( pendingSubtodo != 0 ) {
882 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 884 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
883 } 885 }
884 pendingSubtodo = 0; 886 pendingSubtodo = 0;
885 return; 887 return;
886 } 888 }
887 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 889 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
888 if ( pendingSubtodo != 0 ) { 890 if ( pendingSubtodo != 0 ) {
889 bool allowReparent = true; 891 bool allowReparent = true;
890 QListViewItem *par = item; 892 QListViewItem *par = item;
891 while ( par ) { 893 while ( par ) {
892 if ( par == pendingSubtodo ) { 894 if ( par == pendingSubtodo ) {
893 allowReparent = false; 895 allowReparent = false;
894 break; 896 break;
895 } 897 }
896 par = par->parent(); 898 par = par->parent();
897 } 899 }
898 if ( !allowReparent ) { 900 if ( !allowReparent ) {
899 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 901 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
900 qDebug("Recursive reparenting not possible "); 902 qDebug("Recursive reparenting not possible ");
901 pendingSubtodo = 0; 903 pendingSubtodo = 0;
902 } else { 904 } else {
903 Todo* newParent = todoItem->todo(); 905 Todo* newParent = todoItem->todo();
904 Todo* newSub = pendingSubtodo->todo(); 906 Todo* newSub = pendingSubtodo->todo();
905 pendingSubtodo = 0; 907 pendingSubtodo = 0;
906 emit reparentTodoSignal( newParent,newSub ); 908 emit reparentTodoSignal( newParent,newSub );
907 return; 909 return;
908 } 910 }
909 } 911 }
910 int completed = todoItem->todo()->isCompleted(); // Completed or not? 912 int completed = todoItem->todo()->isCompleted(); // Completed or not?
911 913
912 if (todoItem->isOn()) { 914 if (todoItem->isOn()) {
913 if (!completed) { 915 if (!completed) {
914 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 916 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
915 } 917 }
916 } else { 918 } else {
917 if (completed) { 919 if (completed) {
918 todoItem->todo()->setCompleted(false); 920 todoItem->todo()->setCompleted(false);
919 } 921 }
920 } 922 }
921} 923}
922 924
923void KOTodoView::setDocumentId( const QString &id ) 925void KOTodoView::setDocumentId( const QString &id )
924{ 926{
925 kdDebug() << "KOTodoView::setDocumentId()" << endl; 927 kdDebug() << "KOTodoView::setDocumentId()" << endl;
926 928
927 mDocPrefs->setDoc( id ); 929 mDocPrefs->setDoc( id );
928} 930}
929 931
930void KOTodoView::itemStateChanged( QListViewItem *item ) 932void KOTodoView::itemStateChanged( QListViewItem *item )
931{ 933{
932 if (!item) return; 934 if (!item) return;
933 935
934 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 936 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
935 937
936// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 938// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
937 939
938 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 940 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
939} 941}
940 942
941void KOTodoView::saveLayout(KConfig *config, const QString &group) const 943void KOTodoView::saveLayout(KConfig *config, const QString &group) const
942{ 944{
943 mTodoListView->saveLayout(config,group); 945 mTodoListView->saveLayout(config,group);
944} 946}
945 947
946void KOTodoView::restoreLayout(KConfig *config, const QString &group) 948void KOTodoView::restoreLayout(KConfig *config, const QString &group)
947{ 949{
948 mTodoListView->restoreLayout(config,group); 950 mTodoListView->restoreLayout(config,group);
949} 951}
950 952
951void KOTodoView::processSelectionChange() 953void KOTodoView::processSelectionChange()
952{ 954{
953// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 955// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
954 956
955 KOTodoViewItem *item = 957 KOTodoViewItem *item =
956 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 958 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
957 959
958 if ( !item ) { 960 if ( !item ) {
959 emit incidenceSelected( 0 ); 961 emit incidenceSelected( 0 );
960 } else { 962 } else {
961 emit incidenceSelected( item->todo() ); 963 emit incidenceSelected( item->todo() );
962 } 964 }
963} 965}
964 966
965void KOTodoView::modified(bool b) 967void KOTodoView::modified(bool b)
966{ 968{
967 emit isModified(b); 969 emit isModified(b);
968} 970}
969void KOTodoView::setTodoModified( Todo* todo ) 971void KOTodoView::setTodoModified( Todo* todo )
970{ 972{
971 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 973 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
972} 974}
973void KOTodoView::clearSelection() 975void KOTodoView::clearSelection()
974{ 976{
975 mTodoListView->selectAll( false ); 977 mTodoListView->selectAll( false );
976} 978}
977 979
978void KOTodoView::purgeCompleted() 980void KOTodoView::purgeCompleted()
979{ 981{
980 emit purgeCompletedSignal(); 982 emit purgeCompletedSignal();
981} 983}
982void KOTodoView::toggleQuickTodo() 984void KOTodoView::toggleQuickTodo()
983{ 985{
984 if ( mQuickAdd->isVisible() ) { 986 if ( mQuickAdd->isVisible() ) {
985 mQuickAdd->hide(); 987 mQuickAdd->hide();
986 KOPrefs::instance()->mEnableQuickTodo = false; 988 KOPrefs::instance()->mEnableQuickTodo = false;
987 } 989 }
988 else { 990 else {
989 mQuickAdd->show(); 991 mQuickAdd->show();
990 KOPrefs::instance()->mEnableQuickTodo = true; 992 KOPrefs::instance()->mEnableQuickTodo = true;
991 } 993 }
992 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 994 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
993 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 995 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
994} 996}
995void KOTodoView::toggleCompleted() 997void KOTodoView::toggleCompleted()
996{ 998{
997 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 999 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
998 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1000 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
999 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1001 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1000 updateView(); 1002 updateView();
1001} 1003}
1002 1004
1003void KOTodoView::addQuickTodo() 1005void KOTodoView::addQuickTodo()
1004{ 1006{
1005 Todo *todo = new Todo(); 1007 Todo *todo = new Todo();
1006 todo->setSummary(mQuickAdd->text()); 1008 todo->setSummary(mQuickAdd->text());
1007 todo->setOrganizer(KOPrefs::instance()->email()); 1009 todo->setOrganizer(KOPrefs::instance()->email());
1008 CalFilter * cf = mCalendar->filter(); 1010 CalFilter * cf = mCalendar->filter();
1009 if ( cf ) { 1011 if ( cf ) {
1010 if ( cf->isEnabled()&& cf->showCategories()) { 1012 if ( cf->isEnabled()&& cf->showCategories()) {
1011 todo->setCategories(cf->categoryList()); 1013 todo->setCategories(cf->categoryList());
1012 } 1014 }
1013 if ( cf->isEnabled() ) 1015 if ( cf->isEnabled() )
1014 todo->setSecrecy( cf->getSecrecy()); 1016 todo->setSecrecy( cf->getSecrecy());
1015 } 1017 }
1016 mCalendar->addTodo(todo); 1018 mCalendar->addTodo(todo);
1017 mQuickAdd->setText(""); 1019 mQuickAdd->setText("");
1018 todoModified (todo, KOGlobals::EVENTADDED ); 1020 todoModified (todo, KOGlobals::EVENTADDED );
1019 updateView(); 1021 updateView();
1020} 1022}
1021void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1023void KOTodoView::keyPressEvent ( QKeyEvent * e )
1022{ 1024{
1023 // e->ignore(); 1025 // e->ignore();
1024 //return; 1026 //return;
1025 //qDebug("KOTodoView::keyPressEvent "); 1027 //qDebug("KOTodoView::keyPressEvent ");
1026 switch ( e->key() ) { 1028 switch ( e->key() ) {
1027 case Qt::Key_Down: 1029 case Qt::Key_Down:
1028 case Qt::Key_Up: 1030 case Qt::Key_Up:
1029 QWidget::keyPressEvent ( e ); 1031 QWidget::keyPressEvent ( e );
1030 break; 1032 break;
1031 1033
1032 case Qt::Key_Q: 1034 case Qt::Key_Q:
1033 toggleQuickTodo(); 1035 toggleQuickTodo();
1034 break; 1036 break;
1035 case Qt::Key_U: 1037 case Qt::Key_U:
1036 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1038 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1037 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1039 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1038 unparentTodo(); 1040 unparentTodo();
1039 e->accept(); 1041 e->accept();
1040 } else 1042 } else
1041 e->ignore(); 1043 e->ignore();
1042 break; 1044 break;
1043 case Qt::Key_S: 1045 case Qt::Key_S:
1044 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1046 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1045 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1047 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1046 reparentTodo(); 1048 reparentTodo();
1047 e->accept(); 1049 e->accept();
1048 } else 1050 } else
1049 e->ignore(); 1051 e->ignore();
1050 break; 1052 break;
1051 case Qt::Key_P: 1053 case Qt::Key_P:
1052 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1054 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1053 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1055 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1054 if ( pendingSubtodo ) 1056 if ( pendingSubtodo )
1055 itemClicked(mActiveItem); 1057 itemClicked(mActiveItem);
1056 e->accept(); 1058 e->accept();
1057 } else 1059 } else
1058 e->ignore(); 1060 e->ignore();
1059 break; 1061 break;
1060 case Qt::Key_Escape: 1062 case Qt::Key_Escape:
1061 if ( pendingSubtodo ) { 1063 if ( pendingSubtodo ) {
1062 itemClicked(0); 1064 itemClicked(0);
1063 e->accept(); 1065 e->accept();
1064 } else 1066 } else
1065 e->ignore(); 1067 e->ignore();
1066 break; 1068 break;
1067 default: 1069 default:
1068 e->ignore(); 1070 e->ignore();
1069 } 1071 }
1070 1072
1071 if ( true ) { 1073 if ( true ) {
1072 if ( e->key() == Qt::Key_I ) { 1074 if ( e->key() == Qt::Key_I ) {
1073 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1075 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1074 if ( cn ) { 1076 if ( cn ) {
1075 mActiveItem = cn; 1077 mActiveItem = cn;
1076 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1078 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1077 if ( ci ){ 1079 if ( ci ){
1078 showTodo(); 1080 showTodo();
1079 cn = (KOTodoViewItem*)cn->itemBelow(); 1081 cn = (KOTodoViewItem*)cn->itemBelow();
1080 if ( cn ) { 1082 if ( cn ) {
1081 mTodoListView->setCurrentItem ( cn ); 1083 mTodoListView->setCurrentItem ( cn );
1082 mTodoListView->ensureItemVisible ( cn ); 1084 mTodoListView->ensureItemVisible ( cn );
1083 } 1085 }
1084 1086
1085 } 1087 }
1086 } 1088 }
1087 e->accept(); 1089 e->accept();
1088 1090
1089 } 1091 }
1090 1092
1091 } 1093 }
1092 1094
1093} 1095}
1094void KOTodoView::updateTodo( Todo * t, int type ) 1096void KOTodoView::updateTodo( Todo * t, int type )
1095{ 1097{
1096 if ( mBlockUpdate) 1098 if ( mBlockUpdate)
1097 return; 1099 return;
1098 1100
1099 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1101 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1100 itemIterator = mTodoMap.find(t); 1102 itemIterator = mTodoMap.find(t);
1101 if (itemIterator != mTodoMap.end()) { 1103 if (itemIterator != mTodoMap.end()) {
1102 (*itemIterator)->construct(); 1104 (*itemIterator)->construct();
1103 } else { 1105 } else {
1104 if ( type == KOGlobals::EVENTADDED ) { 1106 if ( type == KOGlobals::EVENTADDED ) {
1105 insertTodoItem( t ); 1107 insertTodoItem( t );
1106 } 1108 }
1107 } 1109 }
1108 1110
1109} 1111}
1110 1112
1111void KOTodoView::todoModified(Todo * t , int p ) 1113void KOTodoView::todoModified(Todo * t , int p )
1112{ 1114{
1113 mBlockUpdate = true; 1115 mBlockUpdate = true;
1114 emit todoModifiedSignal ( t, p ); 1116 emit todoModifiedSignal ( t, p );
1115 mBlockUpdate = false; 1117 mBlockUpdate = false;
1116} 1118}