-rw-r--r-- | korganizer/kotodoeditor.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index ec5c2d1..70dfbd1 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -188,195 +188,195 @@ void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | |||
188 | mTodo = todo; | 188 | mTodo = todo; |
189 | readTodo(mTodo); | 189 | readTodo(mTodo); |
190 | if ( editDescription ) { | 190 | if ( editDescription ) { |
191 | showPage( 1 ); | 191 | showPage( 1 ); |
192 | mGeneral->setFocusOn( 1 ); | 192 | mGeneral->setFocusOn( 1 ); |
193 | } else { | 193 | } else { |
194 | showPage( 0 ); | 194 | showPage( 0 ); |
195 | mGeneral->setFocusOn( 2 ); | 195 | mGeneral->setFocusOn( 2 ); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) | 199 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) |
200 | { | 200 | { |
201 | //init(); | 201 | //init(); |
202 | 202 | ||
203 | mTodo = 0; | 203 | mTodo = 0; |
204 | setDefaults(due,relatedTodo,allDay); | 204 | setDefaults(due,relatedTodo,allDay); |
205 | } | 205 | } |
206 | 206 | ||
207 | void KOTodoEditor::loadDefaults() | 207 | void KOTodoEditor::loadDefaults() |
208 | { | 208 | { |
209 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); | 209 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); |
210 | } | 210 | } |
211 | 211 | ||
212 | bool KOTodoEditor::processInput( bool emitTime ) | 212 | bool KOTodoEditor::processInput( bool emitTime ) |
213 | { | 213 | { |
214 | if (!validateInput()) return false; | 214 | if (!validateInput()) return false; |
215 | 215 | ||
216 | Todo *todo = 0; | 216 | Todo *todo = 0; |
217 | 217 | ||
218 | if (mTodo) todo = mTodo; | 218 | if (mTodo) todo = mTodo; |
219 | else { | 219 | else { |
220 | todo = new Todo; | 220 | todo = new Todo; |
221 | todo->setOrganizer(KOPrefs::instance()->email()); | 221 | todo->setOrganizer(KOPrefs::instance()->email()); |
222 | } | 222 | } |
223 | 223 | ||
224 | writeTodo(todo); | 224 | writeTodo(todo); |
225 | if ( emitTime ) { | 225 | if ( emitTime ) { |
226 | globalFlagBlockAgenda = 1; | 226 | globalFlagBlockAgenda = 1; |
227 | emit showAgendaView( false ); | 227 | emit showAgendaView( false ); |
228 | if ( todo->hasDueDate() ) | 228 | if ( todo->hasDueDate() ) |
229 | emit jumpToTime( todo->dtDue().date() ); | 229 | emit jumpToTime( todo->dtDue().date() ); |
230 | globalFlagBlockAgenda = 2; | 230 | globalFlagBlockAgenda = 2; |
231 | } | 231 | } |
232 | if (mTodo) { | 232 | if (mTodo) { |
233 | todo->setRevision(todo->revision()+1); | 233 | todo->setRevision(todo->revision()+1); |
234 | emit todoChanged(todo); | 234 | emit todoChanged(todo); |
235 | } else { | 235 | } else { |
236 | mCalendar->addTodo(todo); | 236 | mCalendar->addTodo(todo); |
237 | mTodo = todo; | 237 | mTodo = todo; |
238 | emit todoAdded(todo); | 238 | emit todoAdded(todo); |
239 | } | 239 | } |
240 | 240 | ||
241 | return true; | 241 | return true; |
242 | } | 242 | } |
243 | 243 | ||
244 | void KOTodoEditor::deleteTodo() | 244 | void KOTodoEditor::deleteTodo() |
245 | { | 245 | { |
246 | if (mTodo) { | 246 | if (mTodo) { |
247 | if (KOPrefs::instance()->mConfirm) { | 247 | if (KOPrefs::instance()->mConfirm) { |
248 | switch (msgItemDelete()) { | 248 | switch (msgItemDelete()) { |
249 | case KMessageBox::Continue: // OK | 249 | case KMessageBox::Continue: // OK |
250 | emit todoToBeDeleted(mTodo); | 250 | emit todoToBeDeleted(mTodo); |
251 | emit dialogClose(mTodo); | 251 | emit dialogClose(mTodo); |
252 | mCalendar->deleteTodo(mTodo); | 252 | mCalendar->deleteTodo(mTodo); |
253 | emit todoDeleted(); | 253 | emit todoDeleted(); |
254 | reject(); | 254 | reject(); |
255 | break; | 255 | break; |
256 | } | 256 | } |
257 | } | 257 | } |
258 | else { | 258 | else { |
259 | emit todoToBeDeleted(mTodo); | 259 | emit todoToBeDeleted(mTodo); |
260 | emit dialogClose(mTodo); | 260 | emit dialogClose(mTodo); |
261 | mCalendar->deleteTodo(mTodo); | 261 | mCalendar->deleteTodo(mTodo); |
262 | emit todoDeleted(); | 262 | emit todoDeleted(); |
263 | reject(); | 263 | reject(); |
264 | } | 264 | } |
265 | } else { | 265 | } else { |
266 | reject(); | 266 | reject(); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | 270 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) |
271 | { | 271 | { |
272 | mRelatedTodo = relatedEvent; | 272 | mRelatedTodo = relatedEvent; |
273 | 273 | ||
274 | mGeneral->setDefaults(due,allDay); | 274 | mGeneral->setDefaults(due,allDay); |
275 | mDetails->setDefaults(); | 275 | mDetails->setDefaults(); |
276 | showPage( 0 ); | 276 | showPage( 0 ); |
277 | if ( mRelatedTodo ) { | 277 | if ( mRelatedTodo ) { |
278 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 278 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
279 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | 279 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); |
280 | if ( mRelatedTodo->priority() < 3 ) | 280 | if ( mRelatedTodo->priority() < 3 ) |
281 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); | 281 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); |
282 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); | 282 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); |
283 | int len = mRelatedTodo->summary().length(); | 283 | int len = mRelatedTodo->summary().length(); |
284 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | ||
285 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | ||
286 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | 284 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); |
285 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | ||
286 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | ||
287 | 287 | ||
288 | } else | 288 | } else |
289 | mGeneral->setFocusOn( 2 ); | 289 | mGeneral->setFocusOn( 2 ); |
290 | } | 290 | } |
291 | 291 | ||
292 | void KOTodoEditor::readTodo(Todo *todo) | 292 | void KOTodoEditor::readTodo(Todo *todo) |
293 | { | 293 | { |
294 | mGeneral->readTodo(todo); | 294 | mGeneral->readTodo(todo); |
295 | mDetails->readEvent(todo); | 295 | mDetails->readEvent(todo); |
296 | mRelatedTodo = 0;//todo->relatedTo(); | 296 | mRelatedTodo = 0;//todo->relatedTo(); |
297 | // categories | 297 | // categories |
298 | // mCategoryDialog->setSelected(todo->categories()); | 298 | // mCategoryDialog->setSelected(todo->categories()); |
299 | 299 | ||
300 | // We should handle read-only events here. | 300 | // We should handle read-only events here. |
301 | } | 301 | } |
302 | 302 | ||
303 | void KOTodoEditor::writeTodo(Todo *event) | 303 | void KOTodoEditor::writeTodo(Todo *event) |
304 | { | 304 | { |
305 | mGeneral->writeTodo(event); | 305 | mGeneral->writeTodo(event); |
306 | mDetails->writeEvent(event); | 306 | mDetails->writeEvent(event); |
307 | 307 | ||
308 | // set related event, i.e. parent to-do in this case. | 308 | // set related event, i.e. parent to-do in this case. |
309 | if (mRelatedTodo) { | 309 | if (mRelatedTodo) { |
310 | event->setRelatedTo(mRelatedTodo); | 310 | event->setRelatedTo(mRelatedTodo); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | bool KOTodoEditor::validateInput() | 314 | bool KOTodoEditor::validateInput() |
315 | { | 315 | { |
316 | if (!mGeneral->validateInput()) return false; | 316 | if (!mGeneral->validateInput()) return false; |
317 | if (!mDetails->validateInput()) return false; | 317 | if (!mDetails->validateInput()) return false; |
318 | return true; | 318 | return true; |
319 | } | 319 | } |
320 | 320 | ||
321 | int KOTodoEditor::msgItemDelete() | 321 | int KOTodoEditor::msgItemDelete() |
322 | { | 322 | { |
323 | return KMessageBox::warningContinueCancel(this, | 323 | return KMessageBox::warningContinueCancel(this, |
324 | i18n("This item will be permanently deleted."), | 324 | i18n("This item will be permanently deleted."), |
325 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 325 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
326 | } | 326 | } |
327 | 327 | ||
328 | void KOTodoEditor::modified (int modification) | 328 | void KOTodoEditor::modified (int modification) |
329 | { | 329 | { |
330 | if (modification == KOGlobals::CATEGORY_MODIFIED || | 330 | if (modification == KOGlobals::CATEGORY_MODIFIED || |
331 | KOGlobals::UNKNOWN_MODIFIED == modification ) | 331 | KOGlobals::UNKNOWN_MODIFIED == modification ) |
332 | // mCategoryDialog->setSelected (mTodo->categories ()); | 332 | // mCategoryDialog->setSelected (mTodo->categories ()); |
333 | mGeneral->modified (mTodo, modification); | 333 | mGeneral->modified (mTodo, modification); |
334 | 334 | ||
335 | } | 335 | } |
336 | 336 | ||
337 | void KOTodoEditor::slotLoadTemplate() | 337 | void KOTodoEditor::slotLoadTemplate() |
338 | { | 338 | { |
339 | 339 | ||
340 | QString fileName =locateLocal( "templates", "todos" ); | 340 | QString fileName =locateLocal( "templates", "todos" ); |
341 | QDir t_dir; | 341 | QDir t_dir; |
342 | if ( !t_dir.exists(fileName) ) | 342 | if ( !t_dir.exists(fileName) ) |
343 | t_dir.mkdir ( fileName ); | 343 | t_dir.mkdir ( fileName ); |
344 | fileName += "/todo"; | 344 | fileName += "/todo"; |
345 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); | 345 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); |
346 | if ( fileName.length() == 0 ) | 346 | if ( fileName.length() == 0 ) |
347 | return; | 347 | return; |
348 | CalendarLocal cal; | 348 | CalendarLocal cal; |
349 | ICalFormat format; | 349 | ICalFormat format; |
350 | if ( !format.load( &cal, fileName ) ) { | 350 | if ( !format.load( &cal, fileName ) ) { |
351 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 351 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
352 | .arg( fileName ) ); | 352 | .arg( fileName ) ); |
353 | return ; | 353 | return ; |
354 | } | 354 | } |
355 | QPtrList<Todo> todos = cal.todos(); | 355 | QPtrList<Todo> todos = cal.todos(); |
356 | Todo * todo = todos.first(); | 356 | Todo * todo = todos.first(); |
357 | if ( !todo ) { | 357 | if ( !todo ) { |
358 | KMessageBox::error( this, | 358 | KMessageBox::error( this, |
359 | i18n("Template does not\ncontain a valid Todo.")); | 359 | i18n("Template does not\ncontain a valid Todo.")); |
360 | } else { | 360 | } else { |
361 | readTodo( todo ); | 361 | readTodo( todo ); |
362 | } | 362 | } |
363 | 363 | ||
364 | } | 364 | } |
365 | 365 | ||
366 | void KOTodoEditor::slotSaveTemplate() | 366 | void KOTodoEditor::slotSaveTemplate() |
367 | { | 367 | { |
368 | QString fileName =locateLocal( "templates", "todos" ); | 368 | QString fileName =locateLocal( "templates", "todos" ); |
369 | QDir t_dir; | 369 | QDir t_dir; |
370 | if ( !t_dir.exists(fileName) ) | 370 | if ( !t_dir.exists(fileName) ) |
371 | t_dir.mkdir ( fileName ); | 371 | t_dir.mkdir ( fileName ); |
372 | fileName += "/todo"; | 372 | fileName += "/todo"; |
373 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); | 373 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); |
374 | if ( fileName.length() > 0 ) | 374 | if ( fileName.length() > 0 ) |
375 | saveTemplate( fileName ); | 375 | saveTemplate( fileName ); |
376 | } | 376 | } |
377 | 377 | ||
378 | void KOTodoEditor::saveTemplate( const QString &templateName ) | 378 | void KOTodoEditor::saveTemplate( const QString &templateName ) |
379 | { | 379 | { |
380 | Todo *todo = new Todo; | 380 | Todo *todo = new Todo; |
381 | writeTodo( todo ); | 381 | writeTodo( todo ); |
382 | saveAsTemplate( todo, templateName ); | 382 | saveAsTemplate( todo, templateName ); |