summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 902f3f4..2f5259f 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -2,513 +2,513 @@
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 Incidence *to = destinationEvent; 142 Incidence *to = destinationEvent;
143 while(to) { 143 while(to) {
144 if (to->uid() == todo->uid()) { 144 if (to->uid() == todo->uid()) {
145 KMessageBox::sorry(this, 145 KMessageBox::sorry(this,
146 i18n("Cannot move To-Do to itself\nor a child of itself"), 146 i18n("Cannot move To-Do to itself\nor a child of itself"),
147 i18n("Drop To-Do")); 147 i18n("Drop To-Do"));
148 delete todo; 148 delete todo;
149 return; 149 return;
150 } 150 }
151 to = to->relatedTo(); 151 to = to->relatedTo();
152 } 152 }
153 internalDrop = true; 153 internalDrop = true;
154 if ( destinationEvent ) 154 if ( destinationEvent )
155 reparentTodoSignal( destinationEvent, existingTodo ); 155 reparentTodoSignal( destinationEvent, existingTodo );
156 else 156 else
157 unparentTodoSignal(existingTodo); 157 unparentTodoSignal(existingTodo);
158 delete todo; 158 delete todo;
159 } else { 159 } else {
160 mCalendar->addTodo(todo); 160 mCalendar->addTodo(todo);
161 emit todoDropped(todo, KOGlobals::EVENTADDED); 161 emit todoDropped(todo, KOGlobals::EVENTADDED);
162 if ( destinationEvent ) 162 if ( destinationEvent )
163 reparentTodoSignal( destinationEvent, todo ); 163 reparentTodoSignal( destinationEvent, todo );
164 } 164 }
165 } 165 }
166 else { 166 else {
167 QString text; 167 QString text;
168 if (QTextDrag::decode(e,text)) { 168 if (QTextDrag::decode(e,text)) {
169 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 169 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
170 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 170 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
171 qDebug("Dropped : " + text); 171 qDebug("Dropped : " + text);
172 QStringList emails = QStringList::split(",",text); 172 QStringList emails = QStringList::split(",",text);
173 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 173 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
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 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 183 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
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#ifndef KORG_NODND 192#ifndef KORG_NODND
193 QPoint p(contentsToViewport(e->pos())); 193 QPoint p(contentsToViewport(e->pos()));
194 QListViewItem *i = itemAt(p); 194 QListViewItem *i = itemAt(p);
195 mMousePressed = false; 195 mMousePressed = false;
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 QListView::contentsMousePressEvent(e); 210 QListView::contentsMousePressEvent(e);
211} 211}
212 212
213void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 213void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
214{ 214{
215 215
216#ifndef KORG_NODND 216#ifndef KORG_NODND
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 DndFactory factory( mCalendar ); 223 DndFactory factory( mCalendar );
224 ICalDrag *vd = factory.createDrag( 224 ICalDrag *vd = factory.createDrag(
225 ((KOTodoViewItem *)item)->todo(),viewport()); 225 ((KOTodoViewItem *)item)->todo(),viewport());
226 internalDrop = false; 226 internalDrop = false;
227 // we cannot do any senseful here, because the DnD is still broken in Qt 227 // we cannot do any senseful here, because the DnD is still broken in Qt
228 if (vd->drag()) { 228 if (vd->drag()) {
229 if ( !internalDrop ) { 229 if ( !internalDrop ) {
230 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 230 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
231 qDebug("Dnd: External move: Delete drag source "); 231 qDebug("Dnd: External move: Delete drag source ");
232 } else 232 } else
233 qDebug("Dnd: Internal move "); 233 qDebug("Dnd: Internal move ");
234 234
235 } else { 235 } else {
236 if ( !internalDrop ) { 236 if ( !internalDrop ) {
237 qDebug("Dnd: External Copy"); 237 qDebug("Dnd: External Copy");
238 } else 238 } else
239 qDebug("DnD: Internal copy: Copy pending"); 239 qDebug("DnD: Internal copy: Copy pending");
240 } 240 }
241 } 241 }
242 } 242 }
243#endif 243#endif
244} 244}
245void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 245void KOTodoListView::keyPressEvent ( QKeyEvent * e )
246{ 246{
247 247
248 QListViewItem* cn; 248 QListViewItem* cn;
249 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 249 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
250 cn = currentItem(); 250 cn = currentItem();
251 if ( cn ) { 251 if ( cn ) {
252 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 252 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
253 if ( ci ){ 253 if ( ci ){
254 if ( e->state() == ShiftButton ) 254 if ( e->state() == ShiftButton )
255 ci->setOn( false ); 255 ci->setOn( false );
256 else 256 else
257 ci->setOn( true ); 257 ci->setOn( true );
258 cn = cn->nextSibling(); 258 cn = cn->itemBelow();
259 if ( cn ) { 259 if ( cn ) {
260 setCurrentItem ( cn ); 260 setCurrentItem ( cn );
261 ensureItemVisible ( cn ); 261 ensureItemVisible ( cn );
262 } 262 }
263 263
264 } 264 }
265 } 265 }
266 266
267 return; 267 return;
268 } 268 }
269 269
270 // qDebug("KOTodoListView::keyPressEvent "); 270 // qDebug("KOTodoListView::keyPressEvent ");
271 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 271 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
272 switch ( e->key() ) { 272 switch ( e->key() ) {
273 case Qt::Key_Down: 273 case Qt::Key_Down:
274 case Qt::Key_Up: 274 case Qt::Key_Up:
275 QListView::keyPressEvent ( e ); 275 QListView::keyPressEvent ( e );
276 break; 276 break;
277 case Qt::Key_Left: 277 case Qt::Key_Left:
278 case Qt::Key_Right: 278 case Qt::Key_Right:
279 QListView::keyPressEvent ( e ); 279 QListView::keyPressEvent ( e );
280 e->accept(); 280 e->accept();
281 return; 281 return;
282 break; 282 break;
283 default: 283 default:
284 e->ignore(); 284 e->ignore();
285 break; 285 break;
286 } 286 }
287 return; 287 return;
288 } 288 }
289 e->ignore(); 289 e->ignore();
290} 290}
291void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 291void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
292{ 292{
293 QListView::contentsMouseReleaseEvent(e); 293 QListView::contentsMouseReleaseEvent(e);
294 mMousePressed = false; 294 mMousePressed = false;
295} 295}
296 296
297void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 297void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
298{ 298{
299 if (!e) return; 299 if (!e) return;
300 300
301 QPoint vp = contentsToViewport(e->pos()); 301 QPoint vp = contentsToViewport(e->pos());
302 302
303 QListViewItem *item = itemAt(vp); 303 QListViewItem *item = itemAt(vp);
304 304
305 emit double_Clicked(item); 305 emit double_Clicked(item);
306 if (!item) return; 306 if (!item) return;
307 307
308 emit doubleClicked(item,vp,0); 308 emit doubleClicked(item,vp,0);
309} 309}
310 310
311///////////////////////////////////////////////////////////////////////////// 311/////////////////////////////////////////////////////////////////////////////
312 312
313KOQuickTodo::KOQuickTodo(QWidget *parent) : 313KOQuickTodo::KOQuickTodo(QWidget *parent) :
314 QLineEdit(parent) 314 QLineEdit(parent)
315{ 315{
316 setText(i18n("Click to add a new Todo")); 316 setText(i18n("Click to add a new Todo"));
317} 317}
318 318
319void KOQuickTodo::focusInEvent(QFocusEvent *ev) 319void KOQuickTodo::focusInEvent(QFocusEvent *ev)
320{ 320{
321 if ( text()==i18n("Click to add a new Todo") ) 321 if ( text()==i18n("Click to add a new Todo") )
322 setText(""); 322 setText("");
323 QLineEdit::focusInEvent(ev); 323 QLineEdit::focusInEvent(ev);
324} 324}
325 325
326void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 326void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
327{ 327{
328 setText(i18n("Click to add a new Todo")); 328 setText(i18n("Click to add a new Todo"));
329 QLineEdit::focusOutEvent(ev); 329 QLineEdit::focusOutEvent(ev);
330} 330}
331 331
332///////////////////////////////////////////////////////////////////////////// 332/////////////////////////////////////////////////////////////////////////////
333 333
334KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 334KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
335 KOrg::BaseView(calendar,parent,name) 335 KOrg::BaseView(calendar,parent,name)
336{ 336{
337 isFlatDisplay = false; 337 isFlatDisplay = false;
338 mNavigator = 0; 338 mNavigator = 0;
339 QBoxLayout *topLayout = new QVBoxLayout(this); 339 QBoxLayout *topLayout = new QVBoxLayout(this);
340 mName = QString ( name ); 340 mName = QString ( name );
341 mBlockUpdate = false; 341 mBlockUpdate = false;
342 mQuickAdd = new KOQuickTodo(this); 342 mQuickAdd = new KOQuickTodo(this);
343 topLayout->addWidget(mQuickAdd); 343 topLayout->addWidget(mQuickAdd);
344 344
345 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 345 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
346 346
347 mTodoListView = new KOTodoListView(calendar,this, name ); 347 mTodoListView = new KOTodoListView(calendar,this, name );
348 topLayout->addWidget(mTodoListView); 348 topLayout->addWidget(mTodoListView);
349 //mTodoListView->header()->setMaximumHeight(30); 349 //mTodoListView->header()->setMaximumHeight(30);
350 mTodoListView->setRootIsDecorated(true); 350 mTodoListView->setRootIsDecorated(true);
351 mTodoListView->setAllColumnsShowFocus(true); 351 mTodoListView->setAllColumnsShowFocus(true);
352 352
353 mTodoListView->setShowSortIndicator(true); 353 mTodoListView->setShowSortIndicator(true);
354 354
355 mTodoListView->addColumn(i18n("Todo")); 355 mTodoListView->addColumn(i18n("Todo"));
356 mTodoListView->addColumn(i18n("Prio")); 356 mTodoListView->addColumn(i18n("Prio"));
357 mTodoListView->setColumnAlignment(1,AlignHCenter); 357 mTodoListView->setColumnAlignment(1,AlignHCenter);
358 mTodoListView->addColumn(i18n("Complete")); 358 mTodoListView->addColumn(i18n("Complete"));
359 mTodoListView->setColumnAlignment(2,AlignCenter); 359 mTodoListView->setColumnAlignment(2,AlignCenter);
360 360
361 mTodoListView->addColumn(i18n("Due Date")); 361 mTodoListView->addColumn(i18n("Due Date"));
362 mTodoListView->setColumnAlignment(3,AlignLeft); 362 mTodoListView->setColumnAlignment(3,AlignLeft);
363 mTodoListView->addColumn(i18n("Due Time")); 363 mTodoListView->addColumn(i18n("Due Time"));
364 mTodoListView->setColumnAlignment(4,AlignHCenter); 364 mTodoListView->setColumnAlignment(4,AlignHCenter);
365 365
366 mTodoListView->addColumn(i18n("Start Date")); 366 mTodoListView->addColumn(i18n("Start Date"));
367 mTodoListView->setColumnAlignment(5,AlignLeft); 367 mTodoListView->setColumnAlignment(5,AlignLeft);
368 mTodoListView->addColumn(i18n("Start Time")); 368 mTodoListView->addColumn(i18n("Start Time"));
369 mTodoListView->setColumnAlignment(6,AlignHCenter); 369 mTodoListView->setColumnAlignment(6,AlignHCenter);
370 370
371 mTodoListView->addColumn(i18n("Cancelled")); 371 mTodoListView->addColumn(i18n("Cancelled"));
372 mTodoListView->addColumn(i18n("Categories")); 372 mTodoListView->addColumn(i18n("Categories"));
373#if 0 373#if 0
374 mTodoListView->addColumn(i18n("Sort Id")); 374 mTodoListView->addColumn(i18n("Sort Id"));
375 mTodoListView->setColumnAlignment(4,AlignHCenter); 375 mTodoListView->setColumnAlignment(4,AlignHCenter);
376#endif 376#endif
377 377
378 mTodoListView->setMinimumHeight( 60 ); 378 mTodoListView->setMinimumHeight( 60 );
379 mTodoListView->setItemsRenameable( true ); 379 mTodoListView->setItemsRenameable( true );
380 mTodoListView->setRenameable( 0 ); 380 mTodoListView->setRenameable( 0 );
381 mTodoListView->setColumnWidth( 0, 120 ); 381 mTodoListView->setColumnWidth( 0, 120 );
382 mTodoListView->setColumnWidthMode(0, QListView::Manual); 382 mTodoListView->setColumnWidthMode(0, QListView::Manual);
383 mTodoListView->setColumnWidthMode(1, QListView::Manual); 383 mTodoListView->setColumnWidthMode(1, QListView::Manual);
384 mTodoListView->setColumnWidthMode(2, QListView::Manual); 384 mTodoListView->setColumnWidthMode(2, QListView::Manual);
385 mTodoListView->setColumnWidthMode(3, QListView::Manual); 385 mTodoListView->setColumnWidthMode(3, QListView::Manual);
386 mTodoListView->setColumnWidthMode(4, QListView::Manual); 386 mTodoListView->setColumnWidthMode(4, QListView::Manual);
387 mTodoListView->setColumnWidthMode(5, QListView::Manual); 387 mTodoListView->setColumnWidthMode(5, QListView::Manual);
388 mTodoListView->setColumnWidthMode(6, QListView::Manual); 388 mTodoListView->setColumnWidthMode(6, QListView::Manual);
389 mTodoListView->setColumnWidthMode(7, QListView::Manual); 389 mTodoListView->setColumnWidthMode(7, QListView::Manual);
390 mTodoListView->setColumnWidthMode(8, QListView::Manual); 390 mTodoListView->setColumnWidthMode(8, QListView::Manual);
391 391
392 392
393 mPriorityPopupMenu = new QPopupMenu(this); 393 mPriorityPopupMenu = new QPopupMenu(this);
394 for (int i = 1; i <= 5; i++) { 394 for (int i = 1; i <= 5; i++) {
395 QString label = QString ("%1").arg (i); 395 QString label = QString ("%1").arg (i);
396 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 396 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
397 } 397 }
398 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 398 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
399 399
400 mPercentageCompletedPopupMenu = new QPopupMenu(this); 400 mPercentageCompletedPopupMenu = new QPopupMenu(this);
401 for (int i = 0; i <= 100; i+=20) { 401 for (int i = 0; i <= 100; i+=20) {
402 QString label = QString ("%1 %").arg (i); 402 QString label = QString ("%1 %").arg (i);
403 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 403 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
404 } 404 }
405 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 405 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
406 406
407 407
408 408
409 mItemPopupMenu = new QPopupMenu(this); 409 mItemPopupMenu = new QPopupMenu(this);
410 mItemPopupMenu->insertItem(i18n("Show..."), this, 410 mItemPopupMenu->insertItem(i18n("Show..."), this,
411 SLOT (showTodo())); 411 SLOT (showTodo()));
412 mItemPopupMenu->insertItem(i18n("Edit..."), this, 412 mItemPopupMenu->insertItem(i18n("Edit..."), this,
413 SLOT (editTodo())); 413 SLOT (editTodo()));
414 mItemPopupMenu->insertItem( i18n("Delete"), this, 414 mItemPopupMenu->insertItem( i18n("Delete"), this,
415 SLOT (deleteTodo())); 415 SLOT (deleteTodo()));
416 mItemPopupMenu->insertItem( i18n("Clone..."), this, 416 mItemPopupMenu->insertItem( i18n("Clone..."), this,
417 SLOT (cloneTodo())); 417 SLOT (cloneTodo()));
418 mItemPopupMenu->insertItem( i18n("Move..."), this, 418 mItemPopupMenu->insertItem( i18n("Move..."), this,
419 SLOT (moveTodo())); 419 SLOT (moveTodo()));
420 mItemPopupMenu->insertItem( i18n("Beam..."), this, 420 mItemPopupMenu->insertItem( i18n("Beam..."), this,
421 SLOT (beamTodo())); 421 SLOT (beamTodo()));
422 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 422 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
423 SLOT (cancelTodo())); 423 SLOT (cancelTodo()));
424 mItemPopupMenu->insertSeparator(); 424 mItemPopupMenu->insertSeparator();
425 425
426 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 426 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
427 SLOT (newTodo())); 427 SLOT (newTodo()));
428 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 428 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
429 SLOT (newSubTodo())); 429 SLOT (newSubTodo()));
430 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 430 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
431 SLOT (unparentTodo()),0,21); 431 SLOT (unparentTodo()),0,21);
432 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 432 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
433 SLOT (reparentTodo()),0,22); 433 SLOT (reparentTodo()),0,22);
434 mItemPopupMenu->insertSeparator(); 434 mItemPopupMenu->insertSeparator();
435#if 0 435#if 0
436 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 436 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
437 this, SLOT( purgeCompleted() ) ); 437 this, SLOT( purgeCompleted() ) );
438 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 438 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
439 this, SLOT( toggleCompleted() ),0, 33 ); 439 this, SLOT( toggleCompleted() ),0, 33 );
440 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 440 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
441 this, SLOT( toggleQuickTodo() ),0, 34 ); 441 this, SLOT( toggleQuickTodo() ),0, 34 );
442 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 442 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
443 this, SLOT( toggleRunning() ),0, 35 ); 443 this, SLOT( toggleRunning() ),0, 35 );
444 444
445#endif 445#endif
446 mPopupMenu = new QPopupMenu(this); 446 mPopupMenu = new QPopupMenu(this);
447 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 447 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
448 SLOT (newTodo()),0,1); 448 SLOT (newTodo()),0,1);
449 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 449 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
450 this, SLOT(purgeCompleted()),0,2); 450 this, SLOT(purgeCompleted()),0,2);
451 mPopupMenu->insertItem(i18n("Show Completed"), 451 mPopupMenu->insertItem(i18n("Show Completed"),
452 this, SLOT( toggleCompleted() ),0,3 ); 452 this, SLOT( toggleCompleted() ),0,3 );
453 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 453 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
454 this, SLOT( toggleQuickTodo() ),0,4 ); 454 this, SLOT( toggleQuickTodo() ),0,4 );
455 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 455 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
456 this, SLOT( toggleRunning() ),0,5 ); 456 this, SLOT( toggleRunning() ),0,5 );
457 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 457 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
458 this, SLOT( setAllOpen() ),0,6 ); 458 this, SLOT( setAllOpen() ),0,6 );
459 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 459 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
460 this, SLOT( setAllClose() ),0,7 ); 460 this, SLOT( setAllClose() ),0,7 );
461 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 461 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
462 this, SLOT( setAllFlat() ),0,8 ); 462 this, SLOT( setAllFlat() ),0,8 );
463 mDocPrefs = new DocPrefs( name ); 463 mDocPrefs = new DocPrefs( name );
464 464
465 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 465 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
466 mPopupMenu->setCheckable( true ); 466 mPopupMenu->setCheckable( true );
467 mItemPopupMenu->setCheckable( true ); 467 mItemPopupMenu->setCheckable( true );
468 468
469 469
470 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 470 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
471 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 471 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
472 472
473 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 473 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
474 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 474 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
475 475
476 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 476 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
477 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 477 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
478 478
479 479
480 // Double clicking conflicts with opening/closing the subtree 480 // Double clicking conflicts with opening/closing the subtree
481 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 481 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
482 SLOT( editItem( QListViewItem *) ) ); 482 SLOT( editItem( QListViewItem *) ) );
483 /* 483 /*
484 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 484 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
485 const QPoint &,int ) ), 485 const QPoint &,int ) ),
486 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 486 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
487 */ 487 */
488 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 488 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
489 const QPoint &,int ) ), 489 const QPoint &,int ) ),
490 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 490 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
491 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 491 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
492 SLOT( itemClicked( QListViewItem * ) ) ); 492 SLOT( itemClicked( QListViewItem * ) ) );
493 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 493 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
494 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 494 SLOT( itemDoubleClicked( QListViewItem * ) ) );
495 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 495 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
496 SLOT( updateView() ) ); 496 SLOT( updateView() ) );
497 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 497 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
498 SLOT( todoModified(Todo *, int) ) ); 498 SLOT( todoModified(Todo *, int) ) );
499 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 499 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
500 SLOT( itemStateChanged( QListViewItem * ) ) ); 500 SLOT( itemStateChanged( QListViewItem * ) ) );
501 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 501 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
502 SLOT( itemStateChanged( QListViewItem * ) ) ); 502 SLOT( itemStateChanged( QListViewItem * ) ) );
503 503
504#if 0 504#if 0
505 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 505 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
506 SLOT(selectionChanged(QListViewItem *))); 506 SLOT(selectionChanged(QListViewItem *)));
507 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 507 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
508 SLOT(selectionChanged(QListViewItem *))); 508 SLOT(selectionChanged(QListViewItem *)));
509 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 509 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
510 SLOT(selectionChanged(QListViewItem *))); 510 SLOT(selectionChanged(QListViewItem *)));
511#endif 511#endif
512 512
513 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 513 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
514 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 514 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));