-rw-r--r-- | korganizer/kotodoview.cpp | 3 |
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 | |||
@@ -1061,216 +1061,219 @@ void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | |||
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 | } |
1078 | void KOTodoView::newTodo() | 1078 | void KOTodoView::newTodo() |
1079 | { | 1079 | { |
1080 | emit newTodoSignal(); | 1080 | emit newTodoSignal(); |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | void KOTodoView::newSubTodo() | 1083 | void KOTodoView::newSubTodo() |
1084 | { | 1084 | { |
1085 | if (mActiveItem) { | 1085 | if (mActiveItem) { |
1086 | emit newSubTodoSignal(mActiveItem->todo()); | 1086 | emit newSubTodoSignal(mActiveItem->todo()); |
1087 | } | 1087 | } |
1088 | } | 1088 | } |
1089 | void KOTodoView::unparentTodo() | 1089 | void 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 | ||
1096 | void KOTodoView::reparentTodo() | 1096 | void 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 | } |
1103 | void KOTodoView::editTodo() | 1103 | void KOTodoView::editTodo() |
1104 | { | 1104 | { |
1105 | if (mActiveItem) { | 1105 | if (mActiveItem) { |
1106 | emit editTodoSignal(mActiveItem->todo()); | 1106 | emit editTodoSignal(mActiveItem->todo()); |
1107 | } | 1107 | } |
1108 | } | 1108 | } |
1109 | void KOTodoView::cloneTodo() | 1109 | void 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 | } |
1115 | void KOTodoView::cancelTodo() | 1115 | void 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 | } |
1121 | void KOTodoView::moveTodo() | 1121 | void 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 | } |
1127 | void KOTodoView::beamTodo() | 1127 | void 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 | ||
1135 | void KOTodoView::showTodo() | 1135 | void 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 | ||
1142 | void KOTodoView::deleteTodo() | 1142 | void 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 | ||
1149 | void KOTodoView::setNewPriority(int index) | 1149 | void 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 | ||
1159 | void KOTodoView::setNewPercentage(int index) | 1160 | void 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 | ||
1183 | void KOTodoView::fillCategories () | 1186 | void 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 | } |
1196 | void KOTodoView::fillCal () | 1199 | void 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 | } |
1210 | void KOTodoView::changedCal (int index ) | 1213 | void 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 | } |
1216 | void KOTodoView::changedCategories(int index) | 1219 | void 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 | } |
1238 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1241 | void 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 | } |