1 /* This file is part of the KDE project 2 Copyright (C) 2011 Shreya Pandit <shreya@shreyapandit.com> 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this library; see the file COPYING.LIB. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef WEBBROWSERWIDGET_H 21 #define WEBBROWSERWIDGET_H 22 #include <QProgressBar> 23 #include <QWidget> 24 #include "widgetfactory.h" 25 #include "container.h" 26 #include <formeditor/FormWidgetInterface.h> 27 #include <widget/dataviewcommon/kexiformdataiteminterface.h> 28 #include <QHBoxLayout> 29 #include <QVBoxLayout> 30 #include <QUrl> 31 #include<QWebView> 32 33 class QPushButton; 34 class QWebView; 35 class QVBoxLayout; 36 class QWebHistory; 37 class QHBoxLayout; 38 class QProgressBar; 39 class QHBoxLayout; 40 class QUrl; 41 42 class WebBrowserWidget : public QWidget, 43 public KexiFormDataItemInterface, 44 public KFormDesigner::FormWidgetInterface 45 { 46 Q_OBJECT 47 48 Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource) 49 Q_PROPERTY(QString dataSourcePartClass READ dataSourcePluginId WRITE setDataSourcePluginId) 50 Q_PROPERTY(QString url READ url WRITE setUrl) 51 Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor) 52 Q_PROPERTY(QString title READ title) 53 Q_PROPERTY(QIcon icon READ icon) 54 Q_PROPERTY(bool modified READ modified) 55 Q_PROPERTY(qreal textScale READ textScale WRITE setTextScale) 56 57 public: 58 explicit WebBrowserWidget(QWidget *parent = 0); 59 ~WebBrowserWidget(); 60 61 inline QString dataSource() const { 62 return KexiFormDataItemInterface::dataSource(); 63 } 64 inline QString dataSourcePluginId() const { 65 return KexiFormDataItemInterface::dataSourcePluginId(); 66 } 67 68 inline QString url() const { 69 70 return m_view->url().toString(); 71 } 72 73 inline bool modified() const { 74 75 return m_view->isModified(); 76 } 77 78 inline QString title() const { 79 80 return m_view->title(); 81 } 82 83 inline qreal zoomFactor() const { 84 85 return m_view->zoomFactor(); 86 } 87 88 inline QIcon icon() const 89 { 90 return m_view->icon(); 91 } 92 93 inline qreal textScale () const 94 { 95 return m_view->textSizeMultiplier(); 96 } 97 98 virtual QVariant value(); 99 virtual bool valueIsNull(); 100 virtual bool valueIsEmpty(); 101 virtual bool cursorAtStart(); 102 virtual bool cursorAtEnd(); 103 virtual void clear(); 104 void updateToolBar(); 105 bool isReadOnly() const; 106 virtual void setReadOnly(bool readOnly); 107 virtual void setInvalidState(const QString& displayText); 108 109 public Q_SLOTS: 110 void setDataSource(const QString &ds); 111 void setDataSourcePluginId(const QString &ds); 112 void setUrl(const QString& url); 113 void setZoomFactor(qreal factor); 114 void setTextScale(qreal scale); 115 void hide_bar(); 116 117 protected: 118 virtual void setValueInternal(const QVariant& add, bool removeOld); 119 void setUrl(const QUrl& url); 120 bool m_readOnly; 121 122 private: 123 QWebView* m_view; 124 QVBoxLayout* v_layout; 125 QProgressBar* m_pbar; 126 bool m_urlChanged_enabled; 127 QPushButton* m_back; 128 QPushButton* m_forward; 129 QPushButton* m_reload; 130 QPushButton* m_stop; 131 QHBoxLayout* h_layout; 132 }; 133 134 #endif 135