summaryrefslogtreecommitdiffstats
path: root/examples/help
diff options
context:
space:
mode:
authorQt by Nokia <qt-info@nokia.com>2011-04-27 12:05:43 +0200
committeraxis <qt-info@nokia.com>2011-04-27 12:05:43 +0200
commit50123887ba0f33cf47520bee7c419d68742af2d1 (patch)
tree0eb8679b9e4e4370e59b44bfdcae616816e39aca /examples/help
Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
Diffstat (limited to 'examples/help')
-rw-r--r--examples/help/README38
-rw-r--r--examples/help/contextsensitivehelp/contextsensitivehelp.pro20
-rw-r--r--examples/help/contextsensitivehelp/doc/amount.html11
-rw-r--r--examples/help/contextsensitivehelp/doc/filter.html12
-rw-r--r--examples/help/contextsensitivehelp/doc/plants.html44
-rw-r--r--examples/help/contextsensitivehelp/doc/rain.html11
-rw-r--r--examples/help/contextsensitivehelp/doc/source.html33
-rw-r--r--examples/help/contextsensitivehelp/doc/temperature.html13
-rw-r--r--examples/help/contextsensitivehelp/doc/time.html11
-rw-r--r--examples/help/contextsensitivehelp/doc/wateringmachine.qchbin0 -> 25600 bytes
-rw-r--r--examples/help/contextsensitivehelp/doc/wateringmachine.qhcbin0 -> 8192 bytes
-rw-r--r--examples/help/contextsensitivehelp/doc/wateringmachine.qhcp14
-rw-r--r--examples/help/contextsensitivehelp/doc/wateringmachine.qhp25
-rw-r--r--examples/help/contextsensitivehelp/helpbrowser.cpp80
-rw-r--r--examples/help/contextsensitivehelp/helpbrowser.h64
-rw-r--r--examples/help/contextsensitivehelp/main.cpp50
-rw-r--r--examples/help/contextsensitivehelp/wateringconfigdialog.cpp68
-rw-r--r--examples/help/contextsensitivehelp/wateringconfigdialog.h61
-rw-r--r--examples/help/contextsensitivehelp/wateringconfigdialog.ui446
-rw-r--r--examples/help/help.pro13
-rw-r--r--examples/help/remotecontrol/enter.pngbin0 -> 315 bytes
-rw-r--r--examples/help/remotecontrol/main.cpp53
-rw-r--r--examples/help/remotecontrol/remotecontrol.cpp174
-rw-r--r--examples/help/remotecontrol/remotecontrol.h78
-rw-r--r--examples/help/remotecontrol/remotecontrol.pro15
-rw-r--r--examples/help/remotecontrol/remotecontrol.qrc5
-rw-r--r--examples/help/remotecontrol/remotecontrol.ui228
-rw-r--r--examples/help/simpletextviewer/assistant.cpp109
-rw-r--r--examples/help/simpletextviewer/assistant.h62
-rw-r--r--examples/help/simpletextviewer/documentation/about.txt9
-rw-r--r--examples/help/simpletextviewer/documentation/browse.html34
-rw-r--r--examples/help/simpletextviewer/documentation/filedialog.html48
-rw-r--r--examples/help/simpletextviewer/documentation/findfile.html32
-rw-r--r--examples/help/simpletextviewer/documentation/images/browse.pngbin0 -> 21553 bytes
-rw-r--r--examples/help/simpletextviewer/documentation/images/fadedfilemenu.pngbin0 -> 9589 bytes
-rw-r--r--examples/help/simpletextviewer/documentation/images/filedialog.pngbin0 -> 12318 bytes
-rw-r--r--examples/help/simpletextviewer/documentation/images/handbook.pngbin0 -> 1060 bytes
-rw-r--r--examples/help/simpletextviewer/documentation/images/icon.pngbin0 -> 5513 bytes
-rw-r--r--examples/help/simpletextviewer/documentation/images/mainwindow.pngbin0 -> 12769 bytes
-rw-r--r--examples/help/simpletextviewer/documentation/images/open.pngbin0 -> 11697 bytes
-rw-r--r--examples/help/simpletextviewer/documentation/images/wildcard.pngbin0 -> 11266 bytes
-rw-r--r--examples/help/simpletextviewer/documentation/index.html41
-rw-r--r--examples/help/simpletextviewer/documentation/intro.html28
-rw-r--r--examples/help/simpletextviewer/documentation/openfile.html36
-rw-r--r--examples/help/simpletextviewer/documentation/simpletextviewer.qchbin0 -> 108544 bytes
-rw-r--r--examples/help/simpletextviewer/documentation/simpletextviewer.qhcbin0 -> 18432 bytes
-rw-r--r--examples/help/simpletextviewer/documentation/simpletextviewer.qhcp30
-rw-r--r--examples/help/simpletextviewer/documentation/simpletextviewer.qhp49
-rw-r--r--examples/help/simpletextviewer/documentation/wildcardmatching.html57
-rw-r--r--examples/help/simpletextviewer/findfiledialog.cpp221
-rw-r--r--examples/help/simpletextviewer/findfiledialog.h98
-rw-r--r--examples/help/simpletextviewer/main.cpp51
-rw-r--r--examples/help/simpletextviewer/mainwindow.cpp146
-rw-r--r--examples/help/simpletextviewer/mainwindow.h83
-rw-r--r--examples/help/simpletextviewer/simpletextviewer.pro18
-rw-r--r--examples/help/simpletextviewer/textedit.cpp74
-rw-r--r--examples/help/simpletextviewer/textedit.h60
57 files changed, 2853 insertions, 0 deletions
diff --git a/examples/help/README b/examples/help/README
new file mode 100644
index 000000000..85f5a4373
--- /dev/null
+++ b/examples/help/README
@@ -0,0 +1,38 @@
+Support for interactive help is provided by the Qt Assistant application.
+Developers can take advantages of the facilities it offers to display
+specially-prepared documentation to users of their applications.
+
+
+The example launcher provided with Qt can be used to explore each of the
+examples in this directory.
+
+Documentation for these examples can be found via the Tutorial and Examples
+link in the main Qt documentation.
+
+
+Finding the Qt Examples and Demos launcher
+==========================================
+
+On Windows:
+
+The launcher can be accessed via the Windows Start menu. Select the menu
+entry entitled "Qt Examples and Demos" entry in the submenu containing
+the Qt tools.
+
+On Mac OS X:
+
+For the binary distribution, the qtdemo executable is installed in the
+/Developer/Applications/Qt directory. For the source distribution, it is
+installed alongside the other Qt tools on the path specified when Qt is
+configured.
+
+On Unix/Linux:
+
+The qtdemo executable is installed alongside the other Qt tools on the path
+specified when Qt is configured.
+
+On all platforms:
+
+The source code for the launcher can be found in the demos/qtdemo directory
+in the Qt package. This example is built at the same time as the Qt libraries,
+tools, examples, and demonstrations.
diff --git a/examples/help/contextsensitivehelp/contextsensitivehelp.pro b/examples/help/contextsensitivehelp/contextsensitivehelp.pro
new file mode 100644
index 000000000..ef85c840d
--- /dev/null
+++ b/examples/help/contextsensitivehelp/contextsensitivehelp.pro
@@ -0,0 +1,20 @@
+TEMPLATE = app
+
+CONFIG += help
+
+SOURCES += main.cpp \
+ wateringconfigdialog.cpp \
+ helpbrowser.cpp
+
+HEADERS += wateringconfigdialog.h \
+ helpbrowser.h
+
+FORMS += wateringconfigdialog.ui
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qttools/help/contextsensitivehelp
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.png *.doc doc
+sources.path = $$[QT_INSTALL_EXAMPLES]/qttools/help/contextsensitivehelp
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/help/contextsensitivehelp/doc/amount.html b/examples/help/contextsensitivehelp/doc/amount.html
new file mode 100644
index 000000000..7a02a6fd5
--- /dev/null
+++ b/examples/help/contextsensitivehelp/doc/amount.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <title>Water amount</title>
+ </head>
+ <body>
+ Depending on the plant, temperature and rain fall the amount needs to be larger
+ or smaller. On a really hot day without rain, the suggested <a href="plants.html">amount</a>
+ can be increased by about 10%.
+ </body>
+</html>
diff --git a/examples/help/contextsensitivehelp/doc/filter.html b/examples/help/contextsensitivehelp/doc/filter.html
new file mode 100644
index 000000000..64861126d
--- /dev/null
+++ b/examples/help/contextsensitivehelp/doc/filter.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>Filter</title>
+</head>
+<body>
+Depending on the source of water, it needs to be filtered or not. Filtering
+is strongly recommened for the river and lake.
+
+
+</body>
+</html>
diff --git a/examples/help/contextsensitivehelp/doc/plants.html b/examples/help/contextsensitivehelp/doc/plants.html
new file mode 100644
index 000000000..2d2bb6788
--- /dev/null
+++ b/examples/help/contextsensitivehelp/doc/plants.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <title>Plants</title>
+ </head>
+ <body>
+ Different kind of plants need different amounts of water. Here's a short
+ overview over the most common grown plants and their avarage need of water:
+ <br>
+ <table border=1>
+ <tr>
+ <td>Kind</td>
+ <td>Amount</td>
+ </tr>
+ <tr>
+ <td>Squash</td>
+ <td>2000</td>
+ </tr>
+ <tr>
+ <td>Bean</td>
+ <td>1500</td>
+ </tr>
+ <tr>
+ <td>Carrot</td>
+ <td>1200</td>
+ </tr>
+ <tr>
+ <td>Strawberry</td>
+ <td>1300</td>
+ </tr>
+ <tr>
+ <td>Raspberry</td>
+ <td>1000</td>
+ </tr>
+ <tr>
+ <td>Blueberry</td>
+ <td>1100</td>
+ </tr>
+ </table>
+ <br><br>
+ <font color="#ff0000">Warning:</font> Watering them too much or too little will
+ cause irreversible damage!
+ </body>
+</html>
diff --git a/examples/help/contextsensitivehelp/doc/rain.html b/examples/help/contextsensitivehelp/doc/rain.html
new file mode 100644
index 000000000..1ffe45240
--- /dev/null
+++ b/examples/help/contextsensitivehelp/doc/rain.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <title>Rain</title>
+ </head>
+ <body>
+ Depending on the rain fall, the automated watering system should not be
+ switched on at all. Also, the <a href="./temperature.html">temperature</a> should be
+ considered.
+ </body>
+</html>
diff --git a/examples/help/contextsensitivehelp/doc/source.html b/examples/help/contextsensitivehelp/doc/source.html
new file mode 100644
index 000000000..68b2f8c71
--- /dev/null
+++ b/examples/help/contextsensitivehelp/doc/source.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <title>Water Source</title>
+ </head>
+ <body>
+ The current pipe system connects to four different sources. Be aware
+ that only a limited amount of water can be taken from some sources.
+ <br>
+ <table border=1>
+ <tr>
+ <td>Source</td>
+ <td>Amount</td>
+ </tr>
+ <tr>
+ <td>Fountain</td>
+ <td>4000</td>
+ </tr>
+ <tr>
+ <td>River</td>
+ <td>6000</td>
+ </tr>
+ <tr>
+ <td>Lake</td>
+ <td>10000</td>
+ </tr>
+ <tr>
+ <td>Public Water System</td>
+ <td>unlimited</td>
+ </tr>
+ </table>
+ </body>
+</html>
diff --git a/examples/help/contextsensitivehelp/doc/temperature.html b/examples/help/contextsensitivehelp/doc/temperature.html
new file mode 100644
index 000000000..4145ed725
--- /dev/null
+++ b/examples/help/contextsensitivehelp/doc/temperature.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <title>Temperature</title>
+ </head>
+ <body>
+ Depending on the temperature, the plants need more or less water. The higher
+ the temperature the higher the need for water. If the temperature does not
+ reach a certain level, maybe no automatic watering should be done at all.<br>
+ Before setting this parameter for good, you should also take the amount of <a href="./rain.html">
+ rain</a> into account.
+ </body>
+</html>
diff --git a/examples/help/contextsensitivehelp/doc/time.html b/examples/help/contextsensitivehelp/doc/time.html
new file mode 100644
index 000000000..0cc81f4d0
--- /dev/null
+++ b/examples/help/contextsensitivehelp/doc/time.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>Starting time</title>
+</head>
+<body>
+Starting the watering too early may be ineffective since most water
+will evaporate.
+
+</body>
+</html>
diff --git a/examples/help/contextsensitivehelp/doc/wateringmachine.qch b/examples/help/contextsensitivehelp/doc/wateringmachine.qch
new file mode 100644
index 000000000..35d29be22
--- /dev/null
+++ b/examples/help/contextsensitivehelp/doc/wateringmachine.qch
Binary files differ
diff --git a/examples/help/contextsensitivehelp/doc/wateringmachine.qhc b/examples/help/contextsensitivehelp/doc/wateringmachine.qhc
new file mode 100644
index 000000000..b5653c3ff
--- /dev/null
+++ b/examples/help/contextsensitivehelp/doc/wateringmachine.qhc
Binary files differ
diff --git a/examples/help/contextsensitivehelp/doc/wateringmachine.qhcp b/examples/help/contextsensitivehelp/doc/wateringmachine.qhcp
new file mode 100644
index 000000000..eebf6520e
--- /dev/null
+++ b/examples/help/contextsensitivehelp/doc/wateringmachine.qhcp
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<QHelpCollectionProject version="1.0">
+ <docFiles>
+ <generate>
+ <file>
+ <input>wateringmachine.qhp</input>
+ <output>wateringmachine.qch</output>
+ </file>
+ </generate>
+ <register>
+ <file>wateringmachine.qch</file>
+ </register>
+ </docFiles>
+</QHelpCollectionProject> \ No newline at end of file
diff --git a/examples/help/contextsensitivehelp/doc/wateringmachine.qhp b/examples/help/contextsensitivehelp/doc/wateringmachine.qhp
new file mode 100644
index 000000000..6dd08e7ae
--- /dev/null
+++ b/examples/help/contextsensitivehelp/doc/wateringmachine.qhp
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<QtHelpProject version="1.0">
+ <virtualFolder>wateringmachine</virtualFolder>
+ <namespace>wateringcompany.com.1-0-0.premium</namespace>
+ <filterSection>
+ <keywords>
+ <keyword name="plants" id="plants" ref="plants.html"/>
+ <keyword name="temperature" id="temperature" ref="temperature.html"/>
+ <keyword name="rain" id="rain" ref="rain.html"/>
+ <keyword name="time" id="time" ref="time.html"/>
+ <keyword name="amount" id="amount" ref="amount.html"/>
+ <keyword name="source" id="source" ref="source.html"/>
+ <keyword name="filtering" id="filtering" ref="filter.html"/>
+ </keywords>
+ <files>
+ <file>plants.html</file>
+ <file>temperature.html</file>
+ <file>rain.html</file>
+ <file>time.html</file>
+ <file>amount.html</file>
+ <file>source.html</file>
+ <file>filter.html</file>
+ </files>
+ </filterSection>
+</QtHelpProject>
diff --git a/examples/help/contextsensitivehelp/helpbrowser.cpp b/examples/help/contextsensitivehelp/helpbrowser.cpp
new file mode 100644
index 000000000..d37a72f3b
--- /dev/null
+++ b/examples/help/contextsensitivehelp/helpbrowser.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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 <QtCore/QLibraryInfo>
+#include <QtGui/QApplication>
+#include <QtHelp/QHelpEngineCore>
+
+#include "helpbrowser.h"
+
+HelpBrowser::HelpBrowser(QWidget *parent)
+ : QTextBrowser(parent)
+{
+ QString collectionFile = QLibraryInfo::location(QLibraryInfo::ExamplesPath)
+ + QLatin1String("/help/contextsensitivehelp/doc/wateringmachine.qhc");
+
+ m_helpEngine = new QHelpEngineCore(collectionFile, this);
+ if (!m_helpEngine->setupData()) {
+ delete m_helpEngine;
+ m_helpEngine = 0;
+ }
+}
+
+void HelpBrowser::showHelpForKeyword(const QString &id)
+{
+ if (m_helpEngine) {
+ QMap<QString, QUrl> links = m_helpEngine->linksForIdentifier(id);
+ if (links.count())
+ setSource(links.constBegin().value());
+ }
+}
+
+QVariant HelpBrowser::loadResource(int type, const QUrl &name)
+{
+ QByteArray ba;
+ if (type < 4 && m_helpEngine) {
+ QUrl url(name);
+ if (name.isRelative())
+ url = source().resolved(url);
+ ba = m_helpEngine->fileData(url);
+ }
+ return ba;
+}
+
diff --git a/examples/help/contextsensitivehelp/helpbrowser.h b/examples/help/contextsensitivehelp/helpbrowser.h
new file mode 100644
index 000000000..684ed6827
--- /dev/null
+++ b/examples/help/contextsensitivehelp/helpbrowser.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** 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 HELPBROWSER_H
+#define HELPBROWSER_H
+
+#include <QtGui/QTextBrowser>
+
+QT_BEGIN_NAMESPACE
+class QHelpEngineCore;
+QT_END_NAMESPACE;
+
+class HelpBrowser : public QTextBrowser
+{
+ Q_OBJECT
+
+public:
+ HelpBrowser(QWidget *parent);
+ void showHelpForKeyword(const QString &id);
+
+private:
+ QVariant loadResource(int type, const QUrl &name);
+
+ QHelpEngineCore *m_helpEngine;
+};
+
+#endif
diff --git a/examples/help/contextsensitivehelp/main.cpp b/examples/help/contextsensitivehelp/main.cpp
new file mode 100644
index 000000000..ca15d9fb6
--- /dev/null
+++ b/examples/help/contextsensitivehelp/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 <QtGui/QApplication>
+
+#include "wateringconfigdialog.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ WateringConfigDialog dia;
+ return dia.exec();
+}
diff --git a/examples/help/contextsensitivehelp/wateringconfigdialog.cpp b/examples/help/contextsensitivehelp/wateringconfigdialog.cpp
new file mode 100644
index 000000000..0529bfcfc
--- /dev/null
+++ b/examples/help/contextsensitivehelp/wateringconfigdialog.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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 "wateringconfigdialog.h"
+
+WateringConfigDialog::WateringConfigDialog()
+{
+ m_ui.setupUi(this);
+ m_widgetInfo.insert(m_ui.plantComboBox, tr("plants"));
+ m_widgetInfo.insert(m_ui.temperatureCheckBox, tr("temperature"));
+ m_widgetInfo.insert(m_ui.temperatureSpinBox, tr("temperature"));
+ m_widgetInfo.insert(m_ui.rainCheckBox, tr("rain"));
+ m_widgetInfo.insert(m_ui.rainSpinBox, tr("rain"));
+ m_widgetInfo.insert(m_ui.startTimeEdit, tr("starting time"));
+ m_widgetInfo.insert(m_ui.amountSpinBox, tr("water amount"));
+ m_widgetInfo.insert(m_ui.sourceComboBox, tr("water source"));
+ m_widgetInfo.insert(m_ui.filterCheckBox, tr("water filtering"));
+
+ connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)),
+ this, SLOT(focusChanged(QWidget*,QWidget*)));
+}
+
+void WateringConfigDialog::focusChanged(QWidget *, QWidget *now)
+{
+ if (m_widgetInfo.contains(now)) {
+ m_ui.helpLabel->setText(tr("Information about %1:").arg(m_widgetInfo.value(now)));
+ QStringList lst = m_widgetInfo.value(now).split(QLatin1Char(' '));
+ m_ui.helpBrowser->showHelpForKeyword(lst.last());
+ }
+}
+
diff --git a/examples/help/contextsensitivehelp/wateringconfigdialog.h b/examples/help/contextsensitivehelp/wateringconfigdialog.h
new file mode 100644
index 000000000..d1fd98643
--- /dev/null
+++ b/examples/help/contextsensitivehelp/wateringconfigdialog.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** 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 WATERINGCONFIGDIALOG_H
+#define WATERINGCONFIGDIALOG_H
+
+#include <QtGui/QDialog>
+#include "ui_wateringconfigdialog.h"
+
+class WateringConfigDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ WateringConfigDialog();
+
+private slots:
+ void focusChanged(QWidget *old, QWidget *now);
+
+private:
+ Ui::WateringConfigDialog m_ui;
+ QMap<QWidget*, QString> m_widgetInfo;
+};
+
+#endif
diff --git a/examples/help/contextsensitivehelp/wateringconfigdialog.ui b/examples/help/contextsensitivehelp/wateringconfigdialog.ui
new file mode 100644
index 000000000..d7a473a3c
--- /dev/null
+++ b/examples/help/contextsensitivehelp/wateringconfigdialog.ui
@@ -0,0 +1,446 @@
+<ui version="4.0" >
+ <class>WateringConfigDialog</class>
+ <widget class="QDialog" name="WateringConfigDialog" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>334</width>
+ <height>550</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Watering Configuration</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <item>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string>Plant:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="3" >
+ <widget class="QComboBox" name="plantComboBox" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <item>
+ <property name="text" >
+ <string>Squash</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Bean</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Carrot</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Strawberry</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Raspberry</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Blueberry</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>67</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>Water when:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" colspan="3" >
+ <widget class="QCheckBox" name="temperatureCheckBox" >
+ <property name="text" >
+ <string>Temperature is higher than:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="4" column="2" >
+ <widget class="QSpinBox" name="temperatureSpinBox" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
+ <property name="specialValueText" >
+ <string/>
+ </property>
+ <property name="suffix" >
+ <string>C</string>
+ </property>
+ <property name="minimum" >
+ <number>10</number>
+ </property>
+ <property name="maximum" >
+ <number>60</number>
+ </property>
+ <property name="value" >
+ <number>20</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="3" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="5" column="1" colspan="3" >
+ <widget class="QCheckBox" name="rainCheckBox" >
+ <property name="text" >
+ <string>Rain less than:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="6" column="2" >
+ <widget class="QSpinBox" name="rainSpinBox" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
+ <property name="specialValueText" >
+ <string/>
+ </property>
+ <property name="suffix" >
+ <string>mm</string>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="3" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="7" column="2" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="8" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Starting Time:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="1" colspan="3" >
+ <widget class="QTimeEdit" name="startTimeEdit" />
+ </item>
+ <item row="9" column="0" >
+ <widget class="QLabel" name="label_4" >
+ <property name="text" >
+ <string>Amount:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="1" colspan="3" >
+ <widget class="QSpinBox" name="amountSpinBox" >
+ <property name="suffix" >
+ <string>l</string>
+ </property>
+ <property name="minimum" >
+ <number>100</number>
+ </property>
+ <property name="maximum" >
+ <number>10000</number>
+ </property>
+ <property name="singleStep" >
+ <number>100</number>
+ </property>
+ <property name="value" >
+ <number>1000</number>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="0" >
+ <widget class="QLabel" name="label_5" >
+ <property name="text" >
+ <string>Source:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="1" colspan="3" >
+ <widget class="QComboBox" name="sourceComboBox" >
+ <item>
+ <property name="text" >
+ <string>Fountain</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>River</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Lake</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Public Water System</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="11" column="0" >
+ <widget class="QLabel" name="label_6" >
+ <property name="text" >
+ <string>Filter:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="11" column="1" colspan="2" >
+ <widget class="QCheckBox" name="filterCheckBox" >
+ <property name="text" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="12" column="0" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="4" column="4" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QGridLayout" >
+ <item row="0" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0" colspan="2" >
+ <widget class="HelpBrowser" name="helpBrowser" />
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="helpLabel" >
+ <property name="text" >
+ <string>&lt;a href="test">Show Details&lt;/a></string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="Line" name="line" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>HelpBrowser</class>
+ <extends>QTextBrowser</extends>
+ <header>helpbrowser.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>WateringConfigDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>227</x>
+ <y>372</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>WateringConfigDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>286</x>
+ <y>378</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>temperatureCheckBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>temperatureSpinBox</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>132</x>
+ <y>101</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>132</x>
+ <y>125</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>rainCheckBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>rainSpinBox</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>110</x>
+ <y>154</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>113</x>
+ <y>169</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/examples/help/help.pro b/examples/help/help.pro
new file mode 100644
index 000000000..f03ec01f4
--- /dev/null
+++ b/examples/help/help.pro
@@ -0,0 +1,13 @@
+TEMPLATE = subdirs
+CONFIG += ordered
+
+SUBDIRS += contextsensitivehelp \
+ remotecontrol \
+ simpletextviewer
+
+# install
+sources.files = README *.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qttools/help
+INSTALLS += sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/help/remotecontrol/enter.png b/examples/help/remotecontrol/enter.png
new file mode 100644
index 000000000..f397f4b9c
--- /dev/null
+++ b/examples/help/remotecontrol/enter.png
Binary files differ
diff --git a/examples/help/remotecontrol/main.cpp b/examples/help/remotecontrol/main.cpp
new file mode 100644
index 000000000..ad561ce4f
--- /dev/null
+++ b/examples/help/remotecontrol/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** 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/QApplication>
+#include "remotecontrol.h"
+
+int main(int argc, char *argv[])
+{
+ Q_INIT_RESOURCE(remotecontrol);
+
+ QApplication a(argc, argv);
+ RemoteControl w;
+ w.show();
+ a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
+ return a.exec();
+}
diff --git a/examples/help/remotecontrol/remotecontrol.cpp b/examples/help/remotecontrol/remotecontrol.cpp
new file mode 100644
index 000000000..45d3fde82
--- /dev/null
+++ b/examples/help/remotecontrol/remotecontrol.cpp
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** 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 <QtCore/QDir>
+#include <QtCore/QProcess>
+#include <QtCore/QTextStream>
+#include <QtCore/QLibraryInfo>
+
+#include <QtGui/QMessageBox>
+
+#include "remotecontrol.h"
+
+RemoteControl::RemoteControl(QWidget *parent, Qt::WFlags flags)
+ : QMainWindow(parent, flags)
+{
+ ui.setupUi(this);
+ connect(ui.indexLineEdit, SIGNAL(returnPressed()),
+ this, SLOT(on_indexButton_clicked()));
+ connect(ui.identifierLineEdit, SIGNAL(returnPressed()),
+ this, SLOT(on_identifierButton_clicked()));
+ connect(ui.urlLineEdit, SIGNAL(returnPressed()),
+ this, SLOT(on_urlButton_clicked()));
+
+ QString rc;
+ QTextStream(&rc) << QLatin1String("qthelp://com.trolltech.qt.")
+ << (QT_VERSION >> 16) << ((QT_VERSION >> 8) & 0xFF)
+ << (QT_VERSION & 0xFF)
+ << QLatin1String("/qdoc/index.html");
+
+ ui.startUrlLineEdit->setText(rc);
+
+ process = new QProcess(this);
+ connect(process, SIGNAL(finished(int,QProcess::ExitStatus)),
+ this, SLOT(helpViewerClosed()));
+}
+
+RemoteControl::~RemoteControl()
+{
+ if (process->state() == QProcess::Running) {
+ process->terminate();
+ process->waitForFinished(3000);
+ }
+}
+
+void RemoteControl::on_actionQuit_triggered()
+{
+ close();
+}
+
+void RemoteControl::on_launchButton_clicked()
+{
+ if (process->state() == QProcess::Running)
+ return;
+
+ QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator();
+#if !defined(Q_OS_MAC)
+ app += QLatin1String("assistant");
+#else
+ app += QLatin1String("Assistant.app/Contents/MacOS/Assistant");
+#endif
+
+ ui.contentsCheckBox->setChecked(true);
+ ui.indexCheckBox->setChecked(true);
+ ui.bookmarksCheckBox->setChecked(true);
+
+ QStringList args;
+ args << QLatin1String("-enableRemoteControl");
+ process->start(app, args);
+ if (!process->waitForStarted()) {
+ QMessageBox::critical(this, tr("Remote Control"),
+ tr("Could not start Qt Assistant from %1.").arg(app));
+ return;
+ }
+
+ if (!ui.startUrlLineEdit->text().isEmpty())
+ sendCommand(QLatin1String("SetSource ")
+ + ui.startUrlLineEdit->text());
+
+ ui.launchButton->setEnabled(false);
+ ui.startUrlLineEdit->setEnabled(false);
+ ui.actionGroupBox->setEnabled(true);
+}
+
+void RemoteControl::sendCommand(const QString &cmd)
+{
+ if (process->state() != QProcess::Running)
+ return;
+ process->write(cmd.toLocal8Bit() + '\n');
+}
+
+void RemoteControl::on_indexButton_clicked()
+{
+ sendCommand(QLatin1String("ActivateKeyword ")
+ + ui.indexLineEdit->text());
+}
+
+void RemoteControl::on_identifierButton_clicked()
+{
+ sendCommand(QLatin1String("ActivateIdentifier ")
+ + ui.identifierLineEdit->text());
+}
+
+void RemoteControl::on_urlButton_clicked()
+{
+ sendCommand(QLatin1String("SetSource ")
+ + ui.urlLineEdit->text());
+}
+
+void RemoteControl::on_syncContentsButton_clicked()
+{
+ sendCommand(QLatin1String("SyncContents"));
+}
+
+void RemoteControl::on_contentsCheckBox_toggled(bool checked)
+{
+ sendCommand(checked ?
+ QLatin1String("Show Contents") : QLatin1String("Hide Contents"));
+}
+
+void RemoteControl::on_indexCheckBox_toggled(bool checked)
+{
+ sendCommand(checked ?
+ QLatin1String("Show Index") : QLatin1String("Hide Index"));
+}
+
+void RemoteControl::on_bookmarksCheckBox_toggled(bool checked)
+{
+ sendCommand(checked ?
+ QLatin1String("Show Bookmarks") : QLatin1String("Hide Bookmarks"));
+}
+
+void RemoteControl::helpViewerClosed()
+{
+ ui.launchButton->setEnabled(true);
+ ui.startUrlLineEdit->setEnabled(true);
+ ui.actionGroupBox->setEnabled(false);
+}
diff --git a/examples/help/remotecontrol/remotecontrol.h b/examples/help/remotecontrol/remotecontrol.h
new file mode 100644
index 000000000..e440add3f
--- /dev/null
+++ b/examples/help/remotecontrol/remotecontrol.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** 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 REMOTECONTROL_H
+#define REMOTECONTROL_H
+
+#include <QtGui/QMainWindow>
+#include "ui_remotecontrol.h"
+
+QT_BEGIN_NAMESPACE
+class QProcess;
+QT_END_NAMESPACE;
+
+class RemoteControl : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ RemoteControl(QWidget *parent = 0, Qt::WFlags flags = 0);
+ ~RemoteControl();
+
+private:
+ Ui::RemoteControlClass ui;
+ QProcess *process;
+
+private slots:
+ void on_launchButton_clicked();
+ void on_actionQuit_triggered();
+ void on_indexButton_clicked();
+ void on_identifierButton_clicked();
+ void on_urlButton_clicked();
+ void on_syncContentsButton_clicked();
+ void on_contentsCheckBox_toggled(bool checked);
+ void on_indexCheckBox_toggled(bool checked);
+ void on_bookmarksCheckBox_toggled(bool checked);
+ void helpViewerClosed();
+
+ void sendCommand(const QString &cmd);
+};
+
+#endif // REMOTECONTROL_H
diff --git a/examples/help/remotecontrol/remotecontrol.pro b/examples/help/remotecontrol/remotecontrol.pro
new file mode 100644
index 000000000..f080b3c0b
--- /dev/null
+++ b/examples/help/remotecontrol/remotecontrol.pro
@@ -0,0 +1,15 @@
+TEMPLATE = app
+
+HEADERS += remotecontrol.h
+SOURCES += main.cpp \
+ remotecontrol.cpp
+FORMS += remotecontrol.ui
+RESOURCES += remotecontrol.qrc
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qttools/help/remotecontrol
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.png *.doc doc
+sources.path = $$[QT_INSTALL_EXAMPLES]/qttools/help/remotecontrol
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/help/remotecontrol/remotecontrol.qrc b/examples/help/remotecontrol/remotecontrol.qrc
new file mode 100644
index 000000000..9b4299d21
--- /dev/null
+++ b/examples/help/remotecontrol/remotecontrol.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/remotecontrol" >
+ <file>enter.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/help/remotecontrol/remotecontrol.ui b/examples/help/remotecontrol/remotecontrol.ui
new file mode 100644
index 000000000..1cfc7f540
--- /dev/null
+++ b/examples/help/remotecontrol/remotecontrol.ui
@@ -0,0 +1,228 @@
+<ui version="4.0" >
+ <class>RemoteControlClass</class>
+ <widget class="QMainWindow" name="RemoteControlClass" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>344</width>
+ <height>364</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>RemoteControl</string>
+ </property>
+ <widget class="QWidget" name="centralWidget" >
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Start URL:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="2" >
+ <widget class="QLineEdit" name="startUrlLineEdit" />
+ </item>
+ <item row="1" column="1" >
+ <widget class="QPushButton" name="launchButton" >
+ <property name="text" >
+ <string>Launch Qt HelpViewer</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>101</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>113</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="3" column="0" colspan="3" >
+ <widget class="QGroupBox" name="actionGroupBox" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
+ <property name="title" >
+ <string>Actions</string>
+ </property>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>Search in Index:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="2" >
+ <layout class="QHBoxLayout" >
+ <property name="spacing" >
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLineEdit" name="indexLineEdit" />
+ </item>
+ <item>
+ <widget class="QToolButton" name="indexButton" >
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="remotecontrol.qrc" >:/remotecontrol/enter.png</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label_4" >
+ <property name="text" >
+ <string>Identifier:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" colspan="2" >
+ <layout class="QHBoxLayout" >
+ <property name="spacing" >
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLineEdit" name="identifierLineEdit" />
+ </item>
+ <item>
+ <widget class="QToolButton" name="identifierButton" >
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="remotecontrol.qrc" >:/remotecontrol/enter.png</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string>Show URL:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" colspan="2" >
+ <layout class="QHBoxLayout" >
+ <property name="spacing" >
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLineEdit" name="urlLineEdit" />
+ </item>
+ <item>
+ <widget class="QToolButton" name="urlButton" >
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="remotecontrol.qrc" >:/remotecontrol/enter.png</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QPushButton" name="syncContentsButton" >
+ <property name="text" >
+ <string>Sync Contents</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>81</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="4" column="0" colspan="3" >
+ <widget class="QCheckBox" name="contentsCheckBox" >
+ <property name="text" >
+ <string>Show Contents</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" >
+ <widget class="QCheckBox" name="indexCheckBox" >
+ <property name="text" >
+ <string>Show Index</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0" colspan="3" >
+ <widget class="QCheckBox" name="bookmarksCheckBox" >
+ <property name="text" >
+ <string>Show Bookmarks</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>344</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile" >
+ <property name="title" >
+ <string>File</string>
+ </property>
+ <addaction name="actionQuit" />
+ </widget>
+ <addaction name="menuFile" />
+ </widget>
+ <widget class="QStatusBar" name="statusBar" />
+ <action name="actionQuit" >
+ <property name="text" >
+ <string>Quit</string>
+ </property>
+ </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11" />
+ <resources>
+ <include location="remotecontrol.qrc" />
+ </resources>
+ <connections/>
+</ui>
diff --git a/examples/help/simpletextviewer/assistant.cpp b/examples/help/simpletextviewer/assistant.cpp
new file mode 100644
index 000000000..2223b4bbf
--- /dev/null
+++ b/examples/help/simpletextviewer/assistant.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** 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 <QtCore/QByteArray>
+#include <QtCore/QDir>
+#include <QtCore/QLibraryInfo>
+#include <QtCore/QProcess>
+
+#include <QtGui/QMessageBox>
+
+#include "assistant.h"
+
+Assistant::Assistant()
+ : proc(0)
+{
+}
+
+//! [0]
+Assistant::~Assistant()
+{
+ if (proc && proc->state() == QProcess::Running) {
+ proc->terminate();
+ proc->waitForFinished(3000);
+ }
+ delete proc;
+}
+//! [0]
+
+//! [1]
+void Assistant::showDocumentation(const QString &page)
+{
+ if (!startAssistant())
+ return;
+
+ QByteArray ba("SetSource ");
+ ba.append("qthelp://com.trolltech.examples.simpletextviewer/doc/");
+
+ proc->write(ba + page.toLocal8Bit() + '\n');
+}
+//! [1]
+
+//! [2]
+bool Assistant::startAssistant()
+{
+ if (!proc)
+ proc = new QProcess();
+
+ if (proc->state() != QProcess::Running) {
+ QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator();
+#if !defined(Q_OS_MAC)
+ app += QLatin1String("assistant");
+#else
+ app += QLatin1String("Assistant.app/Contents/MacOS/Assistant");
+#endif
+
+ QStringList args;
+ args << QLatin1String("-collectionFile")
+ << QLibraryInfo::location(QLibraryInfo::ExamplesPath)
+ + QLatin1String("/help/simpletextviewer/documentation/simpletextviewer.qhc")
+ << QLatin1String("-enableRemoteControl");
+
+ proc->start(app, args);
+
+ if (!proc->waitForStarted()) {
+ QMessageBox::critical(0, QObject::tr("Simple Text Viewer"),
+ QObject::tr("Unable to launch Qt Assistant (%1)").arg(app));
+ return false;
+ }
+ }
+ return true;
+}
+//! [2]
diff --git a/examples/help/simpletextviewer/assistant.h b/examples/help/simpletextviewer/assistant.h
new file mode 100644
index 000000000..3f508dd82
--- /dev/null
+++ b/examples/help/simpletextviewer/assistant.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** 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 ASSISTANT_H
+#define ASSISTANT_H
+
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+class QProcess;
+QT_END_NAMESPACE
+
+class Assistant
+{
+public:
+ Assistant();
+ ~Assistant();
+ void showDocumentation(const QString &file);
+
+private:
+ bool startAssistant();
+ QProcess *proc;
+};
+
+#endif
diff --git a/examples/help/simpletextviewer/documentation/about.txt b/examples/help/simpletextviewer/documentation/about.txt
new file mode 100644
index 000000000..eeab35f4a
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/about.txt
@@ -0,0 +1,9 @@
+The Simple Text Viewer enables the user to select and view existing
+files.
+
+HTML files is displayed using rich text, while other files are
+presented as plain text. The application provides a file dialog
+allowing the user to search for files using wildcard matching. The
+search is performed within in the specified directory, and the user is
+given an option to browse the existing file system to find the
+relevant directory.
diff --git a/examples/help/simpletextviewer/documentation/browse.html b/examples/help/simpletextviewer/documentation/browse.html
new file mode 100644
index 000000000..987abf31f
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/browse.html
@@ -0,0 +1,34 @@
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Browse</title>
+ </head>
+ <body style="font-size:12pt;font-family:helvetica">
+
+ <p><center><h2>Browse</h2></center></p>
+
+ <p>
+ The file dialog let you browse the current file system to
+ specify the directory in which the file you want to open
+ resides.
+ Note that only the specified directory will be searched, any
+ subdirectories will simply be ignored.
+ </p>
+
+ <br />
+ <br />
+ <table align="center" cellpadding="2" cellspacing="1" border="0" width="100%">
+ <tr valign="top" bgcolor="#f0f0f0">
+ <td><center><img src="images/browse.png" /></center></td>
+ </tr>
+ </table>
+
+ <br />
+ <br />
+ <p>
+ See also: <a href="filedialog.html">File Dialog</a>, <a href="wildcardmatching.html">Wildcard Matching</a>,
+ <a href="findfile.html">Find File</a>
+ </p>
+ </body>
+</html>
+
diff --git a/examples/help/simpletextviewer/documentation/filedialog.html b/examples/help/simpletextviewer/documentation/filedialog.html
new file mode 100644
index 000000000..afa65ed57
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/filedialog.html
@@ -0,0 +1,48 @@
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>File Dialog</title>
+ </head>
+ <body style="font-size:12pt;font-family:helvetica">
+
+ <p><center><h2>File Dialog</h2></center></p>
+
+ <p>
+ In the file dialog you can name a particular file name, or
+ search for files using wildcard matching, i.e. specify a
+ file name containing wildcards. In addition you must specify
+ the directory in which the file you search for resides.
+ </p>
+
+ <br />
+ <br />
+ <table align="center" cellpadding="2" cellspacing="1" border="0" width="100%">
+ <tr valign="top" bgcolor="#f0f0f0">
+ <td><center><img src="images/filedialog.png" /></center></td>
+ </tr>
+ </table>
+
+ <br />
+ <br />
+ <p>
+ By default the dialog will search for all files (*) in the
+ current directory (the directory the application is run from).
+ </p>
+
+ <p>
+ When editing the file name and directory parameters, an
+ overview of the matching files are displayed in the
+ dialog. The overview is updated whenever the parameters
+ change.
+ </p>
+
+ <br />
+ <br />
+ <p>
+ See also: <a href="browse.html">Browse</a>, <a href="wildcardmatching.html">Wildcard Matching</a>,
+ <a href="findfile.html">Find File</a>
+ </p>
+ </body>
+</html>
+
+
diff --git a/examples/help/simpletextviewer/documentation/findfile.html b/examples/help/simpletextviewer/documentation/findfile.html
new file mode 100644
index 000000000..32e014718
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/findfile.html
@@ -0,0 +1,32 @@
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Find File</title>
+ </head>
+ <body style="font-size:12pt;font-family:helvetica">
+
+ <p><center><h2>Find File</h2></center></p>
+
+ <p>
+ To open and view a file in the Simple Text Viewer, select the
+ 'Open...' option in the 'File' menu. The application will then
+ provide you with a file dialog that you can use to search for
+ any existing file.
+ </p>
+
+ <br />
+ <br />
+ <table align="center" cellpadding="2" cellspacing="1" border="0" width="100%">
+ <tr valign="top" bgcolor="#f0f0f0">
+ <td><center><img src="images/fadedfilemenu.png" /></center></td>
+ </tr>
+ </table>
+
+ <br />
+ <br />
+ <p>
+ See also: <a href="openfile.html">Open File</a>, <a href="filedialog.html">File Dialog</a>
+ </p>
+ </body>
+</html>
+
diff --git a/examples/help/simpletextviewer/documentation/images/browse.png b/examples/help/simpletextviewer/documentation/images/browse.png
new file mode 100644
index 000000000..86db6b19e
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/images/browse.png
Binary files differ
diff --git a/examples/help/simpletextviewer/documentation/images/fadedfilemenu.png b/examples/help/simpletextviewer/documentation/images/fadedfilemenu.png
new file mode 100644
index 000000000..fde0e43f6
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/images/fadedfilemenu.png
Binary files differ
diff --git a/examples/help/simpletextviewer/documentation/images/filedialog.png b/examples/help/simpletextviewer/documentation/images/filedialog.png
new file mode 100644
index 000000000..883a33a26
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/images/filedialog.png
Binary files differ
diff --git a/examples/help/simpletextviewer/documentation/images/handbook.png b/examples/help/simpletextviewer/documentation/images/handbook.png
new file mode 100644
index 000000000..3bd2b928b
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/images/handbook.png
Binary files differ
diff --git a/examples/help/simpletextviewer/documentation/images/icon.png b/examples/help/simpletextviewer/documentation/images/icon.png
new file mode 100644
index 000000000..6daec0ade
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/images/icon.png
Binary files differ
diff --git a/examples/help/simpletextviewer/documentation/images/mainwindow.png b/examples/help/simpletextviewer/documentation/images/mainwindow.png
new file mode 100644
index 000000000..c28d5e9ff
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/images/mainwindow.png
Binary files differ
diff --git a/examples/help/simpletextviewer/documentation/images/open.png b/examples/help/simpletextviewer/documentation/images/open.png
new file mode 100644
index 000000000..1e5bba3c8
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/images/open.png
Binary files differ
diff --git a/examples/help/simpletextviewer/documentation/images/wildcard.png b/examples/help/simpletextviewer/documentation/images/wildcard.png
new file mode 100644
index 000000000..6e83a56cc
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/images/wildcard.png
Binary files differ
diff --git a/examples/help/simpletextviewer/documentation/index.html b/examples/help/simpletextviewer/documentation/index.html
new file mode 100644
index 000000000..5a7b1d5fa
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/index.html
@@ -0,0 +1,41 @@
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Manual</title>
+ </head>
+ <body style="font-size:12pt;font-family:helvetica">
+
+ <p><center><h2>Simple Text Viewer</h2></center></p>
+
+ <p>
+ The Simple Text Viewer enables the user to select and view
+ existing files.
+ </p>
+
+ <p><center>
+ <img src="images/mainwindow.png" />
+ </center></p>
+
+ <p>
+ HTML files is displayed using rich text, while
+ other files are presented as plain text. The application
+ provides a file dialog allowing the user to search for files
+ using wildcard matching. The search is performed within in the
+ specified directory, and the user is given an option to browse
+ the existing file system to find the relevant directory.
+ </p>
+
+ <ul>
+ <li><a href="findfile.html">Find File</a></li>
+ <ul>
+ <li><a href="filedialog.html">File Dialog</a></li>
+ <li><a href="wildcardmatching.html">WildCard Matching</a></li>
+ <li><a href="browse.html">Browse</a></li>
+ </ul>
+ <li><a href="openfile.html">Open File</a></li>
+ </ul>
+ </body>
+</html>
+
+
+
diff --git a/examples/help/simpletextviewer/documentation/intro.html b/examples/help/simpletextviewer/documentation/intro.html
new file mode 100644
index 000000000..2e2aa40de
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/intro.html
@@ -0,0 +1,28 @@
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Manual</title>
+ </head>
+ <body style="font-size:12pt;font-family:helvetica">
+
+ <p><center><h2>Simple Text Viewer</h2></center></p>
+
+ <p>
+ The Simple Text Viewer enables the user to select and view
+ existing files.
+ </p>
+
+ <p><center>
+ <img src="images/mainwindow.png" />
+ </center></p>
+
+ <p>
+ The application provides its own custom documentation that is
+ available through the <b>Help</b> menu in the main window's menubar
+ and through the <b>Help</b> button in the application's find file
+ dialog.
+ </p>
+
+ </body>
+</html>
+
diff --git a/examples/help/simpletextviewer/documentation/openfile.html b/examples/help/simpletextviewer/documentation/openfile.html
new file mode 100644
index 000000000..e172de95e
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/openfile.html
@@ -0,0 +1,36 @@
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Open File</title>
+ </head>
+ <body style="font-size:12pt;font-family:helvetica">
+
+ <p><center><h2>Open File</h2></center></p>
+
+ <p>
+ Once the file you want to view appears in the dialog's
+ display, you can open it in two different ways.
+ </p>
+
+ <p>
+ By pressing the 'Open' button the currently selected file will
+ be opened. By default, the first file in the list of matching
+ files is selected. Another way of opening a file is to simply
+ double click the displayed file name.
+ </p>
+
+ <br />
+ <br />
+ <table align="center" cellpadding="2" cellspacing="1" border="0" width="100%">
+ <tr valign="top" bgcolor="#f0f0f0">
+ <td><center><img src="images/open.png" /></center></td>
+ </tr>
+ </table>
+
+ <br />
+ <br />
+ <p>
+ See also: <a href="findfile.html">Find File</a>
+ </p>
+ </body>
+</html>
diff --git a/examples/help/simpletextviewer/documentation/simpletextviewer.qch b/examples/help/simpletextviewer/documentation/simpletextviewer.qch
new file mode 100644
index 000000000..c40132803
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/simpletextviewer.qch
Binary files differ
diff --git a/examples/help/simpletextviewer/documentation/simpletextviewer.qhc b/examples/help/simpletextviewer/documentation/simpletextviewer.qhc
new file mode 100644
index 000000000..db380cabf
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/simpletextviewer.qhc
Binary files differ
diff --git a/examples/help/simpletextviewer/documentation/simpletextviewer.qhcp b/examples/help/simpletextviewer/documentation/simpletextviewer.qhcp
new file mode 100644
index 000000000..e7c23210b
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/simpletextviewer.qhcp
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QHelpCollectionProject version="1.0">
+ <assistant>
+ <title>Simple Text Viewer</title>
+ <applicationIcon>images/handbook.png</applicationIcon>
+ <cacheDirectory>Trolltech/SimpleTextViewer</cacheDirectory>
+ <startPage>qthelp://com.trolltech.examples.simpletextviewer/doc/index.html</startPage>
+ <aboutMenuText>
+ <text>About Simple Text Viewer</text>
+ </aboutMenuText>
+ <aboutDialog>
+ <file>about.txt</file>
+ <icon>images/icon.png</icon>
+ </aboutDialog>
+ <enableDocumentationManager>false</enableDocumentationManager>
+ <enableAddressBar>false</enableAddressBar>
+ <enableFilterFunctionality>false</enableFilterFunctionality>
+ </assistant>
+ <docFiles>
+ <generate>
+ <file>
+ <input>simpletextviewer.qhp</input>
+ <output>simpletextviewer.qch</output>
+ </file>
+ </generate>
+ <register>
+ <file>simpletextviewer.qch</file>
+ </register>
+ </docFiles>
+ </QHelpCollectionProject>
diff --git a/examples/help/simpletextviewer/documentation/simpletextviewer.qhp b/examples/help/simpletextviewer/documentation/simpletextviewer.qhp
new file mode 100644
index 000000000..4cb83a5f3
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/simpletextviewer.qhp
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QtHelpProject version="1.0">
+ <namespace>com.trolltech.examples.simpletextviewer</namespace>
+ <virtualFolder>doc</virtualFolder>
+ <filterSection>
+ <toc>
+ <section title="Simple Text Viewer" ref="index.html">
+ <section title="Find File" ref="./findfile.html">
+ <section title="File Dialog" ref="./filedialog.html"></section>
+ <section title="Wildcard Matching" ref="./wildcardmatching.html"></section>
+ <section title="Browse" ref="./browse.html"></section>
+ </section>
+ <section title="Open File" ref="./openfile.html"></section>
+ </section>
+ </toc>
+ <keywords>
+ <keyword name="Display" ref="./index.html"/>
+ <keyword name="Rich text" ref="./index.html"/>
+ <keyword name="Plain text" ref="./index.html"/>
+ <keyword name="Find" ref="./findfile.html"/>
+ <keyword name="File menu" ref="./findfile.html"/>
+ <keyword name="File name" ref="./filedialog.html"/>
+ <keyword name="File dialog" ref="./filedialog.html"/>
+ <keyword name="File globbing" ref="./wildcardmatching.html"/>
+ <keyword name="Wildcard matching" ref="./wildcardmatching.html"/>
+ <keyword name="Wildcard syntax" ref="./wildcardmatching.html"/>
+ <keyword name="Browse" ref="./browse.html"/>
+ <keyword name="Directory" ref="./browse.html"/>
+ <keyword name="Open" ref="./openfile.html"/>
+ <keyword name="Select" ref="./openfile.html"/>
+ </keywords>
+ <files>
+ <file>browse.html</file>
+ <file>filedialog.html</file>
+ <file>findfile.html</file>
+ <file>index.html</file>
+ <file>intro.html</file>
+ <file>openfile.html</file>
+ <file>wildcardmatching.html</file>
+ <file>images/browse.png</file>
+ <file>images/fadedfilemenu.png</file>
+ <file>images/filedialog.png</file>
+ <file>images/handbook.png</file>
+ <file>images/mainwindow.png</file>
+ <file>images/open.png</file>
+ <file>images/wildcard.png</file>
+ </files>
+ </filterSection>
+ </QtHelpProject>
diff --git a/examples/help/simpletextviewer/documentation/wildcardmatching.html b/examples/help/simpletextviewer/documentation/wildcardmatching.html
new file mode 100644
index 000000000..eb1839a06
--- /dev/null
+++ b/examples/help/simpletextviewer/documentation/wildcardmatching.html
@@ -0,0 +1,57 @@
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Wildcard Matching</title>
+ </head>
+ <body style="font-size:12pt;font-family:helvetica">
+
+ <p><center><h2>Wildcard Matching</h2></center></p>
+
+ <p>
+ Most command shells such as bash or cmd.exe support "file
+ globbing", the ability to identify a group of files by using
+ wildcards.
+
+ <br />
+ <br />
+ <table align="center" cellpadding="2" cellspacing="1" border="0" width="100%">
+ <tr valign="top" bgcolor="#f0f0f0">
+ <td><center><img src="images/wildcard.png" /></center></td>
+ </tr>
+ </table>
+
+ <br />
+ <br />
+ <p>
+ Wildcard matching provides four features:
+ </p>
+
+ <ul>
+ <li>Any character represents itself apart from those
+ mentioned below. Thus 'c' matches the character 'c'.
+ </li>
+ <li>The '?' character matches any single character.</li>
+ <li>The '*' matches zero or more of any characters.</li>
+ <li>Sets of characters can be represented in square brackets.
+ Within the character class, like outside, backslash
+ has no special meaning.
+ </li>
+ </ul>
+
+ <p>
+ For example we could identify HTML files with
+ <code>*.html</code>. This will match zero or more characters
+ followed by a dot followed by 'h', 't', 'm' and 'l'.
+ </p>
+
+ <br />
+ <br />
+ <p>
+ See also: <a href="browse.html">Browse</a>, <a href="filedialog.html">File Dialog</a>,
+ <a href="findfile.html">Find File</a>
+ </p>
+ </body>
+</html>
+
+
+
diff --git a/examples/help/simpletextviewer/findfiledialog.cpp b/examples/help/simpletextviewer/findfiledialog.cpp
new file mode 100644
index 000000000..086be965d
--- /dev/null
+++ b/examples/help/simpletextviewer/findfiledialog.cpp
@@ -0,0 +1,221 @@
+/****************************************************************************
+**
+** 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 <QtCore/QDir>
+#include <QtGui/QLayout>
+#include <QtGui/QComboBox>
+#include <QtGui/QTreeWidget>
+#include <QtGui/QLayout>
+#include <QtGui/QFileDialog>
+#include <QtGui/QDialogButtonBox>
+#include <QtGui/QToolButton>
+#include <QtGui/QPushButton>
+#include <QtGui/QLabel>
+
+#include "findfiledialog.h"
+#include "assistant.h"
+#include "textedit.h"
+
+//! [0]
+FindFileDialog::FindFileDialog(TextEdit *editor, Assistant *assistant)
+ : QDialog(editor)
+{
+ currentAssistant = assistant;
+ currentEditor = editor;
+//! [0]
+
+ createButtons();
+ createComboBoxes();
+ createFilesTree();
+ createLabels();
+ createLayout();
+
+ directoryComboBox->addItem(QDir::toNativeSeparators(QDir::currentPath()));
+ fileNameComboBox->addItem("*");
+ findFiles();
+
+ setWindowTitle(tr("Find File"));
+//! [1]
+}
+//! [1]
+
+void FindFileDialog::browse()
+{
+ QString currentDirectory = directoryComboBox->currentText();
+ QString newDirectory = QFileDialog::getExistingDirectory(this,
+ tr("Select Directory"), currentDirectory);
+ if (!newDirectory.isEmpty()) {
+ directoryComboBox->addItem(QDir::toNativeSeparators(newDirectory));
+ directoryComboBox->setCurrentIndex(directoryComboBox->count() - 1);
+ update();
+ }
+}
+
+//! [2]
+void FindFileDialog::help()
+{
+ currentAssistant->showDocumentation("filedialog.html");
+}
+//! [2]
+
+void FindFileDialog::openFile(QTreeWidgetItem *item)
+{
+ if (!item) {
+ item = foundFilesTree->currentItem();
+ if (!item)
+ return;
+ }
+
+ QString fileName = item->text(0);
+ QString path = directoryComboBox->currentText() + QDir::separator();
+
+ currentEditor->setContents(path + fileName);
+ close();
+}
+
+void FindFileDialog::update()
+{
+ findFiles();
+ buttonBox->button(QDialogButtonBox::Open)->setEnabled(
+ foundFilesTree->topLevelItemCount() > 0);
+}
+
+void FindFileDialog::findFiles()
+{
+ QRegExp filePattern(fileNameComboBox->currentText() + "*");
+ filePattern.setPatternSyntax(QRegExp::Wildcard);
+
+ QDir directory(directoryComboBox->currentText());
+
+ QStringList allFiles = directory.entryList(QDir::Files | QDir::NoSymLinks);
+ QStringList matchingFiles;
+
+ foreach (QString file, allFiles) {
+ if (filePattern.exactMatch(file))
+ matchingFiles << file;
+ }
+ showFiles(matchingFiles);
+}
+
+void FindFileDialog::showFiles(const QStringList &files)
+{
+ foundFilesTree->clear();
+
+ for (int i = 0; i < files.count(); ++i) {
+ QTreeWidgetItem *item = new QTreeWidgetItem(foundFilesTree);
+ item->setText(0, files[i]);
+ }
+
+ if (files.count() > 0)
+ foundFilesTree->setCurrentItem(foundFilesTree->topLevelItem(0));
+}
+
+void FindFileDialog::createButtons()
+{
+ browseButton = new QToolButton;
+ browseButton->setText(tr("..."));
+ connect(browseButton, SIGNAL(clicked()), this, SLOT(browse()));
+
+ buttonBox = new QDialogButtonBox(QDialogButtonBox::Open
+ | QDialogButtonBox::Cancel
+ | QDialogButtonBox::Help);
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(openFile()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(help()));
+}
+
+void FindFileDialog::createComboBoxes()
+{
+ directoryComboBox = new QComboBox;
+ fileNameComboBox = new QComboBox;
+
+ fileNameComboBox->setEditable(true);
+ fileNameComboBox->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Preferred);
+
+ directoryComboBox->setMinimumContentsLength(30);
+ directoryComboBox->setSizeAdjustPolicy(
+ QComboBox::AdjustToMinimumContentsLength);
+ directoryComboBox->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Preferred);
+
+ connect(fileNameComboBox, SIGNAL(editTextChanged(QString)),
+ this, SLOT(update()));
+ connect(directoryComboBox, SIGNAL(currentIndexChanged(QString)),
+ this, SLOT(update()));
+}
+
+void FindFileDialog::createFilesTree()
+{
+ foundFilesTree = new QTreeWidget;
+ foundFilesTree->setColumnCount(1);
+ foundFilesTree->setHeaderLabels(QStringList(tr("Matching Files")));
+ foundFilesTree->setRootIsDecorated(false);
+ foundFilesTree->setSelectionMode(QAbstractItemView::SingleSelection);
+
+ connect(foundFilesTree, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
+ this, SLOT(openFile(QTreeWidgetItem*)));
+}
+
+void FindFileDialog::createLabels()
+{
+ directoryLabel = new QLabel(tr("Search in:"));
+ fileNameLabel = new QLabel(tr("File name (including wildcards):"));
+}
+
+void FindFileDialog::createLayout()
+{
+ QHBoxLayout *fileLayout = new QHBoxLayout;
+ fileLayout->addWidget(fileNameLabel);
+ fileLayout->addWidget(fileNameComboBox);
+
+ QHBoxLayout *directoryLayout = new QHBoxLayout;
+ directoryLayout->addWidget(directoryLabel);
+ directoryLayout->addWidget(directoryComboBox);
+ directoryLayout->addWidget(browseButton);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addLayout(fileLayout);
+ mainLayout->addLayout(directoryLayout);
+ mainLayout->addWidget(foundFilesTree);
+ mainLayout->addStretch();
+ mainLayout->addWidget(buttonBox);
+ setLayout(mainLayout);
+}
diff --git a/examples/help/simpletextviewer/findfiledialog.h b/examples/help/simpletextviewer/findfiledialog.h
new file mode 100644
index 000000000..71abd4aac
--- /dev/null
+++ b/examples/help/simpletextviewer/findfiledialog.h
@@ -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$
+**
+****************************************************************************/
+
+#ifndef FINDFILEDIALOG_H
+#define FINDFILEDIALOG_H
+
+#include <QtGui/QDialog>
+
+QT_BEGIN_NAMESPACE
+class QComboBox;
+class QDialogButtonBox;
+class QLabel;
+class QToolButton;
+class QTreeWidget;
+class QTreeWidgetItem;
+QT_END_NAMESPACE
+
+class Assistant;
+class TextEdit;
+
+//! [0]
+class FindFileDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ FindFileDialog(TextEdit *editor, Assistant *assistant);
+
+private slots:
+ void browse();
+ void help();
+ void openFile(QTreeWidgetItem *item = 0);
+ void update();
+
+private:
+ void findFiles();
+ void showFiles(const QStringList &files);
+
+ void createButtons();
+ void createComboBoxes();
+ void createFilesTree();
+ void createLabels();
+ void createLayout();
+
+ Assistant *currentAssistant;
+ TextEdit *currentEditor;
+ QTreeWidget *foundFilesTree;
+
+ QComboBox *directoryComboBox;
+ QComboBox *fileNameComboBox;
+
+ QLabel *directoryLabel;
+ QLabel *fileNameLabel;
+
+ QDialogButtonBox *buttonBox;
+
+ QToolButton *browseButton;
+};
+//! [0]
+
+#endif
diff --git a/examples/help/simpletextviewer/main.cpp b/examples/help/simpletextviewer/main.cpp
new file mode 100644
index 000000000..4c8aab9c8
--- /dev/null
+++ b/examples/help/simpletextviewer/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** 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/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/help/simpletextviewer/mainwindow.cpp b/examples/help/simpletextviewer/mainwindow.cpp
new file mode 100644
index 000000000..61fbdf3cb
--- /dev/null
+++ b/examples/help/simpletextviewer/mainwindow.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** 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 <QtCore/QLibraryInfo>
+#include <QtGui/QApplication>
+#include <QtGui/QAction>
+#include <QtGui/QMenu>
+#include <QtGui/QMenuBar>
+#include <QtGui/QMessageBox>
+
+#include "mainwindow.h"
+#include "findfiledialog.h"
+#include "assistant.h"
+#include "textedit.h"
+
+// ![0]
+MainWindow::MainWindow()
+{
+ assistant = new Assistant;
+// ![0]
+ textViewer = new TextEdit;
+ textViewer->setContents(QLibraryInfo::location(QLibraryInfo::ExamplesPath)
+ + QLatin1String("/help/simpletextviewer/documentation/intro.html"));
+ setCentralWidget(textViewer);
+
+ createActions();
+ createMenus();
+
+ setWindowTitle(tr("Simple Text Viewer"));
+ resize(750, 400);
+// ![1]
+}
+//! [1]
+
+//! [2]
+void MainWindow::closeEvent(QCloseEvent *)
+{
+ delete assistant;
+}
+//! [2]
+
+void MainWindow::about()
+{
+ QMessageBox::about(this, tr("About Simple Text Viewer"),
+ tr("This example demonstrates how to use\n"
+ "Qt Assistant as help system for your\n"
+ "own application."));
+}
+
+//! [3]
+void MainWindow::showDocumentation()
+{
+ assistant->showDocumentation("index.html");
+}
+//! [3]
+
+void MainWindow::open()
+{
+ FindFileDialog dialog(textViewer, assistant);
+ dialog.exec();
+}
+
+//! [4]
+void MainWindow::createActions()
+{
+ assistantAct = new QAction(tr("Help Contents"), this);
+ assistantAct->setShortcut(QKeySequence::HelpContents);
+ connect(assistantAct, SIGNAL(triggered()), this, SLOT(showDocumentation()));
+//! [4]
+
+ openAct = new QAction(tr("&Open..."), this);
+ openAct->setShortcut(QKeySequence::Open);
+ connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
+
+ clearAct = new QAction(tr("&Clear"), this);
+ clearAct->setShortcut(tr("Ctrl+C"));
+ connect(clearAct, SIGNAL(triggered()), textViewer, SLOT(clear()));
+
+ exitAct = new QAction(tr("E&xit"), this);
+ exitAct->setShortcuts(QKeySequence::Quit);
+ connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
+
+ aboutAct = new QAction(tr("&About"), this);
+ connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
+
+ aboutQtAct = new QAction(tr("About &Qt"), this);
+ connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+//! [5]
+}
+//! [5]
+
+void MainWindow::createMenus()
+{
+ fileMenu = new QMenu(tr("&File"), this);
+ fileMenu->addAction(openAct);
+ fileMenu->addAction(clearAct);
+ fileMenu->addSeparator();
+ fileMenu->addAction(exitAct);
+
+ helpMenu = new QMenu(tr("&Help"), this);
+ helpMenu->addAction(assistantAct);
+ helpMenu->addSeparator();
+ helpMenu->addAction(aboutAct);
+ helpMenu->addAction(aboutQtAct);
+
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(helpMenu);
+}
diff --git a/examples/help/simpletextviewer/mainwindow.h b/examples/help/simpletextviewer/mainwindow.h
new file mode 100644
index 000000000..4fab382f2
--- /dev/null
+++ b/examples/help/simpletextviewer/mainwindow.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** 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 <QtGui/QMainWindow>
+
+class Assistant;
+class TextEdit;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+ void showDocumentation(const QString &file);
+
+private slots:
+ void about();
+ void showDocumentation();
+ void open();
+
+protected:
+ void closeEvent(QCloseEvent *event);
+
+private:
+ void createActions();
+ void createMenus();
+
+ Assistant *assistant;
+ TextEdit *textViewer;
+
+ QMenu *fileMenu;
+ QMenu *helpMenu;
+
+ QAction *assistantAct;
+ QAction *clearAct;
+ QAction *openAct;
+ QAction *exitAct;
+ QAction *aboutAct;
+ QAction *aboutQtAct;
+};
+
+#endif
diff --git a/examples/help/simpletextviewer/simpletextviewer.pro b/examples/help/simpletextviewer/simpletextviewer.pro
new file mode 100644
index 000000000..46bda4cef
--- /dev/null
+++ b/examples/help/simpletextviewer/simpletextviewer.pro
@@ -0,0 +1,18 @@
+HEADERS = mainwindow.h \
+ findfiledialog.h \
+ assistant.h \
+ textedit.h
+SOURCES = main.cpp \
+ mainwindow.cpp \
+ findfiledialog.cpp \
+ assistant.cpp \
+ textedit.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qttools/help/simpletextviewer
+sources.files = $$SOURCES $$HEADERS $$RESOURCES documentation *.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qttools/help/simpletextviewer
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+
diff --git a/examples/help/simpletextviewer/textedit.cpp b/examples/help/simpletextviewer/textedit.cpp
new file mode 100644
index 000000000..52d85b380
--- /dev/null
+++ b/examples/help/simpletextviewer/textedit.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** 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 <QtCore/QFileInfo>
+#include <QtCore/QFile>
+
+#include "textedit.h"
+
+TextEdit::TextEdit(QWidget *parent)
+ : QTextEdit(parent)
+{
+ setReadOnly(true);
+}
+
+void TextEdit::setContents(const QString &fileName)
+{
+ QFileInfo fi(fileName);
+ srcUrl = QUrl::fromLocalFile(fi.absoluteFilePath());
+ QFile file(fileName);
+ if (file.open(QIODevice::ReadOnly)) {
+ QString data(file.readAll());
+ if (fileName.endsWith(".html"))
+ setHtml(data);
+ else
+ setPlainText(data);
+ }
+}
+
+QVariant TextEdit::loadResource(int type, const QUrl &name)
+{
+ if (type == QTextDocument::ImageResource) {
+ QFile file(srcUrl.resolved(name).toLocalFile());
+ if (file.open(QIODevice::ReadOnly))
+ return file.readAll();
+ }
+ return QTextEdit::loadResource(type, name);
+}
diff --git a/examples/help/simpletextviewer/textedit.h b/examples/help/simpletextviewer/textedit.h
new file mode 100644
index 000000000..b9ecabd1d
--- /dev/null
+++ b/examples/help/simpletextviewer/textedit.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** 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 TEXTEDIT_H
+#define TEXTEDIT_H
+
+#include <QtCore/QUrl>
+#include <QtGui/QTextEdit>
+
+class TextEdit : public QTextEdit
+{
+ Q_OBJECT
+
+public:
+ TextEdit(QWidget *parent = 0);
+ void setContents(const QString &fileName);
+
+private:
+ QVariant loadResource(int type, const QUrl &name);
+ QUrl srcUrl;
+};
+
+#endif