-rw-r--r-- | korganizer/kotodoview.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 98c9bd9..8d957eb 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1087,201 +1087,214 @@ void KOTodoView::showTodo() | |||
1087 | void KOTodoView::deleteTodo() | 1087 | void KOTodoView::deleteTodo() |
1088 | { | 1088 | { |
1089 | if (mActiveItem) { | 1089 | if (mActiveItem) { |
1090 | emit deleteTodoSignal(mActiveItem->todo()); | 1090 | emit deleteTodoSignal(mActiveItem->todo()); |
1091 | } | 1091 | } |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | void KOTodoView::setNewPriority(int index) | 1094 | void KOTodoView::setNewPriority(int index) |
1095 | { | 1095 | { |
1096 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1096 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1097 | mActiveItem->todo()->setPriority(mPriority[index]); | 1097 | mActiveItem->todo()->setPriority(mPriority[index]); |
1098 | mActiveItem->construct(); | 1098 | mActiveItem->construct(); |
1099 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1099 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1100 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1100 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1101 | } | 1101 | } |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | void KOTodoView::setNewPercentage(int index) | 1104 | void KOTodoView::setNewPercentage(int index) |
1105 | { | 1105 | { |
1106 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1106 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1107 | 1107 | ||
1108 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1108 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1109 | mActiveItem->setOn( true ); | 1109 | mActiveItem->setOn( true ); |
1110 | return; | 1110 | return; |
1111 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1111 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1112 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1112 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1113 | if ( par && par->isOn() ) | 1113 | if ( par && par->isOn() ) |
1114 | par->setOn( false ); | 1114 | par->setOn( false ); |
1115 | } | 1115 | } |
1116 | if (mPercentage[index] == 100) { | 1116 | if (mPercentage[index] == 100) { |
1117 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1117 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1118 | } else { | 1118 | } else { |
1119 | mActiveItem->todo()->setCompleted(false); | 1119 | mActiveItem->todo()->setCompleted(false); |
1120 | } | 1120 | } |
1121 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1121 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1122 | mActiveItem->construct(); | 1122 | mActiveItem->construct(); |
1123 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1123 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1124 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1124 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | 1128 | ||
1129 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 1129 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
1130 | { | 1130 | { |
1131 | QPopupMenu* tempMenu = new QPopupMenu (this); | 1131 | QPopupMenu* tempMenu = new QPopupMenu (this); |
1132 | QStringList checkedCategories = todoItem->todo()->categories (); | 1132 | QStringList checkedCategories = todoItem->todo()->categories (); |
1133 | 1133 | ||
1134 | tempMenu->setCheckable (true); | 1134 | tempMenu->setCheckable (true); |
1135 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1135 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1136 | it != KOPrefs::instance()->mCustomCategories.end (); | 1136 | it != KOPrefs::instance()->mCustomCategories.end (); |
1137 | ++it) { | 1137 | ++it) { |
1138 | int index = tempMenu->insertItem (*it); | 1138 | int index = tempMenu->insertItem (*it); |
1139 | mCategory[index] = *it; | 1139 | mCategory[index] = *it; |
1140 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 1140 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 1143 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
1144 | return tempMenu; | 1144 | return tempMenu; |
1145 | 1145 | ||
1146 | 1146 | ||
1147 | } | 1147 | } |
1148 | void KOTodoView::changedCategories(int index) | 1148 | void KOTodoView::changedCategories(int index) |
1149 | { | 1149 | { |
1150 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1150 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1151 | QStringList categories = mActiveItem->todo()->categories (); | 1151 | QStringList categories = mActiveItem->todo()->categories (); |
1152 | QString colcat = categories.first(); | 1152 | QString colcat = categories.first(); |
1153 | if (categories.find (mCategory[index]) != categories.end ()) | 1153 | if (categories.find (mCategory[index]) != categories.end ()) |
1154 | categories.remove (mCategory[index]); | 1154 | categories.remove (mCategory[index]); |
1155 | else | 1155 | else |
1156 | categories.insert (categories.end(), mCategory[index]); | 1156 | categories.insert (categories.end(), mCategory[index]); |
1157 | categories.sort (); | 1157 | categories.sort (); |
1158 | if ( !colcat.isEmpty() ) { | 1158 | if ( !colcat.isEmpty() ) { |
1159 | if ( categories.find ( colcat ) != categories.end () ) { | 1159 | if ( categories.find ( colcat ) != categories.end () ) { |
1160 | categories.remove( colcat ); | 1160 | categories.remove( colcat ); |
1161 | categories.prepend( colcat ); | 1161 | categories.prepend( colcat ); |
1162 | } | 1162 | } |
1163 | } | 1163 | } |
1164 | mActiveItem->todo()->setCategories (categories); | 1164 | mActiveItem->todo()->setCategories (categories); |
1165 | mActiveItem->construct(); | 1165 | mActiveItem->construct(); |
1166 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1166 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1167 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1167 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1168 | } | 1168 | } |
1169 | } | 1169 | } |
1170 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1170 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1171 | { | 1171 | { |
1172 | if ( pendingSubtodo != 0 ) { | 1172 | if ( pendingSubtodo != 0 ) { |
1173 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1173 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1174 | } | 1174 | } |
1175 | pendingSubtodo = 0; | 1175 | pendingSubtodo = 0; |
1176 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1176 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1177 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1177 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1178 | //qDebug("ROW %d ", row); | 1178 | //qDebug("ROW %d ", row); |
1179 | if (!item) { | 1179 | if (!item) { |
1180 | newTodo(); | 1180 | newTodo(); |
1181 | return; | 1181 | return; |
1182 | } else { | 1182 | } else { |
1183 | if ( row == 2 || row == 1 ) { | 1183 | if ( row == 1 ) { |
1184 | mActiveItem = (KOTodoViewItem *) item; | 1184 | mActiveItem = (KOTodoViewItem *) item; |
1185 | newSubTodo(); | 1185 | newSubTodo(); |
1186 | return; | 1186 | return; |
1187 | } | 1187 | } |
1188 | if ( row == 5 || row == 6 ) { | 1188 | if ( row == 5 || row == 6 || row == 2) { |
1189 | mActiveItem = (KOTodoViewItem *) item; | 1189 | mActiveItem = (KOTodoViewItem *) item; |
1190 | toggleRunningItem(); | 1190 | Todo * t = mActiveItem->todo(); |
1191 | return; | 1191 | if ( t->isRunning() ) { |
1192 | if ( t->runTime() < 15) { | ||
1193 | t->stopRunning(); | ||
1194 | mActiveItem->construct(); | ||
1195 | return; | ||
1196 | } | ||
1197 | else | ||
1198 | toggleRunningItem(); | ||
1199 | return; | ||
1200 | } else { | ||
1201 | t->setRunning( true ); | ||
1202 | mActiveItem->construct(); | ||
1203 | return; | ||
1204 | } | ||
1192 | } | 1205 | } |
1193 | } | 1206 | } |
1194 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1207 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1195 | editItem( item ); | 1208 | editItem( item ); |
1196 | else | 1209 | else |
1197 | showItem( item , QPoint(), 0 ); | 1210 | showItem( item , QPoint(), 0 ); |
1198 | } | 1211 | } |
1199 | void KOTodoView::toggleRunningItem() | 1212 | void KOTodoView::toggleRunningItem() |
1200 | { | 1213 | { |
1201 | // qDebug("KOTodoView::toggleRunning() "); | 1214 | // qDebug("KOTodoView::toggleRunning() "); |
1202 | if ( ! mActiveItem ) | 1215 | if ( ! mActiveItem ) |
1203 | return; | 1216 | return; |
1204 | Todo * t = mActiveItem->todo(); | 1217 | Todo * t = mActiveItem->todo(); |
1205 | if ( t->isRunning() ) { | 1218 | if ( t->isRunning() ) { |
1206 | KOStopTodoPrefs tp ( t, this ); | 1219 | KOStopTodoPrefs tp ( t, this ); |
1207 | if (QApplication::desktop()->width() < 800 ){ | 1220 | if (QApplication::desktop()->width() < 800 ){ |
1208 | int wid = tp.width(); | 1221 | int wid = tp.width(); |
1209 | int hei = tp.height(); | 1222 | int hei = tp.height(); |
1210 | int xx = (QApplication::desktop()->width()-wid)/2; | 1223 | int xx = (QApplication::desktop()->width()-wid)/2; |
1211 | int yy = (QApplication::desktop()->height()-hei)/2; | 1224 | int yy = (QApplication::desktop()->height()-hei)/2; |
1212 | tp.setGeometry( xx,yy,wid,hei ); | 1225 | tp.setGeometry( xx,yy,wid,hei ); |
1213 | } | 1226 | } |
1214 | tp.exec(); | 1227 | tp.exec(); |
1215 | mActiveItem->construct(); | 1228 | mActiveItem->construct(); |
1216 | } else { | 1229 | } else { |
1217 | int result = KMessageBox::warningContinueCancel(this, | 1230 | int result = KMessageBox::warningContinueCancel(this, |
1218 | i18n("<center>%1</center> <center>is not running. Do you want to set\nthe state to running?</center>").arg(mActiveItem->text(0).left( 25 ) ),i18n("Start todo"),i18n("Start todo"),i18n("Cancel"), true); | 1231 | i18n("<center>%1</center> <center>is not running. Do you want to set\nthe state to running?</center>").arg(mActiveItem->text(0).left( 25 ) ),i18n("Start todo"),i18n("Start todo"),i18n("Cancel"), true); |
1219 | if (result != KMessageBox::Continue) return; | 1232 | if (result != KMessageBox::Continue) return; |
1220 | t->setRunning( true ); | 1233 | t->setRunning( true ); |
1221 | mActiveItem->construct(); | 1234 | mActiveItem->construct(); |
1222 | } | 1235 | } |
1223 | } | 1236 | } |
1224 | 1237 | ||
1225 | void KOTodoView::itemClicked(QListViewItem *item) | 1238 | void KOTodoView::itemClicked(QListViewItem *item) |
1226 | { | 1239 | { |
1227 | //qDebug("KOTodoView::itemClicked %d", item); | 1240 | //qDebug("KOTodoView::itemClicked %d", item); |
1228 | if (!item) { | 1241 | if (!item) { |
1229 | if ( pendingSubtodo != 0 ) { | 1242 | if ( pendingSubtodo != 0 ) { |
1230 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1243 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1231 | } | 1244 | } |
1232 | pendingSubtodo = 0; | 1245 | pendingSubtodo = 0; |
1233 | return; | 1246 | return; |
1234 | } | 1247 | } |
1235 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1248 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1236 | if ( pendingSubtodo != 0 ) { | 1249 | if ( pendingSubtodo != 0 ) { |
1237 | bool allowReparent = true; | 1250 | bool allowReparent = true; |
1238 | QListViewItem *par = item; | 1251 | QListViewItem *par = item; |
1239 | while ( par ) { | 1252 | while ( par ) { |
1240 | if ( par == pendingSubtodo ) { | 1253 | if ( par == pendingSubtodo ) { |
1241 | allowReparent = false; | 1254 | allowReparent = false; |
1242 | break; | 1255 | break; |
1243 | } | 1256 | } |
1244 | par = par->parent(); | 1257 | par = par->parent(); |
1245 | } | 1258 | } |
1246 | if ( !allowReparent ) { | 1259 | if ( !allowReparent ) { |
1247 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1260 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1248 | pendingSubtodo = 0; | 1261 | pendingSubtodo = 0; |
1249 | } else { | 1262 | } else { |
1250 | Todo* newParent = todoItem->todo(); | 1263 | Todo* newParent = todoItem->todo(); |
1251 | Todo* newSub = pendingSubtodo->todo(); | 1264 | Todo* newSub = pendingSubtodo->todo(); |
1252 | pendingSubtodo = 0; | 1265 | pendingSubtodo = 0; |
1253 | emit reparentTodoSignal( newParent,newSub ); | 1266 | emit reparentTodoSignal( newParent,newSub ); |
1254 | return; | 1267 | return; |
1255 | } | 1268 | } |
1256 | } | 1269 | } |
1257 | 1270 | ||
1258 | } | 1271 | } |
1259 | 1272 | ||
1260 | void KOTodoView::setDocumentId( const QString &id ) | 1273 | void KOTodoView::setDocumentId( const QString &id ) |
1261 | { | 1274 | { |
1262 | 1275 | ||
1263 | mDocPrefs->setDoc( id ); | 1276 | mDocPrefs->setDoc( id ); |
1264 | } | 1277 | } |
1265 | 1278 | ||
1266 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1279 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1267 | { | 1280 | { |
1268 | if (!item) return; | 1281 | if (!item) return; |
1269 | 1282 | ||
1270 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1283 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1271 | 1284 | ||
1272 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1285 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1273 | 1286 | ||
1274 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1287 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1275 | } | 1288 | } |
1276 | 1289 | ||
1277 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1290 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1278 | { | 1291 | { |
1279 | mTodoListView->saveLayout(config,group); | 1292 | mTodoListView->saveLayout(config,group); |
1280 | } | 1293 | } |
1281 | 1294 | ||
1282 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1295 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1283 | { | 1296 | { |
1284 | mTodoListView->restoreLayout(config,group); | 1297 | mTodoListView->restoreLayout(config,group); |
1285 | } | 1298 | } |
1286 | 1299 | ||
1287 | void KOTodoView::processSelectionChange() | 1300 | void KOTodoView::processSelectionChange() |