- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qgraphicswebview.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
    00003
    00004     This library is free software; you can redistribute it and/or
    00005     modify it under the terms of the GNU Library General Public
    00006     License as published by the Free Software Foundation; either
    00007     version 2 of the License, or (at your option) any later version.
    00008
    00009     This library is distributed in the hope that it will be useful,
    00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012     Library General Public License for more details.
    00013
    00014     You should have received a copy of the GNU Library General Public License
    00015     along with this library; see the file COPYING.LIB.  If not, write to
    00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    00017     Boston, MA 02110-1301, USA.
    00018 */
    00019
    00020 #ifndef QGraphicsWebView_h
    00021 #define QGraphicsWebView_h
    00022
    00023 #include "qwebkitglobal.h"
    00024 #include "qwebpage.h"
    00025 #include <QtCore/qurl.h>
    00026 #include <QtGui/qevent.h>
    00027 #include <QtGui/qgraphicswidget.h>
    00028 #include <QtGui/qicon.h>
    00029 #include <QtGui/qpainter.h>
    00030 #include <QtNetwork/qnetworkaccessmanager.h>
    00031
    00032 class QWebPage;
    00033 class QWebHistory;
    00034 class QWebSettings;
    00035
    00036 class QGraphicsWebViewPrivate;
    00037
    00038 class QWEBKIT_EXPORT QGraphicsWebView : public QGraphicsWidget {
    00039     Q_OBJECT
    00040
    00041     Q_PROPERTY(QString title READ title NOTIFY titleChanged)
    00042     Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
    00043     Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
    00044
    00045     Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
    00046
    00047     Q_PROPERTY(bool modified READ isModified)
    00048     Q_PROPERTY(bool resizesToContents READ resizesToContents WRITE setResizesToContents)
    00049     Q_PROPERTY(bool tiledBackingStoreFrozen READ isTiledBackingStoreFrozen WRITE setTiledBackingStoreFrozen)
    00050
    00051 public:
    00052     explicit QGraphicsWebView(QGraphicsItem* parent = 0);
    00053     ~QGraphicsWebView();
    00054
    00055     QWebPage* page() const;
    00056     void setPage(QWebPage*);
    00057
    00058     QUrl url() const;
    00059     void setUrl(const QUrl&);
    00060
    00061     QString title() const;
    00062     QIcon icon() const;
    00063
    00064     qreal zoomFactor() const;
    00065     void setZoomFactor(qreal);
    00066
    00067     bool isModified() const;
    00068
    00069     void load(const QUrl &url);
    00070     void load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray& body = QByteArray());
    00071
    00072     void setHtml(const QString& html, const QUrl& baseUrl = QUrl());
    00073     // FIXME: Consider rename to setHtml?
    00074     void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl());
    00075
    00076     QWebHistory* history() const;
    00077     QWebSettings* settings() const;
    00078
    00079     QAction* pageAction(QWebPage::WebAction action) const;
    00080     void triggerPageAction(QWebPage::WebAction action, bool checked = false);
    00081
    00082     bool findText(const QString& subString, QWebPage::FindFlags options = 0);
    00083
    00084     bool resizesToContents() const;
    00085     void setResizesToContents(bool enabled);
    00086
    00087     bool isTiledBackingStoreFrozen() const;
    00088     void setTiledBackingStoreFrozen(bool frozen);
    00089
    00090     virtual void setGeometry(const QRectF& rect);
    00091     virtual void updateGeometry();
    00092     virtual void paint(QPainter*, const QStyleOptionGraphicsItem* options, QWidget* widget = 0);
    00093     virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value);
    00094     virtual bool event(QEvent*);
    00095
    00096     virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint) const;
    00097
    00098     virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
    00099
    00100 public Q_SLOTS:
    00101     void stop();
    00102     void back();
    00103     void forward();
    00104     void reload();
    00105
    00106 Q_SIGNALS:
    00107     void loadStarted();
    00108     void loadFinished(bool);
    00109
    00110     void loadProgress(int progress);
    00111     void urlChanged(const QUrl&);
    00112     void titleChanged(const QString&);
    00113     void iconChanged();
    00114     void statusBarMessage(const QString& message);
    00115     void linkClicked(const QUrl&);
    00116
    00117 protected:
    00118     virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
    00119     virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
    00120     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
    00121     virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
    00122     virtual void hoverMoveEvent(QGraphicsSceneHoverEvent*);
    00123     virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
    00124 #ifndef QT_NO_WHEELEVENT
    00125     virtual void wheelEvent(QGraphicsSceneWheelEvent*);
    00126 #endif
    00127     virtual void keyPressEvent(QKeyEvent*);
    00128     virtual void keyReleaseEvent(QKeyEvent*);
    00129 #ifndef QT_NO_CONTEXTMENU
    00130     virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
    00131 #endif
    00132     virtual void dragEnterEvent(QGraphicsSceneDragDropEvent*);
    00133     virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent*);
    00134     virtual void dragMoveEvent(QGraphicsSceneDragDropEvent*);
    00135     virtual void dropEvent(QGraphicsSceneDragDropEvent*);
    00136     virtual void focusInEvent(QFocusEvent*);
    00137     virtual void focusOutEvent(QFocusEvent*);
    00138     virtual void inputMethodEvent(QInputMethodEvent*);
    00139     virtual bool focusNextPrevChild(bool next);
    00140
    00141     virtual bool sceneEvent(QEvent*);
    00142
    00143 private:
    00144     Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success))
    00145     Q_PRIVATE_SLOT(d, void _q_updateMicroFocus())
    00146     Q_PRIVATE_SLOT(d, void _q_pageDestroyed())
    00147     // we don't want to change the moc based on USE() macro, so this function is here
    00148     // but will be empty if ACCLERATED_COMPOSITING is disabled
    00149     Q_PRIVATE_SLOT(d, void syncLayers())
    00150     Q_PRIVATE_SLOT(d, void _q_contentsSizeChanged(const QSize&))
    00151     Q_PRIVATE_SLOT(d, void _q_scaleChanged())
    00152
    00153     QGraphicsWebViewPrivate* const d;
    00154     friend class QGraphicsWebViewPrivate;
    00155 };
    00156
    00157 #endif // QGraphicsWebView_h