browsercore/appfw/Api/Managers/webpagecontroller.h
changeset 0 1450b09d0cfd
child 3 0954f5dd2cd0
child 5 0f2326c2a325
equal deleted inserted replaced
-1:000000000000 0:1450b09d0cfd
       
     1 /*
       
     2 * Copyright (c) 2009 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 
       
    19 #ifndef __WRTPAGEMANAGER_H__
       
    20 #define __WRTPAGEMANAGER_H__
       
    21 
       
    22 //#include <QWidget>
       
    23 #include <QAction>
       
    24 #include <QNetworkReply>
       
    25 #include <QSslError>
       
    26 #include <qwebframe.h>
       
    27 #include <QIcon>
       
    28 #include <QEvent>
       
    29 #include "browserpagefactory.h"
       
    30 #include "BWFGlobal.h"
       
    31 #include "messageboxproxy.h"
       
    32 
       
    33 #define WEBPAGE_ZOOM_RANGE_MIN 25
       
    34 #define WEBPAGE_ZOOM_RANGE_MAX 300
       
    35 #define WEBPAGE_ZOOM_PAGE_STEP 20
       
    36 
       
    37 class QGraphicsWebView;
       
    38 
       
    39 namespace WRT {
       
    40     class WrtPage;
       
    41     class WrtBrowserContainer;
       
    42 }
       
    43 
       
    44 using namespace WRT;
       
    45 
       
    46 // -----------------------------------------------------------
       
    47 
       
    48 class BWF_EXPORT WebPageControllerUpdateViewPortEvent : public QEvent {
       
    49   public:
       
    50     WebPageControllerUpdateViewPortEvent() : QEvent(staticType()) {}
       
    51     static QEvent::Type staticType() {
       
    52         static int s_type = QEvent::registerEventType();
       
    53         return (QEvent::Type)s_type;
       
    54     }
       
    55 };
       
    56 
       
    57 // -----------------------------------------------------------
       
    58 
       
    59 class WebPageControllerPrivate;
       
    60 
       
    61 class BWF_EXPORT WebPageController : public QObject, public BrowserPageFactory
       
    62 {
       
    63     Q_OBJECT
       
    64 public:
       
    65    /*!
       
    66     * WebPageController Constructor
       
    67     * @param parent: parent QObject 
       
    68     */  
       
    69     WebPageController(QObject* parent = 0);
       
    70     /*!
       
    71      * WebPageController Destructor
       
    72      */ 
       
    73     ~WebPageController();
       
    74 
       
    75 public:
       
    76 
       
    77     QString currentDocTitle();
       
    78     Q_PROPERTY(QString currentDocTitle READ currentDocTitle)
       
    79 
       
    80     QString currentDocUrl() const;
       
    81     Q_PROPERTY(QString currentDocUrl READ currentDocUrl)
       
    82 
       
    83     QString currentPartialUrl();
       
    84     Q_PROPERTY(QUrl currentPartialUrl READ currentPartialUrl)
       
    85 
       
    86     QString currentRequestedUrl() const;
       
    87     Q_PROPERTY(QString currentRequestedUrl READ currentRequestedUrl)
       
    88 
       
    89     QVariant currentContentWindowObject();
       
    90     Q_PROPERTY(QVariant currentWindowObject READ currentContentWindowObject)
       
    91    
       
    92     int currentPageIndex();
       
    93     Q_PROPERTY(int currentPageIndex READ currentPageIndex)
       
    94 
       
    95     int contentsYPos();
       
    96     Q_PROPERTY(int contentsYPos READ contentsYPos)
       
    97 
       
    98     /* This indicates whether the current page is secure or not */
       
    99     int secureState();
       
   100     Q_PROPERTY(int secureState READ secureState)
       
   101 
       
   102     int loadState();
       
   103     Q_PROPERTY(int loadState READ loadState)
       
   104 
       
   105     QString  loadText();
       
   106     Q_PROPERTY(QString loadText READ loadText)
       
   107 
       
   108     int loadProgressValue();
       
   109     Q_PROPERTY(int loadProgressValue READ loadProgressValue)
       
   110 
       
   111     bool isPageLoading();
       
   112     Q_PROPERTY(bool isPageLoading READ isPageLoading)
       
   113 
       
   114     bool loadCanceled();
       
   115     Q_PROPERTY(bool loadCanceled READ loadCanceled)
       
   116 
       
   117     QWebPage* openPage();
       
   118     QWebPage* openPageFromHistory(int index);
       
   119     void closePage(WRT::WrtBrowserContainer*);
       
   120 
       
   121     WRT::WrtBrowserContainer* currentPage() const;
       
   122     void closeCurrentPage();
       
   123 
       
   124     QList<WRT::WrtBrowserContainer*>* allPages();
       
   125     WRT::WrtBrowserContainer * findPageByMainFrameName(const QString & name);
       
   126 
       
   127     QString title();
       
   128 //    QWidget * widgetParent();
       
   129 
       
   130     void setOffline(bool offline);
       
   131     void initUASettingsAndData();
       
   132     
       
   133     QList<QAction*> getContext();
       
   134 
       
   135     // persistent storage related methods
       
   136     void saveHistory();
       
   137     void clearHistoryInMemory();
       
   138     void deleteHistory();    
       
   139     
       
   140     WRT::WrtBrowserContainer* restoreHistory(QWidget* parent, int index);
       
   141     WRT::WrtBrowserContainer* startupRestoreHistory(QWidget* parent, int index, WRT::WrtBrowserContainer* page);
       
   142     void saveNumberOfWindows();
       
   143     int restoreNumberOfWindows();
       
   144     int historyWindowCount();
       
   145     
       
   146     void setLastUrl(QString url);
       
   147 
       
   148     QIcon pageIcon();
       
   149     
       
   150     QGraphicsWebView* webView();
       
   151     void updatePageThumbnails();
       
   152     void resizeAndUpdatePageThumbnails(QSize& s);
       
   153 
       
   154 private:
       
   155     void checkAndUpdatePageThumbnails();
       
   156     WRT::WrtBrowserContainer* openPage(QObject* parent, WRT::WrtBrowserContainer* page=0);
       
   157 
       
   158 public: // public actions available for this view
       
   159     QAction * getActionReload();
       
   160     QAction * getActionStop();
       
   161     QAction * getActionBack();
       
   162     QAction * getActionForward();
       
   163     QAction * getActionWebInspector();
       
   164     
       
   165 public slots:
       
   166     void setLoadState(int);
       
   167     int pageCount();
       
   168     QString getLastUrl();
       
   169     void deleteCookies();
       
   170     void deleteCache();
       
   171     void deleteDataFiles();
       
   172     void savePopupSettings(int);
       
   173     bool getPopupSettings();
       
   174     
       
   175     void currentReload();
       
   176     void currentStop();
       
   177     void currentBack();
       
   178     void currentForward();
       
   179 
       
   180     void currentLoad(const QString &url);
       
   181     void currentLoad(const QUrl & url);
       
   182     void currentSetFromHistory(int historyIndex);
       
   183     void gotoCurrentItem();
       
   184     void pageGotoCurrentItem(int index);
       
   185     void pageReload(int index);
       
   186     void setCurrentPage(WRT::WrtBrowserContainer*);
       
   187          	    
       
   188     void webInspector();
       
   189 
       
   190     static WebPageController* getSingleton();
       
   191 
       
   192     void urlTextChanged(QString );
       
   193     void loadFromHistory();
       
   194     void loadLocalFile();
       
   195     QString guessUrlFromString(const QString &s);
       
   196 
       
   197 private slots:
       
   198     void settingChanged(const QString &key);
       
   199     void updateStatePageLoading();
       
   200     void updateStatePageLoadComplete(bool);
       
   201     void updateActions(bool pageIsLoading=false);
       
   202     void unsupportedContentArrived(QNetworkReply *);
       
   203     void createWindow(WrtBrowserContainer* page);
       
   204     void networkRequestFinished(QNetworkReply *reply);
       
   205     void updateJSActions();
       
   206     void urlChanged(const QUrl &url);
       
   207     void secureStateChange(int);
       
   208 
       
   209 signals:
       
   210     void pageCreated( WRT::WrtBrowserContainer* newPage);
       
   211     void pageDeleted( WRT::WrtBrowserContainer* oldPage);
       
   212     void pageChanged( WRT::WrtBrowserContainer* oldPage, WRT::WrtBrowserContainer* newPage );
       
   213 
       
   214     void titleChanged(const QString &);
       
   215     void loadStarted();
       
   216     void loadProgress( const int progress );
       
   217     void loadFinished( const bool ok );
       
   218 
       
   219     void currentPageIconChanged();
       
   220     void currentPageUrlChanged( const QUrl & url);
       
   221     void partialUrlChanged(QString url);
       
   222     void unsupportedContent(QNetworkReply *);
       
   223 
       
   224     void networkRequestStarted(QWebFrame*, QNetworkRequest*);
       
   225     void networkRequestError(QNetworkReply *reply);
       
   226     void sslErrors(QNetworkReply *, const QList<QSslError> &);
       
   227     void showMessageBox(WRT::MessageBoxProxy*);
       
   228 
       
   229     void linkClicked( const QString & url );
       
   230     void selectionChanged();
       
   231 
       
   232     void pageScrollPositionZero();
       
   233     void pageScrollRequested(int, int, const QRect & );
       
   234 
       
   235     void showSecureIcon();
       
   236     void hideSecureIcon();
       
   237 
       
   238     // All signals for urlsearch 
       
   239     void pageLoadStarted();
       
   240     void pageLoadProgress( const int progress );
       
   241     void pageLoadFinished( const bool ok );
       
   242     void pageUrlChanged( const QString str );
       
   243     void pageIconChanged();
       
   244  
       
   245 private:
       
   246     QString partialUrl(const QUrl &url);
       
   247 
       
   248     WebPageControllerPrivate * const d;
       
   249 };
       
   250 #endif // __WRTPAGEMANAGER_H__