148 mExtensionManager = new NmUiExtensionManager(); |
143 mExtensionManager = new NmUiExtensionManager(); |
149 |
144 |
150 // Create view stack |
145 // Create view stack |
151 mViewStack = new QStack<NmBaseView*>; |
146 mViewStack = new QStack<NmBaseView*>; |
152 |
147 |
153 // Create back action and connect it to popView() |
148 // Create back action and connect it to prepareForPopView() |
154 if (mMainWindow) { |
149 if (mMainWindow) { |
155 mBackAction = new HbAction(Hb::BackNaviAction,this); |
150 mBackAction = new HbAction(Hb::BackNaviAction,this); |
156 connect(mBackAction, SIGNAL(triggered()), this, SLOT(popView())); |
151 connect(mBackAction, SIGNAL(triggered()), this, SLOT(prepareForPopView())); |
|
152 |
157 // Show mainwindow |
153 // Show mainwindow |
158 mMainWindow->show(); |
154 // Services will active it when the view is ready |
|
155 if (!service) { |
|
156 mMainWindow->show(); |
|
157 } |
159 } |
158 } |
160 |
159 |
161 // async operation completion related notifications |
160 // async operation completion related notifications |
162 connect( |
161 connect( |
163 mUiEngine, SIGNAL(operationCompleted(const NmOperationCompletionEvent &)), |
162 mUiEngine, SIGNAL(operationCompleted(const NmOperationCompletionEvent &)), |
262 NMLOG("nmailui: pushView done"); |
261 NMLOG("nmailui: pushView done"); |
263 } |
262 } |
264 } |
263 } |
265 |
264 |
266 /*! |
265 /*! |
|
266 Ask from view that is it ok to pop view. This kind of 2-phase popView is needed |
|
267 because view may show query dialog for user response. |
|
268 */ |
|
269 void NmApplication::prepareForPopView() |
|
270 { |
|
271 if (mViewStack->size() > 0) { |
|
272 // Get view pointer |
|
273 NmBaseView *view = mViewStack->top(); |
|
274 |
|
275 // View will call/signal popView if exitting is ok. |
|
276 view->okToExitView(); |
|
277 } |
|
278 // If the view stack is now empty quit the app |
|
279 // This happens also when the app has been started as a service |
|
280 else if (mViewStack->size() == 0) { |
|
281 exitApplication(); |
|
282 } |
|
283 } |
|
284 |
|
285 /*! |
267 Pop view from view stack. View object is deleted. |
286 Pop view from view stack. View object is deleted. |
268 */ |
287 */ |
269 void NmApplication::popView() |
288 void NmApplication::popView() |
270 { |
289 { |
271 NMLOG("nmailui: popView enter"); |
290 NMLOG("nmailui: popView enter"); |
272 if (mViewStack->size() > 0) { |
291 if (mViewStack->size() > 0) { |
273 // Get view pointer |
292 // Get view pointer |
274 NmBaseView *view = mViewStack->top(); |
293 NmBaseView *view = mViewStack->top(); |
275 |
294 |
276 // ask view if it's ok to exit |
295 // ask view if it's ok to exit |
277 if (view->okToExitView()) { |
296 NmUiViewId topViewId = view->nmailViewId(); |
278 NmUiViewId topViewId = view->nmailViewId(); |
297 |
279 |
298 // Prepare for send animation if returing from editor and message has been sent. |
280 // Prepare for send animation if returing from editor and message has been sent. |
299 if (topViewId == NmUiViewMessageEditor && mUiEngine->isSendingMessage()) { |
281 if (topViewId == NmUiViewMessageEditor && mUiEngine->isSendingMessage()) { |
300 mEffects->prepareEffect(NmUiEffects::NmEditorSendMessageAnimation); |
282 mEffects->prepareEffect(NmUiEffects::NmEditorSendMessageAnimation); |
301 } |
|
302 mViewStack->pop(); |
|
303 // Call custom exit function |
|
304 view->aboutToExitView(); |
|
305 // Remove view from stack. |
|
306 mMainWindow->removeView(view); |
|
307 |
|
308 // if we were in editor and sent a message, pop viewer from stack first |
|
309 // so we can go straight to mail list |
|
310 if (!mViewStack->isEmpty() && topViewId == NmUiViewMessageEditor && |
|
311 mUiEngine->isSendingMessage() && |
|
312 mViewStack->top()->nmailViewId() == NmUiViewMessageViewer) { |
|
313 NmBaseView *tmpView = mViewStack->pop(); |
|
314 mMainWindow->removeView(tmpView); |
|
315 delete tmpView; |
|
316 tmpView = NULL; |
|
317 } |
|
318 |
|
319 if (!mViewStack->isEmpty()) { |
|
320 // Activate next view in stack |
|
321 NmBaseView *showView = mViewStack->top(); |
|
322 mMainWindow->addView(showView); |
|
323 mMainWindow->setCurrentView(showView); |
|
324 // Store activated view id |
|
325 mActiveViewId=showView->nmailViewId(); |
|
326 // Perform send animation if requested. |
|
327 mEffects->startEffect(NmUiEffects::NmEditorSendMessageAnimation); |
|
328 } |
|
329 |
|
330 delete view; |
|
331 view = NULL; |
|
332 |
|
333 #ifndef NM_WINS_ENV |
|
334 // If view was started as service, move the app now |
|
335 // to the background, unless it was started when the app |
|
336 // was already in foreground.. |
|
337 if (mServiceViewId == topViewId) { |
|
338 mServiceViewId = NmUiViewNone; |
|
339 |
|
340 // if started as embedded, do not hide the app |
|
341 if (!XQServiceUtil::isEmbedded() && |
|
342 !mForegroundService) { |
|
343 XQServiceUtil::toBackground(true); |
283 } |
344 } |
284 mViewStack->pop(); |
345 } |
285 // Call custom exit function |
|
286 view->aboutToExitView(); |
|
287 // Remove view from stack. |
|
288 mMainWindow->removeView(view); |
|
289 |
|
290 // if we were in editor and sent a message, pop viewer from stack first |
|
291 // so we can go straight to mail list |
|
292 if (!mViewStack->isEmpty() && topViewId == NmUiViewMessageEditor && |
|
293 mUiEngine->isSendingMessage() && |
|
294 mViewStack->top()->nmailViewId() == NmUiViewMessageViewer) { |
|
295 NmBaseView *tmpView = mViewStack->pop(); |
|
296 mMainWindow->removeView(tmpView); |
|
297 delete tmpView; |
|
298 tmpView = NULL; |
|
299 } |
|
300 |
|
301 if (!mViewStack->isEmpty()) { |
|
302 // Activate next view in stack |
|
303 NmBaseView *showView = mViewStack->top(); |
|
304 mMainWindow->addView(showView); |
|
305 mMainWindow->setCurrentView(showView); |
|
306 // Store activated view id |
|
307 mActiveViewId=showView->nmailViewId(); |
|
308 // Perform send animation if requested. |
|
309 mEffects->startEffect(NmUiEffects::NmEditorSendMessageAnimation); |
|
310 } |
|
311 |
|
312 delete view; |
|
313 view = NULL; |
|
314 |
|
315 #ifndef NM_WINS_ENV |
|
316 // If view was started as service, move the app now |
|
317 // to the background, unless it was started when the app |
|
318 // was already in foreground.. |
|
319 if (mServiceViewId == topViewId) { |
|
320 mServiceViewId = NmUiViewNone; |
|
321 |
|
322 // if started as embedded, do not hide the app |
|
323 if (!XQServiceUtil::isEmbedded() && |
|
324 !mForegroundService) { |
|
325 XQServiceUtil::toBackground(true); |
|
326 } |
|
327 } |
|
328 #endif |
346 #endif |
329 } |
|
330 } |
347 } |
331 |
348 |
332 // If the view stack is now empty quit the app |
349 // If the view stack is now empty quit the app |
333 // This happens also when the app has been started as a service |
350 // This happens also when the app has been started as a service |
334 if (mViewStack->size()==0) { |
351 if (mViewStack->size()==0) { |
427 if (startParam->service() && !mViewStack->isEmpty() && |
444 if (startParam->service() && !mViewStack->isEmpty() && |
428 mViewStack->top()->nmailViewId() == NmUiViewMessageEditor) { |
445 mViewStack->top()->nmailViewId() == NmUiViewMessageEditor) { |
429 break; |
446 break; |
430 } |
447 } |
431 |
448 |
432 NmMessageListModel &messageListModel = |
449 NmMessageListModel &model = |
433 mUiEngine->messageListModel(startParam->mailboxId(), |
450 mUiEngine->messageListModelForSearch(startParam->mailboxId()); |
434 startParam->folderId()); |
|
435 |
|
436 NmMessageSearchListModel &searchListModel = |
|
437 mUiEngine->messageSearchListModel(&messageListModel); |
|
438 |
451 |
439 NmMessageSearchListView *searchListView = new NmMessageSearchListView( |
452 NmMessageSearchListView *searchListView = new NmMessageSearchListView( |
440 *this, startParam, *mUiEngine, searchListModel, |
453 *this, startParam, *mUiEngine, model, |
441 new HbDocumentLoader(mMainWindow)); |
454 new HbDocumentLoader(mMainWindow)); |
442 |
455 |
443 pushView(searchListView); |
456 pushView(searchListView); |
444 } |
457 } |
445 break; |
458 break; |