29 #include <HbAbstractViewItem> |
29 #include <HbAbstractViewItem> |
30 #include <HbAbstractItemView> |
30 #include <HbAbstractItemView> |
31 #include <HbGroupBox> |
31 #include <HbGroupBox> |
32 #include <HbListViewItem> |
32 #include <HbListViewItem> |
33 #include <hbapplication> // hbapplication |
33 #include <hbapplication> // hbapplication |
34 #include <hbactivitymanager> // hbactivitymanager |
34 #include <AfActivityStorage.h> |
|
35 |
35 |
36 |
36 // User includes |
37 // User includes |
37 #include <agendautil.h> |
38 #include <agendautil.h> |
38 #include "agendaeventviewer.h" |
39 #include "agendaeventviewer.h" |
39 #include "notesmainview.h" |
40 #include "notesmainview.h" |
97 */ |
98 */ |
98 void NotesMainView::setupView( |
99 void NotesMainView::setupView( |
99 NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader) |
100 NotesAppControllerIf &controllerIf, NotesDocLoader *docLoader) |
100 { |
101 { |
101 OstTraceFunctionEntry0( NOTESMAINVIEW_SETUPVIEW_ENTRY ); |
102 OstTraceFunctionEntry0( NOTESMAINVIEW_SETUPVIEW_ENTRY ); |
102 |
103 // Get a pointer to activity storage |
|
104 mActivityStorage = new AfActivityStorage(this); |
|
105 |
|
106 |
103 mDocLoader = docLoader; |
107 mDocLoader = docLoader; |
104 mAppControllerIf = &controllerIf; |
108 mAppControllerIf = &controllerIf; |
105 mNotesModel = mAppControllerIf->notesModel(); |
109 mNotesModel = mAppControllerIf->notesModel(); |
106 mAgendaUtil = mAppControllerIf->agendaUtil(); |
110 mAgendaUtil = mAppControllerIf->agendaUtil(); |
107 |
111 |
155 |
159 |
156 // Set the graphics size for the icons. |
160 // Set the graphics size for the icons. |
157 HbListViewItem *prototype = mListView->listItemPrototype(); |
161 HbListViewItem *prototype = mListView->listItemPrototype(); |
158 prototype->setGraphicsSize(HbListViewItem::SmallIcon); |
162 prototype->setGraphicsSize(HbListViewItem::SmallIcon); |
159 |
163 |
160 // Get a pointer to activity Manager |
164 |
161 HbActivityManager* activityManager = |
165 // clean up any previous versions of this activity |
162 qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
163 |
|
164 // clean up any previous versions of this activity from the activity manager |
|
165 // ignore return value as the first boot would always return a false |
166 // ignore return value as the first boot would always return a false |
166 // bool declared on for debugging purpose |
167 // bool declared on for debugging purpose |
167 bool ok = activityManager->removeActivity(notes); |
168 bool ok = removeActivity(); |
168 |
169 |
169 // connect main view for the first time to recieve aboutToQuit signal |
170 // connect main view for the first time to recieve aboutToQuit signal |
170 connect( |
171 connect( |
171 qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), |
172 qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), |
172 this, SLOT(saveActivity())); |
173 this, SLOT(saveActivity())); |
767 saveActivity saves main view as an activity |
768 saveActivity saves main view as an activity |
768 */ |
769 */ |
769 void NotesMainView::saveActivity() |
770 void NotesMainView::saveActivity() |
770 { |
771 { |
771 OstTraceFunctionEntry0( NOTESMAINVIEW_SAVEACTIVITY_ENTRY ); |
772 OstTraceFunctionEntry0( NOTESMAINVIEW_SAVEACTIVITY_ENTRY ); |
772 // Get a pointer to activity Manager |
773 |
773 HbActivityManager* activityManager = |
|
774 qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
775 |
774 |
776 // check if a valid screenshot is already captured |
775 // check if a valid screenshot is already captured |
777 if (!mIsScreenShotCapruted) { |
776 if (!mIsScreenShotCapruted) { |
778 mScreenShot.clear(); |
777 mScreenShot.clear(); |
779 mScreenShot.insert( |
778 mScreenShot.insert( |
786 QDataStream stream( |
785 QDataStream stream( |
787 &serializedActivity, QIODevice::WriteOnly | QIODevice::Append); |
786 &serializedActivity, QIODevice::WriteOnly | QIODevice::Append); |
788 stream << NotesNamespace::NotesMainViewId; |
787 stream << NotesNamespace::NotesMainViewId; |
789 |
788 |
790 // add the activity to the activity manager |
789 // add the activity to the activity manager |
791 bool ok = activityManager->addActivity( |
790 bool ok = mActivityStorage->saveActivity( |
792 notes, serializedActivity, mScreenShot); |
791 notes, serializedActivity, mScreenShot); |
|
792 |
793 if (!ok) { |
793 if (!ok) { |
794 qFatal("Add failed" ); |
794 qFatal("Add failed" ); |
795 } |
795 } |
796 OstTraceFunctionExit0( NOTESMAINVIEW_SAVEACTIVITY_EXIT ); |
796 OstTraceFunctionExit0( NOTESMAINVIEW_SAVEACTIVITY_EXIT ); |
797 } |
797 } |
798 |
798 |
|
799 bool NotesMainView::removeActivity() |
|
800 { |
|
801 OstTraceFunctionEntry0( NOTESMAINVIEW_REMOVEACTIVITY_ENTRY ); |
|
802 OstTraceFunctionExit0( NOTESMAINVIEW_REMOVEACTIVITY_EXIT); |
|
803 return mActivityStorage->removeActivity(notes); |
|
804 } |
799 // End of file --Don't remove this. |
805 // End of file --Don't remove this. |