ginebra2/ContentViews/GWebContentView.h
changeset 5 0f2326c2a325
parent 0 1450b09d0cfd
child 6 1c3b8676e58c
equal deleted inserted replaced
1:b0dd75e285d2 5:0f2326c2a325
     1 /*
     1 /*
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 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 *
     5 * under the terms of "Eclipse Public License v1.0"
     5 * This program is free software: you can redistribute it and/or modify
     6 * which accompanies this distribution, and is available
     6 * it under the terms of the GNU Lesser General Public License as published by
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * the Free Software Foundation, version 2.1 of the License.
     8 *
     8 *
     9 * Initial Contributors:
     9 * This program is distributed in the hope that it will be useful,
    10 * Nokia Corporation - initial contribution.
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11 *
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12 * Contributors:
    12 * GNU Lesser General Public License for more details.
    13 *
    13 *
    14 * Description: 
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not,
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
    15 *
    19 *
    16 */
    20 */
    17 
       
    18 
    21 
    19 #ifndef GWebContentView_H
    22 #ifndef GWebContentView_H
    20 #define GWebContentView_H
    23 #define GWebContentView_H
    21 
    24 
    22 #include <QObject>
    25 #include <QObject>
    23 #include <QVariant>
    26 #include <QVariant>
    24 #include <QGraphicsWidget>
    27 #include <QGraphicsWidget>
    25 #include <qwebelement.h>
    28 #include <QWebElement>
    26 #include "qgraphicswebview.h"
    29 #include <QGraphicsWebView>
    27 #include "controllableviewimpl.h"
    30 #include "controllableviewimpl.h"
    28 #include "messageboxproxy.h"
    31 #include "messageboxproxy.h"
    29 #include "ZoomMetaData.h"
    32 #include "ZoomMetaData.h"
    30 #include "GWebPage.h"
    33 #include "GWebPage.h"
    31 #include "ContentViewDelegate.h"
    34 #include "ContentViewDelegate.h"
    32 #include "GWebTouchNavigation.h"
    35 #include "GContentViewTouchNavigation.h"
    33 
    36 
    34 class WebViewEventContext;
    37 class WebViewEventContext;
    35 class QContextMenuEvent;
    38 class QContextMenuEvent;
    36 class QWebPage;
    39 class QWebPage;
    37 class QWebFrame;
    40 class QWebFrame;
    42 }
    45 }
    43 
    46 
    44 namespace GVA {
    47 namespace GVA {
    45 
    48 
    46   class GWebPage;
    49   class GWebPage;
       
    50   class WebPageWrapper;
    47   class ChromeWidget;
    51   class ChromeWidget;
    48   class ContentViewDelegate;
    52   class ContentViewDelegate;
    49 
    53 
    50   class GWebContentView : public ControllableViewBase
    54   class GWebContentView : public ControllableViewBase
    51   {
    55   {
    92 
    96 
    93       void  changeZoomAction(qreal zoom);
    97       void  changeZoomAction(qreal zoom);
    94       void deactivateZoomActions();
    98       void deactivateZoomActions();
    95 
    99 
    96       // Super page methods.
   100       // Super page methods.
    97       GWebPage * createSuperPage(const QString &name);
   101       GWebPage * createSuperPage(const QString &name, bool persist = false);
    98       void destroySuperPage(const QString &name);
   102       void destroySuperPage(const QString &name);
    99       QObjectList getSuperPages();
   103       QObjectList getSuperPages();
   100       void setCurrentSuperPage(const QString &name);
   104       void setCurrentSuperPage(const QString &name);
   101       GWebPage * currentSuperPage() {return m_currentSuperPage.value();}
   105       GWebPage * currentSuperPage() {return m_currentSuperPage.value();}
   102       void showSuperPage(const QString &name);
   106       void showSuperPage(const QString &name);
   112       virtual void hide() {
   116       virtual void hide() {
   113           qDebug() << "GWebContentView::hide: " << widget();
   117           qDebug() << "GWebContentView::hide: " << widget();
   114           widget()->hide();
   118           widget()->hide();
   115       }
   119       }
   116 
   120 
   117 	  bool gesturesEnabled() const { return m_touchNavigation->enabled(); }
   121       bool gesturesEnabled() const { return m_touchNavigation->enabled(); }
   118       void setGesturesEnabled(bool value) { m_touchNavigation->setEnabled(value); }
   122       void setGesturesEnabled(bool value) { m_touchNavigation->setEnabled(value); }
       
   123 
       
   124       bool enabled() const;
       
   125       void setEnabled(bool value);
       
   126 
       
   127       bool frozen() const { return webWidget()->frozen(); }
       
   128       void freeze() { return webWidget()->freeze(); }
       
   129       void unfreeze() { return webWidget()->unfreeze(); }
   119 
   130 
   120   signals:
   131   signals:
   121       void ContextChanged();
   132       void ContextChanged();
   122       void iconChanged();
   133       void iconChanged();
   123       void loadFinished(bool ok);
   134       void loadFinished(bool ok);
   147       void zoomBy(qreal delta) { zoomIn(delta); }
   158       void zoomBy(qreal delta) { zoomIn(delta); }
   148       void zoom(bool in);
   159       void zoom(bool in);
   149       void toggleZoom();
   160       void toggleZoom();
   150       void stopZoom();
   161       void stopZoom();
   151       void scrollBy(int deltaX, int deltaY) { scrollViewBy(deltaX, deltaY); }
   162       void scrollBy(int deltaX, int deltaY) { scrollViewBy(deltaX, deltaY); }
       
   163       void scrollTo(int x, int y) { scrollViewTo(x,y);}
   152       int scrollX();
   164       int scrollX();
   153       int scrollY();
   165       int scrollY();
   154       int contentWidth();
   166       int contentWidth();
   155       int contentHeight();
   167       int contentHeight();
   156 
   168 
   173   protected:
   185   protected:
   174     GWebContentViewWidget *webWidgetConst() const { return m_widget; }
   186     GWebContentViewWidget *webWidgetConst() const { return m_widget; }
   175     ChromeWidget *chrome() { return m_chrome; }
   187     ChromeWidget *chrome() { return m_chrome; }
   176     void updateWebPage(WRT::WrtBrowserContainer * pg);
   188     void updateWebPage(WRT::WrtBrowserContainer * pg);
   177     void changeContentViewZoomInfo(WRT::WrtBrowserContainer* newPage);
   189     void changeContentViewZoomInfo(WRT::WrtBrowserContainer* newPage);
   178     
   190 
   179   protected:
   191   protected:
   180     GWebContentViewWidget *m_widget;
   192     GWebContentViewWidget *m_widget;
   181     QNetworkAccessManager *m_networkMgr; //Owned
   193     QNetworkAccessManager *m_networkMgr; //Owned
       
   194     ChromeWidget *m_chrome;  // not owned
   182 
   195 
   183   private:
   196   private:
   184     void setZoomActions();
   197     void setActions();
   185 
   198     virtual void setJSObject(const QString &objectName);
   186     ChromeWidget *m_chrome;  // not owned
   199     QMap<QString, QAction*>  m_actions;
   187     QAction * m_actionZoomIn;
       
   188     QAction * m_actionZoomOut;
       
   189     QTimeLine * m_timeLine;
   200     QTimeLine * m_timeLine;
   190     bool m_zoomIn;
   201     bool m_zoomIn;
   191 
   202 
   192     GWebTouchNavigation* m_touchNavigation;
   203     GContentViewTouchNavigation* m_touchNavigation;
   193     bool m_backEnabled;
   204     bool m_backEnabled;
   194     bool m_forwardEnabled;
   205     bool m_forwardEnabled;
   195 
   206 
   196     ChromeWidget *m_chromeWidget;  // not owned
   207     ChromeWidget *m_chromeWidget;  // not owned
       
   208     WebPageWrapper* m_sharedPage;
   197     typedef QMap<QString, GWebPage *> PageMap;
   209     typedef QMap<QString, GWebPage *> PageMap;
   198     PageMap m_superPages;
   210     PageMap m_superPages;
   199     PageMap::iterator m_currentSuperPage;
   211     PageMap::iterator m_currentSuperPage;
   200     bool m_currentPageIsSuperPage;
   212     bool m_currentPageIsSuperPage;
   201     QTimer *m_timer;
   213     QTimer *m_timer;
   202     qreal m_value;
   214     qreal m_value;
   203     bool m_gesturesEnabled;
   215     bool m_gesturesEnabled;
       
   216     bool m_enabled;
   204   };
   217   };
   205 
   218 
   206 }
   219 }
   207 
   220 
   208 #endif // GWebContentView_H
   221 #endif // GWebContentView_H