summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
authorzautrix <zautrix>2005-07-06 11:17:00 (UTC)
committer zautrix <zautrix>2005-07-06 11:17:00 (UTC)
commit7e22293b1ec1ee190ca8db6c8ecd079bafdae520 (patch) (unidiff)
treeaed67fbbd844480e3dc0a7b5587edca766b51a5f /korganizer/kotodoview.cpp
parent3b77a857e17e04e47d22ba6017dd723ed922e3fc (diff)
downloadkdepimpi-7e22293b1ec1ee190ca8db6c8ecd079bafdae520.zip
kdepimpi-7e22293b1ec1ee190ca8db6c8ecd079bafdae520.tar.gz
kdepimpi-7e22293b1ec1ee190ca8db6c8ecd079bafdae520.tar.bz2
fixes
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 86e1bd9..a87e6fc 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -965,408 +965,411 @@ KOTodoView::insertTodoItem(Todo *todo)
965 965
966 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 966 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
967 // TODO: Check, if dynmaic cast is necessary 967 // TODO: Check, if dynmaic cast is necessary
968 968
969 pendingSubtodo = 0; 969 pendingSubtodo = 0;
970 Incidence *incidence = todo->relatedTo(); 970 Incidence *incidence = todo->relatedTo();
971 while ( incidence && !incidence->calEnabled() ) 971 while ( incidence && !incidence->calEnabled() )
972 incidence = incidence->relatedTo(); 972 incidence = incidence->relatedTo();
973 if (incidence && incidence->typeID() == todoID ) { 973 if (incidence && incidence->typeID() == todoID ) {
974 Todo *relatedTodo = static_cast<Todo *>(incidence); 974 Todo *relatedTodo = static_cast<Todo *>(incidence);
975 975
976 // kdDebug() << " has Related" << endl; 976 // kdDebug() << " has Related" << endl;
977 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 977 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
978 itemIterator = mTodoMap.find(relatedTodo); 978 itemIterator = mTodoMap.find(relatedTodo);
979 if (itemIterator == mTodoMap.end()) { 979 if (itemIterator == mTodoMap.end()) {
980 // kdDebug() << " related not yet in list" << endl; 980 // kdDebug() << " related not yet in list" << endl;
981 itemIterator = insertTodoItem (relatedTodo); 981 itemIterator = insertTodoItem (relatedTodo);
982 } 982 }
983 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 983 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
984 // and one into the map. Sure finding is more easy but why? -zecke 984 // and one into the map. Sure finding is more easy but why? -zecke
985 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 985 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
986 return mTodoMap.insert(todo,todoItem); 986 return mTodoMap.insert(todo,todoItem);
987 } else { 987 } else {
988 // kdDebug() << " no Related" << endl; 988 // kdDebug() << " no Related" << endl;
989 // see above -zecke 989 // see above -zecke
990 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 990 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
991 return mTodoMap.insert(todo,todoItem); 991 return mTodoMap.insert(todo,todoItem);
992 } 992 }
993} 993}
994 994
995 995
996void KOTodoView::updateConfig() 996void KOTodoView::updateConfig()
997{ 997{
998 updateView(); 998 updateView();
999 mTodoListView->repaintContents(); 999 mTodoListView->repaintContents();
1000} 1000}
1001 1001
1002QPtrList<Incidence> KOTodoView::selectedIncidences() 1002QPtrList<Incidence> KOTodoView::selectedIncidences()
1003{ 1003{
1004 QPtrList<Incidence> selected; 1004 QPtrList<Incidence> selected;
1005 1005
1006 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 1006 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
1007// if (!item) item = mActiveItem; 1007// if (!item) item = mActiveItem;
1008 if (item) selected.append(item->todo()); 1008 if (item) selected.append(item->todo());
1009 1009
1010 return selected; 1010 return selected;
1011} 1011}
1012 1012
1013QPtrList<Todo> KOTodoView::selectedTodos() 1013QPtrList<Todo> KOTodoView::selectedTodos()
1014{ 1014{
1015 QPtrList<Todo> selected; 1015 QPtrList<Todo> selected;
1016 1016
1017 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 1017 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
1018// if (!item) item = mActiveItem; 1018// if (!item) item = mActiveItem;
1019 if (item) selected.append(item->todo()); 1019 if (item) selected.append(item->todo());
1020 1020
1021 return selected; 1021 return selected;
1022} 1022}
1023 1023
1024void KOTodoView::changeEventDisplay(Event *, int) 1024void KOTodoView::changeEventDisplay(Event *, int)
1025{ 1025{
1026 updateView(); 1026 updateView();
1027} 1027}
1028 1028
1029void KOTodoView::showDates(const QDate &, const QDate &) 1029void KOTodoView::showDates(const QDate &, const QDate &)
1030{ 1030{
1031} 1031}
1032 1032
1033void KOTodoView::showEvents(QPtrList<Event>) 1033void KOTodoView::showEvents(QPtrList<Event>)
1034{ 1034{
1035 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 1035 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
1036} 1036}
1037 1037
1038void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1038void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1039 const QDate &td) 1039 const QDate &td)
1040{ 1040{
1041#ifndef KORG_NOPRINTER 1041#ifndef KORG_NOPRINTER
1042 calPrinter->preview(CalPrinter::Todolist, fd, td); 1042 calPrinter->preview(CalPrinter::Todolist, fd, td);
1043#endif 1043#endif
1044} 1044}
1045 1045
1046void KOTodoView::editItem(QListViewItem *item ) 1046void KOTodoView::editItem(QListViewItem *item )
1047{ 1047{
1048 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 1048 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
1049} 1049}
1050 1050
1051void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 1051void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
1052{ 1052{
1053 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 1053 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
1054} 1054}
1055 1055
1056void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 1056void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
1057{ 1057{
1058 pendingSubtodo = 0; 1058 pendingSubtodo = 0;
1059 mActiveItem = (KOTodoViewItem *)item; 1059 mActiveItem = (KOTodoViewItem *)item;
1060 if (item) { 1060 if (item) {
1061 switch (column){ 1061 switch (column){
1062 case 1: 1062 case 1:
1063 mPriorityPopupMenu->popup(QCursor::pos ()); break; 1063 mPriorityPopupMenu->popup(QCursor::pos ()); break;
1064 case 2: 1064 case 2:
1065 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 1065 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
1066 case 3: 1066 case 3:
1067 moveTodo(); 1067 moveTodo();
1068 break; 1068 break;
1069 case 8: 1069 case 8:
1070 mCategoryPopupMenu->popup(QCursor::pos ()); break; 1070 mCategoryPopupMenu->popup(QCursor::pos ()); break;
1071 case 9: 1071 case 9:
1072 mCalPopupMenu->popup(QCursor::pos ()); break; 1072 mCalPopupMenu->popup(QCursor::pos ()); break;
1073 default: 1073 default:
1074 mItemPopupMenu->popup(QCursor::pos()); 1074 mItemPopupMenu->popup(QCursor::pos());
1075 } 1075 }
1076 } else mPopupMenu->popup(QCursor::pos()); 1076 } else mPopupMenu->popup(QCursor::pos());
1077} 1077}
1078void KOTodoView::newTodo() 1078void KOTodoView::newTodo()
1079{ 1079{
1080 emit newTodoSignal(); 1080 emit newTodoSignal();
1081} 1081}
1082 1082
1083void KOTodoView::newSubTodo() 1083void KOTodoView::newSubTodo()
1084{ 1084{
1085 if (mActiveItem) { 1085 if (mActiveItem) {
1086 emit newSubTodoSignal(mActiveItem->todo()); 1086 emit newSubTodoSignal(mActiveItem->todo());
1087 } 1087 }
1088} 1088}
1089void KOTodoView::unparentTodo() 1089void KOTodoView::unparentTodo()
1090{ 1090{
1091 if (mActiveItem) { 1091 if (mActiveItem) {
1092 emit unparentTodoSignal(mActiveItem->todo()); 1092 emit unparentTodoSignal(mActiveItem->todo());
1093 } 1093 }
1094} 1094}
1095 1095
1096void KOTodoView::reparentTodo() 1096void KOTodoView::reparentTodo()
1097{ 1097{
1098 if (mActiveItem) { 1098 if (mActiveItem) {
1099 topLevelWidget()->setCaption(i18n("Click on new parent item")); 1099 topLevelWidget()->setCaption(i18n("Click on new parent item"));
1100 pendingSubtodo = mActiveItem; 1100 pendingSubtodo = mActiveItem;
1101 } 1101 }
1102} 1102}
1103void KOTodoView::editTodo() 1103void KOTodoView::editTodo()
1104{ 1104{
1105 if (mActiveItem) { 1105 if (mActiveItem) {
1106 emit editTodoSignal(mActiveItem->todo()); 1106 emit editTodoSignal(mActiveItem->todo());
1107 } 1107 }
1108} 1108}
1109void KOTodoView::cloneTodo() 1109void KOTodoView::cloneTodo()
1110{ 1110{
1111 if (mActiveItem) { 1111 if (mActiveItem) {
1112 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 1112 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
1113 } 1113 }
1114} 1114}
1115void KOTodoView::cancelTodo() 1115void KOTodoView::cancelTodo()
1116{ 1116{
1117 if (mActiveItem) { 1117 if (mActiveItem) {
1118 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 1118 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
1119 } 1119 }
1120} 1120}
1121void KOTodoView::moveTodo() 1121void KOTodoView::moveTodo()
1122{ 1122{
1123 if (mActiveItem) { 1123 if (mActiveItem) {
1124 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 1124 emit moveTodoSignal((Incidence*)mActiveItem->todo());
1125 } 1125 }
1126} 1126}
1127void KOTodoView::beamTodo() 1127void KOTodoView::beamTodo()
1128{ 1128{
1129 if (mActiveItem) { 1129 if (mActiveItem) {
1130 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 1130 emit beamTodoSignal((Incidence*)mActiveItem->todo());
1131 } 1131 }
1132} 1132}
1133 1133
1134 1134
1135void KOTodoView::showTodo() 1135void KOTodoView::showTodo()
1136{ 1136{
1137 if (mActiveItem) { 1137 if (mActiveItem) {
1138 emit showTodoSignal(mActiveItem->todo()); 1138 emit showTodoSignal(mActiveItem->todo());
1139 } 1139 }
1140} 1140}
1141 1141
1142void KOTodoView::deleteTodo() 1142void KOTodoView::deleteTodo()
1143{ 1143{
1144 if (mActiveItem) { 1144 if (mActiveItem) {
1145 emit deleteTodoSignal(mActiveItem->todo()); 1145 emit deleteTodoSignal(mActiveItem->todo());
1146 } 1146 }
1147} 1147}
1148 1148
1149void KOTodoView::setNewPriority(int index) 1149void KOTodoView::setNewPriority(int index)
1150{ 1150{
1151 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1151 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1152 mActiveItem->todo()->setPriority(mPriority[index]); 1152 mActiveItem->todo()->setPriority(mPriority[index]);
1153 mActiveItem->construct(); 1153 mActiveItem->construct();
1154 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1154 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1155 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1155 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1156 } 1156 }
1157 processSelectionChange();
1157} 1158}
1158 1159
1159void KOTodoView::setNewPercentage(int index) 1160void KOTodoView::setNewPercentage(int index)
1160{ 1161{
1161 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1162 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1162 1163
1163 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1164 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1164 mActiveItem->setOn( true ); 1165 mActiveItem->setOn( true );
1166 processSelectionChange();
1165 return; 1167 return;
1166 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1168 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1167 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1169 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1168 if ( par && par->isOn() ) 1170 if ( par && par->isOn() )
1169 par->setOn( false ); 1171 par->setOn( false );
1170 } 1172 }
1171 if (mPercentage[index] == 100) { 1173 if (mPercentage[index] == 100) {
1172 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1174 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1173 } else { 1175 } else {
1174 mActiveItem->todo()->setCompleted(false); 1176 mActiveItem->todo()->setCompleted(false);
1175 } 1177 }
1176 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1178 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1177 mActiveItem->construct(); 1179 mActiveItem->construct();
1178 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1180 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1179 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1181 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1180 } 1182 }
1183 processSelectionChange();
1181} 1184}
1182 1185
1183void KOTodoView::fillCategories () 1186void KOTodoView::fillCategories ()
1184{ 1187{
1185 mCategoryPopupMenu->clear(); 1188 mCategoryPopupMenu->clear();
1186 if ( ! mActiveItem ) return; 1189 if ( ! mActiveItem ) return;
1187 QStringList checkedCategories = mActiveItem->todo()->categories (); 1190 QStringList checkedCategories = mActiveItem->todo()->categories ();
1188 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1191 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1189 it != KOPrefs::instance()->mCustomCategories.end (); 1192 it != KOPrefs::instance()->mCustomCategories.end ();
1190 ++it) { 1193 ++it) {
1191 int index = mCategoryPopupMenu->insertItem (*it); 1194 int index = mCategoryPopupMenu->insertItem (*it);
1192 mCategory[index] = *it; 1195 mCategory[index] = *it;
1193 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); 1196 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true);
1194 } 1197 }
1195} 1198}
1196void KOTodoView::fillCal () 1199void KOTodoView::fillCal ()
1197{ 1200{
1198 mCalPopupMenu->clear(); 1201 mCalPopupMenu->clear();
1199 if (!mActiveItem) return; 1202 if (!mActiveItem) return;
1200 bool readO = mActiveItem->todo()->isReadOnly(); 1203 bool readO = mActiveItem->todo()->isReadOnly();
1201 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 1204 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
1202 while ( kkf ) { 1205 while ( kkf ) {
1203 int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); 1206 int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber);
1204 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) 1207 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO )
1205 mCalPopupMenu->setItemEnabled( index, false ); 1208 mCalPopupMenu->setItemEnabled( index, false );
1206 mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); 1209 mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID());
1207 kkf = KOPrefs::instance()->mCalendars.next(); 1210 kkf = KOPrefs::instance()->mCalendars.next();
1208 } 1211 }
1209} 1212}
1210void KOTodoView::changedCal (int index ) 1213void KOTodoView::changedCal (int index )
1211{ 1214{
1212 if (!mActiveItem) return; 1215 if (!mActiveItem) return;
1213 mActiveItem->todo()->setCalID( index ); 1216 mActiveItem->todo()->setCalID( index );
1214 mActiveItem->construct(); 1217 mActiveItem->construct();
1215} 1218}
1216void KOTodoView::changedCategories(int index) 1219void KOTodoView::changedCategories(int index)
1217{ 1220{
1218 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1221 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1219 QStringList categories = mActiveItem->todo()->categories (); 1222 QStringList categories = mActiveItem->todo()->categories ();
1220 QString colcat = categories.first(); 1223 QString colcat = categories.first();
1221 if (categories.find (mCategory[index]) != categories.end ()) 1224 if (categories.find (mCategory[index]) != categories.end ())
1222 categories.remove (mCategory[index]); 1225 categories.remove (mCategory[index]);
1223 else 1226 else
1224 categories.insert (categories.end(), mCategory[index]); 1227 categories.insert (categories.end(), mCategory[index]);
1225 categories.sort (); 1228 categories.sort ();
1226 if ( !colcat.isEmpty() ) { 1229 if ( !colcat.isEmpty() ) {
1227 if ( categories.find ( colcat ) != categories.end () ) { 1230 if ( categories.find ( colcat ) != categories.end () ) {
1228 categories.remove( colcat ); 1231 categories.remove( colcat );
1229 categories.prepend( colcat ); 1232 categories.prepend( colcat );
1230 } 1233 }
1231 } 1234 }
1232 mActiveItem->todo()->setCategories (categories); 1235 mActiveItem->todo()->setCategories (categories);
1233 mActiveItem->construct(); 1236 mActiveItem->construct();
1234 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1237 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1235 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1238 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1236 } 1239 }
1237} 1240}
1238void KOTodoView::itemDoubleClicked(QListViewItem *item) 1241void KOTodoView::itemDoubleClicked(QListViewItem *item)
1239{ 1242{
1240 if ( pendingSubtodo != 0 ) { 1243 if ( pendingSubtodo != 0 ) {
1241 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1244 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1242 } 1245 }
1243 pendingSubtodo = 0; 1246 pendingSubtodo = 0;
1244 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1247 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1245 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1248 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1246 //qDebug("ROW %d ", row); 1249 //qDebug("ROW %d ", row);
1247 if (!item) { 1250 if (!item) {
1248 newTodo(); 1251 newTodo();
1249 return; 1252 return;
1250 } else { 1253 } else {
1251 if ( row == 1 ) { 1254 if ( row == 1 ) {
1252 mActiveItem = (KOTodoViewItem *) item; 1255 mActiveItem = (KOTodoViewItem *) item;
1253 newSubTodo(); 1256 newSubTodo();
1254 return; 1257 return;
1255 } 1258 }
1256 if ( row == 5 || row == 6 || row == 2) { 1259 if ( row == 5 || row == 6 || row == 2) {
1257 mActiveItem = (KOTodoViewItem *) item; 1260 mActiveItem = (KOTodoViewItem *) item;
1258 Todo * t = mActiveItem->todo(); 1261 Todo * t = mActiveItem->todo();
1259 if ( t->isRunning() ) { 1262 if ( t->isRunning() ) {
1260 if ( t->runTime() < 15) { 1263 if ( t->runTime() < 15) {
1261 t->stopRunning(); 1264 t->stopRunning();
1262 mActiveItem->construct(); 1265 mActiveItem->construct();
1263 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); 1266 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!"));
1264 return; 1267 return;
1265 } 1268 }
1266 else 1269 else
1267 toggleRunningItem(); 1270 toggleRunningItem();
1268 return; 1271 return;
1269 } else { 1272 } else {
1270 t->setRunning( true ); 1273 t->setRunning( true );
1271 mActiveItem->construct(); 1274 mActiveItem->construct();
1272 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); 1275 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!"));
1273 return; 1276 return;
1274 } 1277 }
1275 } 1278 }
1276 } 1279 }
1277 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1280 if ( KOPrefs::instance()->mEditOnDoubleClick )
1278 editItem( item ); 1281 editItem( item );
1279 else 1282 else
1280 showItem( item , QPoint(), 0 ); 1283 showItem( item , QPoint(), 0 );
1281} 1284}
1282void KOTodoView::toggleRunningItem() 1285void KOTodoView::toggleRunningItem()
1283{ 1286{
1284 // qDebug("KOTodoView::toggleRunning() "); 1287 // qDebug("KOTodoView::toggleRunning() ");
1285 if ( ! mActiveItem ) 1288 if ( ! mActiveItem )
1286 return; 1289 return;
1287 Todo * t = mActiveItem->todo(); 1290 Todo * t = mActiveItem->todo();
1288 if ( t->isRunning() ) { 1291 if ( t->isRunning() ) {
1289 KOStopTodoPrefs tp ( t, this ); 1292 KOStopTodoPrefs tp ( t, this );
1290 if (QApplication::desktop()->width() <= 800 ){ 1293 if (QApplication::desktop()->width() <= 800 ){
1291 int wid = tp.width(); 1294 int wid = tp.width();
1292 int hei = tp.height(); 1295 int hei = tp.height();
1293 int xx = (QApplication::desktop()->width()-wid)/2; 1296 int xx = (QApplication::desktop()->width()-wid)/2;
1294 int yy = (QApplication::desktop()->height()-hei)/2; 1297 int yy = (QApplication::desktop()->height()-hei)/2;
1295 tp.setGeometry( xx,yy,wid,hei ); 1298 tp.setGeometry( xx,yy,wid,hei );
1296 } 1299 }
1297 tp.exec(); 1300 tp.exec();
1298 mActiveItem->construct(); 1301 mActiveItem->construct();
1299 } else { 1302 } else {
1300 KOStartTodoPrefs tp ( t->summary(), this ); 1303 KOStartTodoPrefs tp ( t->summary(), this );
1301 if (QApplication::desktop()->width() <= 800 ){ 1304 if (QApplication::desktop()->width() <= 800 ){
1302 int wid = tp.width(); 1305 int wid = tp.width();
1303 int hei = tp.height(); 1306 int hei = tp.height();
1304 int xx = (QApplication::desktop()->width()-wid)/2; 1307 int xx = (QApplication::desktop()->width()-wid)/2;
1305 int yy = (QApplication::desktop()->height()-hei)/2; 1308 int yy = (QApplication::desktop()->height()-hei)/2;
1306 tp.setGeometry( xx,yy,wid,hei ); 1309 tp.setGeometry( xx,yy,wid,hei );
1307 } 1310 }
1308 if ( !tp.exec() ) return; 1311 if ( !tp.exec() ) return;
1309 if ( tp.stopAll() ) { 1312 if ( tp.stopAll() ) {
1310 mCalendar->stopAllTodos(); 1313 mCalendar->stopAllTodos();
1311 t->setRunning( true ); 1314 t->setRunning( true );
1312 updateView(); 1315 updateView();
1313 } else { 1316 } else {
1314 t->setRunning( true ); 1317 t->setRunning( true );
1315 mActiveItem->construct(); 1318 mActiveItem->construct();
1316 } 1319 }
1317 } 1320 }
1318} 1321}
1319 1322
1320void KOTodoView::itemClicked(QListViewItem *item) 1323void KOTodoView::itemClicked(QListViewItem *item)
1321{ 1324{
1322 //qDebug("KOTodoView::itemClicked %d", item); 1325 //qDebug("KOTodoView::itemClicked %d", item);
1323 if (!item) { 1326 if (!item) {
1324 if ( pendingSubtodo != 0 ) { 1327 if ( pendingSubtodo != 0 ) {
1325 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1328 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1326 } 1329 }
1327 pendingSubtodo = 0; 1330 pendingSubtodo = 0;
1328 return; 1331 return;
1329 } 1332 }
1330 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1333 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1331 if ( pendingSubtodo != 0 ) { 1334 if ( pendingSubtodo != 0 ) {
1332 bool allowReparent = true; 1335 bool allowReparent = true;
1333 QListViewItem *par = item; 1336 QListViewItem *par = item;
1334 while ( par ) { 1337 while ( par ) {
1335 if ( par == pendingSubtodo ) { 1338 if ( par == pendingSubtodo ) {
1336 allowReparent = false; 1339 allowReparent = false;
1337 break; 1340 break;
1338 } 1341 }
1339 par = par->parent(); 1342 par = par->parent();
1340 } 1343 }
1341 if ( !allowReparent ) { 1344 if ( !allowReparent ) {
1342 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1345 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1343 pendingSubtodo = 0; 1346 pendingSubtodo = 0;
1344 } else { 1347 } else {
1345 Todo* newParent = todoItem->todo(); 1348 Todo* newParent = todoItem->todo();
1346 Todo* newSub = pendingSubtodo->todo(); 1349 Todo* newSub = pendingSubtodo->todo();
1347 pendingSubtodo = 0; 1350 pendingSubtodo = 0;
1348 emit reparentTodoSignal( newParent,newSub ); 1351 emit reparentTodoSignal( newParent,newSub );
1349 return; 1352 return;
1350 } 1353 }
1351 } 1354 }
1352 1355
1353} 1356}
1354 1357
1355void KOTodoView::setDocumentId( const QString &id ) 1358void KOTodoView::setDocumentId( const QString &id )
1356{ 1359{
1357 1360
1358 mDocPrefs->setDoc( id ); 1361 mDocPrefs->setDoc( id );
1359} 1362}
1360 1363
1361void KOTodoView::itemStateChanged( QListViewItem *item ) 1364void KOTodoView::itemStateChanged( QListViewItem *item )
1362{ 1365{
1363 if (!item) return; 1366 if (!item) return;
1364 1367
1365 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1368 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1366 1369
1367// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1370// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1368 1371
1369 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1372 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1370} 1373}
1371 1374
1372void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1375void KOTodoView::saveLayout(KConfig *config, const QString &group) const