45 NmUiEngine &uiEngine, |
45 NmUiEngine &uiEngine, |
46 HbMainWindow *mainWindow, |
46 HbMainWindow *mainWindow, |
47 NmAttachmentManager &attaManager, |
47 NmAttachmentManager &attaManager, |
48 bool toolbarEnabled, |
48 bool toolbarEnabled, |
49 QGraphicsItem *parent) |
49 QGraphicsItem *parent) |
50 :NmBaseView(startParam, parent), |
50 :NmBaseView(startParam, application, parent), |
51 mApplication(application), |
51 mApplication(application), |
52 mUiEngine(uiEngine), |
52 mUiEngine(uiEngine), |
53 mMainWindow(mainWindow), |
53 mMainWindow(mainWindow), |
54 mAttaManager(attaManager), |
54 mAttaManager(attaManager), |
55 mToolbarEnabled(toolbarEnabled), |
55 mToolbarEnabled(toolbarEnabled), |
69 webFrameloadingCompleted(false), |
69 webFrameloadingCompleted(false), |
70 mLatestLoadingSize(QSize(0,0)), |
70 mLatestLoadingSize(QSize(0,0)), |
71 mAttaIndexUnderFetch(NmNotFoundError), |
71 mAttaIndexUnderFetch(NmNotFoundError), |
72 mAttaWidget(NULL), |
72 mAttaWidget(NULL), |
73 mViewReady(false), |
73 mViewReady(false), |
74 mWaitNoteCancelled(false), |
74 mWaitNoteCancelled(false) |
75 mOkAction(NULL), |
|
76 mCancelAction(NULL) |
|
77 { |
75 { |
78 // Create documentloader |
76 // Create documentloader |
79 mDocumentLoader = new NmUiDocumentLoader(mMainWindow); |
77 mDocumentLoader = new NmUiDocumentLoader(mMainWindow); |
80 // Get screensize |
78 // Get screensize |
81 mScreenSize = mApplication.screenSize(); |
79 mScreenSize = mApplication.screenSize(); |
105 delete mWaitDialog; |
103 delete mWaitDialog; |
106 mWaitDialog = NULL; |
104 mWaitDialog = NULL; |
107 // remove view from osbserving atta manager events |
105 // remove view from osbserving atta manager events |
108 mAttaManager.clearObserver(); |
106 mAttaManager.clearObserver(); |
109 mAttaManager.cancelFetch(); |
107 mAttaManager.cancelFetch(); |
110 delete mOkAction; |
|
111 mOkAction = NULL; |
|
112 delete mCancelAction; |
|
113 mCancelAction = NULL; |
|
114 } |
108 } |
115 |
109 |
116 /*! |
110 /*! |
117 View is about to exit |
111 View is about to exit |
118 */ |
112 */ |
365 if (!mWaitNoteCancelled) { |
358 if (!mWaitNoteCancelled) { |
366 if (mMessageFetchingOperation && mMessageFetchingOperation->isRunning()) { |
359 if (mMessageFetchingOperation && mMessageFetchingOperation->isRunning()) { |
367 mMessageFetchingOperation->cancelOperation(); |
360 mMessageFetchingOperation->cancelOperation(); |
368 } |
361 } |
369 mWaitNoteCancelled = true; |
362 mWaitNoteCancelled = true; |
370 QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection); |
363 QMetaObject::invokeMethod(&mApplication, "prepareForPopView", Qt::QueuedConnection); |
371 } |
364 } |
372 } |
365 } |
373 |
366 |
374 |
367 |
375 /*! |
368 /*! |
1022 } |
1015 } |
1023 break; |
1016 break; |
1024 case NmActionResponseCommandDeleteMail: { |
1017 case NmActionResponseCommandDeleteMail: { |
1025 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
1018 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
1026 messageBox->setText(hbTrId("txt_mail_dialog_delete_mail")); |
1019 messageBox->setText(hbTrId("txt_mail_dialog_delete_mail")); |
1027 messageBox->setTimeout(HbMessageBox::NoTimeout); |
1020 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
1028 |
|
1029 mOkAction = new HbAction(tr("Ok"),messageBox); |
|
1030 mCancelAction = new HbAction(tr("Cancel"),messageBox); |
|
1031 messageBox->addAction(mOkAction); |
|
1032 messageBox->addAction(mCancelAction); |
|
1033 |
|
1034 // Read user selection |
|
1035 messageBox->open(this, SLOT(deleteButton(HbAction*))); |
1021 messageBox->open(this, SLOT(deleteButton(HbAction*))); |
1036 } |
1022 } |
1037 break; |
1023 break; |
1038 default: |
1024 default: |
1039 break; |
1025 break; |
1040 } |
1026 } |
1041 } |
1027 } |
1055 /*! |
1041 /*! |
1056 Slot. Signaled when delete button is pressed |
1042 Slot. Signaled when delete button is pressed |
1057 */ |
1043 */ |
1058 void NmViewerView::deleteButton(HbAction* result) |
1044 void NmViewerView::deleteButton(HbAction* result) |
1059 { |
1045 { |
1060 if (result == mOkAction ) { |
1046 HbMessageBox *dlg = static_cast<HbMessageBox*>(sender()); |
|
1047 if(result == dlg->actions().at(0)) |
|
1048 { |
1061 QList<NmId> messageList; |
1049 QList<NmId> messageList; |
1062 messageList.append(mStartParam->messageId()); |
1050 messageList.append(mStartParam->messageId()); |
1063 |
1051 |
1064 int err = mUiEngine.deleteMessages(mStartParam->mailboxId(), |
1052 int err = mUiEngine.deleteMessages(mStartParam->mailboxId(), |
1065 mStartParam->folderId(), |
1053 mStartParam->folderId(), |
1066 messageList); |
1054 messageList); |
1067 |
1055 |
1068 messageList.clear(); |
1056 messageList.clear(); |
1069 if (NmNoError != err) { |
1057 if (NmNoError != err) { |
1070 // Failed to delete the messages! |
1058 // Failed to delete the messages! |
1071 NMLOG(QString("NmViewerView::handleActionCommand(): failed err=%1").arg(err)); |
1059 NMLOG(QString("NmViewerView::handleActionCommand(): failed err=%1").arg(err)); |
1072 } |
1060 } |
1073 } |
1061 } |
1074 |
1062 } |
1075 mCancelAction = NULL; |
1063 |
1076 mOkAction = NULL; |
1064 |
1077 } |
1065 /*! |
1078 |
1066 This is called when attachment fetch progress changes |
1079 |
|
1080 /*! |
|
1081 Slot. Signaled when attachment fetch progress changes |
|
1082 */ |
1067 */ |
1083 void NmViewerView::progressChanged(int value) |
1068 void NmViewerView::progressChanged(int value) |
1084 { |
1069 { |
1085 if (mAttaIndexUnderFetch != NmNotFoundError) { |
1070 if (mAttaIndexUnderFetch != NmNotFoundError) { |
1086 // emit signal |
1071 // emit signal |
1089 } |
1074 } |
1090 } |
1075 } |
1091 } |
1076 } |
1092 |
1077 |
1093 /*! |
1078 /*! |
1094 Slot. Signaled when attachment fetch is completed |
1079 This is called when attachment fetch is completed |
1095 */ |
1080 */ |
1096 void NmViewerView::fetchCompleted(int result) |
1081 void NmViewerView::fetchCompleted(int result) |
1097 { |
1082 { |
1098 if (mAttaWidget && mAttaIndexUnderFetch != NmNotFoundError) { |
1083 if (mAttaWidget && mAttaIndexUnderFetch != NmNotFoundError) { |
1099 if (result == NmNoError) { |
1084 if (result == NmNoError) { |
1100 progressValueChanged(mAttaIndexUnderFetch, 100); |
1085 progressValueChanged(mAttaIndexUnderFetch, 100); |
|
1086 openAttachment(mAttaIndexUnderFetch); |
1101 } |
1087 } |
1102 else { |
1088 else { |
1103 mAttaWidget->hideProgressBar(mAttaIndexUnderFetch); |
1089 mAttaWidget->hideProgressBar(mAttaIndexUnderFetch); |
1104 } |
1090 } |
1105 } |
1091 } |
1114 NMLOG("NmViewerView::messageDeleted"); |
1100 NMLOG("NmViewerView::messageDeleted"); |
1115 if ((mStartParam->viewId() == NmUiViewMessageViewer) |
1101 if ((mStartParam->viewId() == NmUiViewMessageViewer) |
1116 && (mStartParam->mailboxId()== mailboxId) |
1102 && (mStartParam->mailboxId()== mailboxId) |
1117 && (mStartParam->folderId()== folderId) |
1103 && (mStartParam->folderId()== folderId) |
1118 && (mStartParam->messageId()== messageId)){ |
1104 && (mStartParam->messageId()== messageId)){ |
1119 mApplication.popView(); |
1105 mApplication.prepareForPopView(); |
1120 } |
1106 } |
1121 } |
1107 } |
1122 |
1108 |