summaryrefslogtreecommitdiffstats
path: root/examples/help/simpletextviewer
diff options
context:
space:
mode:
Diffstat (limited to 'examples/help/simpletextviewer')
-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
30 files changed, 1286 insertions, 0 deletions
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