Plasma
webview.h
Go to the documentation of this file.00001 /* 00002 * Copyright 2006-2007 Aaron Seigo <aseigo@kde.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program 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 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef PLASMA_WEBVIEW_H 00021 #define PLASMA_WEBVIEW_H 00022 00023 #include <plasma/plasma_export.h> 00024 #include <QtGui/QGraphicsWidget> 00025 00026 #include <kurl.h> 00027 00028 class QWebPage; 00029 class QWebFrame; 00030 class QKeyEvent; 00031 class QGraphicsSceneDragDropEvent; 00032 class QGraphicsSceneMouseEvent; 00033 class QGraphicsSceneWheelEvent; 00034 class QRect; 00035 00036 namespace Plasma 00037 { 00038 00039 class WebViewPrivate; 00040 00046 class PLASMA_EXPORT WebView : public QGraphicsWidget 00047 { 00048 Q_OBJECT 00049 00050 public: 00051 explicit WebView(QGraphicsItem *parent = 0); 00052 ~WebView(); 00053 00059 void setUrl(const KUrl &url); 00060 00068 void setHtml(const QByteArray &html, const KUrl &baseUrl = KUrl()); 00069 00077 void setHtml(const QString &html, const KUrl &baseUrl = KUrl()); 00078 00082 QRectF geometry() const; 00083 00091 void setPage(QWebPage *page); 00092 00097 QWebPage *page() const; 00098 00102 QWebFrame *mainFrame() const; 00103 00107 void setGeometry(const QRectF &geometry); 00108 00109 Q_SIGNALS: 00116 void loadProgress(int percent); 00117 00124 void loadFinished(bool success); 00125 00126 protected: 00130 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); 00131 void mouseMoveEvent(QGraphicsSceneMouseEvent *event); 00132 void hoverMoveEvent(QGraphicsSceneHoverEvent *event); 00133 void mousePressEvent(QGraphicsSceneMouseEvent *event); 00134 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); 00135 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); 00136 void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); 00137 void wheelEvent(QGraphicsSceneWheelEvent *event); 00138 void keyPressEvent(QKeyEvent * event); 00139 void keyReleaseEvent(QKeyEvent * event); 00140 void focusInEvent(QFocusEvent * event); 00141 void focusOutEvent(QFocusEvent * event); 00142 void dragEnterEvent(QGraphicsSceneDragDropEvent * event); 00143 void dragLeaveEvent(QGraphicsSceneDragDropEvent * event); 00144 void dragMoveEvent(QGraphicsSceneDragDropEvent * event); 00145 void dropEvent(QGraphicsSceneDragDropEvent * event); 00146 00147 private: 00148 Q_PRIVATE_SLOT(d, void loadingFinished(bool success)) 00149 Q_PRIVATE_SLOT(d, void updateRequested(const QRect& dirtyRect)) 00150 Q_PRIVATE_SLOT(d, void scrollRequested(int dx, int dy, const QRect &scrollRect)) 00151 00152 WebViewPrivate * const d; 00153 friend class WebViewPrivate; 00154 }; 00155 00156 } // namespace Plasma 00157 00158 #endif // Multiple incluson guard 00159