summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
authorzautrix <zautrix>2005-07-03 15:58:48 (UTC)
committer zautrix <zautrix>2005-07-03 15:58:48 (UTC)
commit9be5bd1c7e9ee829dd73f5b4a36a2f4331edf68e (patch) (unidiff)
tree4e5e6a4e6eac36df79891d61ed1d1cd76ed6105d /korganizer/kotodoview.cpp
parent0c632bafd2d058504118dc8957fc4808a784f548 (diff)
downloadkdepimpi-9be5bd1c7e9ee829dd73f5b4a36a2f4331edf68e.zip
kdepimpi-9be5bd1c7e9ee829dd73f5b4a36a2f4331edf68e.tar.gz
kdepimpi-9be5bd1c7e9ee829dd73f5b4a36a2f4331edf68e.tar.bz2
fixes
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp53
1 files changed, 41 insertions, 12 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index e2966f8..4f42c83 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -558,42 +558,56 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
558 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 558 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
559 } 559 }
560 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 560 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
561 561
562 mPercentageCompletedPopupMenu = new QPopupMenu(this); 562 mPercentageCompletedPopupMenu = new QPopupMenu(this);
563 for (int i = 0; i <= 100; i+=20) { 563 for (int i = 0; i <= 100; i+=20) {
564 QString label = QString ("%1 %").arg (i); 564 QString label = QString ("%1 %").arg (i);
565 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 565 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
566 } 566 }
567 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 567 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
568 568
569 569
570 mCategoryPopupMenu = new QPopupMenu (this);
571 mCategoryPopupMenu->setCheckable (true);
572 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
573 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ()));
574
575 mCalPopupMenu = new QPopupMenu (this);
576 mCalPopupMenu->setCheckable (true);
577 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int)));
578 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ()));
579
580
581
570 582
571 mItemPopupMenu = new QPopupMenu(this); 583 mItemPopupMenu = new QPopupMenu(this);
572 mItemPopupMenu->insertItem(i18n("Show..."), this, 584 mItemPopupMenu->insertItem(i18n("Show"), this,
573 SLOT (showTodo())); 585 SLOT (showTodo()));
574 mItemPopupMenu->insertItem(i18n("Edit..."), this, 586 mItemPopupMenu->insertItem(i18n("Edit..."), this,
575 SLOT (editTodo())); 587 SLOT (editTodo()));
576 mItemPopupMenu->insertItem( i18n("Delete"), this, 588 mItemPopupMenu->insertItem( i18n("Delete"), this,
577 SLOT (deleteTodo())); 589 SLOT (deleteTodo()));
578 mItemPopupMenu->insertItem( i18n("Clone..."), this, 590 mItemPopupMenu->insertItem( i18n("Clone..."), this,
579 SLOT (cloneTodo())); 591 SLOT (cloneTodo()));
580 mItemPopupMenu->insertItem( i18n("Move..."), this, 592 mItemPopupMenu->insertItem( i18n("Move..."), this,
581 SLOT (moveTodo())); 593 SLOT (moveTodo()));
582#ifndef DESKTOP_VERSION 594#ifndef DESKTOP_VERSION
583 mItemPopupMenu->insertItem( i18n("Beam..."), this, 595 mItemPopupMenu->insertItem( i18n("Beam..."), this,
584 SLOT (beamTodo())); 596 SLOT (beamTodo()));
585#endif 597#endif
586 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 598 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
587 SLOT (cancelTodo())); 599 SLOT (cancelTodo()));
600 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu);
601 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu);
588 mItemPopupMenu->insertSeparator(); 602 mItemPopupMenu->insertSeparator();
589 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 603 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
590 SLOT (toggleRunningItem())); 604 SLOT (toggleRunningItem()));
591 mItemPopupMenu->insertSeparator(); 605 mItemPopupMenu->insertSeparator();
592 /* 606 /*
593 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 607 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
594 SLOT (newTodo())); 608 SLOT (newTodo()));
595 */ 609 */
596 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 610 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
597 SLOT (newSubTodo())); 611 SLOT (newSubTodo()));
598 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 612 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
599 SLOT (unparentTodo()),0,21); 613 SLOT (unparentTodo()),0,21);
@@ -1044,25 +1058,27 @@ void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
1044 pendingSubtodo = 0; 1058 pendingSubtodo = 0;
1045 mActiveItem = (KOTodoViewItem *)item; 1059 mActiveItem = (KOTodoViewItem *)item;
1046 if (item) { 1060 if (item) {
1047 switch (column){ 1061 switch (column){
1048 case 1: 1062 case 1:
1049 mPriorityPopupMenu->popup(QCursor::pos ()); break; 1063 mPriorityPopupMenu->popup(QCursor::pos ()); break;
1050 case 2: 1064 case 2:
1051 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 1065 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
1052 case 3: 1066 case 3:
1053 moveTodo(); 1067 moveTodo();
1054 break; 1068 break;
1055 case 8: 1069 case 8:
1056 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 1070 mCategoryPopupMenu->popup(QCursor::pos ()); break;
1071 case 9:
1072 mCalPopupMenu->popup(QCursor::pos ()); break;
1057 default: 1073 default:
1058 mItemPopupMenu->popup(QCursor::pos()); 1074 mItemPopupMenu->popup(QCursor::pos());
1059 } 1075 }
1060 } else mPopupMenu->popup(QCursor::pos()); 1076 } else mPopupMenu->popup(QCursor::pos());
1061} 1077}
1062void KOTodoView::newTodo() 1078void KOTodoView::newTodo()
1063{ 1079{
1064 emit newTodoSignal(); 1080 emit newTodoSignal();
1065} 1081}
1066 1082
1067void KOTodoView::newSubTodo() 1083void KOTodoView::newSubTodo()
1068{ 1084{
@@ -1155,43 +1171,56 @@ void KOTodoView::setNewPercentage(int index)
1155 if (mPercentage[index] == 100) { 1171 if (mPercentage[index] == 100) {
1156 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1172 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1157 } else { 1173 } else {
1158 mActiveItem->todo()->setCompleted(false); 1174 mActiveItem->todo()->setCompleted(false);
1159 } 1175 }
1160 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1176 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1161 mActiveItem->construct(); 1177 mActiveItem->construct();
1162 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1178 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1163 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1179 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1164 } 1180 }
1165} 1181}
1166 1182
1167 1183void KOTodoView::fillCategories ()
1168QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
1169{ 1184{
1170 if ( !mCategoryPopupMenu ) {
1171 mCategoryPopupMenu = new QPopupMenu (this);
1172 mCategoryPopupMenu->setCheckable (true);
1173 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
1174 }
1175 mCategoryPopupMenu->clear(); 1185 mCategoryPopupMenu->clear();
1176 QStringList checkedCategories = todoItem->todo()->categories (); 1186 if ( ! mActiveItem ) return;
1177 1187 QStringList checkedCategories = mActiveItem->todo()->categories ();
1178 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1188 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1179 it != KOPrefs::instance()->mCustomCategories.end (); 1189 it != KOPrefs::instance()->mCustomCategories.end ();
1180 ++it) { 1190 ++it) {
1181 int index = mCategoryPopupMenu->insertItem (*it); 1191 int index = mCategoryPopupMenu->insertItem (*it);
1182 mCategory[index] = *it; 1192 mCategory[index] = *it;
1183 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); 1193 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true);
1184 } 1194 }
1185 return mCategoryPopupMenu; 1195}
1196void KOTodoView::fillCal ()
1197{
1198 mCalPopupMenu->clear();
1199 if (!mActiveItem) return;
1200 bool readO = mActiveItem->todo()->isReadOnly();
1201 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
1202 while ( kkf ) {
1203 int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber);
1204 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO )
1205 mCalPopupMenu->setItemEnabled( index, false );
1206 mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID());
1207 kkf = KOPrefs::instance()->mCalendars.next();
1208 }
1209}
1210void KOTodoView::changedCal (int index )
1211{
1212 if (!mActiveItem) return;
1213 mActiveItem->todo()->setCalID( index );
1214 mActiveItem->construct();
1186} 1215}
1187void KOTodoView::changedCategories(int index) 1216void KOTodoView::changedCategories(int index)
1188{ 1217{
1189 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1218 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1190 QStringList categories = mActiveItem->todo()->categories (); 1219 QStringList categories = mActiveItem->todo()->categories ();
1191 QString colcat = categories.first(); 1220 QString colcat = categories.first();
1192 if (categories.find (mCategory[index]) != categories.end ()) 1221 if (categories.find (mCategory[index]) != categories.end ())
1193 categories.remove (mCategory[index]); 1222 categories.remove (mCategory[index]);
1194 else 1223 else
1195 categories.insert (categories.end(), mCategory[index]); 1224 categories.insert (categories.end(), mCategory[index]);
1196 categories.sort (); 1225 categories.sort ();
1197 if ( !colcat.isEmpty() ) { 1226 if ( !colcat.isEmpty() ) {