From a62045bd0ef52f3d439cb862ee7a38366536a0ec Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 1 Oct 2009 17:51:17 +0200 Subject: Rename QWebGraphicsItem to QGraphicsWebView MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Alexis Menard on 2009-10-01 Reviewed by Tor Arne Vestbø. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48974 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- src/3rdparty/webkit/WebCore/WebCore.pro | 2 +- src/3rdparty/webkit/WebKit/qt/Api/headers.pri | 2 +- .../webkit/WebKit/qt/Api/qgraphicswebview.cpp | 822 +++++++++++++++++++++ .../webkit/WebKit/qt/Api/qgraphicswebview.h | 144 ++++ .../webkit/WebKit/qt/Api/qwebgraphicsitem.cpp | 822 --------------------- .../webkit/WebKit/qt/Api/qwebgraphicsitem.h | 144 ---- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h | 2 +- .../qt/tests/qgraphicswebview/qgraphicswebview.pro | 6 + .../qgraphicswebview/tst_qgraphicswebview.cpp | 58 ++ .../qt/tests/qwebgraphicsitem/qwebgraphicsitem.pro | 6 - .../qwebgraphicsitem/tst_qwebgraphicsitem.cpp | 58 -- src/3rdparty/webkit/WebKit/qt/tests/tests.pro | 2 +- 12 files changed, 1034 insertions(+), 1034 deletions(-) create mode 100644 src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp create mode 100644 src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h delete mode 100644 src/3rdparty/webkit/WebKit/qt/Api/qwebgraphicsitem.cpp delete mode 100644 src/3rdparty/webkit/WebKit/qt/Api/qwebgraphicsitem.h create mode 100644 src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/qgraphicswebview.pro create mode 100644 src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp delete mode 100644 src/3rdparty/webkit/WebKit/qt/tests/qwebgraphicsitem/qwebgraphicsitem.pro delete mode 100644 src/3rdparty/webkit/WebKit/qt/tests/qwebgraphicsitem/tst_qwebgraphicsitem.cpp diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index c7bd640..bc22b7a 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -2391,7 +2391,7 @@ SOURCES += \ ../WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp \ ../WebKit/qt/WebCoreSupport/InspectorClientQt.cpp \ ../WebKit/qt/Api/qwebframe.cpp \ - ../WebKit/qt/Api/qwebgraphicsitem.cpp \ + ../WebKit/qt/Api/qgraphicswebview.cpp \ ../WebKit/qt/Api/qwebpage.cpp \ ../WebKit/qt/Api/qwebview.cpp \ ../WebKit/qt/Api/qwebelement.cpp \ diff --git a/src/3rdparty/webkit/WebKit/qt/Api/headers.pri b/src/3rdparty/webkit/WebKit/qt/Api/headers.pri index 51abba4..5a95c67 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/headers.pri +++ b/src/3rdparty/webkit/WebKit/qt/Api/headers.pri @@ -1,5 +1,5 @@ WEBKIT_API_HEADERS = $$PWD/qwebframe.h \ - $$PWD/qwebgraphicsitem.h \ + $$PWD/qgraphicswebview.h \ $$PWD/qwebkitglobal.h \ $$PWD/qwebpage.h \ $$PWD/qwebview.h \ diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp new file mode 100644 index 0000000..d8d9d64 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp @@ -0,0 +1,822 @@ +/* + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "qgraphicswebview.h" + +#include "qwebframe.h" +#include "qwebpage.h" +#include "qwebpage_p.h" +#include "QWebPageClient.h" +#include +#include +#include +#include +#include +#if defined(Q_WS_X11) +#include +#endif + +class QGraphicsWebViewPrivate : public QWebPageClient { +public: + QGraphicsWebViewPrivate(QGraphicsWebView* parent) + : q(parent) + , page(0) + , interactive(true) + , progress(1.0) + {} + + virtual void scroll(int dx, int dy, const QRect&); + virtual void update(const QRect& dirtyRect); + + virtual QCursor cursor() const; + virtual void updateCursor(const QCursor& cursor); + + virtual int screenNumber() const; + virtual WId winId() const; + + void _q_doLoadProgress(int progress); + void _q_doLoadFinished(bool success); + void _q_setStatusBarMessage(const QString& message); + + QGraphicsWebView* q; + QWebPage* page; + + QString statusBarMessage; + bool interactive; + qreal progress; +}; + +void QGraphicsWebViewPrivate::_q_doLoadProgress(int progress) +{ + if (qFuzzyCompare(this->progress, qreal(progress / 100.))) + return; + + this->progress = progress / 100.; + + emit q->progressChanged(this->progress); +} + +void QGraphicsWebViewPrivate::_q_doLoadFinished(bool success) +{ + // If the page had no title, still make sure it gets the signal + if (q->title().isEmpty()) + emit q->urlChanged(q->url()); + + if (success) + emit q->loadFinished(); + else + emit q->loadFailed(); +} + +void QGraphicsWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll) +{ + q->scroll(qreal(dx), qreal(dy), QRectF(rectToScroll)); +} + +void QGraphicsWebViewPrivate::update(const QRect & dirtyRect) +{ + q->update(QRectF(dirtyRect)); +} + +QCursor QGraphicsWebViewPrivate::cursor() const +{ + return q->cursor(); +} + +void QGraphicsWebViewPrivate::updateCursor(const QCursor& cursor) +{ + q->setCursor(cursor); +} + +int QGraphicsWebViewPrivate::screenNumber() const +{ +#if defined(Q_WS_X11) + const QList views = q->scene()->views(); + + if (!views.isEmpty()) + return views.at(0)->x11Info().screen(); +#endif + + return 0; +} + +WId QGraphicsWebViewPrivate::winId() const +{ + const QList views = q->scene()->views(); + + if (!views.isEmpty()) + return views.at(0)->winId(); + + return 0; +} + +void QGraphicsWebViewPrivate::_q_setStatusBarMessage(const QString& s) +{ + statusBarMessage = s; + emit q->statusChanged(); +} + +/*! + \class QGraphicsWebView + \brief The QGraphicsWebView class allows web content to be added to a GraphicsView. + \since 4.6 + + A WebGraphicsItem renders web content based on a URL or set data. + + If the width and height of the item is not set, they will + dynamically adjust to a size appropriate for the content. + This width may be large (eg. 980) for typical online web pages. +*/ + +/*! + Constructs an empty QGraphicsWebView with parent \a parent. + + \sa load() +*/ +QGraphicsWebView::QGraphicsWebView(QGraphicsItem* parent) + : QGraphicsWidget(parent) + , d(new QGraphicsWebViewPrivate(this)) +{ +#if QT_VERSION >= 0x040600 + setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); +#endif + setAcceptHoverEvents(true); + setFocusPolicy(Qt::StrongFocus); +} + +/*! + Destroys the web graphicsitem. +*/ +QGraphicsWebView::~QGraphicsWebView() +{ + if (d->page) + d->page->d->view = 0; + + if (d->page && d->page->parent() == this) + delete d->page; + + delete d; +} + +/*! + Returns a pointer to the underlying web page. + + \sa setPage() +*/ +QWebPage* QGraphicsWebView::page() const +{ + if (!d->page) { + QGraphicsWebView* that = const_cast(this); + QWebPage* page = new QWebPage(that); + + // Default to not having a background, in the case + // the page doesn't provide one. + QPalette palette = QApplication::palette(); + palette.setBrush(QPalette::Base, QColor::fromRgbF(0, 0, 0, 0)); + page->setPalette(palette); + + that->setPage(page); + } + + return d->page; +} + +/*! \reimp +*/ +void QGraphicsWebView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget*) +{ + page()->mainFrame()->render(painter, option->exposedRect.toRect()); +} + +/*! \reimp +*/ +bool QGraphicsWebView::sceneEvent(QEvent* event) +{ + // Re-implemented in order to allows fixing event-related bugs in patch releases. + return QGraphicsWidget::sceneEvent(event); +} + +/*! \reimp +*/ +bool QGraphicsWebView::event(QEvent* event) +{ + // Re-implemented in order to allows fixing event-related bugs in patch releases. + + if (d->page) { +#ifndef QT_NO_CURSOR +#if QT_VERSION >= 0x040400 + } else if (event->type() == QEvent::CursorChange) { + // An unsetCursor will set the cursor to Qt::ArrowCursor. + // Thus this cursor change might be a QWidget::unsetCursor() + // If this is not the case and it came from WebCore, the + // QWebPageClient already has set its cursor internally + // to Qt::ArrowCursor, so updating the cursor is always + // right, as it falls back to the last cursor set by + // WebCore. + // FIXME: Add a QEvent::CursorUnset or similar to Qt. + if (cursor().shape() == Qt::ArrowCursor) + d->resetCursor(); +#endif +#endif + } + return QGraphicsWidget::event(event); +} + +/*! + Makes \a page the new web page of the web graphicsitem. + + The parent QObject of the provided page remains the owner + of the object. If the current document is a child of the web + view, it will be deleted. + + \sa page() +*/ +void QGraphicsWebView::setPage(QWebPage* page) +{ + if (d->page == page) + return; + + if (d->page) { + d->page->d->client = 0; // unset the page client + if (d->page->parent() == this) + delete d->page; + else + d->page->disconnect(this); + } + + d->page = page; + if (!d->page) + return; + d->page->d->client = d; // set the page client + + QSize size = geometry().size().toSize(); + page->setViewportSize(size); + + QWebFrame* mainFrame = d->page->mainFrame(); + + connect(mainFrame, SIGNAL(titleChanged(const QString&)), + this, SIGNAL(titleChanged(const QString&))); + connect(mainFrame, SIGNAL(iconChanged()), + this, SIGNAL(iconChanged())); + connect(mainFrame, SIGNAL(urlChanged(const QUrl&)), + this, SIGNAL(urlChanged(const QUrl&))); + connect(d->page, SIGNAL(loadStarted()), + this, SIGNAL(loadStarted())); + connect(d->page, SIGNAL(loadProgress(int)), + this, SLOT(_q_doLoadProgress(int))); + connect(d->page, SIGNAL(loadFinished(bool)), + this, SLOT(_q_doLoadFinished(bool))); + connect(d->page, SIGNAL(statusBarMessage(const QString&)), + this, SLOT(_q_setStatusBarMessage(const QString&))); +} + +/*! + \property QGraphicsWebView::url + \brief the url of the web page currently viewed + + Setting this property clears the view and loads the URL. + + By default, this property contains an empty, invalid URL. + + \sa load(), urlChanged() +*/ + +void QGraphicsWebView::setUrl(const QUrl &url) +{ + page()->mainFrame()->setUrl(url); +} + +QUrl QGraphicsWebView::url() const +{ + if (d->page) + return d->page->mainFrame()->url(); + + return QUrl(); +} + +/*! + \property QGraphicsWebView::title + \brief the title of the web page currently viewed + + By default, this property contains an empty string. + + \sa titleChanged() +*/ +QString QGraphicsWebView::title() const +{ + if (d->page) + return d->page->mainFrame()->title(); + + return QString(); +} + +/*! + \property QGraphicsWebView::icon + \brief the icon associated with the web page currently viewed + + By default, this property contains a null icon. + + \sa iconChanged(), QWebSettings::iconForUrl() +*/ +QIcon QGraphicsWebView::icon() const +{ + if (d->page) + return d->page->mainFrame()->icon(); + + return QIcon(); +} + +/*! + \property QGraphicsWebView::zoomFactor + \since 4.5 + \brief the zoom factor for the view +*/ + +void QGraphicsWebView::setZoomFactor(qreal factor) +{ + if (factor == page()->mainFrame()->zoomFactor()) + return; + + page()->mainFrame()->setZoomFactor(factor); + emit zoomFactorChanged(); +} + +qreal QGraphicsWebView::zoomFactor() const +{ + return page()->mainFrame()->zoomFactor(); +} + +/*! \reimp +*/ +void QGraphicsWebView::updateGeometry() +{ + QGraphicsWidget::updateGeometry(); + + if (!d->page) + return; + + QSize size = geometry().size().toSize(); + d->page->setViewportSize(size); +} + +/*! \reimp +*/ +void QGraphicsWebView::setGeometry(const QRectF& rect) +{ + QGraphicsWidget::setGeometry(rect); + + if (!d->page) + return; + + // NOTE: call geometry() as setGeometry ensures that + // the geometry is within legal bounds (minimumSize, maximumSize) + QSize size = geometry().size().toSize(); + d->page->setViewportSize(size); +} + +/*! + \brief The load status message associated to the web graphicsitem + + Provides the latest status message set during the load of a URL. + Commonly shown by Status Bar widgets. + + \sa statusChanged() +*/ + +QString QGraphicsWebView::status() const +{ + return d->statusBarMessage; +} + +/*! + Convenience slot that stops loading the document. + + \sa reload(), loadFinished() +*/ +void QGraphicsWebView::stop() +{ + if (d->page) + d->page->triggerAction(QWebPage::Stop); +} + +/*! + Convenience slot that loads the previous document in the list of documents + built by navigating links. Does nothing if there is no previous document. + + \sa forward() +*/ +void QGraphicsWebView::back() +{ + if (d->page) + d->page->triggerAction(QWebPage::Back); +} + +/*! + Convenience slot that loads the next document in the list of documents + built by navigating links. Does nothing if there is no next document. + + \sa back() +*/ +void QGraphicsWebView::forward() +{ + if (d->page) + d->page->triggerAction(QWebPage::Forward); +} + +/*! + Reloads the current document. + + \sa stop(), loadStarted() +*/ +void QGraphicsWebView::reload() +{ + if (d->page) + d->page->triggerAction(QWebPage::Reload); +} + +/*! + \property QGraphicsWebView::progress + \brief the progress of loading the current URL, from 0 to 1. +*/ +qreal QGraphicsWebView::progress() const +{ + return d->progress; +} + +/*! + Loads the specified \a url and displays it. + + \note The view remains the same until enough data has arrived to display the new \a url. + + \sa setUrl(), url(), urlChanged() +*/ +void QGraphicsWebView::load(const QUrl& url) +{ + page()->mainFrame()->load(url); +} + +/*! + \fn void QGraphicsWebView::load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation, const QByteArray &body) + + Loads a network request, \a request, using the method specified in \a operation. + + \a body is optional and is only used for POST operations. + + \note The view remains the same until enough data has arrived to display the new url. + + \sa url(), urlChanged() +*/ + +void QGraphicsWebView::load(const QNetworkRequest& request, + QNetworkAccessManager::Operation operation, + const QByteArray& body) +{ + page()->mainFrame()->load(request, operation, body); +} + +/*! + Sets the content of the web graphicsitem to the specified \a html. + + External objects such as stylesheets or images referenced in the HTML + document are located relative to \a baseUrl. + + The \a html is loaded immediately; external objects are loaded asynchronously. + + When using this method, WebKit assumes that external resources such as + JavaScript programs or style sheets are encoded in UTF-8 unless otherwise + specified. For example, the encoding of an external script can be specified + through the charset attribute of the HTML script tag. Alternatively, the + encoding can also be specified by the web server. + + \sa load(), setContent(), QWebFrame::toHtml() +*/ +void QGraphicsWebView::setHtml(const QString& html, const QUrl& baseUrl) +{ + page()->mainFrame()->setHtml(html, baseUrl); +} + +QString QGraphicsWebView::toHtml() const +{ + return page()->mainFrame()->toHtml(); +} + +/*! + Sets the content of the web graphicsitem to the specified content \a data. If the \a mimeType argument + is empty it is currently assumed that the content is HTML but in future versions we may introduce + auto-detection. + + External objects referenced in the content are located relative to \a baseUrl. + + The \a data is loaded immediately; external objects are loaded asynchronously. + + \sa load(), setHtml(), QWebFrame::toHtml() +*/ +void QGraphicsWebView::setContent(const QByteArray& data, const QString& mimeType, const QUrl& baseUrl) +{ + page()->mainFrame()->setContent(data, mimeType, baseUrl); +} + +/*! + Returns a pointer to the view's history of navigated web pages. + + It is equivalent to + + \snippet webkitsnippets/qtwebkit_qwebview_snippet.cpp 0 +*/ +QWebHistory* QGraphicsWebView::history() const +{ + return page()->history(); +} + +/*! + \property QGraphicsWebView::interactive + \brief controls whether the item responds to mouse and key events. +*/ + +bool QGraphicsWebView::isInteractive() const +{ + return d->interactive; +} + +void QGraphicsWebView::setInteractive(bool allowed) +{ + if (d->interactive == allowed) + return; + + d->interactive = allowed; + emit interactivityChanged(); +} + +/*! + Returns a pointer to the view/page specific settings object. + + It is equivalent to + + \snippet webkitsnippets/qtwebkit_qwebview_snippet.cpp 1 + + \sa QWebSettings::globalSettings() +*/ +QWebSettings* QGraphicsWebView::settings() const +{ + return page()->settings(); +} + +/*! \reimp +*/ +void QGraphicsWebView::hoverMoveEvent(QGraphicsSceneHoverEvent* ev) +{ + if (d->interactive && d->page) { + const bool accepted = ev->isAccepted(); + QMouseEvent me = QMouseEvent(QEvent::MouseMove, + ev->pos().toPoint(), Qt::NoButton, + Qt::NoButton, Qt::NoModifier); + d->page->setView(ev->widget()); + d->page->event(&me); + ev->setAccepted(accepted); + } + + if (!ev->isAccepted()) + QGraphicsItem::hoverMoveEvent(ev); +} + +/*! \reimp +*/ +void QGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent* ev) +{ + Q_UNUSED(ev); +} + +/*! \reimp +*/ +void QGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) +{ + if (d->interactive && d->page) { + const bool accepted = ev->isAccepted(); + d->page->event(ev); + ev->setAccepted(accepted); + } + + if (!ev->isAccepted()) + QGraphicsItem::mouseMoveEvent(ev); +} + +/*! \reimp +*/ +void QGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* ev) +{ + if (d->interactive && d->page) { + const bool accepted = ev->isAccepted(); + d->page->event(ev); + ev->setAccepted(accepted); + } + + if (!ev->isAccepted()) + QGraphicsItem::mousePressEvent(ev); +} + +/*! \reimp +*/ +void QGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) +{ + if (d->interactive && d->page) { + const bool accepted = ev->isAccepted(); + d->page->event(ev); + ev->setAccepted(accepted); + } + + if (!ev->isAccepted()) + QGraphicsItem::mouseReleaseEvent(ev); +} + +/*! \reimp +*/ +void QGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev) +{ + if (d->interactive && d->page) { + const bool accepted = ev->isAccepted(); + d->page->event(ev); + ev->setAccepted(accepted); + } + + if (!ev->isAccepted()) + QGraphicsItem::mouseDoubleClickEvent(ev); +} + +/*! \reimp +*/ +void QGraphicsWebView::keyPressEvent(QKeyEvent* ev) +{ + if (d->interactive && d->page) + d->page->event(ev); + + if (!ev->isAccepted()) + QGraphicsItem::keyPressEvent(ev); +} + +/*! \reimp +*/ +void QGraphicsWebView::keyReleaseEvent(QKeyEvent* ev) +{ + if (d->interactive && d->page) + d->page->event(ev); + + if (!ev->isAccepted()) + QGraphicsItem::keyReleaseEvent(ev); +} + +/*! \reimp +*/ +void QGraphicsWebView::focusInEvent(QFocusEvent* ev) +{ + if (d->page) + d->page->event(ev); + else + QGraphicsItem::focusInEvent(ev); +} + +/*! \reimp +*/ +void QGraphicsWebView::focusOutEvent(QFocusEvent* ev) +{ + if (d->page) + d->page->event(ev); + else + QGraphicsItem::focusOutEvent(ev); +} + +/*! \reimp +*/ +bool QGraphicsWebView::focusNextPrevChild(bool next) +{ + if (d->page) + return d->page->focusNextPrevChild(next); + + return QGraphicsWidget::focusNextPrevChild(next); +} + +/*! \reimp +*/ +void QGraphicsWebView::dragEnterEvent(QGraphicsSceneDragDropEvent* ev) +{ +#ifndef QT_NO_DRAGANDDROP + //if (d->page) + // d->page->event(ev); + //Just remove this line below when the code above is working + Q_UNUSED(ev); +#else + Q_UNUSED(ev); +#endif +} + +/*! \reimp +*/ +void QGraphicsWebView::dragLeaveEvent(QGraphicsSceneDragDropEvent* ev) +{ +#ifndef QT_NO_DRAGANDDROP + if (d->interactive && d->page) { + const bool accepted = ev->isAccepted(); + d->page->event(ev); + ev->setAccepted(accepted); + } + + if (!ev->isAccepted()) + QGraphicsWidget::dragLeaveEvent(ev); +#else + Q_UNUSED(ev); +#endif +} + +/*! \reimp +*/ +void QGraphicsWebView::dragMoveEvent(QGraphicsSceneDragDropEvent* ev) +{ +#ifndef QT_NO_DRAGANDDROP + if (d->interactive && d->page) { + const bool accepted = ev->isAccepted(); + d->page->event(ev); + ev->setAccepted(accepted); + } + + if (!ev->isAccepted()) + QGraphicsWidget::dragMoveEvent(ev); +#else + Q_UNUSED(ev); +#endif +} + +/*! \reimp +*/ +void QGraphicsWebView::dropEvent(QGraphicsSceneDragDropEvent* ev) +{ +#ifndef QT_NO_DRAGANDDROP + if (d->interactive && d->page) { + const bool accepted = ev->isAccepted(); + d->page->event(ev); + ev->setAccepted(accepted); + } + + if (!ev->isAccepted()) + QGraphicsWidget::dropEvent(ev); +#else + Q_UNUSED(ev); +#endif +} + +#ifndef QT_NO_CONTEXTMENU +/*! \reimp +*/ +void QGraphicsWebView::contextMenuEvent(QGraphicsSceneContextMenuEvent* ev) +{ + if (d->page) { + const bool accepted = ev->isAccepted(); + d->page->event(ev); + ev->setAccepted(accepted); + } +} +#endif // QT_NO_CONTEXTMENU + +#ifndef QT_NO_WHEELEVENT +/*! \reimp +*/ +void QGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent* ev) +{ + if (d->interactive && d->page) { + const bool accepted = ev->isAccepted(); + d->page->event(ev); + ev->setAccepted(accepted); + } + + if (!ev->isAccepted()) + QGraphicsItem::wheelEvent(ev); +} +#endif // QT_NO_WHEELEVENT + +/*! \reimp +*/ +void QGraphicsWebView::inputMethodEvent(QInputMethodEvent* ev) +{ + if (d->interactive && d->page) + d->page->event(ev); + + if (!ev->isAccepted()) + QGraphicsItem::inputMethodEvent(ev); +} + +#include "moc_qgraphicswebview.cpp" diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h new file mode 100644 index 0000000..a8478d8 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.h @@ -0,0 +1,144 @@ +/* + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef QGraphicsWebView_h +#define QGraphicsWebView_h + +#include "qwebkitglobal.h" +#include +#include +#include +#include +#include +#include + +class QWebPage; +class QWebHistory; +class QWebSettings; + +class QGraphicsWebViewPrivate; + +class QWEBKIT_EXPORT QGraphicsWebView : public QGraphicsWidget { + Q_OBJECT + + Q_PROPERTY(QString title READ title NOTIFY titleChanged) + Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged) + Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged) + Q_PROPERTY(QString status READ status NOTIFY statusChanged) + + Q_PROPERTY(QString html READ toHtml WRITE setHtml) + Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) + Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) + + Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactivityChanged) + +public: + QGraphicsWebView(QGraphicsItem* parent = 0); + ~QGraphicsWebView(); + + QWebPage* page() const; + void setPage(QWebPage*); + + QUrl url() const; + void setUrl(const QUrl&); + + QString title() const; + QIcon icon() const; + + qreal zoomFactor() const; + void setZoomFactor(qreal); + + bool isInteractive() const; + void setInteractive(bool); + + qreal progress() const; + + void load(const QUrl &url); + void load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray& body = QByteArray()); + + QString toHtml() const; + void setHtml(const QString& html, const QUrl& baseUrl = QUrl()); + // FIXME: Consider rename to setHtml? + void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl()); + + QWebHistory* history() const; + QWebSettings* settings() const; + + QString status() const; + + virtual void setGeometry(const QRectF& rect); + virtual void updateGeometry(); + virtual void paint(QPainter*, const QStyleOptionGraphicsItem* options, QWidget* widget = 0); + virtual bool event(QEvent*); + +public Q_SLOTS: + void stop(); + void back(); + void forward(); + void reload(); + +Q_SIGNALS: + void loadStarted(); + void loadFinished(); + void loadFailed(); + + void progressChanged(qreal); + void interactivityChanged(); + void urlChanged(const QUrl&); + void titleChanged(const QString&); + void iconChanged(); + void statusChanged(); + void zoomFactorChanged(); + +protected: + virtual void mousePressEvent(QGraphicsSceneMouseEvent*); + virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*); + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*); + virtual void hoverMoveEvent(QGraphicsSceneHoverEvent*); + virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*); +#ifndef QT_NO_WHEELEVENT + virtual void wheelEvent(QGraphicsSceneWheelEvent*); +#endif + virtual void keyPressEvent(QKeyEvent*); + virtual void keyReleaseEvent(QKeyEvent*); +#ifndef QT_NO_CONTEXTMENU + virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*); +#endif + virtual void dragEnterEvent(QGraphicsSceneDragDropEvent*); + virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent*); + virtual void dragMoveEvent(QGraphicsSceneDragDropEvent*); + virtual void dropEvent(QGraphicsSceneDragDropEvent*); + virtual void focusInEvent(QFocusEvent*); + virtual void focusOutEvent(QFocusEvent*); + virtual void inputMethodEvent(QInputMethodEvent*); + virtual bool focusNextPrevChild(bool next); + + virtual bool sceneEvent(QEvent*); + +private: + Q_PRIVATE_SLOT(d, void _q_doLoadProgress(int progress)) + Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success)) + Q_PRIVATE_SLOT(d, void _q_setStatusBarMessage(const QString& message)) + + QGraphicsWebViewPrivate* const d; + friend class QGraphicsWebViewPrivate; +}; + +#endif // QGraphicsWebView_h diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebgraphicsitem.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebgraphicsitem.cpp deleted file mode 100644 index 196f0b8..0000000 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebgraphicsitem.cpp +++ /dev/null @@ -1,822 +0,0 @@ -/* - Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" -#include "qwebgraphicsitem.h" - -#include "qwebframe.h" -#include "qwebpage.h" -#include "qwebpage_p.h" -#include "QWebPageClient.h" -#include -#include -#include -#include -#include -#if defined(Q_WS_X11) -#include -#endif - -class QWebGraphicsItemPrivate : public QWebPageClient { -public: - QWebGraphicsItemPrivate(QWebGraphicsItem* parent) - : q(parent) - , page(0) - , interactive(true) - , progress(1.0) - {} - - virtual void scroll(int dx, int dy, const QRect&); - virtual void update(const QRect& dirtyRect); - - virtual QCursor cursor() const; - virtual void updateCursor(const QCursor& cursor); - - virtual int screenNumber() const; - virtual WId winId() const; - - void _q_doLoadProgress(int progress); - void _q_doLoadFinished(bool success); - void _q_setStatusBarMessage(const QString& message); - - QWebGraphicsItem* q; - QWebPage* page; - - QString statusBarMessage; - bool interactive; - qreal progress; -}; - -void QWebGraphicsItemPrivate::_q_doLoadProgress(int progress) -{ - if (qFuzzyCompare(this->progress, qreal(progress / 100.))) - return; - - this->progress = progress / 100.; - - emit q->progressChanged(this->progress); -} - -void QWebGraphicsItemPrivate::_q_doLoadFinished(bool success) -{ - // If the page had no title, still make sure it gets the signal - if (q->title().isEmpty()) - emit q->urlChanged(q->url()); - - if (success) - emit q->loadFinished(); - else - emit q->loadFailed(); -} - -void QWebGraphicsItemPrivate::scroll(int dx, int dy, const QRect& rectToScroll) -{ - q->scroll(qreal(dx), qreal(dy), QRectF(rectToScroll)); -} - -void QWebGraphicsItemPrivate::update(const QRect & dirtyRect) -{ - q->update(QRectF(dirtyRect)); -} - -QCursor QWebGraphicsItemPrivate::cursor() const -{ - return q->cursor(); -} - -void QWebGraphicsItemPrivate::updateCursor(const QCursor& cursor) -{ - q->setCursor(cursor); -} - -int QWebGraphicsItemPrivate::screenNumber() const -{ -#if defined(Q_WS_X11) - const QList views = q->scene()->views(); - - if (!views.isEmpty()) - return views.at(0)->x11Info().screen(); -#endif - - return 0; -} - -WId QWebGraphicsItemPrivate::winId() const -{ - const QList views = q->scene()->views(); - - if (!views.isEmpty()) - return views.at(0)->winId(); - - return 0; -} - -void QWebGraphicsItemPrivate::_q_setStatusBarMessage(const QString& s) -{ - statusBarMessage = s; - emit q->statusChanged(); -} - -/*! - \class QWebGraphicsItem - \brief The QWebGraphicsItem class allows web content to be added to a GraphicsView. - \since 4.6 - - A WebGraphicsItem renders web content based on a URL or set data. - - If the width and height of the item is not set, they will - dynamically adjust to a size appropriate for the content. - This width may be large (eg. 980) for typical online web pages. -*/ - -/*! - Constructs an empty QWebGraphicsItem with parent \a parent. - - \sa load() -*/ -QWebGraphicsItem::QWebGraphicsItem(QGraphicsItem* parent) - : QGraphicsWidget(parent) - , d(new QWebGraphicsItemPrivate(this)) -{ -#if QT_VERSION >= 0x040600 - setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); -#endif - setAcceptHoverEvents(true); - setFocusPolicy(Qt::StrongFocus); -} - -/*! - Destroys the web graphicsitem. -*/ -QWebGraphicsItem::~QWebGraphicsItem() -{ - if (d->page) - d->page->d->view = 0; - - if (d->page && d->page->parent() == this) - delete d->page; - - delete d; -} - -/*! - Returns a pointer to the underlying web page. - - \sa setPage() -*/ -QWebPage* QWebGraphicsItem::page() const -{ - if (!d->page) { - QWebGraphicsItem* that = const_cast(this); - QWebPage* page = new QWebPage(that); - - // Default to not having a background, in the case - // the page doesn't provide one. - QPalette palette = QApplication::palette(); - palette.setBrush(QPalette::Base, QColor::fromRgbF(0, 0, 0, 0)); - page->setPalette(palette); - - that->setPage(page); - } - - return d->page; -} - -/*! \reimp -*/ -void QWebGraphicsItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget*) -{ - page()->mainFrame()->render(painter, option->exposedRect.toRect()); -} - -/*! \reimp -*/ -bool QWebGraphicsItem::sceneEvent(QEvent* event) -{ - // Re-implemented in order to allows fixing event-related bugs in patch releases. - return QGraphicsWidget::sceneEvent(event); -} - -/*! \reimp -*/ -bool QWebGraphicsItem::event(QEvent* event) -{ - // Re-implemented in order to allows fixing event-related bugs in patch releases. - - if (d->page) { -#ifndef QT_NO_CURSOR -#if QT_VERSION >= 0x040400 - } else if (event->type() == QEvent::CursorChange) { - // An unsetCursor will set the cursor to Qt::ArrowCursor. - // Thus this cursor change might be a QWidget::unsetCursor() - // If this is not the case and it came from WebCore, the - // QWebPageClient already has set its cursor internally - // to Qt::ArrowCursor, so updating the cursor is always - // right, as it falls back to the last cursor set by - // WebCore. - // FIXME: Add a QEvent::CursorUnset or similar to Qt. - if (cursor().shape() == Qt::ArrowCursor) - d->resetCursor(); -#endif -#endif - } - return QGraphicsWidget::event(event); -} - -/*! - Makes \a page the new web page of the web graphicsitem. - - The parent QObject of the provided page remains the owner - of the object. If the current document is a child of the web - view, it will be deleted. - - \sa page() -*/ -void QWebGraphicsItem::setPage(QWebPage* page) -{ - if (d->page == page) - return; - - if (d->page) { - d->page->d->client = 0; // unset the page client - if (d->page->parent() == this) - delete d->page; - else - d->page->disconnect(this); - } - - d->page = page; - if (!d->page) - return; - d->page->d->client = d; // set the page client - - QSize size = geometry().size().toSize(); - page->setViewportSize(size); - - QWebFrame* mainFrame = d->page->mainFrame(); - - connect(mainFrame, SIGNAL(titleChanged(const QString&)), - this, SIGNAL(titleChanged(const QString&))); - connect(mainFrame, SIGNAL(iconChanged()), - this, SIGNAL(iconChanged())); - connect(mainFrame, SIGNAL(urlChanged(const QUrl&)), - this, SIGNAL(urlChanged(const QUrl&))); - connect(d->page, SIGNAL(loadStarted()), - this, SIGNAL(loadStarted())); - connect(d->page, SIGNAL(loadProgress(int)), - this, SLOT(_q_doLoadProgress(int))); - connect(d->page, SIGNAL(loadFinished(bool)), - this, SLOT(_q_doLoadFinished(bool))); - connect(d->page, SIGNAL(statusBarMessage(const QString&)), - this, SLOT(_q_setStatusBarMessage(const QString&))); -} - -/*! - \property QWebGraphicsItem::url - \brief the url of the web page currently viewed - - Setting this property clears the view and loads the URL. - - By default, this property contains an empty, invalid URL. - - \sa load(), urlChanged() -*/ - -void QWebGraphicsItem::setUrl(const QUrl &url) -{ - page()->mainFrame()->setUrl(url); -} - -QUrl QWebGraphicsItem::url() const -{ - if (d->page) - return d->page->mainFrame()->url(); - - return QUrl(); -} - -/*! - \property QWebGraphicsItem::title - \brief the title of the web page currently viewed - - By default, this property contains an empty string. - - \sa titleChanged() -*/ -QString QWebGraphicsItem::title() const -{ - if (d->page) - return d->page->mainFrame()->title(); - - return QString(); -} - -/*! - \property QWebGraphicsItem::icon - \brief the icon associated with the web page currently viewed - - By default, this property contains a null icon. - - \sa iconChanged(), QWebSettings::iconForUrl() -*/ -QIcon QWebGraphicsItem::icon() const -{ - if (d->page) - return d->page->mainFrame()->icon(); - - return QIcon(); -} - -/*! - \property QWebGraphicsItem::zoomFactor - \since 4.5 - \brief the zoom factor for the view -*/ - -void QWebGraphicsItem::setZoomFactor(qreal factor) -{ - if (factor == page()->mainFrame()->zoomFactor()) - return; - - page()->mainFrame()->setZoomFactor(factor); - emit zoomFactorChanged(); -} - -qreal QWebGraphicsItem::zoomFactor() const -{ - return page()->mainFrame()->zoomFactor(); -} - -/*! \reimp -*/ -void QWebGraphicsItem::updateGeometry() -{ - QGraphicsWidget::updateGeometry(); - - if (!d->page) - return; - - QSize size = geometry().size().toSize(); - d->page->setViewportSize(size); -} - -/*! \reimp -*/ -void QWebGraphicsItem::setGeometry(const QRectF& rect) -{ - QGraphicsWidget::setGeometry(rect); - - if (!d->page) - return; - - // NOTE: call geometry() as setGeometry ensures that - // the geometry is within legal bounds (minimumSize, maximumSize) - QSize size = geometry().size().toSize(); - d->page->setViewportSize(size); -} - -/*! - \brief The load status message associated to the web graphicsitem - - Provides the latest status message set during the load of a URL. - Commonly shown by Status Bar widgets. - - \sa statusChanged() -*/ - -QString QWebGraphicsItem::status() const -{ - return d->statusBarMessage; -} - -/*! - Convenience slot that stops loading the document. - - \sa reload(), loadFinished() -*/ -void QWebGraphicsItem::stop() -{ - if (d->page) - d->page->triggerAction(QWebPage::Stop); -} - -/*! - Convenience slot that loads the previous document in the list of documents - built by navigating links. Does nothing if there is no previous document. - - \sa forward() -*/ -void QWebGraphicsItem::back() -{ - if (d->page) - d->page->triggerAction(QWebPage::Back); -} - -/*! - Convenience slot that loads the next document in the list of documents - built by navigating links. Does nothing if there is no next document. - - \sa back() -*/ -void QWebGraphicsItem::forward() -{ - if (d->page) - d->page->triggerAction(QWebPage::Forward); -} - -/*! - Reloads the current document. - - \sa stop(), loadStarted() -*/ -void QWebGraphicsItem::reload() -{ - if (d->page) - d->page->triggerAction(QWebPage::Reload); -} - -/*! - \property QWebGraphicsItem::progress - \brief the progress of loading the current URL, from 0 to 1. -*/ -qreal QWebGraphicsItem::progress() const -{ - return d->progress; -} - -/*! - Loads the specified \a url and displays it. - - \note The view remains the same until enough data has arrived to display the new \a url. - - \sa setUrl(), url(), urlChanged() -*/ -void QWebGraphicsItem::load(const QUrl& url) -{ - page()->mainFrame()->load(url); -} - -/*! - \fn void QWebGraphicsItem::load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation, const QByteArray &body) - - Loads a network request, \a request, using the method specified in \a operation. - - \a body is optional and is only used for POST operations. - - \note The view remains the same until enough data has arrived to display the new url. - - \sa url(), urlChanged() -*/ - -void QWebGraphicsItem::load(const QNetworkRequest& request, - QNetworkAccessManager::Operation operation, - const QByteArray& body) -{ - page()->mainFrame()->load(request, operation, body); -} - -/*! - Sets the content of the web graphicsitem to the specified \a html. - - External objects such as stylesheets or images referenced in the HTML - document are located relative to \a baseUrl. - - The \a html is loaded immediately; external objects are loaded asynchronously. - - When using this method, WebKit assumes that external resources such as - JavaScript programs or style sheets are encoded in UTF-8 unless otherwise - specified. For example, the encoding of an external script can be specified - through the charset attribute of the HTML script tag. Alternatively, the - encoding can also be specified by the web server. - - \sa load(), setContent(), QWebFrame::toHtml() -*/ -void QWebGraphicsItem::setHtml(const QString& html, const QUrl& baseUrl) -{ - page()->mainFrame()->setHtml(html, baseUrl); -} - -QString QWebGraphicsItem::toHtml() const -{ - return page()->mainFrame()->toHtml(); -} - -/*! - Sets the content of the web graphicsitem to the specified content \a data. If the \a mimeType argument - is empty it is currently assumed that the content is HTML but in future versions we may introduce - auto-detection. - - External objects referenced in the content are located relative to \a baseUrl. - - The \a data is loaded immediately; external objects are loaded asynchronously. - - \sa load(), setHtml(), QWebFrame::toHtml() -*/ -void QWebGraphicsItem::setContent(const QByteArray& data, const QString& mimeType, const QUrl& baseUrl) -{ - page()->mainFrame()->setContent(data, mimeType, baseUrl); -} - -/*! - Returns a pointer to the view's history of navigated web pages. - - It is equivalent to - - \snippet webkitsnippets/qtwebkit_qwebview_snippet.cpp 0 -*/ -QWebHistory* QWebGraphicsItem::history() const -{ - return page()->history(); -} - -/*! - \property QWebGraphicsItem::interactive - \brief controls whether the item responds to mouse and key events. -*/ - -bool QWebGraphicsItem::isInteractive() const -{ - return d->interactive; -} - -void QWebGraphicsItem::setInteractive(bool allowed) -{ - if (d->interactive == allowed) - return; - - d->interactive = allowed; - emit interactivityChanged(); -} - -/*! - Returns a pointer to the view/page specific settings object. - - It is equivalent to - - \snippet webkitsnippets/qtwebkit_qwebview_snippet.cpp 1 - - \sa QWebSettings::globalSettings() -*/ -QWebSettings* QWebGraphicsItem::settings() const -{ - return page()->settings(); -} - -/*! \reimp -*/ -void QWebGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent* ev) -{ - if (d->interactive && d->page) { - const bool accepted = ev->isAccepted(); - QMouseEvent me = QMouseEvent(QEvent::MouseMove, - ev->pos().toPoint(), Qt::NoButton, - Qt::NoButton, Qt::NoModifier); - d->page->setView(ev->widget()); - d->page->event(&me); - ev->setAccepted(accepted); - } - - if (!ev->isAccepted()) - QGraphicsItem::hoverMoveEvent(ev); -} - -/*! \reimp -*/ -void QWebGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* ev) -{ - Q_UNUSED(ev); -} - -/*! \reimp -*/ -void QWebGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) -{ - if (d->interactive && d->page) { - const bool accepted = ev->isAccepted(); - d->page->event(ev); - ev->setAccepted(accepted); - } - - if (!ev->isAccepted()) - QGraphicsItem::mouseMoveEvent(ev); -} - -/*! \reimp -*/ -void QWebGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent* ev) -{ - if (d->interactive && d->page) { - const bool accepted = ev->isAccepted(); - d->page->event(ev); - ev->setAccepted(accepted); - } - - if (!ev->isAccepted()) - QGraphicsItem::mousePressEvent(ev); -} - -/*! \reimp -*/ -void QWebGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) -{ - if (d->interactive && d->page) { - const bool accepted = ev->isAccepted(); - d->page->event(ev); - ev->setAccepted(accepted); - } - - if (!ev->isAccepted()) - QGraphicsItem::mouseReleaseEvent(ev); -} - -/*! \reimp -*/ -void QWebGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev) -{ - if (d->interactive && d->page) { - const bool accepted = ev->isAccepted(); - d->page->event(ev); - ev->setAccepted(accepted); - } - - if (!ev->isAccepted()) - QGraphicsItem::mouseDoubleClickEvent(ev); -} - -/*! \reimp -*/ -void QWebGraphicsItem::keyPressEvent(QKeyEvent* ev) -{ - if (d->interactive && d->page) - d->page->event(ev); - - if (!ev->isAccepted()) - QGraphicsItem::keyPressEvent(ev); -} - -/*! \reimp -*/ -void QWebGraphicsItem::keyReleaseEvent(QKeyEvent* ev) -{ - if (d->interactive && d->page) - d->page->event(ev); - - if (!ev->isAccepted()) - QGraphicsItem::keyReleaseEvent(ev); -} - -/*! \reimp -*/ -void QWebGraphicsItem::focusInEvent(QFocusEvent* ev) -{ - if (d->page) - d->page->event(ev); - else - QGraphicsItem::focusInEvent(ev); -} - -/*! \reimp -*/ -void QWebGraphicsItem::focusOutEvent(QFocusEvent* ev) -{ - if (d->page) - d->page->event(ev); - else - QGraphicsItem::focusOutEvent(ev); -} - -/*! \reimp -*/ -bool QWebGraphicsItem::focusNextPrevChild(bool next) -{ - if (d->page) - return d->page->focusNextPrevChild(next); - - return QGraphicsWidget::focusNextPrevChild(next); -} - -/*! \reimp -*/ -void QWebGraphicsItem::dragEnterEvent(QGraphicsSceneDragDropEvent* ev) -{ -#ifndef QT_NO_DRAGANDDROP - //if (d->page) - // d->page->event(ev); - //Just remove this line below when the code above is working - Q_UNUSED(ev); -#else - Q_UNUSED(ev); -#endif -} - -/*! \reimp -*/ -void QWebGraphicsItem::dragLeaveEvent(QGraphicsSceneDragDropEvent* ev) -{ -#ifndef QT_NO_DRAGANDDROP - if (d->interactive && d->page) { - const bool accepted = ev->isAccepted(); - d->page->event(ev); - ev->setAccepted(accepted); - } - - if (!ev->isAccepted()) - QGraphicsWidget::dragLeaveEvent(ev); -#else - Q_UNUSED(ev); -#endif -} - -/*! \reimp -*/ -void QWebGraphicsItem::dragMoveEvent(QGraphicsSceneDragDropEvent* ev) -{ -#ifndef QT_NO_DRAGANDDROP - if (d->interactive && d->page) { - const bool accepted = ev->isAccepted(); - d->page->event(ev); - ev->setAccepted(accepted); - } - - if (!ev->isAccepted()) - QGraphicsWidget::dragMoveEvent(ev); -#else - Q_UNUSED(ev); -#endif -} - -/*! \reimp -*/ -void QWebGraphicsItem::dropEvent(QGraphicsSceneDragDropEvent* ev) -{ -#ifndef QT_NO_DRAGANDDROP - if (d->interactive && d->page) { - const bool accepted = ev->isAccepted(); - d->page->event(ev); - ev->setAccepted(accepted); - } - - if (!ev->isAccepted()) - QGraphicsWidget::dropEvent(ev); -#else - Q_UNUSED(ev); -#endif -} - -#ifndef QT_NO_CONTEXTMENU -/*! \reimp -*/ -void QWebGraphicsItem::contextMenuEvent(QGraphicsSceneContextMenuEvent* ev) -{ - if (d->page) { - const bool accepted = ev->isAccepted(); - d->page->event(ev); - ev->setAccepted(accepted); - } -} -#endif // QT_NO_CONTEXTMENU - -#ifndef QT_NO_WHEELEVENT -/*! \reimp -*/ -void QWebGraphicsItem::wheelEvent(QGraphicsSceneWheelEvent* ev) -{ - if (d->interactive && d->page) { - const bool accepted = ev->isAccepted(); - d->page->event(ev); - ev->setAccepted(accepted); - } - - if (!ev->isAccepted()) - QGraphicsItem::wheelEvent(ev); -} -#endif // QT_NO_WHEELEVENT - -/*! \reimp -*/ -void QWebGraphicsItem::inputMethodEvent(QInputMethodEvent* ev) -{ - if (d->interactive && d->page) - d->page->event(ev); - - if (!ev->isAccepted()) - QGraphicsItem::inputMethodEvent(ev); -} - -#include "moc_qwebgraphicsitem.cpp" diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebgraphicsitem.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebgraphicsitem.h deleted file mode 100644 index 2c6817a..0000000 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebgraphicsitem.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef QWebGraphicsItem_h -#define QWebGraphicsItem_h - -#include "qwebkitglobal.h" -#include -#include -#include -#include -#include -#include - -class QWebPage; -class QWebHistory; -class QWebSettings; - -class QWebGraphicsItemPrivate; - -class QWEBKIT_EXPORT QWebGraphicsItem : public QGraphicsWidget { - Q_OBJECT - - Q_PROPERTY(QString title READ title NOTIFY titleChanged) - Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged) - Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged) - Q_PROPERTY(QString status READ status NOTIFY statusChanged) - - Q_PROPERTY(QString html READ toHtml WRITE setHtml) - Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) - Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) - - Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactivityChanged) - -public: - QWebGraphicsItem(QGraphicsItem* parent = 0); - ~QWebGraphicsItem(); - - QWebPage* page() const; - void setPage(QWebPage*); - - QUrl url() const; - void setUrl(const QUrl&); - - QString title() const; - QIcon icon() const; - - qreal zoomFactor() const; - void setZoomFactor(qreal); - - bool isInteractive() const; - void setInteractive(bool); - - qreal progress() const; - - void load(const QUrl &url); - void load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray& body = QByteArray()); - - QString toHtml() const; - void setHtml(const QString& html, const QUrl& baseUrl = QUrl()); - // FIXME: Consider rename to setHtml? - void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl()); - - QWebHistory* history() const; - QWebSettings* settings() const; - - QString status() const; - - virtual void setGeometry(const QRectF& rect); - virtual void updateGeometry(); - virtual void paint(QPainter*, const QStyleOptionGraphicsItem* options, QWidget* widget = 0); - virtual bool event(QEvent*); - -public Q_SLOTS: - void stop(); - void back(); - void forward(); - void reload(); - -Q_SIGNALS: - void loadStarted(); - void loadFinished(); - void loadFailed(); - - void progressChanged(qreal); - void interactivityChanged(); - void urlChanged(const QUrl&); - void titleChanged(const QString&); - void iconChanged(); - void statusChanged(); - void zoomFactorChanged(); - -protected: - virtual void mousePressEvent(QGraphicsSceneMouseEvent*); - virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*); - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*); - virtual void hoverMoveEvent(QGraphicsSceneHoverEvent*); - virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*); -#ifndef QT_NO_WHEELEVENT - virtual void wheelEvent(QGraphicsSceneWheelEvent*); -#endif - virtual void keyPressEvent(QKeyEvent*); - virtual void keyReleaseEvent(QKeyEvent*); -#ifndef QT_NO_CONTEXTMENU - virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*); -#endif - virtual void dragEnterEvent(QGraphicsSceneDragDropEvent*); - virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent*); - virtual void dragMoveEvent(QGraphicsSceneDragDropEvent*); - virtual void dropEvent(QGraphicsSceneDragDropEvent*); - virtual void focusInEvent(QFocusEvent*); - virtual void focusOutEvent(QFocusEvent*); - virtual void inputMethodEvent(QInputMethodEvent*); - virtual bool focusNextPrevChild(bool next); - - virtual bool sceneEvent(QEvent*); - -private: - Q_PRIVATE_SLOT(d, void _q_doLoadProgress(int progress)) - Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success)) - Q_PRIVATE_SLOT(d, void _q_setStatusBarMessage(const QString& message)) - - QWebGraphicsItemPrivate* const d; - friend class QWebGraphicsItemPrivate; -}; - -#endif // QWebGraphicsItem_h diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h index b024997..41d1835 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h @@ -371,7 +371,7 @@ private: friend class QWebFrame; friend class QWebPagePrivate; friend class QWebView; - friend class QWebGraphicsItem; + friend class QGraphicsWebView; friend class QWebInspector; friend class WebCore::ChromeClientQt; friend class WebCore::EditorClientQt; diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/qgraphicswebview.pro b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/qgraphicswebview.pro new file mode 100644 index 0000000..cba6f11 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/qgraphicswebview.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +TARGET = tst_qgraphicswebview +include(../../../../WebKit.pri) +SOURCES += tst_qgraphicswebview.cpp +QT += testlib network +QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp new file mode 100644 index 0000000..1a57286 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp @@ -0,0 +1,58 @@ +/* + Copyright (C) 2009 Jakub Wieczorek + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include + +#include + +class tst_QGraphicsWebView : public QObject +{ + Q_OBJECT + +private slots: + void qgraphicswebview(); +}; + +void tst_QGraphicsWebView::qgraphicswebview() +{ + QGraphicsWebView item; + item.url(); + item.title(); + item.icon(); + item.zoomFactor(); + item.isInteractive(); + item.progress(); + item.toHtml(); + item.history(); + item.settings(); + item.status(); + item.page(); + item.setPage(0); + item.page(); + item.setUrl(QUrl()); + item.setZoomFactor(0); + item.setInteractive(true); + item.load(QUrl()); + item.setHtml(QString()); + item.setContent(QByteArray()); +} + +QTEST_MAIN(tst_QGraphicsWebView) + +#include "tst_qgraphicswebview.moc" diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebgraphicsitem/qwebgraphicsitem.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebgraphicsitem/qwebgraphicsitem.pro deleted file mode 100644 index 39e90e7..0000000 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebgraphicsitem/qwebgraphicsitem.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = app -TARGET = tst_qwebgraphicsitem -include(../../../../WebKit.pri) -SOURCES += tst_qwebgraphicsitem.cpp -QT += testlib network -QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebgraphicsitem/tst_qwebgraphicsitem.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebgraphicsitem/tst_qwebgraphicsitem.cpp deleted file mode 100644 index 731e342..0000000 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebgraphicsitem/tst_qwebgraphicsitem.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2009 Jakub Wieczorek - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include - -#include - -class tst_QWebGraphicsItem : public QObject -{ - Q_OBJECT - -private slots: - void qwebgraphicsitem(); -}; - -void tst_QWebGraphicsItem::qwebgraphicsitem() -{ - QWebGraphicsItem item; - item.url(); - item.title(); - item.icon(); - item.zoomFactor(); - item.isInteractive(); - item.progress(); - item.toHtml(); - item.history(); - item.settings(); - item.status(); - item.page(); - item.setPage(0); - item.page(); - item.setUrl(QUrl()); - item.setZoomFactor(0); - item.setInteractive(true); - item.load(QUrl()); - item.setHtml(QString()); - item.setContent(QByteArray()); -} - -QTEST_MAIN(tst_QWebGraphicsItem) - -#include "tst_qwebgraphicsitem.moc" diff --git a/src/3rdparty/webkit/WebKit/qt/tests/tests.pro b/src/3rdparty/webkit/WebKit/qt/tests/tests.pro index ec496e3..81cc8f3 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/tests.pro +++ b/src/3rdparty/webkit/WebKit/qt/tests/tests.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs -SUBDIRS = qwebframe qwebpage qwebelement qwebgraphicsitem qwebhistoryinterface qwebplugindatabase qwebview qwebhistory +SUBDIRS = qwebframe qwebpage qwebelement qgraphicswebview qwebhistoryinterface qwebplugindatabase qwebview qwebhistory greaterThan(QT_MINOR_VERSION, 4): SUBDIRS += benchmarks/painting/tst_painting.pro benchmarks/loading/tst_loading.pro -- cgit v0.12