svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=796610
This commit is contained in:
Alexis Ménard 2008-04-13 21:21:50 +00:00
parent ba0b04412c
commit 1605283e9e
2 changed files with 28 additions and 29 deletions

View File

@ -41,8 +41,8 @@ public:
bool loaded; bool loaded;
}; };
WebContent::WebContent(QGraphicsItem *parent , QObject *parentObject) WebContent::WebContent(QGraphicsItem *parent)
: Widget(parent, parentObject), : QGraphicsWidget(parent),
d(new Private) d(new Private)
{ {
d->page = 0; d->page = 0;
@ -70,13 +70,13 @@ void WebContent::setHtml(const QByteArray &html, const QUrl &baseUrl)
} }
} }
QSizeF WebContent::sizeHint() const QSizeF WebContent::geometry() const
{ {
if (d->loaded && d->page) { if (d->loaded && d->page) {
return d->page->mainFrame()->contentsSize(); return d->page->mainFrame()->contentsSize();
} }
return Widget::size(); return QGraphicsWidget::geometry().size();
} }
void WebContent::setPage(QWebPage *page) void WebContent::setPage(QWebPage *page)
@ -107,7 +107,7 @@ QWebFrame* WebContent::mainFrame() const
return d->page ? d->page->mainFrame() : 0; return d->page ? d->page->mainFrame() : 0;
} }
void WebContent::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void WebContent::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
Q_UNUSED(widget) Q_UNUSED(widget)
@ -120,7 +120,7 @@ void WebContent::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *
void WebContent::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void WebContent::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (!d->page) { if (!d->page) {
Widget::mouseMoveEvent(event); QGraphicsWidget::mouseMoveEvent(event);
return; return;
} }
@ -135,7 +135,7 @@ void WebContent::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void WebContent::mousePressEvent(QGraphicsSceneMouseEvent *event) void WebContent::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (!d->page) { if (!d->page) {
Widget::mousePressEvent(event); QGraphicsWidget::mousePressEvent(event);
return; return;
} }
@ -150,7 +150,7 @@ void WebContent::mousePressEvent(QGraphicsSceneMouseEvent *event)
void WebContent::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void WebContent::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{ {
if (!d->page) { if (!d->page) {
Widget::mouseDoubleClickEvent(event); QGraphicsWidget::mouseDoubleClickEvent(event);
return; return;
} }
@ -165,7 +165,7 @@ void WebContent::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
void WebContent::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void WebContent::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (!d->page) { if (!d->page) {
Widget::mouseReleaseEvent(event); QGraphicsWidget::mouseReleaseEvent(event);
return; return;
} }
@ -180,7 +180,7 @@ void WebContent::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void WebContent::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void WebContent::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{ {
if (!d->page) { if (!d->page) {
Widget::contextMenuEvent(event); QGraphicsWidget::contextMenuEvent(event);
return; return;
} }
@ -195,7 +195,7 @@ void WebContent::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
void WebContent::wheelEvent(QGraphicsSceneWheelEvent *event) void WebContent::wheelEvent(QGraphicsSceneWheelEvent *event)
{ {
if (!d->page) { if (!d->page) {
Widget::wheelEvent(event); QGraphicsWidget::wheelEvent(event);
return; return;
} }
@ -207,35 +207,35 @@ void WebContent::wheelEvent(QGraphicsSceneWheelEvent *event)
if (we.isAccepted()) { if (we.isAccepted()) {
event->accept(); event->accept();
} else { } else {
Widget::wheelEvent(event); QGraphicsWidget::wheelEvent(event);
} }
} }
void WebContent::keyPressEvent(QKeyEvent * event) void WebContent::keyPressEvent(QKeyEvent * event)
{ {
if (!d->page) { if (!d->page) {
Widget::keyPressEvent(event); QGraphicsWidget::keyPressEvent(event);
return; return;
} }
d->page->event(event); d->page->event(event);
if (!event->isAccepted()) { if (!event->isAccepted()) {
Widget::keyPressEvent(event); QGraphicsWidget::keyPressEvent(event);
} }
} }
void WebContent::keyReleaseEvent(QKeyEvent * event) void WebContent::keyReleaseEvent(QKeyEvent * event)
{ {
if (!d->page) { if (!d->page) {
Widget::keyReleaseEvent(event); QGraphicsWidget::keyReleaseEvent(event);
return; return;
} }
d->page->event(event); d->page->event(event);
if (!event->isAccepted()) { if (!event->isAccepted()) {
Widget::keyPressEvent(event); QGraphicsWidget::keyPressEvent(event);
} }
} }
@ -245,7 +245,7 @@ void WebContent::focusInEvent(QFocusEvent * event)
d->page->event(event); d->page->event(event);
} }
Widget::focusInEvent(event); QGraphicsWidget::focusInEvent(event);
} }
void WebContent::focusOutEvent(QFocusEvent * event) void WebContent::focusOutEvent(QFocusEvent * event)
@ -254,13 +254,13 @@ void WebContent::focusOutEvent(QFocusEvent * event)
d->page->event(event); d->page->event(event);
} }
Widget::focusOutEvent(event); QGraphicsWidget::focusOutEvent(event);
} }
void WebContent::dragEnterEvent(QGraphicsSceneDragDropEvent * event) void WebContent::dragEnterEvent(QGraphicsSceneDragDropEvent * event)
{ {
if (!d->page) { if (!d->page) {
Widget::dragEnterEvent(event); QGraphicsWidget::dragEnterEvent(event);
return; return;
} }
@ -276,7 +276,7 @@ void WebContent::dragEnterEvent(QGraphicsSceneDragDropEvent * event)
void WebContent::dragLeaveEvent(QGraphicsSceneDragDropEvent * event) void WebContent::dragLeaveEvent(QGraphicsSceneDragDropEvent * event)
{ {
if (!d->page) { if (!d->page) {
Widget::dragLeaveEvent(event); QGraphicsWidget::dragLeaveEvent(event);
return; return;
} }
@ -291,7 +291,7 @@ void WebContent::dragLeaveEvent(QGraphicsSceneDragDropEvent * event)
void WebContent::dragMoveEvent(QGraphicsSceneDragDropEvent * event) void WebContent::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
{ {
if (!d->page) { if (!d->page) {
Widget::dragMoveEvent(event); QGraphicsWidget::dragMoveEvent(event);
return; return;
} }
@ -309,7 +309,7 @@ void WebContent::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
void WebContent::dropEvent(QGraphicsSceneDragDropEvent * event) void WebContent::dropEvent(QGraphicsSceneDragDropEvent * event)
{ {
if (!d->page) { if (!d->page) {
Widget::dropEvent(event); QGraphicsWidget::dropEvent(event);
return; return;
} }
@ -324,7 +324,7 @@ void WebContent::dropEvent(QGraphicsSceneDragDropEvent * event)
void WebContent::setGeometry(const QRectF &geometry) void WebContent::setGeometry(const QRectF &geometry)
{ {
Widget::setGeometry(geometry); QGraphicsWidget::setGeometry(geometry);
d->page->setViewportSize(geometry.size().toSize()); d->page->setViewportSize(geometry.size().toSize());
} }

View File

@ -21,8 +21,7 @@
#define PLASMA_WEBCONTENT_H #define PLASMA_WEBCONTENT_H
#include <plasma/plasma_export.h> #include <plasma/plasma_export.h>
#include <plasma/widgets/widget.h> #include <QGraphicsWidget>
class QWebPage; class QWebPage;
class QWebFrame; class QWebFrame;
class QKeyEvent; class QKeyEvent;
@ -33,12 +32,12 @@ class QGraphicsSceneWheelEvent;
namespace Plasma namespace Plasma
{ {
class PLASMA_EXPORT WebContent : public Widget class PLASMA_EXPORT WebContent : public QGraphicsWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit WebContent(QGraphicsItem *parent = 0 , QObject *parentObject = 0); explicit WebContent(QGraphicsItem *parent = 0);
~WebContent(); ~WebContent();
/** /**
@ -60,7 +59,7 @@ class PLASMA_EXPORT WebContent : public Widget
/** /**
* Reimplementation * Reimplementation
*/ */
QSizeF sizeHint() const; QSizeF geometry() const;
/** /**
* Sets the page to use in this item. The owner of the webpage remains, * Sets the page to use in this item. The owner of the webpage remains,
@ -108,7 +107,7 @@ class PLASMA_EXPORT WebContent : public Widget
/** /**
* Reimplementation * Reimplementation
*/ */
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);