ginebra2/ContentViews/GWebContentViewJSObject.h
changeset 0 1450b09d0cfd
child 3 0954f5dd2cd0
child 5 0f2326c2a325
equal deleted inserted replaced
-1:000000000000 0:1450b09d0cfd
       
     1 /*
       
     2 * Copyright (c) 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 GWebContentViewJSObject_H_
       
    19 #define GWebContentViewJSObject_H_
       
    20 
       
    21 #include <QObject>
       
    22 #include "controllableviewimpl.h"
       
    23 #include "GWebContentView.h"
       
    24 
       
    25 class WebViewEventContext;
       
    26 
       
    27 namespace GVA {
       
    28 
       
    29 /*! \ingroup JavascriptAPI
       
    30   \brief This class provides the javascript API for GWebContentView.
       
    31  */
       
    32 class GWebContentViewJSObject : public ::ControllableViewJSObject {
       
    33     Q_OBJECT
       
    34   public:
       
    35     GWebContentViewJSObject(GWebContentView *contentView, ::QWebFrame *chromeFrame, const QString &objectName)
       
    36       : ::ControllableViewJSObject(contentView, chromeFrame, objectName)
       
    37     {
       
    38       qDebug() << "GWebContentViewJSObject::GWebContentViewJSObject: " << this;
       
    39     }
       
    40 
       
    41     qreal getZoomFactor() const { return webContentViewConst()->getZoomFactor(); }
       
    42     void setZoomFactor(qreal factor)  { webContentView()->setZoomFactor(factor); }
       
    43     Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor)
       
    44 
       
    45     Q_PROPERTY(QObjectList superPages READ getSuperPages)
       
    46     QObjectList getSuperPages() { return webContentView()->getSuperPages(); }
       
    47 
       
    48     /*! This property holds whether touch navigation is enabled.
       
    49      */
       
    50     Q_PROPERTY(bool gesturesEnabled READ getGesturesEnabled WRITE setGesturesEnabled)
       
    51     bool getGesturesEnabled() const { return webContentViewConst()->gesturesEnabled(); }
       
    52     void setGesturesEnabled(bool value) { webContentView()->setGesturesEnabled(value); }
       
    53 
       
    54 public slots:
       
    55     void loadUrlToCurrentPage(const QString & url)
       
    56         { webContentView()->loadUrlToCurrentPage(url); }
       
    57     QObject *currentPage() { return webContentView()->currentPage(); }
       
    58     void back() { webContentView()->back(); }
       
    59     void forward() { webContentView()->forward(); }
       
    60     void reload() { webContentView()->reload(); }
       
    61     void zoomIn(qreal deltaPercent = 0.1) { webContentView()->zoomIn(deltaPercent); }
       
    62     void zoomOut(qreal deltaPercent = 0.1) { webContentView()->zoomOut(deltaPercent); }
       
    63     void zoomBy(qreal delta) { zoomIn(delta); }
       
    64     void zoom(bool in) { webContentView()->zoom(in); }
       
    65     void toggleZoom() { webContentView()->toggleZoom(); }
       
    66     void stopZoom() { webContentView()->stopZoom(); }
       
    67     void scrollBy(int deltaX, int deltaY) { webContentView()->scrollBy(deltaX, deltaY); }
       
    68     int scrollX() { return webContentView()->scrollX(); }
       
    69     int scrollY() { return webContentView()->scrollY(); }
       
    70     int contentWidth() { return webContentView()->contentWidth(); }
       
    71     int contentHeight() { return webContentView()->contentHeight(); }
       
    72     void showNormalPage() { return webContentView()->showNormalPage(); }
       
    73     bool currentPageIsSuperPage() { return webContentView()->currentPageIsSuperPage(); }
       
    74     void dump() { return webContentView()->dump(); }
       
    75     
       
    76     // Super page slots.
       
    77     QObject * createSuperPage(const QString &name) { return webContentView()->createSuperPage(name); }
       
    78     void destroySuperPage(const QString &name) { webContentView()->destroySuperPage(name); }
       
    79     void setCurrentSuperPage(const QString &name) { webContentView()->setCurrentSuperPage(name); }
       
    80     QObject * currentSuperPage() { return webContentView()->currentSuperPage(); }
       
    81 	QString currentSuperPageName() { return webContentView()->currentSuperPage()->objectName(); }
       
    82     void showSuperPage(const QString &name) { webContentView()->showSuperPage(name); }
       
    83     QObject * superPage(const QString &name) { return webContentView()->superPage(name); }
       
    84     bool isSuperPage(const QString &name) { return webContentView()->isSuperPage(name); }
       
    85 
       
    86 signals:
       
    87     void ContextChanged();
       
    88     void iconChanged();
       
    89     void loadFinished(bool ok);
       
    90     void loadProgress(int progress);
       
    91     void loadStarted();
       
    92     void titleChanged(const QString & title);
       
    93     void urlChanged(const QString & url);
       
    94     void secureConnection(bool secure);
       
    95     void backEnabled(bool enabled);
       
    96     void forwardEnabled(bool enabled);
       
    97     void onStatusBarMessage( const QString & text );
       
    98     void onStatusBarVisibilityChangeRequested(bool visible);
       
    99     void startingPanGesture(int directionHint);
       
   100 
       
   101     // Sent when the display mode changes from landscape to protrait or vice versa.
       
   102     void onDisplayModeChanged(const QString &orientation);
       
   103 
       
   104     void contextEvent(QObject *context);
       
   105 
       
   106 private slots:
       
   107     void statusBarMessage( const QString & text );
       
   108     void statusBarVisibilityChangeRequested(bool visible);
       
   109     void onContextEvent(::WebViewEventContext *context);
       
   110 
       
   111 protected:
       
   112     GWebContentView *webContentView() { return static_cast<GWebContentView *>(m_contentView); }
       
   113     GWebContentView *webContentViewConst() const { return static_cast<GWebContentView *>(m_contentView); }
       
   114 };
       
   115 
       
   116 }
       
   117 
       
   118 #endif /* GWebContentViewJSObject_H_ */