33 #include <tdelocale.h>
34 #include <tdeglobal.h>
35 #include <kiconloader.h>
36 #include <tdemessagebox.h>
39 #include <libkcal/icaldrag.h>
40 #include <libkcal/vcaldrag.h>
41 #include <libkcal/dndfactory.h>
43 #include <libkcal/resourcecalendar.h>
44 #include <libkcal/calfilter.h>
45 #include <libkcal/incidenceformatter.h>
47 #include <libtdepim/clicklineedit.h>
48 #include <libtdepim/kdatepickerpopup.h>
50 #include <libemailfunctions/email.h>
54 #include "koincidencetooltip.h"
55 #include "kodialogmanager.h"
56 #include "kotodoview.h"
58 #include "koglobals.h"
60 #include "kotodoviewitem.h"
61 #include "kotodoview.moc"
62 #ifndef KORG_NOPRINTER
63 #include "kocorehelper.h"
64 #include "calprinter.h"
67 KOTodoListViewToolTip::KOTodoListViewToolTip (TQWidget *parent,
70 :TQToolTip(parent), mCalendar( calendar )
75 void KOTodoListViewToolTip::maybeTip(
const TQPoint & pos)
79 int col=todolist->header()->sectionAt(todolist->contentsX() + pos.x());
83 if( i && KOPrefs::instance()->mEnableToolTips )
87 r=todolist->itemRect(i);
88 headerPos = todolist->header()->sectionPos(col)-todolist->contentsX();
89 r.setLeft( (headerPos < 0 ? 0 : headerPos) );
90 r.setRight(headerPos + todolist->header()->sectionSize(col));
93 TQString tipText( IncidenceFormatter::toolTipStr( mCalendar, i->todo(), TQDate(),
true ) );;
94 if ( !tipText.isEmpty() ) {
103 KOTodoListView::KOTodoListView( TQWidget *parent,
const char *name )
104 : TDEListView( parent, name ), mCalendar( 0 ), mChanger( 0 )
107 mMousePressed =
false;
110 KOTodoListView::~KOTodoListView()
114 void KOTodoListView::setCalendar(
Calendar *cal )
117 setAcceptDrops( mCalendar );
118 viewport()->setAcceptDrops( mCalendar );
121 bool KOTodoListView::event(TQEvent *e)
128 if(e->type()==TQEvent::ApplicationPaletteChange)
131 TDEListView::event(e);
143 return (TDEListView::event(e) || e->type()==TQEvent::ApplicationPaletteChange);
146 void KOTodoListView::contentsDragEnterEvent(TQDragEnterEvent *e)
150 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
151 !TQTextDrag::canDecode( e ) ) {
156 mOldCurrent = currentItem();
160 void KOTodoListView::contentsDragMoveEvent(TQDragMoveEvent *e)
165 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
166 !TQTextDrag::canDecode( e ) ) {
175 void KOTodoListView::contentsDragLeaveEvent( TQDragLeaveEvent * )
180 setCurrentItem(mOldCurrent);
181 setSelected(mOldCurrent,
true);
185 void KOTodoListView::contentsDropEvent( TQDropEvent *e )
188 kdDebug(5850) <<
"KOTodoListView::contentsDropEvent" << endl;
190 if ( !mCalendar || !mChanger ||
191 ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
192 !TQTextDrag::canDecode( e ) ) ) {
198 Todo *todo = factory.createDropTodo(e);
205 Todo *destinationEvent = 0;
206 if (destination) destinationEvent = destination->todo();
208 Todo *existingTodo = mCalendar->todo(todo->
uid());
211 kdDebug(5850) <<
"Drop existing Todo " << existingTodo <<
" onto " << destinationEvent << endl;
214 if (to->
uid() == todo->
uid()) {
215 KMessageBox::information(
this,
216 i18n(
"Cannot move to-do to itself or a child of itself."),
217 i18n(
"Drop To-do"),
"NoDropTodoOntoItself" );
225 if ( mChanger->beginChange( existingTodo, 0, TQString() ) ) {
227 mChanger->changeIncidence( oldTodo, existingTodo, KOGlobals::RELATION_MODIFIED,
this );
228 mChanger->endChange( existingTodo, 0, TQString() );
230 KMessageBox::sorry(
this, i18n(
"Unable to change to-do's parent, "
231 "because the to-do cannot be locked.") );
238 if ( !mChanger->addIncidence( todo, 0, TQString(),
this ) ) {
239 KODialogManager::errorSaveIncidence(
this, todo );
250 kdDebug( 5850 ) <<
"KOTodoListView::contentsDropEvent(): Not dropped on a todo item" << endl;
251 kdDebug( 5850 ) <<
"TODO: Create a new todo with the given data" << endl;
253 }
else if ( TQTextDrag::decode(e, text) ) {
255 kdDebug(5850) <<
"Dropped : " << text << endl;
256 Todo*todo = todoi->todo();
257 if( mChanger->beginChange( todo, 0, TQString() ) ) {
260 if( text.startsWith(
"file:" ) ) {
263 TQStringList emails = KPIM::splitEmailAddrList( text );
264 for(TQStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
265 kdDebug(5850) <<
" Email: " << (*it) << endl;
266 int pos = (*it).find(
"<");
267 TQString name = (*it).left(pos);
268 TQString email = (*it).mid(pos);
269 if (!email.isEmpty() && todoi) {
275 mChanger->changeIncidence( oldtodo, todo, KOGlobals::NOTHING_MODIFIED,
this );
276 mChanger->endChange( todo, 0, TQString() );
278 KMessageBox::sorry(
this, i18n(
"Unable to add attendees to the to-do, "
279 "because the to-do cannot be locked.") );
283 kdDebug(5850) <<
"KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl;
290 void KOTodoListView::contentsMousePressEvent(TQMouseEvent* e)
292 TQListView::contentsMousePressEvent(e);
293 TQPoint p(contentsToViewport(e->pos()));
294 TQListViewItem *i = itemAt(p);
298 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
299 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
301 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
302 if (e->button()==TQt::LeftButton) {
303 mPressPos = e->pos();
304 mMousePressed =
true;
310 void KOTodoListView::contentsMouseMoveEvent(TQMouseEvent* e)
314 TQListView::contentsMouseMoveEvent(e);
315 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
316 TQApplication::startDragDistance()) {
317 mMousePressed =
false;
318 TQListViewItem *item = itemAt(contentsToViewport(mPressPos));
319 if ( item && mCalendar ) {
325 kdDebug(5850) <<
"KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl;
342 void KOTodoListView::contentsMouseReleaseEvent(TQMouseEvent *e)
344 TQListView::contentsMouseReleaseEvent(e);
345 mMousePressed =
false;
348 void KOTodoListView::contentsMouseDoubleClickEvent(TQMouseEvent *e)
352 TQPoint vp = contentsToViewport(e->pos());
354 TQListViewItem *item = itemAt(vp);
358 emit doubleClicked(item,vp,0);
363 KOTodoView::KOTodoView(
Calendar *calendar, TQWidget *parent,
const char* name)
364 : KOrg::
BaseView( calendar, parent, name )
366 TQBoxLayout *topLayout =
new TQVBoxLayout(
this );
368 TQLabel *title =
new TQLabel( i18n(
"To-dos:"),
this );
369 title->setFrameStyle( TQFrame::Panel | TQFrame::Raised );
370 topLayout->addWidget( title );
372 mQuickAdd =
new KPIM::ClickLineEdit(
this, i18n(
"Click to add a new to-do" ) );
373 mQuickAdd->setAcceptDrops(
false );
374 topLayout->addWidget( mQuickAdd );
376 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
378 mTodoListView =
new KOTodoListView(
this );
379 topLayout->addWidget( mTodoListView );
381 mTodoListView->setRootIsDecorated(
true );
382 mTodoListView->setAllColumnsShowFocus(
true );
384 mTodoListView->setShowSortIndicator(
true );
386 mTodoListView->addColumn( i18n(
"Summary") );
387 mTodoListView->addColumn( i18n(
"Recurs") );
388 mTodoListView->addColumn( i18n(
"Priority") );
389 mTodoListView->setColumnAlignment( ePriorityColumn, AlignHCenter );
390 mTodoListView->addColumn( i18n(
"Complete") );
391 mTodoListView->setColumnAlignment( ePercentColumn, AlignRight );
392 mTodoListView->addColumn( i18n(
"Due Date/Time") );
393 mTodoListView->setColumnAlignment( eDueDateColumn, AlignLeft );
394 mTodoListView->addColumn( i18n(
"Categories") );
395 mTodoListView->addColumn( i18n(
"Calendar" ) );
397 mTodoListView->addColumn( i18n(
"Sort Id") );
398 mTodoListView->setColumnAlignment( 4, AlignHCenter );
401 mTodoListView->setMinimumHeight( 60 );
402 mTodoListView->setItemsRenameable(
true );
403 mTodoListView->setRenameable( 0 );
405 mTodoListView->setColumnWidthMode( eSummaryColumn, TQListView::Manual );
406 mTodoListView->setColumnWidthMode( eRecurColumn, TQListView::Manual );
407 mTodoListView->setColumnWidthMode( ePriorityColumn, TQListView::Manual );
408 mTodoListView->setColumnWidthMode( ePercentColumn, TQListView::Manual );
409 mTodoListView->setColumnWidthMode( eDueDateColumn, TQListView::Manual );
410 mTodoListView->setColumnWidthMode( eCategoriesColumn, TQListView::Manual );
411 mTodoListView->setColumnWidthMode( eFolderColumn, TQListView::Manual );
413 mTodoListView->setColumnWidthMode( eDescriptionColumn, TQListView::Manual );
416 mPriorityPopupMenu =
new TQPopupMenu(
this );
417 mPriority[ mPriorityPopupMenu->insertItem( i18n(
"Unspecified priority",
"unspecified") ) ] = 0;
418 mPriority[ mPriorityPopupMenu->insertItem( i18n(
"1 (highest)") ) ] = 1;
419 mPriority[ mPriorityPopupMenu->insertItem( i18n(
"2" ) ) ] = 2;
420 mPriority[ mPriorityPopupMenu->insertItem( i18n(
"3" ) ) ] = 3;
421 mPriority[ mPriorityPopupMenu->insertItem( i18n(
"4" ) ) ] = 4;
422 mPriority[ mPriorityPopupMenu->insertItem( i18n(
"5 (medium)" ) ) ] = 5;
423 mPriority[ mPriorityPopupMenu->insertItem( i18n(
"6" ) ) ] = 6;
424 mPriority[ mPriorityPopupMenu->insertItem( i18n(
"7" ) ) ] = 7;
425 mPriority[ mPriorityPopupMenu->insertItem( i18n(
"8" ) ) ] = 8;
426 mPriority[ mPriorityPopupMenu->insertItem( i18n(
"9 (lowest)" ) ) ] = 9;
427 connect( mPriorityPopupMenu, TQ_SIGNAL( activated(
int ) ),
428 TQ_SLOT( setNewPriority(
int ) ));
430 mPercentageCompletedPopupMenu =
new TQPopupMenu(
this);
431 for (
int i = 0; i <= 100; i+=10) {
432 TQString label = TQString (
"%1 %").arg (i);
433 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
435 connect( mPercentageCompletedPopupMenu, TQ_SIGNAL( activated(
int ) ),
436 TQ_SLOT( setNewPercentage(
int ) ) );
438 mMovePopupMenu =
new KDatePickerPopup(
439 KDatePickerPopup::NoDate |
440 KDatePickerPopup::DatePicker |
441 KDatePickerPopup::Words );
442 mCopyPopupMenu =
new KDatePickerPopup(
443 KDatePickerPopup::NoDate |
444 KDatePickerPopup::DatePicker |
445 KDatePickerPopup::Words );
448 connect( mMovePopupMenu, TQ_SIGNAL( dateChanged( TQDate )),
449 TQ_SLOT( setNewDate( TQDate ) ) );
450 connect( mCopyPopupMenu, TQ_SIGNAL( dateChanged( TQDate )),
451 TQ_SLOT( copyTodoToDate( TQDate ) ) );
453 mItemPopupMenu =
new TQPopupMenu(
this);
454 mItemPopupMenu->insertItem(i18n(
"&Show"),
this,
455 TQ_SLOT (showTodo()));
456 mItemPopupMenu->insertItem(i18n(
"&Edit..."),
this,
457 TQ_SLOT (editTodo()), 0, ePopupEdit );
458 #ifndef KORG_NOPRINTER
459 mItemPopupMenu->insertItem(KOGlobals::self()->smallIcon(
"printer"), i18n(
"&Print..."),
this, TQ_SLOT( printTodo() ) );
461 mItemPopupMenu->insertItem(KOGlobals::self()->smallIconSet(
"edit-delete"), i18n(
"&Delete"),
this,
462 TQ_SLOT (deleteTodo()), 0, ePopupDelete );
463 mItemPopupMenu->insertSeparator();
464 mItemPopupMenu->insertItem(KOGlobals::self()->smallIconSet(
"todo"), i18n(
"New &To-do..."),
this,
465 TQ_SLOT (newTodo()) );
466 mItemPopupMenu->insertItem(i18n(
"New Su&b-to-do..."),
this,
467 TQ_SLOT (newSubTodo()));
468 mItemPopupMenu->insertItem( i18n(
"&Make this To-do Independent"),
this,
469 TQ_SIGNAL( unSubTodoSignal() ), 0, ePopupUnSubTodo );
470 mItemPopupMenu->insertItem( i18n(
"Make all Sub-to-dos &Independent"),
this,
471 TQ_SIGNAL( unAllSubTodoSignal() ), 0, ePopupUnAllSubTodo );
472 mItemPopupMenu->insertSeparator();
473 mItemPopupMenu->insertItem( i18n(
"&Copy To"), mCopyPopupMenu, ePopupCopyTo );
474 mItemPopupMenu->insertItem(i18n(
"&Move To"), mMovePopupMenu, ePopupMoveTo );
475 mItemPopupMenu->insertSeparator();
476 mItemPopupMenu->insertItem(i18n(
"delete completed to-dos",
"Pur&ge Completed"),
477 this, TQ_SLOT( purgeCompleted() ) );
479 connect( mMovePopupMenu, TQ_SIGNAL( dateChanged( TQDate ) ),
480 mItemPopupMenu, TQ_SLOT( hide() ) );
481 connect( mCopyPopupMenu, TQ_SIGNAL( dateChanged( TQDate ) ),
482 mItemPopupMenu, TQ_SLOT( hide() ) );
484 mPopupMenu =
new TQPopupMenu(
this);
485 mPopupMenu->insertItem(KOGlobals::self()->smallIconSet(
"todo"), i18n(
"&New To-do..."),
this,
486 TQ_SLOT(newTodo()) );
487 mPopupMenu->insertItem(i18n(
"delete completed to-dos",
"&Purge Completed"),
488 this, TQ_SLOT(purgeCompleted()));
490 mDocPrefs =
new DocPrefs( name );
493 connect( mTodoListView, TQ_SIGNAL( doubleClicked( TQListViewItem *,
494 const TQPoint &,
int ) ),
495 TQ_SLOT( editItem( TQListViewItem *,
const TQPoint &,
int ) ) );
496 connect( mTodoListView, TQ_SIGNAL( returnPressed( TQListViewItem * ) ),
497 TQ_SLOT( editItem( TQListViewItem * ) ) );
498 connect( mTodoListView, TQ_SIGNAL( contextMenuRequested( TQListViewItem *,
499 const TQPoint &,
int ) ),
500 TQ_SLOT( popupMenu( TQListViewItem *,
const TQPoint &,
int ) ) );
501 connect( mTodoListView, TQ_SIGNAL( expanded( TQListViewItem * ) ),
502 TQ_SLOT( itemStateChanged( TQListViewItem * ) ) );
503 connect( mTodoListView, TQ_SIGNAL( collapsed( TQListViewItem * ) ),
504 TQ_SLOT( itemStateChanged( TQListViewItem * ) ) );
507 connect(mTodoListView,TQ_SIGNAL(selectionChanged(TQListViewItem *)),
508 TQ_SLOT(selectionChanged(TQListViewItem *)));
509 connect(mTodoListView,TQ_SIGNAL(clicked(TQListViewItem *)),
510 TQ_SLOT(selectionChanged(TQListViewItem *)));
511 connect(mTodoListView,TQ_SIGNAL(pressed(TQListViewItem *)),
512 TQ_SLOT(selectionChanged(TQListViewItem *)));
514 connect( mTodoListView, TQ_SIGNAL(selectionChanged() ),
515 TQ_SLOT( processSelectionChange() ) );
516 connect( mQuickAdd, TQ_SIGNAL( returnPressed () ),
517 TQ_SLOT( addQuickTodo() ) );
519 new KOTodoListViewToolTip( mTodoListView->viewport(), calendar, mTodoListView );
522 KOTodoView::~KOTodoView()
527 void KOTodoView::setCalendar(
Calendar *cal )
529 BaseView::setCalendar( cal );
530 mTodoListView->setCalendar( cal );
533 void KOTodoView::updateView()
536 int oldPos = mTodoListView->contentsY();
537 mItemsToDelete.clear();
538 mTodoListView->clear();
564 Todo::List::ConstIterator it;
565 for( it = todoList.begin(); it != todoList.end(); ++it ) {
566 if ( !mTodoMap.contains( *it ) ) {
567 insertTodoItem( *it );
572 mTodoListView->blockSignals(
true );
573 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
574 mTodoListView->blockSignals(
false );
576 mTodoListView->setContentsPos( 0, oldPos );
578 processSelectionChange();
581 void KOTodoView::restoreItemState( TQListViewItem *item )
585 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->
uid() ) );
586 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
587 item = item->nextSibling();
592 TQMap<Todo *,KOTodoViewItem *>::ConstIterator
593 KOTodoView::insertTodoItem(
Todo *todo)
597 if (incidence && incidence->type() ==
"Todo") {
599 Todo *relatedTodo =
dynamic_cast<Todo *
>(incidence);
602 mTodoMap.insert(todo,0);
605 TQMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
606 itemIterator = mTodoMap.find(relatedTodo);
607 if (itemIterator == mTodoMap.end()) {
609 itemIterator = insertTodoItem (relatedTodo);
617 if ( *itemIterator == 0 ) {
624 return mTodoMap.insert(todo,todoItem);
629 return mTodoMap.insert(todo,todoItem);
633 void KOTodoView::removeTodoItems()
636 for ( item = mItemsToDelete.first(); item; item = mItemsToDelete.next() ) {
637 Todo *todo = item->todo();
638 if ( todo && mTodoMap.contains( todo ) ) {
639 mTodoMap.remove( todo );
643 mItemsToDelete.clear();
647 bool KOTodoView::scheduleRemoveTodoItem(
KOTodoViewItem *todoItem )
650 mItemsToDelete.append( todoItem );
651 TQTimer::singleShot( 0,
this, TQ_SLOT( removeTodoItems() ) );
657 void KOTodoView::updateConfig()
659 mTodoListView->repaintContents();
664 Incidence::List selected;
668 if (item) selected.append(item->todo());
673 Todo::List KOTodoView::selectedTodos()
679 if (item) selected.append(item->todo());
684 void KOTodoView::changeIncidenceDisplay(
Incidence *incidence,
int action)
687 if ( incidence->type() !=
"Todo" )
691 Todo *todo =
static_cast<Todo *
>(incidence);
694 if ( mTodoMap.contains( todo ) ) {
695 todoItem = mTodoMap[todo];
698 case KOGlobals::INCIDENCEADDED:
699 case KOGlobals::INCIDENCEEDITED:
703 scheduleRemoveTodoItem( todoItem );
708 if ( parent && mTodoMap.contains(parent) ) {
709 parentItem = mTodoMap[ parent ];
711 if ( todoItem->parent() != parentItem ) {
714 parentItem->insertItem( todoItem );
716 mTodoListView->insertItem( todoItem );
719 todoItem->construct();
723 insertTodoItem( todo );
726 mTodoListView->sort();
728 case KOGlobals::INCIDENCEDELETED:
730 scheduleRemoveTodoItem( todoItem );
734 TQTimer::singleShot( 0,
this, TQ_SLOT( updateView() ) );
740 TQTimer::singleShot(0,
this,TQ_SLOT(updateView()));
744 void KOTodoView::showDates(
const TQDate &,
const TQDate &)
748 void KOTodoView::showIncidences(
const Incidence::List &,
const TQDate & )
750 kdDebug(5850) <<
"KOTodoView::showIncidences( const Incidence::List & ): not yet implemented" << endl;
753 CalPrinterBase::PrintType KOTodoView::printType()
755 return CalPrinterBase::Todolist;
758 void KOTodoView::editItem( TQListViewItem *item )
765 void KOTodoView::editItem( TQListViewItem *item,
const TQPoint &,
int )
770 void KOTodoView::showItem( TQListViewItem *item )
777 void KOTodoView::showItem( TQListViewItem *item,
const TQPoint &,
int )
782 void KOTodoView::popupMenu( TQListViewItem *item,
const TQPoint &,
int column )
785 if ( mActiveItem && mActiveItem->todo() &&
787 bool editable = !mActiveItem->todo()->
isReadOnly();
788 mItemPopupMenu->setItemEnabled( ePopupEdit, editable );
789 mItemPopupMenu->setItemEnabled( ePopupDelete, editable );
790 mItemPopupMenu->setItemEnabled( ePopupMoveTo, editable );
791 mItemPopupMenu->setItemEnabled( ePopupCopyTo, editable );
792 mItemPopupMenu->setItemEnabled( ePopupUnSubTodo, editable );
793 mItemPopupMenu->setItemEnabled( ePopupUnAllSubTodo, editable );
796 TQDate date = mActiveItem->todo()->
dtDue().date();
798 mMovePopupMenu->datePicker()->setDate( date );
800 mMovePopupMenu->datePicker()->setDate( TQDate::currentDate() );
803 case ePriorityColumn:
804 mPriorityPopupMenu->popup( TQCursor::pos() );
806 case ePercentColumn: {
807 mPercentageCompletedPopupMenu->popup( TQCursor::pos() );
811 mMovePopupMenu->popup( TQCursor::pos() );
813 case eCategoriesColumn:
817 mCopyPopupMenu->datePicker()->setDate( date );
818 mCopyPopupMenu->datePicker()->setDate( TQDate::currentDate() );
819 mItemPopupMenu->setItemEnabled( ePopupUnSubTodo,
821 mItemPopupMenu->setItemEnabled( ePopupUnAllSubTodo,
822 !mActiveItem->todo()->
relations().isEmpty() );
823 mItemPopupMenu->popup( TQCursor::pos() );
826 mItemPopupMenu->popup( TQCursor::pos() );
828 }
else mPopupMenu->popup( TQCursor::pos() );
831 void KOTodoView::newTodo()
833 kdDebug() << k_funcinfo << endl;
834 emit newTodoSignal( 0, TQString(),
835 TQDate::currentDate().addDays(7) );
838 void KOTodoView::newSubTodo()
841 emit newSubTodoSignal(mActiveItem->todo());
845 void KOTodoView::editTodo()
847 editItem( mActiveItem );
850 void KOTodoView::showTodo()
852 showItem( mActiveItem );
855 void KOTodoView::printTodo()
857 #ifndef KORG_NOPRINTER
859 CalPrinter printer(
this, BaseView::calendar(), &helper );
860 connect(
this, TQ_SIGNAL(configChanged()), &printer, TQ_SLOT(updateConfig()) );
866 if ( mActiveItem->todo() && mActiveItem->todo()->
hasStartDate() ) {
867 todoDate = mActiveItem->todo()->
dtStart();
869 todoDate = mActiveItem->todo()->
dtDue();
872 printer.print( KOrg::CalPrinterBase::Incidence,
877 void KOTodoView::deleteTodo()
884 void KOTodoView::setNewPriority(
int index)
886 if ( !mActiveItem || !mChanger )
return;
887 Todo *todo = mActiveItem->todo();
889 mChanger->beginChange( todo, 0, TQString() ) ) {
892 mActiveItem->construct();
894 mChanger->changeIncidence( oldTodo, todo, KOGlobals::PRIORITY_MODIFIED,
this );
895 mChanger->endChange( todo, 0, TQString() );
900 void KOTodoView::setNewPercentage(
KOTodoViewItem *item,
int percentage )
902 kdDebug(5850) <<
"KOTodoView::setNewPercentage( " << percentage <<
"), item = " << item << endl;
903 if ( !item || !mChanger )
return;
904 Todo *todo = item->todo();
908 mChanger->beginChange( todo, 0, TQString() ) ) {
919 if ( percentage == 100 ) {
924 item->setState( TQCheckListItem::Off );
930 if ( todo->
doesRecur() && percentage == 100 )
931 mChanger->changeIncidence( oldTodo, todo,
932 KOGlobals::COMPLETION_MODIFIED_WITH_RECURRENCE,
this );
934 mChanger->changeIncidence( oldTodo, todo,
935 KOGlobals::COMPLETION_MODIFIED,
this );
936 mChanger->endChange( todo, 0, TQString() );
940 kdDebug(5850) <<
"No active item, active item is read-only, or locking failed" << endl;
944 void KOTodoView::setNewPercentage(
int index )
946 setNewPercentage( mActiveItem, mPercentage[index] );
949 void KOTodoView::setNewDate( TQDate date )
951 if ( !mActiveItem || !mChanger )
return;
952 Todo *todo = mActiveItem->todo();
955 if ( !todo->
isReadOnly() && mChanger->beginChange( todo, 0, TQString() ) ) {
962 dt.setTime( todo->
dtDue().time() );
968 mActiveItem->construct();
969 mChanger->changeIncidence( oldTodo, todo, KOGlobals::COMPLETION_MODIFIED,
this );
970 mChanger->endChange( todo, 0, TQString() );
973 kdDebug(5850) <<
"No active item, active item is read-only, or locking failed" << endl;
977 void KOTodoView::copyTodoToDate( TQDate date )
979 TQDateTime dt( date );
981 if ( mActiveItem && mChanger ) {
982 Todo *oldTodo = mActiveItem->todo();
989 dt.setTime( oldTodo->
dtDue().time() );
995 TQPair<ResourceCalendar *, TQString>p =
996 CalHelper::incSubResourceCalendar(
calendar(), mActiveItem->todo() );
998 mChanger->addIncidence( newTodo, p.first, p.second,
this );
1004 TQPopupMenu *tempMenu =
new TQPopupMenu(
this );
1005 TQStringList checkedCategories = todoItem->todo()->
categories();
1007 tempMenu->setCheckable(
true );
1008 TQStringList::Iterator it;
1009 for ( it = KOPrefs::instance()->mCustomCategories.begin();
1010 it != KOPrefs::instance()->mCustomCategories.end();
1012 int index = tempMenu->insertItem( *it );
1013 mCategory[ index ] = *it;
1014 if ( checkedCategories.find( *it ) != checkedCategories.end() )
1015 tempMenu->setItemChecked( index,
true );
1018 connect ( tempMenu, TQ_SIGNAL( activated(
int ) ),
1019 TQ_SLOT( changedCategories(
int ) ) );
1023 void KOTodoView::changedCategories(
int index)
1025 if ( !mActiveItem || !mChanger )
return;
1026 Todo *todo = mActiveItem->todo();
1027 if ( !todo )
return;
1029 if ( !todo->
isReadOnly() && mChanger->beginChange( todo, 0, TQString() ) ) {
1032 TQStringList categories = todo->
categories ();
1033 if ( categories.find( mCategory[index] ) != categories.end() )
1034 categories.remove( mCategory[index] );
1036 categories.insert( categories.end(), mCategory[index] );
1039 mActiveItem->construct();
1040 mChanger->changeIncidence( oldTodo, todo, KOGlobals::CATEGORY_MODIFIED,
this );
1041 mChanger->endChange( todo, 0, TQString() );
1044 kdDebug(5850) <<
"No active item, active item is read-only, or locking failed" << endl;
1048 void KOTodoView::setDocumentId(
const TQString &
id )
1050 kdDebug(5850) <<
"KOTodoView::setDocumentId()" << endl;
1052 mDocPrefs->setDoc(
id );
1055 void KOTodoView::itemStateChanged( TQListViewItem *item )
1063 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->
uid(), todoItem->isOpen() );
1066 void KOTodoView::setNewPercentageDelayed(
KOTodoViewItem *item,
int percentage )
1068 mPercentChangedMap.append( qMakePair( item, percentage ) );
1070 TQTimer::singleShot( 0,
this, TQ_SLOT( processDelayedNewPercentage() ) );
1073 void KOTodoView::processDelayedNewPercentage()
1075 TQValueList< TQPair< KOTodoViewItem *, int> >::Iterator it;
1076 for ( it = mPercentChangedMap.begin(); it != mPercentChangedMap.end(); ++it )
1077 setNewPercentage( (*it).first, (*it).second );
1079 mPercentChangedMap.clear();
1082 void KOTodoView::saveLayout(TDEConfig *config,
const TQString &group)
const
1084 mTodoListView->saveLayout(config,group);
1087 void KOTodoView::restoreLayout(TDEConfig *config,
const TQString &group)
1089 mTodoListView->restoreLayout(config,group);
1092 void KOTodoView::processSelectionChange()
1100 emit incidenceSelected( 0, TQDate() );
1103 emit incidenceSelected( item->todo(), TQDate() );
1110 void KOTodoView::clearSelection()
1112 mTodoListView->selectAll(
false );
1115 void KOTodoView::purgeCompleted()
1117 emit purgeCompletedSignal();
1120 void KOTodoView::addQuickTodo()
1122 if ( ! mQuickAdd->text().stripWhiteSpace().isEmpty() ) {
1126 KOPrefs::instance()->email() ) );
1127 if ( !mChanger->addIncidence( todo, 0, TQString(),
this ) ) {
1131 mQuickAdd->setText( TQString() );
1138 mTodoListView->setIncidenceChanger( changer );
CalPrinter is a class for printing Calendars.
bool filterIncidence(Incidence *) const
virtual Todo::List todos(TodoSortField sortField=TodoSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
void setOrganizer(const Person &o)
void addAttendee(Attendee *attendee, bool doUpdate=true)
void addAttachment(Attachment *attachment)
void setSummary(const TQString &summary)
void setRelatedTo(Incidence *relatedTo)
void setPriority(int priority)
Incidence * relatedTo() const
TQStringList categories() const
void setCategories(const TQStringList &categories)
Incidence::List relations() const
bool hasStartDate() const
void setDtDue(const TQDateTime &dtDue, bool first=false)
void setCompleted(bool completed)
TQDateTime dtStart(bool first=false) const
TQDateTime dtDue(bool first=false) const
void setHasDueDate(bool hasDueDate)
void setPercentComplete(int)
This class provides a way of displaying a single Event of Todo-Type in a KTodoView.
DateList selectedIncidenceDates()
TQPopupMenu * getCategoryPopupMenu(KOTodoViewItem *todoItem)
Create a popup menu to set categories.
Incidence::List selectedIncidences()
void setIncidenceChanger(IncidenceChangerBase *changer)
Assign a new incidence change helper object.
This class provides an interface for all views being displayed within the main calendar view.
void editIncidenceSignal(Incidence *, const TQDate &)
instructs the receiver to begin editing the incidence specified in some manner.
void deleteIncidenceSignal(Incidence *)
instructs the receiver to delete the Incidence in some manner; some possibilities include automatical...
void showIncidenceSignal(Incidence *, const TQDate &)
instructs the receiver to show the incidence in read-only mode.
virtual Calendar * calendar()
Return calendar object of this view.