57 { |
59 { |
58 HbMainWindow *window = hbInstance->allMainWindows().first(); |
60 HbMainWindow *window = hbInstance->allMainWindows().first(); |
59 |
61 |
60 mAgendaUtil = mAppControllerIf.agendaUtil(); |
62 mAgendaUtil = mAppControllerIf.agendaUtil(); |
61 |
63 |
62 // Load the main view at the start up. |
64 // Check the Application Startup reason from Activity Manager |
63 loadNotesMainView(); |
65 int activityReason = qobject_cast<HbApplication*>(qApp)->activateReason(); |
|
66 |
|
67 if (Hb::ActivationReasonActivity == activityReason) // Check if application is started |
|
68 // from an application |
|
69 { |
|
70 // Application is started from an activity |
|
71 // extract activity data |
|
72 QVariant data = qobject_cast<HbApplication*>(qApp)->activateData(); |
|
73 // Restore state from activity data |
|
74 QByteArray serializedModel = data.toByteArray(); |
|
75 QDataStream stream(&serializedModel, QIODevice::ReadOnly); |
|
76 int viewId; |
|
77 stream >> viewId; // read stream into an int |
|
78 |
|
79 if (NotesNamespace::NotesMainViewId == viewId) // Check if viewId is main view |
|
80 { |
|
81 // Load MainView |
|
82 loadNotesMainView(); |
|
83 } |
|
84 else if (NotesNamespace::NotesCollectionViewId == viewId) // Check if the viewId is collective view |
|
85 { |
|
86 //no implementation yet, UI Specs not available |
|
87 } |
|
88 } |
|
89 else // application started by either service framework or normally |
|
90 { |
|
91 // Load the main view at the start up. |
|
92 loadNotesMainView(); |
|
93 } |
|
94 |
|
95 connect( |
|
96 mAgendaUtil, SIGNAL(instanceViewCreationCompleted(int)), |
|
97 this,SLOT(handleInstanceViewCreationCompleted(int))); |
64 |
98 |
65 // Delay loading of other views till main view is loaded. |
99 // Delay loading of other views till main view is loaded. |
66 connect( |
100 connect( |
67 window, SIGNAL(viewReady()), |
101 window, SIGNAL(viewReady()), |
68 this, SLOT(loadOtherViews())); |
102 this, SLOT(loadOtherViews())); |
88 switch (viewId) { |
122 switch (viewId) { |
89 case NotesNamespace::NotesMainViewId: |
123 case NotesNamespace::NotesMainViewId: |
90 window->removeView(window->currentView()); |
124 window->removeView(window->currentView()); |
91 window->addView(mMainView); |
125 window->addView(mMainView); |
92 window->setCurrentView(mMainView); |
126 window->setCurrentView(mMainView); |
|
127 mMainView->captureScreenShot(false); |
93 break; |
128 break; |
94 |
129 |
95 case NotesNamespace::NotesCollectionViewId: |
130 case NotesNamespace::NotesCollectionViewId: |
|
131 if (mMainView) |
|
132 { |
|
133 if (mMainView == window->currentView()) |
|
134 { |
|
135 mMainView->captureScreenShot(true); |
|
136 } |
|
137 } |
96 window->removeView(window->currentView()); |
138 window->removeView(window->currentView()); |
97 window->addView(mCollectionView); |
139 window->addView(mCollectionView); |
98 window->setCurrentView(mCollectionView); |
140 window->setCurrentView(mCollectionView); |
99 break; |
141 break; |
100 |
142 |
101 case NotesNamespace::NotesTodoViewId: |
143 case NotesNamespace::NotesTodoViewId: |
|
144 if (mMainView) |
|
145 { |
|
146 if (mMainView == window->currentView()) |
|
147 { |
|
148 mMainView->captureScreenShot(true); |
|
149 } |
|
150 } |
|
151 |
102 window->removeView(window->currentView()); |
152 window->removeView(window->currentView()); |
103 window->addView(mTodoView); |
153 window->addView(mTodoView); |
104 window->setCurrentView(mTodoView); |
154 window->setCurrentView(mTodoView); |
105 break; |
155 break; |
106 |
156 |
107 case NotesNamespace::NotesFavoritesViewId: |
157 case NotesNamespace::NotesFavoritesViewId: |
|
158 if (mMainView) |
|
159 { |
|
160 if (mMainView == window->currentView()) |
|
161 { |
|
162 mMainView->captureScreenShot(true); |
|
163 } |
|
164 } |
|
165 |
108 window->removeView(window->currentView()); |
166 window->removeView(window->currentView()); |
109 window->addView(mFavoriteView); |
167 window->addView(mFavoriteView); |
110 window->setCurrentView(mFavoriteView); |
168 window->setCurrentView(mFavoriteView); |
111 break; |
169 break; |
112 |
170 |
113 case NotesNamespace::NotesNoteViewId: |
171 case NotesNamespace::NotesNoteViewId: |
|
172 if (mMainView) |
|
173 { |
|
174 if (mMainView == window->currentView()) |
|
175 { |
|
176 mMainView->captureScreenShot(true); |
|
177 } |
|
178 } |
|
179 |
114 window->removeView(window->currentView()); |
180 window->removeView(window->currentView()); |
115 window->addView(mNoteView); |
181 window->addView(mNoteView); |
116 window->setCurrentView(mNoteView); |
182 window->setCurrentView(mNoteView); |
117 break; |
183 break; |
118 |
184 |
247 mNoteView, SIGNAL(deleteEntry(ulong)), |
313 mNoteView, SIGNAL(deleteEntry(ulong)), |
248 this, SLOT(deleteEntryFromView(ulong))); |
314 this, SLOT(deleteEntryFromView(ulong))); |
249 } |
315 } |
250 |
316 |
251 /*! |
317 /*! |
252 Delete the entry. |
|
253 */ |
|
254 void NotesViewManager::deleteEntryFromView(ulong entryId) |
|
255 { |
|
256 if (showDeleteConfirmationQuery(entryId)) { |
|
257 // Delete the given note. |
|
258 mAgendaUtil->deleteEntry(entryId); |
|
259 } |
|
260 } |
|
261 |
|
262 /*! |
|
263 Loads other views from the docml file. |
318 Loads other views from the docml file. |
264 */ |
319 */ |
265 void NotesViewManager::loadOtherViews() |
320 void NotesViewManager::loadOtherViews() |
266 { |
321 { |
|
322 mMainView->setupAfterViewReady(); |
|
323 |
267 // Load the collection view. |
324 // Load the collection view. |
268 loadNotesCollectionView(); |
325 loadNotesCollectionView(); |
269 // Load the to-do view. |
326 // Load the to-do view. |
270 loadTodoView(); |
327 loadTodoView(); |
271 // Load the favorites view. |
328 // Load the favorites view. |
278 disconnect( |
335 disconnect( |
279 window, SIGNAL(viewReady()), |
336 window, SIGNAL(viewReady()), |
280 this, SLOT(loadOtherViews())); |
337 this, SLOT(loadOtherViews())); |
281 } |
338 } |
282 |
339 |
283 /* ! |
340 /*! |
284 Show the delete confirmation query. |
341 Delete the entry. |
285 */ |
342 */ |
286 bool NotesViewManager::showDeleteConfirmationQuery(ulong noteId) |
343 void NotesViewManager::deleteEntryFromView(ulong entryId) |
287 { |
344 { |
288 bool retValue(false); |
345 mEntryId = entryId; |
289 |
346 HbMessageBox *confirmationQuery = new HbMessageBox( |
290 HbMessageBox confirmationQuery(HbMessageBox::MessageTypeQuestion); |
347 HbMessageBox::MessageTypeQuestion); |
291 confirmationQuery.setDismissPolicy(HbDialog::NoDismiss); |
348 confirmationQuery->setDismissPolicy(HbDialog::NoDismiss); |
292 confirmationQuery.setTimeout(HbDialog::NoTimeout); |
349 confirmationQuery->setTimeout(HbDialog::NoTimeout); |
293 confirmationQuery.setIconVisible(true); |
350 confirmationQuery->setIconVisible(true); |
294 |
351 |
295 QString displayText; |
352 QString displayText; |
296 QString x; |
353 QString x; |
297 AgendaEntry entry = mAgendaUtil->fetchById(noteId); |
354 AgendaEntry entry = mAgendaUtil->fetchById(entryId); |
298 if (AgendaEntry::TypeTodo == entry.type()) { |
355 if (AgendaEntry::TypeTodo == entry.type()) { |
299 displayText += hbTrId("txt_notes_info_delete_todo_note"); |
356 displayText += hbTrId("txt_notes_info_delete_todo_note"); |
300 } else { |
357 } else { |
301 displayText += hbTrId("txt_notes_info_delete_note"); |
358 displayText += hbTrId("txt_notes_info_delete_note"); |
302 } |
359 } |
303 |
360 |
304 confirmationQuery.setText(displayText); |
361 confirmationQuery->setText(displayText); |
305 |
362 |
306 confirmationQuery.setPrimaryAction(new HbAction( |
363 // Remove the default actions. |
307 hbTrId("txt_notes_button_dialog_delete"), &confirmationQuery)); |
364 QList<QAction *> defaultActions = confirmationQuery->actions(); |
308 confirmationQuery.setSecondaryAction(new HbAction( |
365 for (int index=0;index<defaultActions.count();index++) { |
309 hbTrId("txt_common_button_cancel"), &confirmationQuery)); |
366 confirmationQuery->removeAction(defaultActions[index]); |
310 HbAction *selected = confirmationQuery.exec(); |
|
311 if (selected == confirmationQuery.primaryAction()) { |
|
312 retValue = true; |
|
313 } |
367 } |
314 |
368 defaultActions.clear(); |
315 return retValue; |
369 |
|
370 // Add delete and cancel actions |
|
371 mDeleteAction = new HbAction(hbTrId("txt_notes_button_dialog_delete")); |
|
372 mCancelAction = new HbAction(hbTrId("txt_common_button_cancel")); |
|
373 |
|
374 confirmationQuery->addAction(mDeleteAction); |
|
375 confirmationQuery->addAction(mCancelAction); |
|
376 |
|
377 confirmationQuery->open(this, SLOT(selectedAction(HbAction*))); |
|
378 } |
|
379 |
|
380 /*! |
|
381 Slot to handle the delete action |
|
382 */ |
|
383 void NotesViewManager::selectedAction(HbAction *action) |
|
384 { |
|
385 if (action == mDeleteAction) { |
|
386 // Delete the given note. |
|
387 mAgendaUtil->deleteEntry(mEntryId); |
|
388 } |
|
389 } |
|
390 |
|
391 /*! |
|
392 Slot to handle instance view creation complete. |
|
393 */ |
|
394 void NotesViewManager::handleInstanceViewCreationCompleted(int status) |
|
395 { |
|
396 Q_UNUSED(status) |
|
397 |
|
398 // Update the title for main view. |
|
399 mMainView->updateTitle(); |
|
400 |
|
401 // Populate collections view. |
|
402 mCollectionView->populateListView(); |
|
403 |
|
404 // Update the title for to-do view. |
|
405 mTodoView->updateTitle(); |
|
406 |
|
407 // Update the plain notes view. |
|
408 mNoteView->updateNoteView(); |
|
409 |
|
410 // Update the favorites view. |
|
411 mFavoriteView->updateFavoriteView(); |
316 } |
412 } |
317 // End of file --Don't remove this. |
413 // End of file --Don't remove this. |