emailuis/nmailui/inc/nmviewerview.h
branchRCL_3
changeset 63 d189ee25cf9d
equal deleted inserted replaced
61:dcf0eedfc1a3 63:d189ee25cf9d
       
     1 /*
       
     2  * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef NMVIEWERVIEW_H_
       
    19 #define NMVIEWERVIEW_H_
       
    20 
       
    21 #include <QPointer>
       
    22 
       
    23 #include "nmbaseview.h"
       
    24 #include "nmactionobserver.h"
       
    25 #include "nmattachmentfetchobserver.h"
       
    26 
       
    27 class QWebPage;
       
    28 
       
    29 class HbWidget;
       
    30 class HbMainWindow;
       
    31 class HbScrollArea;
       
    32 
       
    33 class NmApplication;
       
    34 class NmUiEngine;
       
    35 class NmUiStartParam;
       
    36 class NmMailViewerWK;
       
    37 class NmMessage;
       
    38 class NmViewerViewNetManager;
       
    39 class NmViewerHeader;
       
    40 class NmMailViewerWK;
       
    41 class NmUiDocumentLoader;
       
    42 class NmOperation;
       
    43 class HbProgressDialog;
       
    44 class NmAttachmentListWidget;
       
    45 class NmAttachmentManager;
       
    46 class HbMessageBox;
       
    47 class NmMessagePart;
       
    48 
       
    49 class NmViewerView : public NmBaseView, public NmActionObserver, public NmAttachmentFetchObserver
       
    50 {
       
    51     Q_OBJECT
       
    52 public:
       
    53     explicit NmViewerView(
       
    54 				NmApplication &application,
       
    55 				NmUiStartParam* startParam,
       
    56 				NmUiEngine &uiEngine,
       
    57 				HbMainWindow *mainWindow,
       
    58 				NmAttachmentManager &attaManager,
       
    59 				bool toolbar = false,
       
    60 				QGraphicsItem *parent = NULL);
       
    61     ~NmViewerView();
       
    62     void reloadViewContents(NmUiStartParam* startParam);
       
    63     NmUiViewId nmailViewId() const;
       
    64     NmMailViewerWK* webView();
       
    65     NmMessage* message();
       
    66     void viewReady();
       
    67     void aboutToExitView();
       
    68     
       
    69 signals:
       
    70     void progressValueChanged(int index, int value);
       
    71 
       
    72 public slots:
       
    73     void orientationChanged(Qt::Orientation orientation);
       
    74     void adjustViewDimensions();
       
    75     void linkClicked(const QUrl& link);
       
    76     void contentScrollPositionChanged(const QPointF &newPosition);
       
    77     void fetchMessage();
       
    78     void openAttachment(int index);
       
    79 	void createOptionsMenu();
       
    80 
       
    81 private slots:
       
    82     void setMessageData();
       
    83     void messageFetched(int result);
       
    84     void waitNoteCancelled();
       
    85     void webFrameLoaded(bool loaded);
       
    86     void scaleWebViewWhenLoading(const QSize &size);
       
    87     void scaleWebViewWhenLoaded();
       
    88     void messageDeleted(const NmId &mailboxId, const NmId &folderId, const NmId &messageId);
       
    89 
       
    90 public: // From NmActionObserver
       
    91     void handleActionCommand(NmActionResponse &menuResponse);
       
    92 
       
    93 public: // From NmAttachmentFetchObserver
       
    94     void progressChanged(int value);
       
    95     void fetchCompleted(int result);
       
    96 
       
    97 private:
       
    98     void deleteMessage();
       
    99     void loadMessage();
       
   100     void loadViewLayout();
       
   101     QString formatMessage();
       
   102     QString formatHtmlMessage(NmMessagePart *html);
       
   103     QString formatPlainTextMessage(NmMessagePart *plain);
       
   104     bool eventOnTopOfHeaderArea(QGraphicsSceneMouseEvent *event);
       
   105     void changeMessageReadStatus(bool read);
       
   106     void setMailboxName();
       
   107     void createToolBar();
       
   108     void setAttachmentList();
       
   109     void createAndShowWaitDialog();
       
   110 
       
   111 private:
       
   112     NmApplication &mApplication;
       
   113     NmUiEngine &mUiEngine;
       
   114     HbMainWindow *mMainWindow;                       // Not owned
       
   115     NmAttachmentManager  &mAttaManager;
       
   116     bool mToolbarEnabled;					         // is toolbar or options menu in use
       
   117     NmMessage* mMessage;                             // Owned
       
   118     HbScrollArea *mScrollArea;                       // Not owned
       
   119     HbWidget *mViewerContent;                        // Not owned
       
   120     NmMailViewerWK *mWebView;                        // Not owned
       
   121     NmViewerHeader *mHeaderWidget;                   // Not owned
       
   122     NmAttachmentListWidget *mAttaListWidget;         // Not owned
       
   123     QPointF mHeaderStartScenePos;
       
   124     QPointer<NmOperation> mMessageFetchingOperation; // Not owned 
       
   125     QPointF mLatestScrollPos;
       
   126     bool mDisplayingPlainText;
       
   127     QObjectList mWidgetList;
       
   128     NmUiDocumentLoader *mDocumentLoader;             // Owned
       
   129     HbWidget *mScrollAreaContents;                   // Not owned
       
   130     QSize mScreenSize;
       
   131     HbProgressDialog *mWaitDialog;                   // Owned
       
   132     bool webFrameloadingCompleted;
       
   133     QSize mLatestLoadingSize;
       
   134     QList<NmId> mAttaIdList;
       
   135     int mAttaIndexUnderFetch;
       
   136     NmAttachmentListWidget *mAttaWidget;             // Not owned
       
   137     bool mViewReady;
       
   138     bool mWaitNoteCancelled;
       
   139     HbMessageBox *mErrorNote;                       // Owned
       
   140 };
       
   141 
       
   142 #endif /* NMVIEWERVIEW_H_ */