1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "nmuiheaders.h" |
18 #include "nmuiheaders.h" |
19 |
19 |
20 static const char *NMUI_MESSAGE_VIEWER_XML = ":/docml/nmmailviewer.docml"; |
20 static const char *NMUI_MESSAGE_VIEWER_XML = ":/docml/nmmailviewer.docml"; |
21 static const char *NMUI_MESSAGE_VIEWER_VIEW = "nmailViewerView"; |
21 static const char *NMUI_MESSAGE_VIEWER_VIEW = "nmailViewerView"; |
56 mMessage(NULL), |
56 mMessage(NULL), |
57 mScrollArea(NULL), |
57 mScrollArea(NULL), |
58 mViewerContent(NULL), |
58 mViewerContent(NULL), |
59 mWebView(NULL), |
59 mWebView(NULL), |
60 mHeaderWidget(NULL), |
60 mHeaderWidget(NULL), |
61 mViewerContentLayout(NULL), |
|
62 mMessageFetchingOperation(NULL), |
61 mMessageFetchingOperation(NULL), |
63 mDisplayingPlainText(false), |
62 mDisplayingPlainText(false), |
64 mDocumentLoader(NULL), |
63 mDocumentLoader(NULL), |
65 mScrollAreaContents(NULL), |
64 mScrollAreaContents(NULL), |
66 mViewerHeaderContainer(NULL), |
65 mViewerHeaderContainer(NULL), |
69 webFrameloadingCompleted(false), |
68 webFrameloadingCompleted(false), |
70 mLatestLoadingSize(QSize(0,0)), |
69 mLatestLoadingSize(QSize(0,0)), |
71 mAttaIndexUnderFetch(NmNotFoundError), |
70 mAttaIndexUnderFetch(NmNotFoundError), |
72 mAttaWidget(NULL), |
71 mAttaWidget(NULL), |
73 mViewReady(false), |
72 mViewReady(false), |
74 mWaitNoteCancelled(false) |
73 mWaitNoteCancelled(false), |
|
74 mErrorNote(NULL) |
75 { |
75 { |
76 NM_FUNCTION; |
|
77 |
|
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(); |
82 // Connect external delete handling to uiengine signal |
80 // Connect external delete handling to uiengine signal |
151 // Create content and content layout |
147 // Create content and content layout |
152 // qobject_cast not work in this case, using reinterpret_cast |
148 // qobject_cast not work in this case, using reinterpret_cast |
153 mViewerContent = reinterpret_cast<HbWidget *>( |
149 mViewerContent = reinterpret_cast<HbWidget *>( |
154 mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_CONTENT)); |
150 mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_CONTENT)); |
155 // Find scroll area |
151 // Find scroll area |
156 mScrollArea = reinterpret_cast<NmBaseViewScrollArea *>( |
152 mScrollArea = reinterpret_cast<HbScrollArea *>( |
157 mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_SCROLL_AREA)); |
153 mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_SCROLL_AREA)); |
158 if (mScrollArea) { |
154 if (mScrollArea) { |
159 mScrollArea->setParentItem(this); |
155 mScrollArea->setParentItem(this); |
160 mScrollArea->setScrollDirections(Qt::Vertical | Qt::Horizontal); |
156 mScrollArea->setScrollDirections(Qt::Vertical | Qt::Horizontal); |
161 connect(mScrollArea, SIGNAL(scrollPositionChanged(QPointF)), |
157 connect(mScrollArea, SIGNAL(scrollPositionChanged(QPointF)), |
162 this, SLOT(contentScrollPositionChanged(QPointF))); |
158 this, SLOT(contentScrollPositionChanged(QPointF))); |
163 connect(mScrollArea, SIGNAL(handleMousePressEvent(QGraphicsSceneMouseEvent*)), |
|
164 this, SLOT(handleMousePressEvent(QGraphicsSceneMouseEvent*))); |
|
165 connect(mScrollArea, SIGNAL(handleMouseReleaseEvent(QGraphicsSceneMouseEvent*)), |
|
166 this, SLOT(handleMouseReleaseEvent(QGraphicsSceneMouseEvent*))); |
|
167 |
159 |
168 // Get scroll area contents and set layout margins |
160 // Get scroll area contents and set layout margins |
169 mScrollAreaContents = qobject_cast<HbWidget *>( |
161 mScrollAreaContents = qobject_cast<HbWidget *>( |
170 mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_SCROLL_AREA_CONTENTS)); |
162 mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_SCROLL_AREA_CONTENTS)); |
171 if (mScrollAreaContents) { |
163 if (mScrollAreaContents) { |
198 // Set auto load images and private browsing(no history) attributes |
190 // Set auto load images and private browsing(no history) attributes |
199 QWebSettings *settings = mWebView->settings(); |
191 QWebSettings *settings = mWebView->settings(); |
200 if (settings) { |
192 if (settings) { |
201 settings->setAttribute(QWebSettings::AutoLoadImages, true); |
193 settings->setAttribute(QWebSettings::AutoLoadImages, true); |
202 settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); |
194 settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); |
203 } |
195 } |
204 HbEditorInterface editorInterface(mWebView); |
|
205 editorInterface.setInputConstraints(HbEditorConstraintIgnoreFocus); |
|
206 mWebView->setAcceptedMouseButtons(Qt::NoButton); |
|
207 QWebPage *page = mWebView->page(); |
196 QWebPage *page = mWebView->page(); |
208 if (page) { |
197 if (page) { |
209 QWebFrame *frame = page->mainFrame(); |
198 QWebFrame *frame = page->mainFrame(); |
210 if (frame) { |
199 if (frame) { |
211 frame->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff); |
200 frame->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff); |
384 if (page){ |
369 if (page){ |
385 // Set custom network access manager for embedded image handling |
370 // Set custom network access manager for embedded image handling |
386 NmViewerViewNetManager &netMngr = mApplication.networkAccessManager(); |
371 NmViewerViewNetManager &netMngr = mApplication.networkAccessManager(); |
387 netMngr.setView(this); |
372 netMngr.setView(this); |
388 page->setNetworkAccessManager(&netMngr); |
373 page->setNetworkAccessManager(&netMngr); |
|
374 QWebSettings *webSettings = page->settings(); |
|
375 if (webSettings) { |
|
376 webSettings->setObjectCacheCapacities(0,0,0); |
|
377 } |
389 |
378 |
390 connect(page, SIGNAL(loadFinished(bool)), |
379 connect(page, SIGNAL(loadFinished(bool)), |
391 this, SLOT(webFrameLoaded(bool))); |
380 this, SLOT(webFrameLoaded(bool))); |
392 page->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); |
381 page->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); |
393 page->setContentEditable(false); |
382 page->setContentEditable(false); |
590 Typically when view is already open and external view activation occurs |
584 Typically when view is already open and external view activation occurs |
591 for this same view |
585 for this same view |
592 */ |
586 */ |
593 void NmViewerView::reloadViewContents(NmUiStartParam* startParam) |
587 void NmViewerView::reloadViewContents(NmUiStartParam* startParam) |
594 { |
588 { |
595 NM_FUNCTION; |
|
596 |
|
597 // Check start parameter validity, message view cannot |
589 // Check start parameter validity, message view cannot |
598 // be updated if given parameter is zero. |
590 // be updated if given parameter is zero. |
599 if (startParam && startParam->viewId() == NmUiViewMessageViewer && |
591 if (startParam && startParam->viewId() == NmUiViewMessageViewer && |
600 startParam->messageId()!= 0) { |
592 startParam->messageId()!= 0) { |
601 // Delete existing start parameter data |
593 // Delete existing start parameter data |
616 /*! |
608 /*! |
617 nmailViewId |
609 nmailViewId |
618 */ |
610 */ |
619 NmUiViewId NmViewerView::nmailViewId() const |
611 NmUiViewId NmViewerView::nmailViewId() const |
620 { |
612 { |
621 NM_FUNCTION; |
|
622 |
|
623 return NmUiViewMessageViewer; |
613 return NmUiViewMessageViewer; |
624 } |
614 } |
625 |
615 |
626 /*! |
616 /*! |
627 Scale web view width |
617 Scale web view width |
628 */ |
618 */ |
629 void NmViewerView::webFrameLoaded(bool loaded) |
619 void NmViewerView::webFrameLoaded(bool loaded) |
630 { |
620 { |
631 NM_FUNCTION; |
|
632 |
|
633 if (loaded){ |
621 if (loaded){ |
634 webFrameloadingCompleted = true; |
622 webFrameloadingCompleted = true; |
635 // Scale web view after loading the |
623 // Scale web view after loading the |
636 // complete contents, including images |
624 // complete contents, including images |
637 QMetaObject::invokeMethod(this, "scaleWebViewWhenLoaded", Qt::QueuedConnection); |
625 QMetaObject::invokeMethod(this, "scaleWebViewWhenLoaded", Qt::QueuedConnection); |
641 /*! |
629 /*! |
642 Scale web view width when loading is ongoing |
630 Scale web view width when loading is ongoing |
643 */ |
631 */ |
644 void NmViewerView::scaleWebViewWhenLoading(const QSize &size) |
632 void NmViewerView::scaleWebViewWhenLoading(const QSize &size) |
645 { |
633 { |
646 NM_FUNCTION; |
|
647 |
|
648 // Try to scale web view while mainframe is being loaded. |
634 // Try to scale web view while mainframe is being loaded. |
649 // So that screen is scrollable even before images are fully loaded |
635 // So that screen is scrollable even before images are fully loaded |
650 // First check that new size is different than previous, no need to react if |
636 // First check that new size is different than previous, no need to react if |
651 // same size value is received more than once. |
637 // same size value is received more than once. |
652 if (size != mLatestLoadingSize) { |
638 if (size != mLatestLoadingSize) { |
671 /*! |
657 /*! |
672 Scale web view width when loading is completed |
658 Scale web view width when loading is completed |
673 */ |
659 */ |
674 void NmViewerView::scaleWebViewWhenLoaded() |
660 void NmViewerView::scaleWebViewWhenLoaded() |
675 { |
661 { |
676 NM_FUNCTION; |
|
677 |
|
678 if (mWebView&&mWebView->page()) { |
662 if (mWebView&&mWebView->page()) { |
679 QSizeF contentSize = mWebView->page()->mainFrame()->contentsSize(); |
663 QSizeF contentSize = mWebView->page()->mainFrame()->contentsSize(); |
680 int width = (int)contentSize.width(); |
664 int width = (int)contentSize.width(); |
681 int height = (int)contentSize.height(); |
665 int height = (int)contentSize.height(); |
682 // Set content (webview) width |
666 // Set content (webview) width |
792 mApplication.enterNmUiView(param); |
772 mApplication.enterNmUiView(param); |
793 } |
773 } |
794 } |
774 } |
795 |
775 |
796 /*! |
776 /*! |
797 Send mouse release event to web view |
|
798 */ |
|
799 void NmViewerView::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
800 { |
|
801 NM_FUNCTION; |
|
802 handleMouseEvent(event, false); |
|
803 |
|
804 } |
|
805 |
|
806 /*! |
|
807 Send mouse press event |
|
808 */ |
|
809 void NmViewerView::handleMousePressEvent(QGraphicsSceneMouseEvent *event) |
|
810 { |
|
811 NM_FUNCTION; |
|
812 handleMouseEvent(event, true); |
|
813 } |
|
814 |
|
815 /*! |
|
816 Function can be used to check whether mouse event has |
777 Function can be used to check whether mouse event has |
817 occured on top of header area. |
778 occured on top of header area. |
818 */ |
779 */ |
819 bool NmViewerView::eventOnTopOfHeaderArea(QGraphicsSceneMouseEvent *event) |
780 bool NmViewerView::eventOnTopOfHeaderArea(QGraphicsSceneMouseEvent *event) |
820 { |
781 { |
821 NM_FUNCTION; |
|
822 |
|
823 bool ret(false); |
782 bool ret(false); |
824 if (event && mHeaderWidget) { |
783 if (event && mHeaderWidget) { |
825 QPointF lastReleasePoint = event->lastPos(); |
784 QPointF lastReleasePoint = event->lastPos(); |
826 QPointF contentWidgetPos = mScrollAreaContents->pos(); |
785 QPointF contentWidgetPos = mScrollAreaContents->pos(); |
827 int headerHeight = (int)mHeaderWidget->geometry().height(); |
786 int headerHeight = (int)mHeaderWidget->geometry().height(); |
904 Function reacts to scroll position change events and sets |
859 Function reacts to scroll position change events and sets |
905 header to correct position |
860 header to correct position |
906 */ |
861 */ |
907 void NmViewerView::contentScrollPositionChanged(const QPointF &newPosition) |
862 void NmViewerView::contentScrollPositionChanged(const QPointF &newPosition) |
908 { |
863 { |
909 NM_FUNCTION; |
|
910 |
|
911 if (mWebView&&mHeaderWidget){ |
864 if (mWebView&&mHeaderWidget){ |
912 QRectF webViewRect = mWebView->geometry(); |
865 QRectF webViewRect = mWebView->geometry(); |
913 QTransform tr; |
866 QTransform tr; |
914 qreal leftMovementThreshold(webViewRect.width()-mHeaderWidget->geometry().width()); |
867 qreal leftMovementThreshold(webViewRect.width()-mHeaderWidget->geometry().width()); |
915 if (newPosition.x()<0) { |
868 if (newPosition.x()<0) { |
933 createToolBar. Function asks menu commands from extension |
886 createToolBar. Function asks menu commands from extension |
934 to be added to toolbar owned by the HbView. |
887 to be added to toolbar owned by the HbView. |
935 */ |
888 */ |
936 void NmViewerView::createToolBar() |
889 void NmViewerView::createToolBar() |
937 { |
890 { |
938 NM_FUNCTION; |
|
939 |
|
940 HbToolBar *tb = toolBar(); |
891 HbToolBar *tb = toolBar(); |
941 NmUiExtensionManager &extMngr = mApplication.extManager(); |
892 NmUiExtensionManager &extMngr = mApplication.extManager(); |
942 if (tb && &extMngr && mStartParam) { |
893 if (tb && &extMngr && mStartParam) { |
943 tb->clearActions(); |
894 tb->clearActions(); |
944 NmActionRequest request(this, NmActionToolbar, NmActionContextViewViewer, |
895 NmActionRequest request(this, NmActionToolbar, NmActionContextViewViewer, |
955 createOptionsMenu. Functions asks menu commands from extension |
906 createOptionsMenu. Functions asks menu commands from extension |
956 to be added to options menu. |
907 to be added to options menu. |
957 */ |
908 */ |
958 void NmViewerView::createOptionsMenu() |
909 void NmViewerView::createOptionsMenu() |
959 { |
910 { |
960 NM_FUNCTION; |
|
961 |
|
962 HbMenu *optionsMenu = menu(); |
911 HbMenu *optionsMenu = menu(); |
963 NmUiExtensionManager &extMngr = mApplication.extManager(); |
912 NmUiExtensionManager &extMngr = mApplication.extManager(); |
964 if (optionsMenu && &extMngr && mStartParam) { |
913 if (optionsMenu && &extMngr && mStartParam) { |
965 optionsMenu->clearActions(); |
914 optionsMenu->clearActions(); |
966 NmActionRequest request(this, NmActionOptionsMenu, NmActionContextViewViewer, |
915 NmActionRequest request(this, NmActionOptionsMenu, NmActionContextViewViewer, |
978 handleActionCommand. From NmActionObserver, extension manager calls this |
927 handleActionCommand. From NmActionObserver, extension manager calls this |
979 call to handle menu command in the UI. |
928 call to handle menu command in the UI. |
980 */ |
929 */ |
981 void NmViewerView::handleActionCommand(NmActionResponse &actionResponse) |
930 void NmViewerView::handleActionCommand(NmActionResponse &actionResponse) |
982 { |
931 { |
983 NM_FUNCTION; |
|
984 |
|
985 bool showSendInProgressNote = false; |
|
986 |
|
987 // Handle options menu or toolbar |
932 // Handle options menu or toolbar |
988 if (actionResponse.menuType() == NmActionOptionsMenu || |
933 if (actionResponse.menuType() == NmActionOptionsMenu || |
989 actionResponse.menuType() == NmActionToolbar) { |
934 actionResponse.menuType() == NmActionToolbar) { |
990 switch (actionResponse.responseCommand()) { |
935 switch (actionResponse.responseCommand()) { |
991 case NmActionResponseCommandReply: { |
936 case NmActionResponseCommandReply: { |
992 if (mUiEngine.isSendingMessage()) { |
|
993 showSendInProgressNote = true; |
|
994 break; |
|
995 } |
|
996 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor, |
937 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor, |
997 mStartParam->mailboxId(), mStartParam->folderId(), |
938 mStartParam->mailboxId(), mStartParam->folderId(), |
998 mStartParam->messageId(), NmUiEditorReply); |
939 mStartParam->messageId(), NmUiEditorReply); |
999 mApplication.enterNmUiView(startParam); |
940 mApplication.enterNmUiView(startParam); |
1000 } |
941 } |
1001 break; |
942 break; |
1002 case NmActionResponseCommandReplyAll: { |
943 case NmActionResponseCommandReplyAll: { |
1003 if (mUiEngine.isSendingMessage()) { |
|
1004 showSendInProgressNote = true; |
|
1005 break; |
|
1006 } |
|
1007 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor, |
944 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor, |
1008 mStartParam->mailboxId(), mStartParam->folderId(), |
945 mStartParam->mailboxId(), mStartParam->folderId(), |
1009 mStartParam->messageId(), NmUiEditorReplyAll); |
946 mStartParam->messageId(), NmUiEditorReplyAll); |
1010 mApplication.enterNmUiView(startParam); |
947 mApplication.enterNmUiView(startParam); |
1011 } |
948 } |
1012 break; |
949 break; |
1013 case NmActionResponseCommandForward: { |
950 case NmActionResponseCommandForward: { |
1014 if (mUiEngine.isSendingMessage()) { |
|
1015 showSendInProgressNote = true; |
|
1016 break; |
|
1017 } |
|
1018 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor, |
951 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor, |
1019 mStartParam->mailboxId(), mStartParam->folderId(), |
952 mStartParam->mailboxId(), mStartParam->folderId(), |
1020 mStartParam->messageId(), NmUiEditorForward); |
953 mStartParam->messageId(), NmUiEditorForward); |
1021 mApplication.enterNmUiView(startParam); |
954 mApplication.enterNmUiView(startParam); |
1022 } |
955 } |
1100 /*! |
1018 /*! |
1101 externalDelete. From NmMessageListModel, handles viewer shutdown when current message is deleted. |
1019 externalDelete. From NmMessageListModel, handles viewer shutdown when current message is deleted. |
1102 */ |
1020 */ |
1103 void NmViewerView::messageDeleted(const NmId &mailboxId, const NmId &folderId, const NmId &messageId) |
1021 void NmViewerView::messageDeleted(const NmId &mailboxId, const NmId &folderId, const NmId &messageId) |
1104 { |
1022 { |
1105 NM_FUNCTION; |
|
1106 |
|
1107 if ((mStartParam->viewId() == NmUiViewMessageViewer) |
1023 if ((mStartParam->viewId() == NmUiViewMessageViewer) |
1108 && (mStartParam->mailboxId()== mailboxId) |
1024 && (mStartParam->mailboxId()== mailboxId) |
1109 && (mStartParam->folderId()== folderId) |
1025 && (mStartParam->folderId()== folderId) |
1110 && (mStartParam->messageId()== messageId)) { |
1026 && (mStartParam->messageId()== messageId)) { |
1111 mApplication.prepareForPopView(); |
1027 mApplication.prepareForPopView(); |
1115 /*! |
1031 /*! |
1116 Helper function for wait dialog creation. |
1032 Helper function for wait dialog creation. |
1117 */ |
1033 */ |
1118 void NmViewerView::createAndShowWaitDialog() |
1034 void NmViewerView::createAndShowWaitDialog() |
1119 { |
1035 { |
1120 NM_FUNCTION; |
|
1121 |
|
1122 delete mWaitDialog; |
1036 delete mWaitDialog; |
1123 mWaitDialog = NULL; |
1037 mWaitDialog = NULL; |
1124 // Create new wait dialog and set it to me modal with dimmed background |
1038 // Create new wait dialog and set it to me modal with dimmed background |
1125 mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); |
1039 mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); |
|
1040 // Connect to observe orientation change events |
|
1041 connect(mWaitDialog->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), |
|
1042 this, SLOT(orientationChanged(Qt::Orientation))); |
1126 mWaitDialog->setModal(true); |
1043 mWaitDialog->setModal(true); |
1127 mWaitDialog->setBackgroundFaded(true); |
1044 mWaitDialog->setBackgroundFaded(true); |
1128 connect(mWaitDialog, SIGNAL(cancelled()), this, SLOT(waitNoteCancelled())); |
1045 connect(mWaitDialog, SIGNAL(cancelled()), this, SLOT(waitNoteCancelled())); |
1129 mWaitDialog->setText(hbTrId("txt_mail_dialog_loading_mail_content")); |
1046 mWaitDialog->setText(hbTrId("txt_mail_dialog_loading_mail_content")); |
1130 // Display wait dialog |
1047 // Display wait dialog |
1147 /*! |
1062 /*! |
1148 Helper function for heigth. |
1063 Helper function for heigth. |
1149 */ |
1064 */ |
1150 void NmViewerView::setWebViewHeighth(int height) |
1065 void NmViewerView::setWebViewHeighth(int height) |
1151 { |
1066 { |
1152 NM_FUNCTION; |
|
1153 |
|
1154 // null pointer check for mWebView in calling function |
1067 // null pointer check for mWebView in calling function |
1155 mWebView->setMinimumHeight(height); |
1068 mWebView->setMinimumHeight(height); |
1156 mWebView->setMaximumHeight(height); |
1069 mWebView->setMaximumHeight(height); |
1157 mWebView->setPreferredHeight(height); |
1070 mWebView->setPreferredHeight(height); |
1158 } |
1071 } |
1159 |
|
1160 /*! |
|
1161 Helper function for mouse events. |
|
1162 */ |
|
1163 void NmViewerView::handleMouseEvent(QGraphicsSceneMouseEvent *event, bool pressed) |
|
1164 { |
|
1165 NM_FUNCTION; |
|
1166 NmMailViewerWK* view = webView(); |
|
1167 if (event && view && mHeaderWidget && mScrollAreaContents) { |
|
1168 QPointF lastReleasePoint = event->pos(); |
|
1169 QPointF contentWidgetPos = mScrollAreaContents->pos(); |
|
1170 qreal headerHeight = mHeaderWidget->geometry().height(); |
|
1171 qreal y = lastReleasePoint.y()-headerHeight; |
|
1172 y -= contentWidgetPos.y(); |
|
1173 qreal x = lastReleasePoint.x()-contentWidgetPos.x(); |
|
1174 const QPointF pointToWebView(x, y); |
|
1175 event->setPos(pointToWebView); |
|
1176 event->setAccepted(true); |
|
1177 if (pressed) { |
|
1178 view->sendMousePressEvent(event); |
|
1179 } else { |
|
1180 view->sendMouseReleaseEvent(event); |
|
1181 } |
|
1182 } |
|
1183 } |
|