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 Q_PROPERTY(KUrl url READ url WRITE setUrl) 00051 Q_PROPERTY(QString html READ html WRITE setHtml) 00052 Q_PROPERTY(bool dragToScroll READ dragToScroll WRITE setDragToScroll) 00053 Q_PROPERTY(QPointF scrollPosition READ scrollPosition WRITE setScrollPosition) 00054 Q_PROPERTY(QSizeF contentsSize READ contentsSize) 00055 Q_PROPERTY(QRectF viewportGeometry READ viewportGeometry) 00056 Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor) 00057 00058 public: 00059 explicit WebView(QGraphicsItem *parent = 0); 00060 ~WebView(); 00061 00067 void setUrl(const KUrl &url); 00068 00072 KUrl url() const; 00073 00081 void setHtml(const QByteArray &html, const KUrl &baseUrl = KUrl()); 00082 00086 QString html() const; 00087 00095 void setHtml(const QString &html, const KUrl &baseUrl = KUrl()); 00096 00100 QRectF geometry() const; 00101 00106 QSizeF contentsSize() const; 00107 00112 void setScrollPosition(const QPointF &position); 00113 00118 QPointF scrollPosition() const; 00119 00124 QRectF viewportGeometry() const; 00125 00131 qreal zoomFactor() const; 00132 00138 void setZoomFactor(const qreal zoom); 00139 00147 void setPage(QWebPage *page); 00148 00153 QWebPage *page() const; 00154 00158 QWebFrame *mainFrame() const; 00159 00164 void setDragToScroll(bool drag); 00165 00170 bool dragToScroll(); 00171 00175 void setGeometry(const QRectF &geometry); 00176 00177 public Q_SLOTS: 00182 void back(); 00183 00188 void forward(); 00189 00194 void reload(); 00195 00200 void stop(); 00201 00202 Q_SIGNALS: 00209 void loadProgress(int percent); 00210 00217 void loadFinished(bool success); 00218 00223 void urlChanged(const QUrl &url); 00224 00225 protected: 00229 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); 00230 void mouseMoveEvent(QGraphicsSceneMouseEvent *event); 00231 void hoverMoveEvent(QGraphicsSceneHoverEvent *event); 00232 void mousePressEvent(QGraphicsSceneMouseEvent *event); 00233 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); 00234 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); 00235 void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); 00236 void wheelEvent(QGraphicsSceneWheelEvent *event); 00237 void keyPressEvent(QKeyEvent * event); 00238 void keyReleaseEvent(QKeyEvent * event); 00239 void focusInEvent(QFocusEvent * event); 00240 void focusOutEvent(QFocusEvent * event); 00241 void dragEnterEvent(QGraphicsSceneDragDropEvent * event); 00242 void dragLeaveEvent(QGraphicsSceneDragDropEvent * event); 00243 void dragMoveEvent(QGraphicsSceneDragDropEvent * event); 00244 void dropEvent(QGraphicsSceneDragDropEvent * event); 00245 QVariant itemChange(GraphicsItemChange change, const QVariant &value); 00246 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; 00247 00248 private: 00249 Q_PRIVATE_SLOT(d, void loadingFinished(bool success)) 00250 00251 WebViewPrivate * const d; 00252 friend class WebViewPrivate; 00253 }; 00254 00255 } // namespace Plasma 00256 00257 #endif // Multiple incluson guard 00258
KDE 4.6 API Reference