[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bcalligra/kexi-web-Shreya=5D_kexi/plugins/forms/widg?=
From: Shreya Pandit <shreya () shreyapandit ! com>
Date: 2011-06-15 15:23:10
Message-ID: 20110615152310.814BCA60A4 () git ! kde ! org
[Download RAW message or body]
Git commit 397f7a91ddf47ec69eea60eab3de7bd3e8c0c161 by Shreya Pandit.
Committed on 15/06/2011 at 14:17.
Pushed by pandit into branch 'kexi-web-Shreya'.
modified
A +35 -0 kexi/plugins/forms/widgets/CMakeLists.txt
A +98 -0 kexi/plugins/forms/widgets/WebBrowserFactory.cpp [License: \
LGPL (v2.1+)] A +44 -0 kexi/plugins/forms/widgets/WebBrowserFactory.h \
[License: LGPL (v2.1+)] A +171 -0 \
kexi/plugins/forms/widgets/WebBrowserWidget.cpp [License: LGPL (v2.1+)] A \
+120 -0 kexi/plugins/forms/widgets/WebBrowserWidget.h [License: LGPL \
(v2+)]
http://commits.kde.org/calligra/397f7a91ddf47ec69eea60eab3de7bd3e8c0c161
diff --git a/kexi/plugins/forms/widgets/CMakeLists.txt \
b/kexi/plugins/forms/widgets/CMakeLists.txt new file mode 100644
index 0000000..d3a777f
--- /dev/null
+++ b/kexi/plugins/forms/widgets/CMakeLists.txt
@@ -0,0 +1,35 @@
+include_directories( ${CMAKE_SOURCE_DIR}/kexi ${CMAKE_SOURCE_DIR}/kexi/formeditor \
${CMAKE_SOURCE_DIR}/kexi/core ${CMAKE_SOURCE_DIR}/libs ${CMAKE_SOURCE_DIR}/libs/main \
${KDE4_INCLUDES} ) +
+
+
+set(kformdesigner_webbrowser_PART_SRCS
+ WebBrowserWidget.cpp
+ WebBrowserFactory.cpp)
+
+
+kde4_add_library(kformdesigner_webbrowser ${kformdesigner_mapbrowser_PART_SRCS})
+
+set (QT_USE_QTWEBKIT TRUE)
+
+target_link_libraries(
+ kformdesigner_mapbrowser
+ kformdesigner
+ ${MARBLE_LIBRARIES}
+ ${KDE4_KDECORE_LIBS}
+ ${KDE4_KDEUI_LIBS}
+ ${KDE4_KDE3SUPPORT_LIBS}
+ ${QT_QTCORE_LIBRARY}
+ ${QT_QTGUI_LIBRARY}
+ ${QT_QTWEBKIT_LIBRARY}
+ ${QT_QTXML_LIBRARY}
+ ${QT_QT3SUPPORT_LIBRARY}
+ )
+
+
+install(TARGETS kformdesigner_webbrowser DESTINATION ${PLUGIN_INSTALL_DIR})
+
+########### install files ###############
+
+install( FILES kformdesigner_webbrowser.desktop DESTINATION
+ ${SERVICES_INSTALL_DIR}/kformdesigner)
+
diff --git a/kexi/plugins/forms/widgets/WebBrowserFactory.cpp \
b/kexi/plugins/forms/widgets/WebBrowserFactory.cpp new file mode 100644
index 0000000..dcb751b
--- /dev/null
+++ b/kexi/plugins/forms/widgets/WebBrowserFactory.cpp
@@ -0,0 +1,98 @@
+/*
+ <The basic code for the web widget in Kexi forms>
+ Copyright (C) 2011 Shreya Pandit <shreya@shreyapandit.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+
+#include "WebBrowserFactory.h"
+#include "WidgetInfo.h"
+#include "formIO.h"
+#include "klocalizedstring.h"
+#include "WebBrowserWidget.h"
+#include <QVariant>
+#include <QVariantList>
+#include <KDebug>
+#include <KLocale>
+#include <KPluginFactory>
+//using namespace KFormDesigner;
+//the web browser factory
+
+WebBrowserFactory::WebBrowserFactory(QObject* parent, const QVariantList& args)
+ :WidgetFactory(parent, "webbrowser")
+{
+ KFormDesigner::WidgetInfo *webBrowser = new KFormDesigner::WidgetInfo(this);
+ webBrowser->setPixmap("form");
+ webBrowser->setClassName("WebBrowserWidget");
+ webBrowser->setName(i18n("Web Browser"));
+ webBrowser->setNamePrefix(i18nc("This string will be used to name widgets of \
this class. It must _not_ contain white " + \
"spaces and non latin1 characters.", "Web")); + \
webBrowser->setDescription(i18n("Web Browser")); + addClass(webBrowser);
+}
+
+
+
+
+WebBrowserFactory::~WebBrowserFactory()
+{
+
+}
+
+QWidget* WebBrowserFactory::createWidget(const QByteArray& classname,
+ QWidget* parent,
+ const char* name,
+ KFormDesigner::Container* container,
+ KFormDesigner::WidgetFactory::CreateWidgetOptions \
options) +{
+ QWidget *w = 0;
+ QString text(container->form()->library()->textForWidgetName(name, classname));
+//2.0 const bool designMode = options & \
KFormDesigner::WidgetFactory::DesignViewMode; +
+ if (classname == "WebBrowserWidget")
+ w = new WebBrowserWidget(parent);
+
+ if (w){
+ w->setObjectName(name);
+ kDebug() << w << w->objectName() << "created";
+ return w;
+ }
+ kWarning() << "w == 0";
+ return 0;
+}
+
+bool WebBrowserFactory::createMenuActions(const QByteArray &classname, QWidget *w,
+ QMenu *menu, KFormDesigner::Container \
*container) +{
+ return false;
+}
+
+bool WebBrowserFactory::startInlineEditing(InlineEditorCreationArguments& args)
+{
+ return false;
+}
+
+bool WebBrowserFactory::previewWidget(const QByteArray &classname,
+ QWidget *widget, KFormDesigner::Container *)
+{
+ Q_UNUSED(classname);
+ Q_UNUSED(widget);
+ return true;
+}
+
+K_EXPORT_KEXI_FORM_WIDGET_FACTORY_PLUGIN(WebWidgetFactory, webbrowser)
+
+#include "WebBrowserFactory.moc"
diff --git a/kexi/plugins/forms/widgets/WebBrowserFactory.h \
b/kexi/plugins/forms/widgets/WebBrowserFactory.h new file mode 100644
index 0000000..0e1b856
--- /dev/null
+++ b/kexi/plugins/forms/widgets/WebBrowserFactory.h
@@ -0,0 +1,44 @@
+/*
+ <The basic code for the web widget in Kexi forms>
+ Copyright (C) 2011 Shreya Pandit <shreya@shreyapandit.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+
+#ifndef WEBBROWSERFACTORY_H
+#define WEBBROWSERFACTORY_H
+
+#include "widgetfactory.h"
+#include "container.h"
+#include "FormWidgetInterface.h"
+
+class WebBrowserFactory: public KFormDesigner::WidgetFactory
+{
+ Q_OBJECT
+public:
+ WebBrowserFactory(QObject* parent, const QVariantList &args);
+ virtual ~WebBrowserFactory();
+ virtual QWidget* createWidget(const QByteArray &classname, QWidget *parent, \
const char *name, + KFormDesigner::Container \
*container, + CreateWidgetOptions options = \
DefaultOptions); + virtual bool createMenuActions(const QByteArray &classname, \
QWidget *w, + QMenu *menu, KFormDesigner::Container \
*container); + virtual bool startInlineEditing(InlineEditorCreationArguments& \
args); + virtual bool previewWidget(const QByteArray &classname, QWidget *widget,
+ KFormDesigner::Container *container);
+};
+
+#endif // WEBBROWSERFACTORY_H
diff --git a/kexi/plugins/forms/widgets/WebBrowserWidget.cpp \
b/kexi/plugins/forms/widgets/WebBrowserWidget.cpp new file mode 100644
index 0000000..fb2ed58
--- /dev/null
+++ b/kexi/plugins/forms/widgets/WebBrowserWidget.cpp
@@ -0,0 +1,171 @@
+/*
+ <The basic code for the web widget in Kexi forms>
+ Copyright (C) 2011 Shreya Pandit <shreya@shreyapandit.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+
+#include "WebBrowserWidget.h"
+#include <QApplication>
+#include <QLabel>
+#include <QtWebKit>
+#include <QtWebKit/QWebHistory>
+#include <QWebView>
+#include <QtGui/QPushButton>
+#include <QtGui/QLabel>
+#include <QtGui/QHBoxLayout>
+#include <QtGui/QVBoxLayout>
+#include <QtCore/QUrl>
+#include <QtGui/QAction>
+#include <QTextBrowser>
+#include <QWebPage>
+#include <QtGui/QWidget>
+#include <QtGui/QApplication>
+#include <QtGui/QLineEdit>
+
+MyToolBar::MyToolBar(QWidget* parent):QWidget(parent)
+{
+
+ m_backButton = new QPushButton("Back",this);
+ m_forward= new QPushButton("Forward",this);
+ m_reload=new QPushButton("Reload",this);
+
+ m_layout = new QHBoxLayout;
+ m_layout->addWidget(m_backButton);
+ m_layout->addWidget(m_forward);
+ m_layout->addWidget(m_reload);
+ setLayout(m_layout);
+ m_layout->addStretch();
+
+ connect(m_backButton,SIGNAL(clicked()),SLOT(onBackPressed()));
+ connect(m_forward,SIGNAL(clicked()),SLOT(onForward()));
+ connect(m_reload,SIGNAL(clicked()),SLOT(onReload()));
+
+
+}
+
+void MyToolBar::onForward() //this is the slot,ie function
+{
+ emit goForward();
+//emit signal here
+}
+
+
+void MyToolBar::onReload() //this is the slot,ie function
+{
+ emit doreload();
+//emit signal here
+}
+
+
+void MyToolBar::onBackPressed() //this is the slot,ie function
+{
+ emit goBack();
+//emit signal here
+}
+
+WebBrowserWidget::WebBrowserWidget(QWidget *parent)
+ : QWidget(parent),KFormDesigner::FormWidgetInterface()
+{
+
+ m_softkeyAction = new QAction( tr("Options"), this );
+ m_softkeyAction->setSoftKeyRole(QAction::PositiveSoftKey);
+ addAction(m_softkeyAction);
+
+ //m_lineEdit = new QLineEdit(this);
+ //m_lineEdit->setStyleSheet("background-color:white; padding: 6px ; \
color:blue"); + //m_lineEdit->setPlaceholderText("Enter url ...");
+
+ m_view = new QWebView(this);
+ m_view->load(QUrl("http://www.kde.org"));
+
+ m_layout = new QVBoxLayout();
+
+ // m_layout->addWidget(m_lineEdit);
+ m_layout->addWidget(m_view);
+ //m_layout->insertSpacing(1,10);
+
+ //add toolbar
+ m_toolbar = new MyToolBar(this);
+ m_layout->addWidget(m_toolbar);
+
+ setLayout(m_layout);
+ m_layout->addStretch();
+
+ //connect(m_lineEdit,SIGNAL(editingFinished()),SLOT(openUrl()));
+ connect(m_view,SIGNAL(loadFinished(bool)),SLOT(onLoadFinished(bool)));
+ connect(m_toolbar,SIGNAL(goBack()),SLOT(loadPreviousPage()));
+ connect(m_toolbar,SIGNAL(goForward()),SLOT(loadNextPage()));
+ connect(m_toolbar,SIGNAL(doreload()),SLOT(onreload()));
+ connect(m_url,SIGNAL(urlChanged(QUrl)),SLOT(openurl()));
+}
+
+
+
+
+/*void MyWebWidget::setValueInternal(const QVariant &add, bool removeOld) //removes \
and sets a new url each time propert value changes.... +{
+ QUrl u;
+ setUrl(m_url);
+
+}*/
+
+void MyWebWidget::loadPreviousPage()
+{
+ if(m_view->history()->canGoBack())
+ {
+ m_view->history()->back();
+ }
+}
+
+
+void MyWebWidget::loadNextPage()
+{
+ if(m_view->history()->canGoForward())
+ {
+ m_view->history()->forward();
+ }
+}
+
+void MyWebWidget::onreload()
+{
+ m_view->reload();
+}
+
+void MyWebWidget::openUrl()
+{
+ setUrl(m_url);
+}
+
+
+void MyWebWidget::setUrl(m_url)
+{
+ if (!m_url.startsWith("http://",Qt::CaseInsensitive))
+ url.prepend("http://");
+ m_view->load(QUrl(m_url));
+
+}//ok
+
+/*void MyWebWidget::onLoadFinished(bool finished)
+{
+ if(finished){
+ m_lineEdit->clear();
+ m_lineEdit->setPlaceholderText("Enter url ..."); //takes a const qstring \
parameter + }
+}*/
+
+
+#include "WebBrowserWidget.moc"
diff --git a/kexi/plugins/forms/widgets/WebBrowserWidget.h \
b/kexi/plugins/forms/widgets/WebBrowserWidget.h new file mode 100644
index 0000000..75fa0aa
--- /dev/null
+++ b/kexi/plugins/forms/widgets/WebBrowserWidget.h
@@ -0,0 +1,120 @@
+/* <The basic code for the web widget in Kexi forms>
+ Copyright (C) 2011 Shreya Pandit <shreya@shreyapandit.com>
+
+
+ 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 WEBBROWSERWIDGET_H
+#define WEBBROWSERWIDGET_H
+#include <QtGui/QWidget>
+#include "widgetfactory.h" //these already inherit Qt headers reqd
+#include "container.h"
+#include "FormWidgetInterface.h"
+
+
+
+class QWebView;
+class QLineEdit;
+class QVBoxLayout;
+class QLabel;
+class QAction;
+class QWebHistory;
+class MyToolBar; //added
+class QHBoxLayout;
+class QPushButton;
+class QLabel;
+
+
+
+class WebBrowserWidget : public QWidget , public KFormDesigner::FormWidgetInterface
+{
+ Q_OBJECT
+ Q_PROPERTY(QString dataSource READ dataSource WRITE setDataSource)
+ Q_PROPERTY(QString dataSourcePartClass READ dataSourcePartClass WRITE \
setDataSourcePartClass) + Q_PROPERTY(QUrl url READ url WRITE seturl)
+
+
+public:
+ WebBrowserWidget(QWidget *parent=0);
+
+ inline QString dataSource() const {
+ return KexiFormDataItemInterface::dataSource();
+ }
+ inline QString dataSourcePartClass() const {
+ return KexiFormDataItemInterface::dataSourcePartClass();
+ }
+
+ inline QUrl url() const {
+ return m_url;
+ }
+
+public slots:
+
+
+void setDataSource(const QString &ds);
+
+void setDataSourcePartClass(const QString &partClass);
+
+void setUrl(const QUrl & url);
+
+
+//void openUrl();
+ void onLoadFinished(bool finished);
+ void loadPreviousPage();
+
+
+ private:
+ QAction* m_softkeyAction;
+ QWebView* m_view;
+ QLineEdit* m_lineEdit;
+ QLabel* m_label;
+ QVBoxLayout* m_layout;
+ ToolBar* m_toolbar;
+ QUrl* m_url;
+ QWebHistory* m_history;
+
+
+protected:
+ virtual void setValueInternal(const QVariant& add, bool removeOld);
+
+};
+
+class ToolBar : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ToolBar(QWidget *parent = 0);
+ // ~MyToolBar();
+
+signals:
+ void goBack();
+
+private slots:
+ void onBackPressed();
+
+private:
+ QPushButton* m_backButton;
+ QPushbutton* m_forward;
+ QHBoxLayout* m_layout;
+ QPushbutton* m_reload;
+};
+#endif // WEBBROWSERWIDGET_H
+
+
+
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic