228 HbMenu *viewMenu = mEditor->menu(); |
228 HbMenu *viewMenu = mEditor->menu(); |
229 viewMenu->removeAction(mDiscardChangesAction); |
229 viewMenu->removeAction(mDiscardChangesAction); |
230 |
230 |
231 // Set our view as the current view. |
231 // Set our view as the current view. |
232 HbMainWindow *window = hbInstance->allMainWindows().first(); |
232 HbMainWindow *window = hbInstance->allMainWindows().first(); |
233 HbAction *action = new HbAction(Hb::BackAction); |
233 HbAction *action = new HbAction(Hb::BackNaviAction); |
234 mEditor->setNavigationAction(action); |
234 mEditor->setNavigationAction(action); |
235 connect( |
235 connect( |
236 action, SIGNAL(triggered()), |
236 action, SIGNAL(triggered()), |
237 this, SLOT(saveNote())); |
237 this, SLOT(saveNote())); |
238 window->addView(mEditor); |
238 window->addView(mEditor); |
293 /*! |
293 /*! |
294 Deletes the note currently being created/edited and closes the editor. |
294 Deletes the note currently being created/edited and closes the editor. |
295 */ |
295 */ |
296 void NotesNoteEditor::deleteNote() |
296 void NotesNoteEditor::deleteNote() |
297 { |
297 { |
298 if (showDeleteConfirmationQuery()) { |
298 HbMessageBox *confirmationQuery = new HbMessageBox( |
299 mOwner->deleteNote(); |
299 HbMessageBox::MessageTypeQuestion); |
300 |
300 confirmationQuery->setDismissPolicy(HbDialog::NoDismiss); |
301 HbMainWindow *window = hbInstance->allMainWindows().first(); |
301 confirmationQuery->setTimeout(HbDialog::NoTimeout); |
302 bool status = false; |
302 confirmationQuery->setIconVisible(true); |
303 |
303 |
304 // Now close the editor. |
304 QString displayText; |
305 window->removeView(mEditor); |
305 displayText = displayText.append(hbTrId("txt_notes_info_delete_note")); |
306 |
306 |
307 mOwner->editingCompleted(status); |
307 confirmationQuery->setText(displayText); |
308 |
308 |
309 } |
309 // Remove the default actions. |
310 |
310 QList<QAction *> defaultActions = confirmationQuery->actions(); |
|
311 for (int index=0;index<defaultActions.count();index++) { |
|
312 confirmationQuery->removeAction(defaultActions[index]); |
|
313 } |
|
314 defaultActions.clear(); |
|
315 |
|
316 // Add delete and cancel actions. |
|
317 mDeleteNoteAction = new HbAction( |
|
318 hbTrId("txt_notes_button_dialog_delete")); |
|
319 mCancelDeleteAction = new HbAction( |
|
320 hbTrId("txt_common_button_cancel")); |
|
321 confirmationQuery->addAction(mDeleteNoteAction); |
|
322 confirmationQuery->addAction(mCancelDeleteAction); |
|
323 |
|
324 confirmationQuery->open(this, SLOT(selectedAction(HbAction*))); |
311 } |
325 } |
312 |
326 |
313 /*! |
327 /*! |
314 Closes the notes editor and does nothing else. It removes the view off the |
328 Closes the notes editor and does nothing else. It removes the view off the |
315 main window's list of views. |
329 main window's list of views. |
524 } |
538 } |
525 mEditor->menu()->removeAction(mNewNoteAction); |
539 mEditor->menu()->removeAction(mNewNoteAction); |
526 } |
540 } |
527 |
541 |
528 /* ! |
542 /* ! |
529 Show the delete confirmation query. |
543 Slot to handle the selected action from delete message box. |
530 */ |
544 */ |
531 bool NotesNoteEditor::showDeleteConfirmationQuery() |
545 void NotesNoteEditor::selectedAction(HbAction *action) |
532 { |
546 { |
533 bool retValue(false); |
547 if (action == mDeleteNoteAction) { |
534 |
548 mOwner->deleteNote(); |
535 HbMessageBox confirmationQuery(HbMessageBox::MessageTypeQuestion); |
549 |
536 confirmationQuery.setDismissPolicy(HbDialog::NoDismiss); |
550 HbMainWindow *window = hbInstance->allMainWindows().first(); |
537 confirmationQuery.setTimeout(HbDialog::NoTimeout); |
551 bool status = false; |
538 confirmationQuery.setIconVisible(true); |
552 |
539 |
553 // Now close the editor. |
540 QString displayText; |
554 window->removeView(mEditor); |
541 displayText = displayText.append(hbTrId("txt_notes_info_delete_note")); |
555 |
542 |
556 mOwner->editingCompleted(status); |
543 confirmationQuery.setText(displayText); |
557 } |
544 |
|
545 confirmationQuery.setPrimaryAction(new HbAction( |
|
546 hbTrId("txt_notes_button_dialog_delete"), &confirmationQuery)); |
|
547 confirmationQuery.setSecondaryAction(new HbAction( |
|
548 hbTrId("txt_common_button_cancel"), &confirmationQuery)); |
|
549 HbAction *selected = confirmationQuery.exec(); |
|
550 if (selected == confirmationQuery.primaryAction()) { |
|
551 retValue = true; |
|
552 } |
|
553 |
|
554 return retValue; |
|
555 } |
558 } |
556 |
559 |
557 // End of file --Don't remove this. |
560 // End of file --Don't remove this. |