summaryrefslogtreecommitdiffstats
path: root/examples/webkit/webplugin
diff options
context:
space:
mode:
Diffstat (limited to 'examples/webkit/webplugin')
-rw-r--r--examples/webkit/webplugin/csvfactory.cpp98
-rw-r--r--examples/webkit/webplugin/csvfactory.h67
-rw-r--r--examples/webkit/webplugin/csvplugin.qrc6
-rw-r--r--examples/webkit/webplugin/csvview.cpp190
-rw-r--r--examples/webkit/webplugin/csvview.h79
-rw-r--r--examples/webkit/webplugin/main.cpp50
-rw-r--r--examples/webkit/webplugin/mainwindow.cpp59
-rw-r--r--examples/webkit/webplugin/mainwindow.h54
-rw-r--r--examples/webkit/webplugin/webplugin.pro23
9 files changed, 626 insertions, 0 deletions
diff --git a/examples/webkit/webplugin/csvfactory.cpp b/examples/webkit/webplugin/csvfactory.cpp
new file mode 100644
index 0000000..b605a76
--- /dev/null
+++ b/examples/webkit/webplugin/csvfactory.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtNetwork>
+#include <QtWebKit>
+#include "csvfactory.h"
+#include "csvview.h"
+
+CSVFactory::CSVFactory(QWebView *webView, QObject *parent)
+ : QWebPluginFactory(parent)
+{
+ manager = new QNetworkAccessManager(this);
+ this->webView = webView;
+};
+
+//! [begin create]
+QObject *CSVFactory::create(const QString &mimeType, const QUrl &url,
+ const QStringList &argumentNames,
+ const QStringList &argumentValues) const
+{
+ if (mimeType != "text/csv")
+ return 0;
+
+ QHash<QString, QString> arguments;
+ for (int i = 0; i < argumentNames.count(); ++i)
+ arguments[argumentNames[i]] = argumentValues[i];
+
+ CSVView *view = new CSVView(arguments["type"]);
+//! [begin create]
+
+//! [create connection]
+ QWebFrame *frame = webView->page()->mainFrame();
+ frame->addToJavaScriptWindowObject("view", view);
+ frame->evaluateJavaScript("view.rowSelected.connect(fillInTable);\n");
+//! [create connection]
+
+//! [submit request]
+ QNetworkRequest request(url);
+ QNetworkReply *reply = manager->get(request);
+ connect(reply, SIGNAL(finished()), view, SLOT(updateModel()));
+ connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater()));
+
+ return view;
+}
+//! [submit request]
+
+QList<QWebPluginFactory::Plugin> CSVFactory::plugins() const
+{
+ QWebPluginFactory::MimeType mimeType;
+ mimeType.name = "text/csv";
+ mimeType.description = "Comma-separated values";
+ mimeType.fileExtensions = QStringList() << "csv";
+
+ QWebPluginFactory::Plugin plugin;
+ plugin.name = "CSV file viewer";
+ plugin.description = "A CSV file Web plugin.";
+ plugin.mimeTypes = QList<MimeType>() << mimeType;
+
+ return QList<QWebPluginFactory::Plugin>() << plugin;
+}
diff --git a/examples/webkit/webplugin/csvfactory.h b/examples/webkit/webplugin/csvfactory.h
new file mode 100644
index 0000000..5a44c50
--- /dev/null
+++ b/examples/webkit/webplugin/csvfactory.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CSVFACTORY_H
+#define CSVFACTORY_H
+
+#include <QNetworkRequest>
+#include <QWebPluginFactory>
+
+class QNetworkAccessManager;
+class QNetworkReply;
+class QWebView;
+
+class CSVFactory : public QWebPluginFactory
+{
+ Q_OBJECT
+
+public:
+ CSVFactory(QWebView *webView, QObject *parent = 0);
+ QObject *create(const QString &mimeType, const QUrl &url,
+ const QStringList &argumentNames,
+ const QStringList &argumentValues) const;
+ QList<QWebPluginFactory::Plugin> plugins() const;
+
+private:
+ QNetworkAccessManager *manager;
+ QWebView *webView;
+};
+
+#endif
diff --git a/examples/webkit/webplugin/csvplugin.qrc b/examples/webkit/webplugin/csvplugin.qrc
new file mode 100644
index 0000000..14f80e7
--- /dev/null
+++ b/examples/webkit/webplugin/csvplugin.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>pages/index.html</file>
+ <file>data/accounts.csv</file>
+ </qresource>
+</RCC>
diff --git a/examples/webkit/webplugin/csvview.cpp b/examples/webkit/webplugin/csvview.cpp
new file mode 100644
index 0000000..90a1206
--- /dev/null
+++ b/examples/webkit/webplugin/csvview.cpp
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtNetwork>
+#include "csvview.h"
+
+//! [constructor]
+CSVView::CSVView(const QString &mimeType, QWidget *parent)
+ : QTableView(parent)
+{
+ this->mimeType = mimeType;
+
+ setEditTriggers(NoEditTriggers);
+ setSelectionBehavior(SelectRows);
+ setSelectionMode(SingleSelection);
+}
+//! [constructor]
+
+void CSVView::updateModel()
+{
+ QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
+
+ if (reply->error() != QNetworkReply::NoError)
+ return;
+
+ bool hasHeader = false;
+ QString charset = "latin1";
+
+ foreach (QString piece, mimeType.split(";")) {
+ piece = piece.trimmed();
+ if (piece.contains("=")) {
+ int index = piece.indexOf("=");
+ QString left = piece.left(index).trimmed();
+ QString right = piece.mid(index + 1).trimmed();
+ if (left == "header")
+ hasHeader = (right == "present");
+ else if (left == "charset")
+ charset = right;
+ }
+ }
+
+ QTextStream stream(reply);
+ stream.setCodec(QTextCodec::codecForName(charset.toLatin1()));
+
+ QStandardItemModel *model = new QStandardItemModel(this);
+ QList<QStandardItem *> items;
+ bool firstLine = hasHeader;
+ bool wasQuote = false;
+ bool wasCR = false;
+ bool quoted = false;
+ QString text;
+
+ while (!stream.atEnd()) {
+
+ QString ch = stream.read(1);
+
+ if (wasQuote) {
+ if (ch == "\"") {
+ if (quoted) {
+ text += ch; // quoted "" are inserted as "
+ wasQuote = false; // no quotes are pending
+ } else {
+ quoted = true; // unquoted "" starts quoting
+ wasQuote = true; // with a pending quote
+ }
+ continue; // process the next character
+
+ } else {
+ quoted = !quoted; // process the pending quote
+ wasQuote = false; // no quotes are pending
+ } // process the current character
+
+ } else if (wasCR) {
+ wasCR = false;
+
+ if (ch == "\n") { // CR LF represents the end of a row
+ if (!text.isEmpty())
+ items.append(new QStandardItem(QString(text)));
+
+ addRow(firstLine, model, items);
+ items.clear();
+ text = "";
+ firstLine = false;
+ continue; // process the next character
+ } else
+ text += "\r"; // CR on its own is inserted
+ } // process the current character
+
+ // wasQuote is never true here.
+ // wasCR is never true here.
+
+ if (ch == "\"")
+ wasQuote = true; // handle the pending quote later
+
+ else if (ch == ",") {
+ if (quoted)
+ text += ch;
+ else {
+ items.append(new QStandardItem(QString(text)));
+ text = "";
+ }
+ }
+
+ else if (ch == "\r") {
+ if (!quoted)
+ wasCR = true;
+ else
+ text += ch;
+ }
+
+ else if (ch == "\n")
+ text += ch;
+ else
+ text += ch;
+
+ }
+
+ if (items.count() > 0)
+ addRow(firstLine, model, items);
+
+ reply->close();
+
+ setModel(model);
+
+ connect(selectionModel(),
+ SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(exportRow(const QModelIndex &)));
+
+ resizeColumnsToContents();
+ horizontalHeader()->setStretchLastSection(true);
+}
+
+void CSVView::addRow(bool firstLine, QStandardItemModel *model,
+ const QList<QStandardItem *> &items)
+{
+ if (firstLine) {
+ for (int j = 0; j < items.count(); ++j)
+ model->setHorizontalHeaderItem(j, items[j]);
+ } else
+ model->appendRow(items);
+}
+
+//! [export row]
+void CSVView::exportRow(const QModelIndex &current)
+{
+ QString name = model()->index(current.row(), 0).data().toString();
+ QString address = model()->index(current.row(), 1).data().toString();
+ QString quantity = model()->index(current.row(), 2).data().toString();
+
+ emit rowSelected(name, address, quantity);
+}
+//! [export row]
diff --git a/examples/webkit/webplugin/csvview.h b/examples/webkit/webplugin/csvview.h
new file mode 100644
index 0000000..bf8918b
--- /dev/null
+++ b/examples/webkit/webplugin/csvview.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CSVVIEW_H
+#define CSVVIEW_H
+
+#include <QNetworkRequest>
+#include <QStandardItemModel>
+#include <QTableView>
+#include <QWebPluginFactory>
+
+class QNetworkAccessManager;
+class QNetworkReply;
+class QWebFrame;
+
+//! [definition]
+class CSVView : public QTableView
+{
+ Q_OBJECT
+
+public:
+ CSVView(const QString &mimeType, QWidget *parent = 0);
+
+signals:
+ void rowSelected(const QString &name, const QString &address,
+ const QString &quantity);
+
+public slots:
+ void updateModel();
+
+private slots:
+ void exportRow(const QModelIndex &current);
+
+private:
+ void addRow(bool firstLine, QStandardItemModel *model,
+ const QList<QStandardItem *> &items);
+
+ QString mimeType;
+};
+//! [definition]
+
+#endif
diff --git a/examples/webkit/webplugin/main.cpp b/examples/webkit/webplugin/main.cpp
new file mode 100644
index 0000000..fd2b233
--- /dev/null
+++ b/examples/webkit/webplugin/main.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow window;
+ window.show();
+ return app.exec();
+}
diff --git a/examples/webkit/webplugin/mainwindow.cpp b/examples/webkit/webplugin/mainwindow.cpp
new file mode 100644
index 0000000..188e08f
--- /dev/null
+++ b/examples/webkit/webplugin/mainwindow.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QFile>
+#include <QWebView>
+#include "csvfactory.h"
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ QWebSettings::globalSettings()->setAttribute(
+ QWebSettings::PluginsEnabled, true);
+
+ QWebView *webView = new QWebView;
+ CSVFactory *factory = new CSVFactory(webView, this);
+ webView->page()->setPluginFactory(factory);
+ webView->setUrl(QUrl("qrc:/pages/index.html"));
+
+ setCentralWidget(webView);
+ setWindowTitle(tr("Web Plugin Example"));
+}
diff --git a/examples/webkit/webplugin/mainwindow.h b/examples/webkit/webplugin/mainwindow.h
new file mode 100644
index 0000000..12c8306
--- /dev/null
+++ b/examples/webkit/webplugin/mainwindow.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+};
+
+#endif
diff --git a/examples/webkit/webplugin/webplugin.pro b/examples/webkit/webplugin/webplugin.pro
new file mode 100644
index 0000000..cb5ebf3
--- /dev/null
+++ b/examples/webkit/webplugin/webplugin.pro
@@ -0,0 +1,23 @@
+QT += webkit network
+
+HEADERS = csvfactory.h \
+ csvview.h \
+ mainwindow.h
+
+SOURCES = csvfactory.cpp \
+ csvview.cpp \
+ main.cpp \
+ mainwindow.cpp
+
+RESOURCES = csvplugin.qrc
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/webkit/webplugin
+sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/webplugin
+INSTALLS += target sources
+
+symbian {
+ TARGET.UID3 = 0xA000EFFE
+ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+}