summaryrefslogtreecommitdiffstats
path: root/examples/webkit/simplewebplugin
diff options
context:
space:
mode:
Diffstat (limited to 'examples/webkit/simplewebplugin')
-rw-r--r--examples/webkit/simplewebplugin/csvfactory.cpp91
-rw-r--r--examples/webkit/simplewebplugin/csvfactory.h67
-rw-r--r--examples/webkit/simplewebplugin/csvview.cpp176
-rw-r--r--examples/webkit/simplewebplugin/csvview.h71
-rw-r--r--examples/webkit/simplewebplugin/data/accounts.csv11
-rw-r--r--examples/webkit/simplewebplugin/main.cpp52
-rw-r--r--examples/webkit/simplewebplugin/mainwindow.cpp63
-rw-r--r--examples/webkit/simplewebplugin/mainwindow.h54
-rw-r--r--examples/webkit/simplewebplugin/pages/index.html27
-rw-r--r--examples/webkit/simplewebplugin/simplewebplugin.pro23
-rw-r--r--examples/webkit/simplewebplugin/simplewebplugin.qrc6
11 files changed, 641 insertions, 0 deletions
diff --git a/examples/webkit/simplewebplugin/csvfactory.cpp b/examples/webkit/simplewebplugin/csvfactory.cpp
new file mode 100644
index 0000000..56b4558
--- /dev/null
+++ b/examples/webkit/simplewebplugin/csvfactory.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** 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 <QWebPluginFactory>
+#include "csvfactory.h"
+#include "csvview.h"
+
+//! [constructor]
+CSVFactory::CSVFactory(QObject *parent)
+ : QWebPluginFactory(parent)
+{
+ manager = new QNetworkAccessManager(this);
+};
+//! [constructor]
+
+//! [begin create]
+QObject *CSVFactory::create(const QString &mimeType, const QUrl &url,
+ const QStringList &argumentNames,
+ const QStringList &argumentValues) const
+{
+ if (mimeType != "text/csv")
+ return 0;
+
+ CSVView *view = new CSVView(argumentValues[argumentNames.indexOf("type")]);
+//! [begin create]
+
+//! [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]
+
+//! [plugins]
+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;
+}
+//! [plugins]
diff --git a/examples/webkit/simplewebplugin/csvfactory.h b/examples/webkit/simplewebplugin/csvfactory.h
new file mode 100644
index 0000000..0b046c5
--- /dev/null
+++ b/examples/webkit/simplewebplugin/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;
+
+//! [plugin factory]
+class CSVFactory : public QWebPluginFactory
+{
+ Q_OBJECT
+
+public:
+ CSVFactory(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;
+};
+//! [plugin factory]
+
+#endif
diff --git a/examples/webkit/simplewebplugin/csvview.cpp b/examples/webkit/simplewebplugin/csvview.cpp
new file mode 100644
index 0000000..3d87daa
--- /dev/null
+++ b/examples/webkit/simplewebplugin/csvview.cpp
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** 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;
+}
+//! [constructor]
+
+//! [update model begin]
+void CSVView::updateModel()
+{
+ QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
+
+ if (reply->error() != QNetworkReply::NoError)
+ return;
+
+ bool hasHeader = false;
+ QString charset = "latin1";
+//! [update model begin]
+
+ 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;
+ }
+ }
+
+//! [read data begin]
+ QTextStream stream(reply);
+ stream.setCodec(QTextCodec::codecForName(charset.toLatin1()));
+
+ QStandardItemModel *model = new QStandardItemModel(this);
+//! [read data begin]
+ 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);
+
+//! [update model]
+ reply->close();
+
+ setModel(model);
+ resizeColumnsToContents();
+ horizontalHeader()->setStretchLastSection(true);
+}
+//! [update model]
+
+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);
+}
diff --git a/examples/webkit/simplewebplugin/csvview.h b/examples/webkit/simplewebplugin/csvview.h
new file mode 100644
index 0000000..0a136f3
--- /dev/null
+++ b/examples/webkit/simplewebplugin/csvview.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** 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;
+
+//! [definition]
+class CSVView : public QTableView
+{
+ Q_OBJECT
+
+public:
+ CSVView(const QString &mimeType, QWidget *parent = 0);
+
+public slots:
+ void updateModel();
+
+private:
+ void addRow(bool firstLine, QStandardItemModel *model,
+ const QList<QStandardItem *> &items);
+
+ QString mimeType;
+};
+//! [definition]
+
+#endif
diff --git a/examples/webkit/simplewebplugin/data/accounts.csv b/examples/webkit/simplewebplugin/data/accounts.csv
new file mode 100644
index 0000000..2ea3bd6
--- /dev/null
+++ b/examples/webkit/simplewebplugin/data/accounts.csv
@@ -0,0 +1,11 @@
+"Name","Address","Quantity"
+"Kristian Quan","123 Company Place, Big City","4"
+"Matthew Rand","The Orchard, Little Village","2"
+"Eirik Asaki","497 Park Skyway, Future City","29"
+"Jarek Hanssen","1023 Riviera Drive, Southern Precinct","45"
+"Carlos Hartmann","The Manor House, Country Estate","1"
+"Bea King","Floor 201, Sun Tower, Central City","32"
+"Stian Hinton","Mechanical workshop, Fishing Village, North River","0"
+"Shane Bowland","P.O. Box 419, Beach Resort","1"
+"Gavin Holm","19 Library Road, University Campus, near Large Town","16"
+"Adrienna Randles","98 Tapestry Road, Market Town, The Shires","1"
diff --git a/examples/webkit/simplewebplugin/main.cpp b/examples/webkit/simplewebplugin/main.cpp
new file mode 100644
index 0000000..8e823b1
--- /dev/null
+++ b/examples/webkit/simplewebplugin/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** 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"
+
+//! [main]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow window;
+ window.show();
+ return app.exec();
+}
+//! [main]
diff --git a/examples/webkit/simplewebplugin/mainwindow.cpp b/examples/webkit/simplewebplugin/mainwindow.cpp
new file mode 100644
index 0000000..60bdd8b
--- /dev/null
+++ b/examples/webkit/simplewebplugin/mainwindow.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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"
+
+//! [constructor]
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ QWebSettings::globalSettings()->setAttribute(
+ QWebSettings::PluginsEnabled, true);
+
+ QWebView *webView = new QWebView;
+ CSVFactory *factory = new CSVFactory(this);
+ webView->page()->setPluginFactory(factory);
+ QFile file(":/pages/index.html");
+ file.open(QFile::ReadOnly);
+ webView->setHtml(file.readAll());
+
+ setCentralWidget(webView);
+ setWindowTitle(tr("Simple Web Plugin Example"));
+}
+//! [constructor]
diff --git a/examples/webkit/simplewebplugin/mainwindow.h b/examples/webkit/simplewebplugin/mainwindow.h
new file mode 100644
index 0000000..12c8306
--- /dev/null
+++ b/examples/webkit/simplewebplugin/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/simplewebplugin/pages/index.html b/examples/webkit/simplewebplugin/pages/index.html
new file mode 100644
index 0000000..9581a8e
--- /dev/null
+++ b/examples/webkit/simplewebplugin/pages/index.html
@@ -0,0 +1,27 @@
+<html>
+<head>
+<title>Simple Web Plugin</title>
+</head>
+
+<body>
+<h1>Simple Web Plugin</h1>
+
+<p>
+ This plugin displays comma-separated value (CSV) files in Web pages using
+ a subclass of Qt's
+ <a href="http://doc.trolltech.com/4.4/qtableview.html">QTableView</a>
+ widget.
+</p>
+
+<!-- [embedded object] -->
+<object type="text/csv;header=present;charset=utf8"
+ data="qrc:/data/accounts.csv"
+ width="100%" height="300"></object>
+<!-- [embedded object] -->
+
+<p>
+ The above table shows some sample data rendered by the plugin.
+</p>
+
+</body>
+</html>
diff --git a/examples/webkit/simplewebplugin/simplewebplugin.pro b/examples/webkit/simplewebplugin/simplewebplugin.pro
new file mode 100644
index 0000000..c16302d
--- /dev/null
+++ b/examples/webkit/simplewebplugin/simplewebplugin.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 = simplewebplugin.qrc
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/webkit/simplewebplugin
+sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/simplewebplugin
+INSTALLS += target sources
+
+symbian {
+ TARGET.UID3 = 0xA000EFFF
+ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+}
diff --git a/examples/webkit/simplewebplugin/simplewebplugin.qrc b/examples/webkit/simplewebplugin/simplewebplugin.qrc
new file mode 100644
index 0000000..14f80e7
--- /dev/null
+++ b/examples/webkit/simplewebplugin/simplewebplugin.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>pages/index.html</file>
+ <file>data/accounts.csv</file>
+ </qresource>
+</RCC>