summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
authorzautrix <zautrix>2005-03-31 23:55:51 (UTC)
committer zautrix <zautrix>2005-03-31 23:55:51 (UTC)
commitb76ad1e7e329051a47e28c9d132ce3fcd0b25c5c (patch) (unidiff)
treeb0b3d0eb7a3d29981c183275aadeed0cbbef0007 /korganizer/kotodoview.cpp
parentc0fa26aa3b33c293853bdd7d028ddb0545e33c85 (diff)
downloadkdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.zip
kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.tar.gz
kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.tar.bz2
fixes
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp103
1 files changed, 78 insertions, 25 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index e008625..ccc4b01 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -171,218 +171,232 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e)
171 internalDrop = true; 171 internalDrop = true;
172 if ( destinationEvent ) 172 if ( destinationEvent )
173 reparentTodoSignal( destinationEvent, existingTodo ); 173 reparentTodoSignal( destinationEvent, existingTodo );
174 else 174 else
175 unparentTodoSignal(existingTodo); 175 unparentTodoSignal(existingTodo);
176 delete todo; 176 delete todo;
177 } else { 177 } else {
178 mCalendar->addTodo(todo); 178 mCalendar->addTodo(todo);
179 emit todoDropped(todo, KOGlobals::EVENTADDED); 179 emit todoDropped(todo, KOGlobals::EVENTADDED);
180 if ( destinationEvent ) 180 if ( destinationEvent )
181 reparentTodoSignal( destinationEvent, todo ); 181 reparentTodoSignal( destinationEvent, todo );
182 } 182 }
183 } 183 }
184 else { 184 else {
185 QString text; 185 QString text;
186 if (QTextDrag::decode(e,text)) { 186 if (QTextDrag::decode(e,text)) {
187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
189 qDebug("Dropped : " + text); 189 qDebug("Dropped : " + text);
190 QStringList emails = QStringList::split(",",text); 190 QStringList emails = QStringList::split(",",text);
191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
192 int pos = (*it).find("<"); 192 int pos = (*it).find("<");
193 QString name = (*it).left(pos); 193 QString name = (*it).left(pos);
194 QString email = (*it).mid(pos); 194 QString email = (*it).mid(pos);
195 if (!email.isEmpty() && todoi) { 195 if (!email.isEmpty() && todoi) {
196 todoi->todo()->addAttendee(new Attendee(name,email)); 196 todoi->todo()->addAttendee(new Attendee(name,email));
197 } 197 }
198 } 198 }
199 } 199 }
200 else { 200 else {
201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
202 e->ignore(); 202 e->ignore();
203 } 203 }
204 } 204 }
205#endif 205#endif
206} 206}
207 207
208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
209{ 209{
210#ifndef KORG_NODND 210#ifndef KORG_NODND
211 QPoint p(contentsToViewport(e->pos())); 211 QPoint p(contentsToViewport(e->pos()));
212 QListViewItem *i = itemAt(p); 212 QListViewItem *i = itemAt(p);
213 mMousePressed = false; 213 mMousePressed = false;
214 if (i) { 214 if (i) {
215 // if the user clicked into the root decoration of the item, don't 215 // if the user clicked into the root decoration of the item, don't
216 // try to start a drag! 216 // try to start a drag!
217 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + 217 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
218 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 218 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
219 itemMargin() || 219 itemMargin() ||
220 p.x() < header()->sectionPos(header()->mapToIndex(0))) { 220 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
221 if (e->button()==Qt::LeftButton) { 221 if (e->button()==Qt::LeftButton) {
222 mPressPos = e->pos(); 222 mPressPos = e->pos();
223 mMousePressed = true; 223 mMousePressed = true;
224 } 224 }
225 } 225 }
226 } 226 }
227#endif 227#endif
228 QListView::contentsMousePressEvent(e); 228 QListView::contentsMousePressEvent(e);
229} 229}
230void KOTodoListView::paintEvent(QPaintEvent* e) 230void KOTodoListView::paintEvent(QPaintEvent* e)
231{ 231{
232 emit paintNeeded(); 232 emit paintNeeded();
233 QListView::paintEvent( e); 233 QListView::paintEvent( e);
234} 234}
235void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 235void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
236{ 236{
237 237
238#ifndef KORG_NODND 238#ifndef KORG_NODND
239 //QListView::contentsMouseMoveEvent(e); 239 //QListView::contentsMouseMoveEvent(e);
240 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 240 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
241 QApplication::startDragDistance()*3) { 241 QApplication::startDragDistance()*3) {
242 mMousePressed = false; 242 mMousePressed = false;
243 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 243 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
244 if (item) { 244 if (item) {
245 DndFactory factory( mCalendar ); 245 DndFactory factory( mCalendar );
246 ICalDrag *vd = factory.createDrag( 246 ICalDrag *vd = factory.createDrag(
247 ((KOTodoViewItem *)item)->todo(),viewport()); 247 ((KOTodoViewItem *)item)->todo(),viewport());
248 internalDrop = false; 248 internalDrop = false;
249 // we cannot do any senseful here, because the DnD is still broken in Qt 249 // we cannot do any senseful here, because the DnD is still broken in Qt
250 if (vd->drag()) { 250 if (vd->drag()) {
251 if ( !internalDrop ) { 251 if ( !internalDrop ) {
252 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 252 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
253 qDebug("Dnd: External move: Delete drag source "); 253 qDebug("Dnd: External move: Delete drag source ");
254 } else 254 } else
255 qDebug("Dnd: Internal move "); 255 qDebug("Dnd: Internal move ");
256 256
257 } else { 257 } else {
258 if ( !internalDrop ) { 258 if ( !internalDrop ) {
259 qDebug("Dnd: External Copy"); 259 qDebug("Dnd: External Copy");
260 } else 260 } else
261 qDebug("DnD: Internal copy: Copy pending"); 261 qDebug("DnD: Internal copy: Copy pending");
262 } 262 }
263 } 263 }
264 } 264 }
265#endif 265#endif
266} 266}
267void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
268{
269 if ( !e->isAutoRepeat() ) {
270 mFlagKeyPressed = false;
271 }
272}
273
274
267void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 275void KOTodoListView::keyPressEvent ( QKeyEvent * e )
268{ 276{
269 277 qApp->processEvents();
278 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
279 e->ignore();
280 // qDebug(" ignore %d",e->isAutoRepeat() );
281 return;
282 }
283 if (! e->isAutoRepeat() )
284 mFlagKeyPressed = true;
270 QListViewItem* cn; 285 QListViewItem* cn;
271 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 286 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
272 cn = currentItem(); 287 cn = currentItem();
273 if ( cn ) { 288 if ( cn ) {
274 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 289 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
275 if ( ci ){ 290 if ( ci ){
276 if ( e->state() == ShiftButton ) 291 if ( e->state() == ShiftButton )
277 ci->setOn( false ); 292 ci->setOn( false );
278 else 293 else
279 ci->setOn( true ); 294 ci->setOn( true );
280 cn = cn->itemBelow(); 295 cn = cn->itemBelow();
281 if ( cn ) { 296 if ( cn ) {
282 setCurrentItem ( cn ); 297 setCurrentItem ( cn );
283 ensureItemVisible ( cn ); 298 ensureItemVisible ( cn );
284 } 299 }
285 300
286 } 301 }
287 } 302 }
288 303
289 return; 304 return;
290 } 305 }
291 306
292 // qDebug("KOTodoListView::keyPressEvent ");
293 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 307 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
294 switch ( e->key() ) { 308 switch ( e->key() ) {
295 case Qt::Key_Down: 309 case Qt::Key_Down:
296 case Qt::Key_Up: 310 case Qt::Key_Up:
297 QListView::keyPressEvent ( e ); 311 QListView::keyPressEvent ( e );
298 break; 312 break;
299 case Qt::Key_Left: 313 case Qt::Key_Left:
300 case Qt::Key_Right: 314 case Qt::Key_Right:
301 QListView::keyPressEvent ( e ); 315 QListView::keyPressEvent ( e );
302 e->accept(); 316 e->accept();
303 return; 317 return;
304 break; 318 break;
305 default: 319 default:
306 e->ignore(); 320 e->ignore();
307 break; 321 break;
308 } 322 }
309 return; 323 return;
310 } 324 }
311 e->ignore(); 325 e->ignore();
312} 326}
313void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 327void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
314{ 328{
315 QListView::contentsMouseReleaseEvent(e); 329 QListView::contentsMouseReleaseEvent(e);
316 mMousePressed = false; 330 mMousePressed = false;
317} 331}
318 332
319void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 333void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
320{ 334{
321 if (!e) return; 335 if (!e) return;
322 336
323 QPoint vp = contentsToViewport(e->pos()); 337 QPoint vp = contentsToViewport(e->pos());
324 338
325 QListViewItem *item = itemAt(vp); 339 QListViewItem *item = itemAt(vp);
326 340
327 emit double_Clicked(item); 341 emit double_Clicked(item);
328 if (!item) return; 342 if (!item) return;
329 343
330 emit doubleClicked(item,vp,0); 344 emit doubleClicked(item,vp,0);
331} 345}
332 346
333///////////////////////////////////////////////////////////////////////////// 347/////////////////////////////////////////////////////////////////////////////
334 348
335KOQuickTodo::KOQuickTodo(QWidget *parent) : 349KOQuickTodo::KOQuickTodo(QWidget *parent) :
336 QLineEdit(parent) 350 QLineEdit(parent)
337{ 351{
338 setText(i18n("Click to add a new Todo")); 352 setText(i18n("Click to add a new Todo"));
339} 353}
340 354
341void KOQuickTodo::focusInEvent(QFocusEvent *ev) 355void KOQuickTodo::focusInEvent(QFocusEvent *ev)
342{ 356{
343 if ( text()==i18n("Click to add a new Todo") ) 357 if ( text()==i18n("Click to add a new Todo") )
344 setText(""); 358 setText("");
345 QLineEdit::focusInEvent(ev); 359 QLineEdit::focusInEvent(ev);
346} 360}
347 361
348void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 362void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
349{ 363{
350 setText(i18n("Click to add a new Todo")); 364 setText(i18n("Click to add a new Todo"));
351 QLineEdit::focusOutEvent(ev); 365 QLineEdit::focusOutEvent(ev);
352} 366}
353 367
354///////////////////////////////////////////////////////////////////////////// 368/////////////////////////////////////////////////////////////////////////////
355 369
356KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 370KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
357 KOrg::BaseView(calendar,parent,name) 371 KOrg::BaseView(calendar,parent,name)
358{ 372{
359 mPendingUpdateBeforeRepaint = false; 373 mPendingUpdateBeforeRepaint = false;
360 isFlatDisplay = false; 374 isFlatDisplay = false;
361 mNavigator = 0; 375 mNavigator = 0;
362 QBoxLayout *topLayout = new QVBoxLayout(this); 376 QBoxLayout *topLayout = new QVBoxLayout(this);
363 mName = QString ( name ); 377 mName = QString ( name );
364 mBlockUpdate = false; 378 mBlockUpdate = false;
365 mQuickAdd = new KOQuickTodo(this); 379 mQuickAdd = new KOQuickTodo(this);
366 topLayout->addWidget(mQuickAdd); 380 topLayout->addWidget(mQuickAdd);
367 381
368 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 382 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
369 383
370 mTodoListView = new KOTodoListView(calendar,this, name ); 384 mTodoListView = new KOTodoListView(calendar,this, name );
371 topLayout->addWidget(mTodoListView); 385 topLayout->addWidget(mTodoListView);
372 //mTodoListView->header()->setMaximumHeight(30); 386 //mTodoListView->header()->setMaximumHeight(30);
373 mTodoListView->setRootIsDecorated(true); 387 mTodoListView->setRootIsDecorated(true);
374 mTodoListView->setAllColumnsShowFocus(true); 388 mTodoListView->setAllColumnsShowFocus(true);
375 389
376 mTodoListView->setShowSortIndicator(true); 390 mTodoListView->setShowSortIndicator(true);
377 391
378 mTodoListView->addColumn(i18n("Todo")); 392 mTodoListView->addColumn(i18n("Todo"));
379 mTodoListView->addColumn(i18n("Prio")); 393 mTodoListView->addColumn(i18n("Prio"));
380 mTodoListView->setColumnAlignment(1,AlignHCenter); 394 mTodoListView->setColumnAlignment(1,AlignHCenter);
381 mTodoListView->addColumn(i18n("Complete")); 395 mTodoListView->addColumn(i18n("Complete"));
382 mTodoListView->setColumnAlignment(2,AlignCenter); 396 mTodoListView->setColumnAlignment(2,AlignCenter);
383 397
384 mTodoListView->addColumn(i18n("Due Date")); 398 mTodoListView->addColumn(i18n("Due Date"));
385 mTodoListView->setColumnAlignment(3,AlignLeft); 399 mTodoListView->setColumnAlignment(3,AlignLeft);
386 mTodoListView->addColumn(i18n("Due Time")); 400 mTodoListView->addColumn(i18n("Due Time"));
387 mTodoListView->setColumnAlignment(4,AlignHCenter); 401 mTodoListView->setColumnAlignment(4,AlignHCenter);
388 402
@@ -505,306 +519,344 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
505 // Double clicking conflicts with opening/closing the subtree 519 // Double clicking conflicts with opening/closing the subtree
506 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 520 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
507 SLOT( editItem( QListViewItem *) ) ); 521 SLOT( editItem( QListViewItem *) ) );
508 /* 522 /*
509 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 523 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
510 const QPoint &,int ) ), 524 const QPoint &,int ) ),
511 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 525 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
512 */ 526 */
513 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 527 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
514 const QPoint &,int ) ), 528 const QPoint &,int ) ),
515 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 529 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
516 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 530 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
517 SLOT( itemClicked( QListViewItem * ) ) ); 531 SLOT( itemClicked( QListViewItem * ) ) );
518 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 532 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
519 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 533 SLOT( itemDoubleClicked( QListViewItem * ) ) );
520 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 534 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
521 SLOT( updateView() ) ); 535 SLOT( updateView() ) );
522 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 536 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
523 SLOT( todoModified(Todo *, int) ) ); 537 SLOT( todoModified(Todo *, int) ) );
524 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 538 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
525 SLOT( itemStateChanged( QListViewItem * ) ) ); 539 SLOT( itemStateChanged( QListViewItem * ) ) );
526 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 540 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
527 SLOT( itemStateChanged( QListViewItem * ) ) ); 541 SLOT( itemStateChanged( QListViewItem * ) ) );
528 connect( mTodoListView, SIGNAL( paintNeeded() ), 542 connect( mTodoListView, SIGNAL( paintNeeded() ),
529 SLOT( paintNeeded()) ); 543 SLOT( paintNeeded()) );
530 544
531#if 0 545#if 0
532 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 546 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
533 SLOT(selectionChanged(QListViewItem *))); 547 SLOT(selectionChanged(QListViewItem *)));
534 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 548 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
535 SLOT(selectionChanged(QListViewItem *))); 549 SLOT(selectionChanged(QListViewItem *)));
536 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 550 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
537 SLOT(selectionChanged(QListViewItem *))); 551 SLOT(selectionChanged(QListViewItem *)));
538#endif 552#endif
539 553
540 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 554 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
541 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 555 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
542 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 556 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
543 557
544 connect( mTodoListView, SIGNAL(selectionChanged() ), 558 connect( mTodoListView, SIGNAL(selectionChanged() ),
545 SLOT( processSelectionChange() ) ); 559 SLOT( processSelectionChange() ) );
546 connect( mQuickAdd, SIGNAL( returnPressed () ), 560 connect( mQuickAdd, SIGNAL( returnPressed () ),
547 SLOT( addQuickTodo() ) ); 561 SLOT( addQuickTodo() ) );
548 562
549} 563}
550 564
551KOTodoView::~KOTodoView() 565KOTodoView::~KOTodoView()
552{ 566{
553 // delete mKOTodoViewWhatsThis; 567 // delete mKOTodoViewWhatsThis;
554 delete mDocPrefs; 568 delete mDocPrefs;
555} 569}
556QString KOTodoView::getWhatsThisText(QPoint p) 570QString KOTodoView::getWhatsThisText(QPoint p)
557{ 571{
558 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 572 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
559 if ( item ) 573 if ( item )
560 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 574 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
561 KOPrefs::instance()->mWTshowDetails, 575 KOPrefs::instance()->mWTshowDetails,
562 KOPrefs::instance()->mWTshowCreated, 576 KOPrefs::instance()->mWTshowCreated,
563 KOPrefs::instance()->mWTshowChanged); 577 KOPrefs::instance()->mWTshowChanged);
564 return i18n("That is the todo view" ); 578 return i18n("That is the todo view" );
565 579
566} 580}
567 581
568void KOTodoView::jumpToDate () 582void KOTodoView::jumpToDate ()
569{ 583{
570 // if (mActiveItem) { 584 // if (mActiveItem) {
571// mActiveItem->todo()); 585// mActiveItem->todo());
572// if ( mActiveItem->todo()->hasDueDate() ) 586// if ( mActiveItem->todo()->hasDueDate() )
573// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 587// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
574} 588}
575void KOTodoView::paintNeeded() 589void KOTodoView::paintNeeded()
576{ 590{
577 if ( mPendingUpdateBeforeRepaint ) { 591 if ( mPendingUpdateBeforeRepaint ) {
578 updateView(); 592 updateView();
579 mPendingUpdateBeforeRepaint = false; 593 mPendingUpdateBeforeRepaint = false;
580 } 594 }
581} 595}
582void KOTodoView::paintEvent(QPaintEvent * pevent) 596void KOTodoView::paintEvent(QPaintEvent * pevent)
583{ 597{
584 if ( mPendingUpdateBeforeRepaint ) { 598 if ( mPendingUpdateBeforeRepaint ) {
585 updateView(); 599 updateView();
586 mPendingUpdateBeforeRepaint = false; 600 mPendingUpdateBeforeRepaint = false;
587 } 601 }
588 KOrg::BaseView::paintEvent( pevent); 602 KOrg::BaseView::paintEvent( pevent);
589} 603}
590 604
591void KOTodoView::updateView() 605void KOTodoView::updateView()
592{ 606{
593 pendingSubtodo = 0; 607 pendingSubtodo = 0;
594 if ( mBlockUpdate ) { 608 if ( mBlockUpdate ) {
595 return; 609 return;
596 } 610 }
597 if ( !isVisible() ) { 611 if ( !isVisible() ) {
598 mPendingUpdateBeforeRepaint = true; 612 mPendingUpdateBeforeRepaint = true;
599 return; 613 return;
600 } 614 }
615 storeCurrentItem();
601 //qDebug("KOTodoView::updateView() %x", this); 616 //qDebug("KOTodoView::updateView() %x", this);
602 if ( isFlatDisplay ) { 617 if ( isFlatDisplay ) {
603 displayAllFlat(); 618 displayAllFlat();
619 resetCurrentItem();
604 return; 620 return;
605 } 621 }
606 //qDebug("update "); 622 //qDebug("update ");
607// kdDebug() << "KOTodoView::updateView()" << endl; 623// kdDebug() << "KOTodoView::updateView()" << endl;
608 QFont fo = KOPrefs::instance()->mTodoViewFont; 624 QFont fo = KOPrefs::instance()->mTodoViewFont;
609 Incidence* oldInc = 0; 625
610 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
611 if (mActiveItem)
612 oldInc = mActiveItem->todo();
613 626
614 mTodoListView->clear(); 627 mTodoListView->clear();
615 if ( mName == "todolistsmall" ) { 628 if ( mName == "todolistsmall" ) {
616 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 629 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
617 int ps = fo.pointSize() -2; 630 int ps = fo.pointSize() -2;
618 if ( ps > 12 ) 631 if ( ps > 12 )
619 ps -= 2; 632 ps -= 2;
620 fo.setPointSize( ps ); 633 fo.setPointSize( ps );
621 } 634 }
622 } 635 }
623 636
624 mTodoListView->setFont( fo ); 637 mTodoListView->setFont( fo );
625 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 638 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
626 //mTodoListView->header()->setMaximumHeight(fm.height()); 639 //mTodoListView->header()->setMaximumHeight(fm.height());
627 QPtrList<Todo> todoList = calendar()->todos(); 640 QPtrList<Todo> todoList = calendar()->todos();
628 641
629/* 642/*
630 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 643 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
631 Event *t; 644 Event *t;
632 for(t = todoList.first(); t; t = todoList.next()) { 645 for(t = todoList.first(); t; t = todoList.next()) {
633 kdDebug() << " " << t->getSummary() << endl; 646 kdDebug() << " " << t->getSummary() << endl;
634 647
635 if (t->getRelatedTo()) { 648 if (t->getRelatedTo()) {
636 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 649 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
637 } 650 }
638 651
639 QPtrList<Event> l = t->getRelations(); 652 QPtrList<Event> l = t->getRelations();
640 Event *c; 653 Event *c;
641 for(c=l.first();c;c=l.next()) { 654 for(c=l.first();c;c=l.next()) {
642 kdDebug() << " - relation: " << c->getSummary() << endl; 655 kdDebug() << " - relation: " << c->getSummary() << endl;
643 } 656 }
644 } 657 }
645*/ 658*/
646 659
647 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 660 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
648 // specific order of events. That means that we have to generate parent items 661 // specific order of events. That means that we have to generate parent items
649 // recursively for proper hierarchical display of Todos. 662 // recursively for proper hierarchical display of Todos.
650 mTodoMap.clear(); 663 mTodoMap.clear();
651 Todo *todo; 664 Todo *todo;
652 todo = todoList.first();// todo; todo = todoList.next()) { 665 todo = todoList.first();// todo; todo = todoList.next()) {
653 while ( todo ) { 666 while ( todo ) {
654 bool next = true; 667 bool next = true;
655 // qDebug("todo %s ", todo->summary().latin1()); 668 // qDebug("todo %s ", todo->summary().latin1());
656 Incidence *incidence = todo->relatedTo(); 669 Incidence *incidence = todo->relatedTo();
657 while ( incidence ) { 670 while ( incidence ) {
658 if ( incidence->type() == "Todo") { 671 if ( incidence->type() == "Todo") {
659 //qDebug("related %s ",incidence->summary().latin1() ); 672 //qDebug("related %s ",incidence->summary().latin1() );
660 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 673 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
661 //qDebug("related not found "); 674 //qDebug("related not found ");
662 todoList.remove( ); 675 todoList.remove( );
663 todo = todoList.current(); 676 todo = todoList.current();
664 next = false; 677 next = false;
665 incidence = 0; 678 incidence = 0;
666 679
667 } else { 680 } else {
668 //qDebug("related found "); 681 //qDebug("related found ");
669 incidence = incidence->relatedTo(); 682 incidence = incidence->relatedTo();
670 } 683 }
671 } else 684 } else
672 incidence = 0; 685 incidence = 0;
673 } 686 }
674 if ( next ) 687 if ( next )
675 todo = todoList.next(); 688 todo = todoList.next();
676 } 689 }
677// qDebug("again .... "); 690// qDebug("again .... ");
678// for(todo = todoList.first(); todo; todo = todoList.next()) { 691// for(todo = todoList.first(); todo; todo = todoList.next()) {
679 692
680// qDebug("yytodo %s ", todo->summary().latin1()); 693// qDebug("yytodo %s ", todo->summary().latin1());
681// } 694// }
682 //qDebug("for "); 695 //qDebug("for ");
683 for(todo = todoList.first(); todo; todo = todoList.next()) { 696 for(todo = todoList.first(); todo; todo = todoList.next()) {
684 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 697 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
685 { 698 {
686 insertTodoItem(todo); 699 insertTodoItem(todo);
687 } 700 }
688 } 701 }
689 //qDebug("for end "); 702 //qDebug("for end ");
690 // Restore opened/closed state 703 // Restore opened/closed state
691 mTodoListView->blockSignals( true ); 704 mTodoListView->blockSignals( true );
692 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 705 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
693 mTodoListView->blockSignals( false ); 706 mTodoListView->blockSignals( false );
694 mTodoListView->setFocus(); 707 resetCurrentItem();
695 if ( mTodoListView->firstChild () ) {
696 if ( oldInc ) {
697 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
698 while ( item ) {
699 if ( item->todo() == oldInc ) {
700 mTodoListView->setCurrentItem( item );
701 mTodoListView->ensureItemVisible( item );
702 break;
703 }
704 item = (KOTodoViewItem*)item->itemBelow();
705 }
706 if ( ! item )
707 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
708 } else {
709 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
710 }
711 }
712 processSelectionChange(); 708 processSelectionChange();
713} 709}
714 710
711void KOTodoView::storeCurrentItem()
712{
713 mCurItem = 0;
714 mCurItemRootParent = 0;
715 mCurItemAbove = 0;
716 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
717 if (mActiveItem) {
718 mCurItem = mActiveItem->todo();
719 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
720 if ( activeItemAbove )
721 mCurItemAbove = activeItemAbove->todo();
722 while ( mActiveItem->parent() != 0 )
723 mActiveItem = (KOTodoViewItem*)mActiveItem->parent();
724 mCurItemRootParent = mActiveItem->todo();
725 }
726 mActiveItem = 0;
727}
728
729void KOTodoView::resetCurrentItem()
730{
731 mTodoListView->setFocus();
732 KOTodoViewItem* foundItem = 0;
733 KOTodoViewItem* foundItemRoot = 0;
734 KOTodoViewItem* foundItemAbove = 0;
735 if ( mTodoListView->firstChild () ) {
736 if ( mCurItem ) {
737 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
738 while ( item ) {
739 if ( item->todo() == mCurItem ) {
740 foundItem = item;
741 break;
742 } else if ( item->todo() == mCurItemAbove ) {
743 foundItemAbove = item;
744
745 } else if ( item->todo() == mCurItemRootParent ) {
746 foundItemRoot = item;
747 }
748 item = (KOTodoViewItem*)item->itemBelow();
749 }
750 if ( ! foundItem ) {
751 if ( foundItemAbove )
752 foundItem = foundItemAbove;
753 else
754 foundItem = foundItemRoot;
755 }
756 }
757 if ( foundItem ) {
758 mTodoListView->setCurrentItem( foundItem );
759 mTodoListView->ensureItemVisible( foundItem );
760 } else {
761 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
762 }
763 }
764 mTodoListView->setFocus();
765}
766//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
715bool KOTodoView::checkTodo( Todo * todo ) 767bool KOTodoView::checkTodo( Todo * todo )
716{ 768{
717 769
718 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 770 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
719 return false; 771 return false;
720 if ( !todo->isCompleted() ) { 772 if ( !todo->isCompleted() ) {
721 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 773 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
722 return true; 774 return true;
723 } 775 }
724 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 776 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
725 if ( todo->hasStartDate() ) 777 if ( todo->hasStartDate() )
726 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 778 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
727 return false; 779 return false;
728 if ( todo->hasDueDate() ) 780 if ( todo->hasDueDate() )
729 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 781 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
730 return false; 782 return false;
731 } 783 }
732 return true; 784 return true;
733} 785}
734 786
735void KOTodoView::restoreItemState( QListViewItem *item ) 787void KOTodoView::restoreItemState( QListViewItem *item )
736{ 788{
737 pendingSubtodo = 0; 789 pendingSubtodo = 0;
738 while( item ) { 790 while( item ) {
739 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 791 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
740 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 792 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
741 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 793 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
742 item = item->nextSibling(); 794 item = item->nextSibling();
743 } 795 }
744} 796}
745 797
746 798
747QMap<Todo *,KOTodoViewItem *>::ConstIterator 799QMap<Todo *,KOTodoViewItem *>::ConstIterator
748 KOTodoView::insertTodoItem(Todo *todo) 800 KOTodoView::insertTodoItem(Todo *todo)
749{ 801{
750 802
751// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 803// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
752 // TODO: Check, if dynmaic cast is necessary 804 // TODO: Check, if dynmaic cast is necessary
753 805
754 pendingSubtodo = 0; 806 pendingSubtodo = 0;
755 Incidence *incidence = todo->relatedTo(); 807 Incidence *incidence = todo->relatedTo();
756 if (incidence && incidence->type() == "Todo") { 808 if (incidence && incidence->type() == "Todo") {
757 Todo *relatedTodo = static_cast<Todo *>(incidence); 809 Todo *relatedTodo = static_cast<Todo *>(incidence);
758 810
759// kdDebug() << " has Related" << endl; 811// kdDebug() << " has Related" << endl;
760 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 812 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
761 itemIterator = mTodoMap.find(relatedTodo); 813 itemIterator = mTodoMap.find(relatedTodo);
762 if (itemIterator == mTodoMap.end()) { 814 if (itemIterator == mTodoMap.end()) {
763// kdDebug() << " related not yet in list" << endl; 815// kdDebug() << " related not yet in list" << endl;
764 itemIterator = insertTodoItem (relatedTodo); 816 itemIterator = insertTodoItem (relatedTodo);
765 } 817 }
766 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 818 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
767 // and one into the map. Sure finding is more easy but why? -zecke 819 // and one into the map. Sure finding is more easy but why? -zecke
768 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 820 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
769 return mTodoMap.insert(todo,todoItem); 821 return mTodoMap.insert(todo,todoItem);
770 } else { 822 } else {
771// kdDebug() << " no Related" << endl; 823// kdDebug() << " no Related" << endl;
772 // see above -zecke 824 // see above -zecke
773 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 825 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
774 return mTodoMap.insert(todo,todoItem); 826 return mTodoMap.insert(todo,todoItem);
775 } 827 }
776} 828}
777 829
778 830
779void KOTodoView::updateConfig() 831void KOTodoView::updateConfig()
780{ 832{
781 updateView(); 833 updateView();
782 mTodoListView->repaintContents(); 834 mTodoListView->repaintContents();
783} 835}
784 836
785QPtrList<Incidence> KOTodoView::selectedIncidences() 837QPtrList<Incidence> KOTodoView::selectedIncidences()
786{ 838{
787 QPtrList<Incidence> selected; 839 QPtrList<Incidence> selected;
788 840
789 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 841 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
790// if (!item) item = mActiveItem; 842// if (!item) item = mActiveItem;
791 if (item) selected.append(item->todo()); 843 if (item) selected.append(item->todo());
792 844
793 return selected; 845 return selected;
794} 846}
795 847
796QPtrList<Todo> KOTodoView::selectedTodos() 848QPtrList<Todo> KOTodoView::selectedTodos()
797{ 849{
798 QPtrList<Todo> selected; 850 QPtrList<Todo> selected;
799 851
800 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 852 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
801// if (!item) item = mActiveItem; 853// if (!item) item = mActiveItem;
802 if (item) selected.append(item->todo()); 854 if (item) selected.append(item->todo());
803 855
804 return selected; 856 return selected;
805} 857}
806 858
807void KOTodoView::changeEventDisplay(Event *, int) 859void KOTodoView::changeEventDisplay(Event *, int)
808{ 860{
809 updateView(); 861 updateView();
810} 862}
@@ -1146,194 +1198,195 @@ void KOTodoView::setAllClose()
1146 } 1198 }
1147 setOpen(mTodoListView->firstChild(), false); 1199 setOpen(mTodoListView->firstChild(), false);
1148} 1200}
1149void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1201void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1150{ 1202{
1151 1203
1152 while ( item ) { 1204 while ( item ) {
1153 setOpen( item->firstChild(), setOpenI ); 1205 setOpen( item->firstChild(), setOpenI );
1154 item->setOpen( setOpenI ); 1206 item->setOpen( setOpenI );
1155 item = item->nextSibling(); 1207 item = item->nextSibling();
1156 } 1208 }
1157} 1209}
1158 1210
1159void KOTodoView::displayAllFlat() 1211void KOTodoView::displayAllFlat()
1160{ 1212{
1161 pendingSubtodo = 0; 1213 pendingSubtodo = 0;
1162 if ( mBlockUpdate ) { 1214 if ( mBlockUpdate ) {
1163 return; 1215 return;
1164 } 1216 }
1165 mPopupMenu->setItemChecked( 8,true ); 1217 mPopupMenu->setItemChecked( 8,true );
1166 isFlatDisplay = true; 1218 isFlatDisplay = true;
1167 QPtrList<Todo> todoList = calendar()->todos(); 1219 QPtrList<Todo> todoList = calendar()->todos();
1168 mTodoMap.clear(); 1220 mTodoMap.clear();
1169 mTodoListView->clear(); 1221 mTodoListView->clear();
1170 Todo *todo; 1222 Todo *todo;
1171 for(todo = todoList.first(); todo; todo = todoList.next()) { 1223 for(todo = todoList.first(); todo; todo = todoList.next()) {
1172 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1224 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1173 mTodoMap.insert(todo,todoItem); 1225 mTodoMap.insert(todo,todoItem);
1174 } 1226 }
1175 mTodoListView->setFocus(); 1227 mTodoListView->setFocus();
1176 processSelectionChange(); 1228 processSelectionChange();
1177} 1229}
1178 1230
1179void KOTodoView::setAllFlat() 1231void KOTodoView::setAllFlat()
1180{ 1232{
1181 if ( isFlatDisplay ) { 1233 if ( isFlatDisplay ) {
1182 isFlatDisplay = false; 1234 isFlatDisplay = false;
1183 mPopupMenu->setItemChecked( 8,false ); 1235 mPopupMenu->setItemChecked( 8,false );
1184 updateView(); 1236 updateView();
1185 return; 1237 return;
1186 } 1238 }
1187 displayAllFlat(); 1239 displayAllFlat();
1188} 1240}
1189 1241
1190void KOTodoView::purgeCompleted() 1242void KOTodoView::purgeCompleted()
1191{ 1243{
1192 emit purgeCompletedSignal(); 1244 emit purgeCompletedSignal();
1193} 1245}
1194void KOTodoView::toggleQuickTodo() 1246void KOTodoView::toggleQuickTodo()
1195{ 1247{
1196 if ( mQuickAdd->isVisible() ) { 1248 if ( mQuickAdd->isVisible() ) {
1197 mQuickAdd->hide(); 1249 mQuickAdd->hide();
1198 KOPrefs::instance()->mEnableQuickTodo = false; 1250 KOPrefs::instance()->mEnableQuickTodo = false;
1199 } 1251 }
1200 else { 1252 else {
1201 mQuickAdd->show(); 1253 mQuickAdd->show();
1202 KOPrefs::instance()->mEnableQuickTodo = true; 1254 KOPrefs::instance()->mEnableQuickTodo = true;
1203 } 1255 }
1204 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1256 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1205 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1257 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1206} 1258}
1207 1259
1208void KOTodoView::toggleRunning() 1260void KOTodoView::toggleRunning()
1209{ 1261{
1210 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1262 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1211 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1263 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1212 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1264 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1213 updateView(); 1265 updateView();
1214} 1266}
1215 1267
1216void KOTodoView::toggleCompleted() 1268void KOTodoView::toggleCompleted()
1217{ 1269{
1218 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1270 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1219 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1271 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1220 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1272 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1221 updateView(); 1273 updateView();
1222} 1274}
1223 1275
1224void KOTodoView::addQuickTodo() 1276void KOTodoView::addQuickTodo()
1225{ 1277{
1226 Todo *todo = new Todo(); 1278 Todo *todo = new Todo();
1227 todo->setSummary(mQuickAdd->text()); 1279 todo->setSummary(mQuickAdd->text());
1228 todo->setOrganizer(KOPrefs::instance()->email()); 1280 todo->setOrganizer(KOPrefs::instance()->email());
1229 CalFilter * cf = mCalendar->filter(); 1281 CalFilter * cf = mCalendar->filter();
1230 if ( cf ) { 1282 if ( cf ) {
1231 if ( cf->isEnabled()&& cf->showCategories()) { 1283 if ( cf->isEnabled()&& cf->showCategories()) {
1232 todo->setCategories(cf->categoryList()); 1284 todo->setCategories(cf->categoryList());
1233 } 1285 }
1234 if ( cf->isEnabled() ) 1286 if ( cf->isEnabled() )
1235 todo->setSecrecy( cf->getSecrecy()); 1287 todo->setSecrecy( cf->getSecrecy());
1236 } 1288 }
1237 mCalendar->addTodo(todo); 1289 mCalendar->addTodo(todo);
1238 mQuickAdd->setText(""); 1290 mQuickAdd->setText("");
1239 todoModified (todo, KOGlobals::EVENTADDED ); 1291 todoModified (todo, KOGlobals::EVENTADDED );
1240 updateView(); 1292 updateView();
1241} 1293}
1294
1242void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1295void KOTodoView::keyPressEvent ( QKeyEvent * e )
1243{ 1296{
1244 // e->ignore(); 1297 // e->ignore();
1245 //return; 1298 //return;
1246 //qDebug("KOTodoView::keyPressEvent "); 1299 //qDebug("KOTodoView::keyPressEvent ");
1247 switch ( e->key() ) { 1300 switch ( e->key() ) {
1248 case Qt::Key_Down: 1301 case Qt::Key_Down:
1249 case Qt::Key_Up: 1302 case Qt::Key_Up:
1250 QWidget::keyPressEvent ( e ); 1303 QWidget::keyPressEvent ( e );
1251 break; 1304 break;
1252 1305
1253 case Qt::Key_Q: 1306 case Qt::Key_Q:
1254 toggleQuickTodo(); 1307 toggleQuickTodo();
1255 break; 1308 break;
1256 case Qt::Key_U: 1309 case Qt::Key_U:
1257 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1310 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1258 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1311 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1259 unparentTodo(); 1312 unparentTodo();
1260 e->accept(); 1313 e->accept();
1261 } else 1314 } else
1262 e->ignore(); 1315 e->ignore();
1263 break; 1316 break;
1264 case Qt::Key_S: 1317 case Qt::Key_S:
1265 if ( e->state() == Qt::ControlButton ) { 1318 if ( e->state() == Qt::ControlButton ) {
1266 e->ignore(); 1319 e->ignore();
1267 break; 1320 break;
1268 } 1321 }
1269 if ( e->state() == Qt::ShiftButton ) { 1322 if ( e->state() == Qt::ShiftButton ) {
1270 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1323 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1271 reparentTodo(); 1324 reparentTodo();
1272 e->accept(); 1325 e->accept();
1273 } else 1326 } else
1274 e->ignore(); 1327 e->ignore();
1275 break; 1328 break;
1276 case Qt::Key_P: 1329 case Qt::Key_P:
1277 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1330 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1278 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1331 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1279 if ( pendingSubtodo ) 1332 if ( pendingSubtodo )
1280 itemClicked(mActiveItem); 1333 itemClicked(mActiveItem);
1281 e->accept(); 1334 e->accept();
1282 } else 1335 } else
1283 e->ignore(); 1336 e->ignore();
1284 break; 1337 break;
1285 case Qt::Key_Escape: 1338 case Qt::Key_Escape:
1286 if ( pendingSubtodo ) { 1339 if ( pendingSubtodo ) {
1287 itemClicked(0); 1340 itemClicked(0);
1288 e->accept(); 1341 e->accept();
1289 } else 1342 } else
1290 e->ignore(); 1343 e->ignore();
1291 break; 1344 break;
1292 default: 1345 default:
1293 e->ignore(); 1346 e->ignore();
1294 } 1347 }
1295 1348
1296 if ( true ) { 1349 if ( true ) {
1297 if ( e->key() == Qt::Key_I ) { 1350 if ( e->key() == Qt::Key_I ) {
1298 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1351 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1299 if ( cn ) { 1352 if ( cn ) {
1300 mActiveItem = cn; 1353 mActiveItem = cn;
1301 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1354 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1302 if ( ci ){ 1355 if ( ci ){
1303 showTodo(); 1356 showTodo();
1304 cn = (KOTodoViewItem*)cn->itemBelow(); 1357 cn = (KOTodoViewItem*)cn->itemBelow();
1305 if ( cn ) { 1358 if ( cn ) {
1306 mTodoListView->setCurrentItem ( cn ); 1359 mTodoListView->setCurrentItem ( cn );
1307 mTodoListView->ensureItemVisible ( cn ); 1360 mTodoListView->ensureItemVisible ( cn );
1308 } 1361 }
1309 1362
1310 } 1363 }
1311 } 1364 }
1312 e->accept(); 1365 e->accept();
1313 1366
1314 } 1367 }
1315 1368
1316 } 1369 }
1317 1370
1318} 1371}
1319void KOTodoView::updateTodo( Todo * t, int type ) 1372void KOTodoView::updateTodo( Todo * t, int type )
1320{ 1373{
1321 if ( mBlockUpdate) 1374 if ( mBlockUpdate)
1322 return; 1375 return;
1323 1376
1324 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1377 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1325 itemIterator = mTodoMap.find(t); 1378 itemIterator = mTodoMap.find(t);
1326 if (itemIterator != mTodoMap.end()) { 1379 if (itemIterator != mTodoMap.end()) {
1327 (*itemIterator)->construct(); 1380 (*itemIterator)->construct();
1328 } else { 1381 } else {
1329 if ( type == KOGlobals::EVENTADDED ) { 1382 if ( type == KOGlobals::EVENTADDED ) {
1330 insertTodoItem( t ); 1383 insertTodoItem( t );
1331 } 1384 }
1332 } 1385 }
1333 1386
1334} 1387}
1335 1388
1336void KOTodoView::todoModified(Todo * t , int p ) 1389void KOTodoView::todoModified(Todo * t , int p )
1337{ 1390{
1338 mBlockUpdate = true; 1391 mBlockUpdate = true;
1339 emit todoModifiedSignal ( t, p ); 1392 emit todoModifiedSignal ( t, p );