summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
Unidiff
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 0a315cb..01cf0ff 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -197,52 +197,54 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e)
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 210
211 QPoint p(contentsToViewport(e->pos())); 211 QPoint p(contentsToViewport(e->pos()));
212 QListViewItem *i = itemAt(p); 212 QListViewItem *i = itemAt(p);
213 bool rootClicked = true; 213 bool rootClicked = true;
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 int X = p.x(); 217 int X = p.x();
218 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 218 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
219 if (X > header()->sectionPos(0) + 219 if (X > header()->sectionPos(0) +
220 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 220 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
221 itemMargin() || 221 itemMargin() +i->height()||
222 X < header()->sectionPos(0)) { 222 X < header()->sectionPos(0)) {
223 rootClicked = false; 223 rootClicked = false;
224 } 224 }
225 } else {
226 rootClicked = false;
225 } 227 }
226#ifndef KORG_NODND 228#ifndef KORG_NODND
227 mMousePressed = false; 229 mMousePressed = false;
228 if (! rootClicked ) { 230 if (! rootClicked ) {
229 mPressPos = e->pos(); 231 mPressPos = e->pos();
230 mMousePressed = true; 232 mMousePressed = true;
231 } 233 }
232#endif 234#endif
233 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 235 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
234#ifndef DESKTOP_VERSION 236#ifndef DESKTOP_VERSION
235 if (!( e->button() == RightButton && rootClicked) ) 237 if (!( e->button() == RightButton && rootClicked) )
236 QListView::contentsMousePressEvent(e); 238 QListView::contentsMousePressEvent(e);
237#else 239#else
238 QListView::contentsMousePressEvent(e); 240 QListView::contentsMousePressEvent(e);
239#endif 241#endif
240} 242}
241void KOTodoListView::paintEvent(QPaintEvent* e) 243void KOTodoListView::paintEvent(QPaintEvent* e)
242{ 244{
243 emit paintNeeded(); 245 emit paintNeeded();
244 QListView::paintEvent( e); 246 QListView::paintEvent( e);
245} 247}
246void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 248void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
247{ 249{
248 250
@@ -709,81 +711,81 @@ void KOTodoView::updateView()
709 { 711 {
710 insertTodoItem(todo); 712 insertTodoItem(todo);
711 } 713 }
712 } 714 }
713 //qDebug("for end "); 715 //qDebug("for end ");
714 // Restore opened/closed state 716 // Restore opened/closed state
715 mTodoListView->blockSignals( true ); 717 mTodoListView->blockSignals( true );
716 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 718 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
717 mTodoListView->blockSignals( false ); 719 mTodoListView->blockSignals( false );
718 resetCurrentItem(); 720 resetCurrentItem();
719 processSelectionChange(); 721 processSelectionChange();
720} 722}
721 723
722void KOTodoView::storeCurrentItem() 724void KOTodoView::storeCurrentItem()
723{ 725{
724 mCurItem = 0; 726 mCurItem = 0;
725 mCurItemRootParent = 0; 727 mCurItemRootParent = 0;
726 mCurItemAbove = 0; 728 mCurItemAbove = 0;
727 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 729 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
728 if (mActiveItem) { 730 if (mActiveItem) {
729 mCurItem = mActiveItem->todo(); 731 mCurItem = mActiveItem->todo();
730 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 732 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
731 if ( activeItemAbove ) 733 if ( activeItemAbove )
732 mCurItemAbove = activeItemAbove->todo(); 734 mCurItemAbove = activeItemAbove->todo();
733 while ( mActiveItem->parent() != 0 ) 735 mCurItemRootParent = mCurItem;
734 mActiveItem = (KOTodoViewItem*)mActiveItem->parent(); 736 while ( mCurItemRootParent->relatedTo() != 0 )
735 mCurItemRootParent = mActiveItem->todo(); 737 mCurItemRootParent = mCurItemRootParent->relatedTo();
736 } 738 }
737 mActiveItem = 0; 739 mActiveItem = 0;
738} 740}
739 741
740void KOTodoView::resetCurrentItem() 742void KOTodoView::resetCurrentItem()
741{ 743{
742 mTodoListView->setFocus(); 744 mTodoListView->setFocus();
743 KOTodoViewItem* foundItem = 0; 745 KOTodoViewItem* foundItem = 0;
744 KOTodoViewItem* foundItemRoot = 0; 746 KOTodoViewItem* foundItemRoot = 0;
745 KOTodoViewItem* foundItemAbove = 0; 747 KOTodoViewItem* foundItemAbove = 0;
746 if ( mTodoListView->firstChild () ) { 748 if ( mTodoListView->firstChild () ) {
747 if ( mCurItem ) { 749 if ( mCurItem ) {
748 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 750 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
749 while ( item ) { 751 while ( item ) {
750 if ( item->todo() == mCurItem ) { 752 if ( item->todo() == mCurItem ) {
751 foundItem = item; 753 foundItem = item;
752 break; 754 break;
753 } else if ( item->todo() == mCurItemAbove ) { 755 } else if ( item->todo() == mCurItemAbove ) {
754 foundItemAbove = item; 756 foundItemAbove = item;
755 757
756 } else if ( item->todo() == mCurItemRootParent ) { 758 } else if ( item->todo() == mCurItemRootParent ) {
757 foundItemRoot = item; 759 foundItemRoot = item;
758 } 760 }
759 item = (KOTodoViewItem*)item->itemBelow(); 761 item = (KOTodoViewItem*)item->itemBelow();
760 } 762 }
761 if ( ! foundItem ) { 763 if ( ! foundItem ) {
762 if ( foundItemAbove ) 764 if ( foundItemRoot )
763 foundItem = foundItemAbove;
764 else
765 foundItem = foundItemRoot; 765 foundItem = foundItemRoot;
766 else
767 foundItem = foundItemAbove;
766 } 768 }
767 } 769 }
768 if ( foundItem ) { 770 if ( foundItem ) {
769 mTodoListView->setCurrentItem( foundItem ); 771 mTodoListView->setCurrentItem( foundItem );
770 mTodoListView->ensureItemVisible( foundItem ); 772 mTodoListView->ensureItemVisible( foundItem );
771 } else { 773 } else {
772 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 774 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
773 } 775 }
774 } 776 }
775 mTodoListView->setFocus(); 777 mTodoListView->setFocus();
776} 778}
777//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 779//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
778bool KOTodoView::checkTodo( Todo * todo ) 780bool KOTodoView::checkTodo( Todo * todo )
779{ 781{
780 782
781 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 783 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
782 return false; 784 return false;
783 if ( !todo->isCompleted() ) { 785 if ( !todo->isCompleted() ) {
784 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 786 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
785 return true; 787 return true;
786 } 788 }
787 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 789 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
788 if ( todo->hasStartDate() ) 790 if ( todo->hasStartDate() )
789 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 791 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
@@ -1184,99 +1186,107 @@ void KOTodoView::processSelectionChange()
1184 emit incidenceSelected( 0 ); 1186 emit incidenceSelected( 0 );
1185 } else { 1187 } else {
1186 emit incidenceSelected( item->todo() ); 1188 emit incidenceSelected( item->todo() );
1187 } 1189 }
1188} 1190}
1189 1191
1190void KOTodoView::modified(bool b) 1192void KOTodoView::modified(bool b)
1191{ 1193{
1192 emit isModified(b); 1194 emit isModified(b);
1193} 1195}
1194void KOTodoView::setTodoModified( Todo* todo ) 1196void KOTodoView::setTodoModified( Todo* todo )
1195{ 1197{
1196 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1198 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1197} 1199}
1198void KOTodoView::clearSelection() 1200void KOTodoView::clearSelection()
1199{ 1201{
1200 mTodoListView->selectAll( false ); 1202 mTodoListView->selectAll( false );
1201} 1203}
1202void KOTodoView::setAllOpen() 1204void KOTodoView::setAllOpen()
1203{ 1205{
1204 if ( isFlatDisplay ) { 1206 if ( isFlatDisplay ) {
1205 isFlatDisplay = false; 1207 isFlatDisplay = false;
1206 mPopupMenu->setItemChecked( 8,false ); 1208 mPopupMenu->setItemChecked( 8,false );
1207 updateView(); 1209 updateView();
1210 } else {
1211 storeCurrentItem();
1208 } 1212 }
1209 setOpen(mTodoListView->firstChild(), true); 1213 setOpen(mTodoListView->firstChild(), true);
1214 resetCurrentItem();
1210} 1215}
1211void KOTodoView::setAllClose() 1216void KOTodoView::setAllClose()
1212{ 1217{
1213 if ( isFlatDisplay ) { 1218 if ( isFlatDisplay ) {
1214 isFlatDisplay = false; 1219 isFlatDisplay = false;
1215 mPopupMenu->setItemChecked( 8,false ); 1220 mPopupMenu->setItemChecked( 8,false );
1216 updateView(); 1221 updateView();
1222 } else {
1223 storeCurrentItem();
1217 } 1224 }
1218 setOpen(mTodoListView->firstChild(), false); 1225 setOpen(mTodoListView->firstChild(), false);
1226 resetCurrentItem();
1219} 1227}
1220void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1228void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1221{ 1229{
1222 1230
1223 while ( item ) { 1231 while ( item ) {
1224 setOpen( item->firstChild(), setOpenI ); 1232 setOpen( item->firstChild(), setOpenI );
1225 item->setOpen( setOpenI ); 1233 item->setOpen( setOpenI );
1226 item = item->nextSibling(); 1234 item = item->nextSibling();
1227 } 1235 }
1228} 1236}
1229 1237
1230void KOTodoView::displayAllFlat() 1238void KOTodoView::displayAllFlat()
1231{ 1239{
1232 pendingSubtodo = 0; 1240 pendingSubtodo = 0;
1233 if ( mBlockUpdate ) { 1241 if ( mBlockUpdate ) {
1234 return; 1242 return;
1235 } 1243 }
1236 mPopupMenu->setItemChecked( 8,true ); 1244 mPopupMenu->setItemChecked( 8,true );
1237 isFlatDisplay = true; 1245 isFlatDisplay = true;
1238 QPtrList<Todo> todoList = calendar()->todos(); 1246 QPtrList<Todo> todoList = calendar()->todos();
1239 mTodoMap.clear(); 1247 mTodoMap.clear();
1240 mTodoListView->clear(); 1248 mTodoListView->clear();
1241 Todo *todo; 1249 Todo *todo;
1242 for(todo = todoList.first(); todo; todo = todoList.next()) { 1250 for(todo = todoList.first(); todo; todo = todoList.next()) {
1243 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1251 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1244 mTodoMap.insert(todo,todoItem); 1252 mTodoMap.insert(todo,todoItem);
1245 } 1253 }
1246 mTodoListView->setFocus(); 1254 mTodoListView->setFocus();
1247 processSelectionChange(); 1255 processSelectionChange();
1248} 1256}
1249 1257
1250void KOTodoView::setAllFlat() 1258void KOTodoView::setAllFlat()
1251{ 1259{
1252 if ( isFlatDisplay ) { 1260 if ( isFlatDisplay ) {
1253 isFlatDisplay = false; 1261 isFlatDisplay = false;
1254 mPopupMenu->setItemChecked( 8,false ); 1262 mPopupMenu->setItemChecked( 8,false );
1255 updateView(); 1263 updateView();
1256 return; 1264 return;
1257 } 1265 }
1266 storeCurrentItem();
1258 displayAllFlat(); 1267 displayAllFlat();
1268 resetCurrentItem();
1259} 1269}
1260 1270
1261void KOTodoView::purgeCompleted() 1271void KOTodoView::purgeCompleted()
1262{ 1272{
1263 emit purgeCompletedSignal(); 1273 emit purgeCompletedSignal();
1264} 1274}
1265void KOTodoView::toggleQuickTodo() 1275void KOTodoView::toggleQuickTodo()
1266{ 1276{
1267 if ( mQuickAdd->isVisible() ) { 1277 if ( mQuickAdd->isVisible() ) {
1268 mQuickAdd->hide(); 1278 mQuickAdd->hide();
1269 KOPrefs::instance()->mEnableQuickTodo = false; 1279 KOPrefs::instance()->mEnableQuickTodo = false;
1270 } 1280 }
1271 else { 1281 else {
1272 mQuickAdd->show(); 1282 mQuickAdd->show();
1273 KOPrefs::instance()->mEnableQuickTodo = true; 1283 KOPrefs::instance()->mEnableQuickTodo = true;
1274 } 1284 }
1275 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1285 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1276 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1286 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1277} 1287}
1278 1288
1279void KOTodoView::toggleRunning() 1289void KOTodoView::toggleRunning()
1280{ 1290{
1281 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1291 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1282 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1292 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);