notes/notesui/noteseditor/src/notesnoteeditor.cpp
changeset 83 5aadd1120515
parent 70 a5ed90760192
equal deleted inserted replaced
82:dcd0ca396fa1 83:5aadd1120515
    28 #include <HbDialog>
    28 #include <HbDialog>
    29 #include <HbExtendedLocale>
    29 #include <HbExtendedLocale>
    30 #include <HbMenu>
    30 #include <HbMenu>
    31 #include <CalenEditor>
    31 #include <CalenEditor>
    32 #include <HbMessageBox>
    32 #include <HbMessageBox>
       
    33 #include <HbApplication>
    33 
    34 
    34 // User includes
    35 // User includes
    35 #include "notesnoteeditor.h"
    36 #include "notesnoteeditor.h"
    36 #include "noteseditordocloader.h"
    37 #include "noteseditordocloader.h"
    37 #include "noteseditorcommon.h"
    38 #include "noteseditorcommon.h"
    65 NotesNoteEditor::NotesNoteEditor(NotesEditorPrivate *owner, QObject *parent)
    66 NotesNoteEditor::NotesNoteEditor(NotesEditorPrivate *owner, QObject *parent)
    66 :QObject(parent),
    67 :QObject(parent),
    67  mOwner(owner),
    68  mOwner(owner),
    68  mEntrySavedInCalendar(false),
    69  mEntrySavedInCalendar(false),
    69  mDiscardChangesActionActive(false),
    70  mDiscardChangesActionActive(false),
    70  mIgnoreFirstContentChange(false)
    71  mIgnoreFirstContentChange(false),
       
    72  mForcedExit(false)
    71 {
    73 {
    72 	OstTraceFunctionEntry0( NOTESNOTEEDITOR_NOTESNOTEEDITOR_ENTRY );
    74 	OstTraceFunctionEntry0( NOTESNOTEEDITOR_NOTESNOTEEDITOR_ENTRY );
    73 	mDocLoader = new NotesEditorDocLoader;
    75 	mDocLoader = new NotesEditorDocLoader;
    74 	Q_ASSERT(mDocLoader);
    76 	Q_ASSERT(mDocLoader);
    75 
    77 
   192 {
   194 {
   193 	OstTraceFunctionEntry0( NOTESNOTEEDITOR_EXECUTE_ENTRY );
   195 	OstTraceFunctionEntry0( NOTESNOTEEDITOR_EXECUTE_ENTRY );
   194 	Q_UNUSED(entry)
   196 	Q_UNUSED(entry)
   195 
   197 
   196 	HbExtendedLocale locale = HbExtendedLocale::system();
   198 	HbExtendedLocale locale = HbExtendedLocale::system();
   197 
   199 	  
       
   200 	//if editor is open in background, and user close the app from task switcher
       
   201     //entry should get saved
       
   202     connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()),
       
   203             this, SLOT(forcedExit()));
       
   204     
   198 	if (!mOwner->mNewEntry) {
   205 	if (!mOwner->mNewEntry) {
   199 		mTextEditor->setPlainText(mOwner->mModifiedNote.description());
   206 		mTextEditor->setPlainText(mOwner->mModifiedNote.description());
   200 
   207 
   201 		QString iconName;
   208 		QString iconName;
   202 		if (mOwner->mModifiedNote.favourite()) {
   209 		if (mOwner->mModifiedNote.favourite()) {
   265 	Marks the currently edited note as a to-do.
   272 	Marks the currently edited note as a to-do.
   266  */
   273  */
   267 void NotesNoteEditor::markNoteAsTodo()
   274 void NotesNoteEditor::markNoteAsTodo()
   268 {
   275 {
   269 	OstTraceFunctionEntry0( NOTESNOTEEDITOR_MARKNOTEASTODO_ENTRY );
   276 	OstTraceFunctionEntry0( NOTESNOTEEDITOR_MARKNOTEASTODO_ENTRY );
   270 	mOwner->markNoteAsTodo();
   277 	//if editor is open in background, and user close the app from task switcher
       
   278     //entry should get saved
       
   279     disconnect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()),
       
   280             this, SLOT(forcedExit()));
       
   281     mOwner->markNoteAsTodo();
   271 	OstTraceFunctionExit0( NOTESNOTEEDITOR_MARKNOTEASTODO_EXIT );
   282 	OstTraceFunctionExit0( NOTESNOTEEDITOR_MARKNOTEASTODO_EXIT );
   272 }
   283 }
   273 
   284 
   274 /*!
   285 /*!
   275 	Saves the note. This is called when the Softkey is pressed to save the note.
   286 	Saves the note. This is called when the Softkey is pressed to save the note.
   278  */
   289  */
   279 void NotesNoteEditor::saveNote()
   290 void NotesNoteEditor::saveNote()
   280 {
   291 {
   281 	OstTraceFunctionEntry0( NOTESNOTEEDITOR_SAVENOTE_ENTRY );
   292 	OstTraceFunctionEntry0( NOTESNOTEEDITOR_SAVENOTE_ENTRY );
   282 	bool status = false;
   293 	bool status = false;
   283 
   294     //if editor is open in background, and user close the app from task switcher
       
   295     //entry should get saved
       
   296     disconnect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()),
       
   297             this, SLOT(forcedExit()));
       
   298     
   284 	if (!mOwner->mSaveEntry) {
   299 	if (!mOwner->mSaveEntry) {
   285 		// We don't save the note, since the note was modified by an external
   300 		// We don't save the note, since the note was modified by an external
   286 		// entity. We just Display a message box alerting the user about this
   301 		// entity. We just Display a message box alerting the user about this
   287 		// and just close the editor. Note that this happens only when a note is
   302 		// and just close the editor. Note that this happens only when a note is
   288 		// being edited.
   303 		// being edited.
   593 		mOwner->editingCompleted(status);
   608 		mOwner->editingCompleted(status);
   594 	}
   609 	}
   595 	OstTraceFunctionExit0( NOTESNOTEEDITOR_SELECTEDACTION_EXIT );
   610 	OstTraceFunctionExit0( NOTESNOTEEDITOR_SELECTEDACTION_EXIT );
   596 }
   611 }
   597 
   612 
       
   613 /*!
       
   614     Slot to handle entry when app exit from red key or task switcher.
       
   615  */
       
   616 void NotesNoteEditor::forcedExit()
       
   617 {
       
   618     OstTraceFunctionEntry0( NOTESNOTEEDITOR_FORCEDEXIT_ENTRY );
       
   619     mForcedExit = true;
       
   620     saveNote();
       
   621     OstTraceFunctionExit0( NOTESNOTEEDITOR_FORCEDEXIT_EXIT );
       
   622 }
   598 // End of file	--Don't remove this.
   623 // End of file	--Don't remove this.