diff options
author | David Schulz <david.schulz@digia.com> | 2012-12-06 11:34:35 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-06 12:44:05 +0100 |
commit | 83a6416f9ded3b164a075d72ef1ac7adc1d2f340 (patch) | |
tree | d16bfb6dc02e08311bb21b8353009df145ac072d /examples/help | |
parent | 68d1384704afa8143f785c580f10f5d97528b0b7 (diff) |
QtTools: Doc: Moved assistant examples
... and changed exampledirs in the qdocconf files
to the appropriate modules.
Change-Id: Ic15d9fc845d59fb4e84ee39a52e457666fa09e51
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Diffstat (limited to 'examples/help')
35 files changed, 1 insertions, 1731 deletions
diff --git a/examples/help/help.pro b/examples/help/help.pro index 5a4eb2a35..c98aad8a9 100644 --- a/examples/help/help.pro +++ b/examples/help/help.pro @@ -2,5 +2,4 @@ TEMPLATE = subdirs CONFIG += ordered SUBDIRS += contextsensitivehelp \ - remotecontrol \ - simpletextviewer + remotecontrol diff --git a/examples/help/simpletextviewer/assistant.cpp b/examples/help/simpletextviewer/assistant.cpp deleted file mode 100644 index e8b81de67..000000000 --- a/examples/help/simpletextviewer/assistant.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia Plc 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 <QtWidgets/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 deleted file mode 100644 index 02728e7bd..000000000 --- a/examples/help/simpletextviewer/assistant.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia Plc 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/doc/images/simpletextviewer-example.png b/examples/help/simpletextviewer/doc/images/simpletextviewer-example.png Binary files differdeleted file mode 100644 index 95d290539..000000000 --- a/examples/help/simpletextviewer/doc/images/simpletextviewer-example.png +++ /dev/null diff --git a/examples/help/simpletextviewer/doc/images/simpletextviewer-findfiledialog.png b/examples/help/simpletextviewer/doc/images/simpletextviewer-findfiledialog.png Binary files differdeleted file mode 100644 index f6e55f099..000000000 --- a/examples/help/simpletextviewer/doc/images/simpletextviewer-findfiledialog.png +++ /dev/null diff --git a/examples/help/simpletextviewer/doc/images/simpletextviewer-mainwindow.png b/examples/help/simpletextviewer/doc/images/simpletextviewer-mainwindow.png Binary files differdeleted file mode 100644 index 98c1c61cc..000000000 --- a/examples/help/simpletextviewer/doc/images/simpletextviewer-mainwindow.png +++ /dev/null diff --git a/examples/help/simpletextviewer/doc/src/simpletextviewer.qdoc b/examples/help/simpletextviewer/doc/src/simpletextviewer.qdoc deleted file mode 100644 index dd8904721..000000000 --- a/examples/help/simpletextviewer/doc/src/simpletextviewer.qdoc +++ /dev/null @@ -1,447 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example help/simpletextviewer - \title Simple Text Viewer Example - - \brief The Simple Text Viewer example shows how to use \QA as a customized - help viewer for your application. - - \image simpletextviewer-example.png - - This is done in two stages. Firstly, documentation is created and \QA - is customized; secondly, the functionality to launch and control - \QA is added to the application. - - The Simple Text Viewer application lets the user select and view - existing files. - - The application provides its own custom documentation that is - available from the \gui Help menu in the main window's menu bar - or by clicking the \gui Help button in the application's find file - dialog. - - The example consists of four classes: - - \list - \li \c Assistant provides functionality to launch \QA. - \li \c MainWindow is the main application window. - \li \c FindFileDialog allows the user to search for - files using wildcard matching. - \li \c TextEdit provides a rich text browser that makes - sure that images referenced in HTML documents are - displayed properly. - \endlist - - \note We will only comment on the parts of the implementation - that are relevant to the main issue, that is making Qt Assistant - act as a customized help viewer for our Simple Text Viewer - application. - - \section1 Creating Documentation and Customizing \QA - - How to create the actual documentation in the form of HTML pages is - not in the scope of this example. In general, HTML pages can either - be written by hand or generated with the help of documentation tools - like qdoc or Doxygen. For the purposes of this example we assume that - the HTML files have already been created. So, the only thing that - remains to be done is to tell \QA how to structure and display the - help information. - - \section2 Organizing Documentation for \QA - - Plain HTML files only contain text or documentation about specific topics, - but they usually include no information about how several HTML documents - relate to each other or in which order they are supposed to be read. - What is missing is a table of contents along with an index to access - certain help contents quickly, without having to browse through a lot - of documents in order to find a piece of information. - - To organize the documentation and make it available for \QA, we have - to create a Qt help project (.qhp) file. The first and most important - part of the project file is the definition of the namespace. The namespace - has to be unique and will be the first part of the page URL in \QA. - In addition, we have to set a virtual folder which acts as a common - folder for documentation sets. This means, that two documentation sets - identified by two different namespaces can cross reference HTML files - since those files are in one big virtual folder. However, for this - example, we'll only have one documentation set available, so the - virtual folder name and functionality are not important. - - \code - <?xml version="1.0" encoding="UTF-8"?> - <QtHelpProject version="1.0"> - <namespace>com.trolltech.examples.simpletextviewer</namespace> - <virtualFolder>doc</virtualFolder> - \endcode - - The next step is to define the filter section. A filter section - contains the table of contents, indices and a complete list of - all documentation files, and can have any number of filter attributes - assigned to it. A filter attribute is an ordinary string which can - be freely chosen. Later in \QA, users can then define a custom - filter referencing those attributes. If the attributes of a filter - section match the attributes of the custom filter the documentation - will be shown, otherwise \QA will hide the documentation. - - Again, since we'll only have one documentation set, we do not need - the filtering functionality of \QA and can therefore skip the - filter attributes. - - Now, we build up the table of contents. An item in the table is - defined by the \c section tag which contains the attributes for the - item title as well as link to the actual page. Section tags can be - nested infinitely, but for practical reasons it is not recommended - to nest them deeper than three or four levels. For our example we - want to use the following outline for the table of contents: - - \list - \li Simple Text Viewer - \list - \li Find File - \list - \li File Dialog - \li Wildcard Matching - \li Browse - \endlist - \li Open File - \endlist - \endlist - - In the help project file, the outline is represented by: - - \code - <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> - \endcode - - After the table of contents is defined, we will list all index keywords: - - \code - <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> - \endcode - - As the last step, we have to list all files making up the documentation. - An important point to note here is that all files have to listed, including - image files, and even stylesheets if they are used. - - \code - <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/*.png</file> - </files> - </filterSection> - </QtHelpProject> - \endcode - - The help project file is now finished. If you want to see the resulting - documentation in \QA, you have to generate a Qt compressed help file - out of it and register it with the default help collection of \QA. - - \code - qhelpgenerator simpletextviewer.qhp -o simpletextviewer.qch - assistant -register simpletextviewer.qch - \endcode - - If you start \QA now, you'll see the Simple Text Viewer documentation - beside the Qt documentation. This is OK for testing purposes, but - for the final version we want to only have the Simple Text Viewer - documentation in \QA. - - \section2 Customizing \QA - - The easiest way to make \QA only display the Simple Text Viewer - documentation is to create our own help collection file. A collection - file is stored in a binary format, similar to the compressed help file, - and generated from a help collection project file (*.qhcp). With - the help of a collection file, we can customize the appearance and even - some functionality offered by \QA. - - At first, we change the window title and icon. Instead of showing "\QA" - it will show "Simple Text Viewer", so it is much clearer for the user - that the help viewer actually belongs to our application. - - \code - <?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> - \endcode - - The \c cacheDirectory tag specifies a subdirectory of the users - data directory (see the - \l{Customizing Qt Assistant#Qt Help Collection Files}{Qt Help Collection Files}) - where the cache file for the full text search or the settings file will - be stored. - - After this, we set the page displayed by \QA when launched for the very - first time in its new configuration. The URL consists of the namespace - and virtual folder defined in the Qt help project file, followed by the - actual page file name. - - \code - <startPage>qthelp://com.trolltech.examples.simpletextviewer/doc/index.html</startPage> - \endcode - - Next, we alter the name of the "About" menu item to "About Simple - Text Viewer". The contents of the \gui{About} dialog are also changed - by specifying a file where the about text or icon is taken from. - - \code - <aboutMenuText> - <text>About Simple Text Viewer</text> - </aboutMenuText> - <aboutDialog> - <file>about.txt</file> - <icon>images/icon.png</icon> - </aboutDialog> - \endcode - - \QA offers the possibility to add or remove documentation via its - preferences dialog. This functionality is helpful when using \QA - as the central help viewer for more applications, but in our case - we want to actually prevent the user from removing the documentation. - So, we hide the \gui Documentation tab in the \gui Preferences dialog. - - Since the address bar is not really relevant in such a small - documentation set we switch it off as well. By having just one filter - section, without any filter attributes, we can also disable the filter - functionality of \QA, which means that the filter page and the filter - toolbar will not be available. - - \code - <enableDocumentationManager>false</enableDocumentationManager> - <enableAddressBar>false</enableAddressBar> - <enableFilterFunctionality>false</enableFilterFunctionality> - </assistant> - \endcode - - For testing purposes, we already generated the compressed help file - and registered it with \QA's default help collection. With the - following lines we achieve the same result. The only and important - difference is that we register the compressed help file, not in - the default collection, but in our own collection file. - - \code - <docFiles> - <generate> - <file> - <input>simpletextviewer.qhp</input> - <output>simpletextviewer.qch</output> - </file> - </generate> - <register> - <file>simpletextviewer.qch</file> - </register> - </docFiles> - </QHelpCollectionProject> - \endcode - - As the last step, we have to generate the binary collection file - out of the help collection project file. This is done by running the - \c qcollectiongenerator tool. - - \code - qcollectiongenerator simpletextviewer.qhcp -o simpletextviewer.qhc - \endcode - - To test all our customizations made to \QA, we add the collection - file name to the command line: - - \code - assistant -collectionFile simpletextviewer.qhc - \endcode - - \section1 Controlling \QA via the Assistant Class - - We will first take a look at how to start and operate \QA from a - remote application. For that purpose, we create a class called - \c Assistant. - - This class provides a public function that is used to show pages - of the documentation, and one private helper function to make sure - that \QA is up and running. - - Launching \QA is done in the function \c startAssistant() by simply - creating and starting a QProcess. If the process is already running, - the function returns immediately. Otherwise, the process has - to be set up and started. - - \snippet simpletextviewer/assistant.cpp 2 - - To start the process we need the executable name of \QA as well as the - command line arguments for running \QA in a customized mode. The - executable name is a little bit tricky since it depends on the - platform, but fortunately it is only different on Mac OS X. - - The displayed documentation can be altered using the \c -collectionFile - command line argument when launching \QA. When started without any options, - \QA displays a default set of documentation. When Qt is installed, - the default documentation set in \QA contains the Qt reference - documentation as well as the tools that come with Qt, such as Qt - Designer and \c qmake. - - In our example, we replace the default documentation set with our - custom documentation by passing our application-specific collection - file to the process's command line options. - - As the last argument, we add \c -enableRemoteControl, which makes \QA - listen to its \c stdin channel for commands, such as those to display - a certain page in the documentation. - Then we start the process and wait until it is actually running. If, - for some reason \QA cannot be started, \c startAssistant() will return - false. - - The implementation for \c showDocumentation() is now straightforward. - Firstly, we ensure that \QA is running, then we send the request to - display the \a page via the \c stdin channel of the process. It is very - important here that the command is terminated by the '\\0' character - followed by an end of line token to flush the channel. - - \snippet simpletextviewer/assistant.cpp 1 - - Finally, we make sure that \QA is terminated properly in the case that - the application is shut down. The destructor of QProcess kills the - process, meaning that the application has no possibility to do things - like save user settings, which would result in corrupted settings files. - To avoid this, we ask \QA to terminate in the destructor of the - \c Assistant class. - - \snippet simpletextviewer/assistant.cpp 0 - - \section1 MainWindow Class - - \image simpletextviewer-mainwindow.png - - The \c MainWindow class provides the main application window with - two menus: the \gui File menu lets the user open and view an - existing file, while the \gui Help menu provides information about - the application and about Qt, and lets the user open \QA to - display the application's documentation. - - To be able to access the help functionality, we initialize the - \c Assistant object in the \c MainWindow's constructor. - - \snippet simpletextviewer/mainwindow.cpp 0 - \dots - \snippet simpletextviewer/mainwindow.cpp 1 - - Then we create all the actions for the Simple Text Viewer application. - Of special interest is the \c assistantAct action accessible - via the \key{F1} shortcut or the \gui Help > \gui {Help Contents} menu item. - This action is connected to the \c showDocumentation() slot of - the \c MainWindow class. - - \snippet simpletextviewer/mainwindow.cpp 4 - \dots - \snippet simpletextviewer/mainwindow.cpp 5 - - In the \c showDocumentation() slot, we call the \c showDocumentation() - function of the \c Assistant class with the URL of home page of the - documentation. - - \snippet simpletextviewer/mainwindow.cpp 3 - - Finally, we must reimplement the protected QWidget::closeEvent() - event handler to ensure that the application's \QA instance is - properly closed before we terminate the application. - - \snippet simpletextviewer/mainwindow.cpp 2 - - \section1 FindFileDialog Class - - \image simpletextviewer-findfiledialog.png - - The Simple Text Viewer application provides a find file dialog - allowing the user to search for files using wildcard matching. The - search is performed within the specified directory, and the user - is given an option to browse the existing file system to find the - relevant directory. - - In the constructor we save the references to the \c Assistant - and \c QTextEdit objects passed as arguments. The \c Assistant - object will be used in the \c FindFileDialog's \c help() slot, - as we will see shortly, while the QTextEdit will be used in the - dialog's \c openFile() slot to display the chosen file. - - \snippet simpletextviewer/findfiledialog.cpp 0 - \dots - \snippet simpletextviewer/findfiledialog.cpp 1 - - The most relevant member to observe in the \c FindFileDialog - class is the private \c help() slot. The slot is connected to the - dialog's \gui Help button, and brings the current \QA instance - to the foreground with the documentation for the dialog by - calling \c Assistant's \c showDocumentation() function. - - \snippet simpletextviewer/findfiledialog.cpp 2 - - \section1 Summary - - In order to make \QA act as a customized help tool for - your application, you must provide your application with a - process that controls \QA in addition to a custom help collection - file including Qt compressed help files. - - For more information about the options and settings available to - applications that use \QA as a custom help viewer, see - \l{Customizing Qt Assistant}. -*/ diff --git a/examples/help/simpletextviewer/documentation/about.txt b/examples/help/simpletextviewer/documentation/about.txt deleted file mode 100644 index eeab35f4a..000000000 --- a/examples/help/simpletextviewer/documentation/about.txt +++ /dev/null @@ -1,9 +0,0 @@ -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 deleted file mode 100644 index 987abf31f..000000000 --- a/examples/help/simpletextviewer/documentation/browse.html +++ /dev/null @@ -1,34 +0,0 @@ -<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 deleted file mode 100644 index afa65ed57..000000000 --- a/examples/help/simpletextviewer/documentation/filedialog.html +++ /dev/null @@ -1,48 +0,0 @@ -<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 deleted file mode 100644 index 32e014718..000000000 --- a/examples/help/simpletextviewer/documentation/findfile.html +++ /dev/null @@ -1,32 +0,0 @@ -<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 Binary files differdeleted file mode 100644 index 86db6b19e..000000000 --- a/examples/help/simpletextviewer/documentation/images/browse.png +++ /dev/null diff --git a/examples/help/simpletextviewer/documentation/images/fadedfilemenu.png b/examples/help/simpletextviewer/documentation/images/fadedfilemenu.png Binary files differdeleted file mode 100644 index fde0e43f6..000000000 --- a/examples/help/simpletextviewer/documentation/images/fadedfilemenu.png +++ /dev/null diff --git a/examples/help/simpletextviewer/documentation/images/filedialog.png b/examples/help/simpletextviewer/documentation/images/filedialog.png Binary files differdeleted file mode 100644 index 883a33a26..000000000 --- a/examples/help/simpletextviewer/documentation/images/filedialog.png +++ /dev/null diff --git a/examples/help/simpletextviewer/documentation/images/handbook.png b/examples/help/simpletextviewer/documentation/images/handbook.png Binary files differdeleted file mode 100644 index 3bd2b928b..000000000 --- a/examples/help/simpletextviewer/documentation/images/handbook.png +++ /dev/null diff --git a/examples/help/simpletextviewer/documentation/images/icon.png b/examples/help/simpletextviewer/documentation/images/icon.png Binary files differdeleted file mode 100644 index 6daec0ade..000000000 --- a/examples/help/simpletextviewer/documentation/images/icon.png +++ /dev/null diff --git a/examples/help/simpletextviewer/documentation/images/mainwindow.png b/examples/help/simpletextviewer/documentation/images/mainwindow.png Binary files differdeleted file mode 100644 index c28d5e9ff..000000000 --- a/examples/help/simpletextviewer/documentation/images/mainwindow.png +++ /dev/null diff --git a/examples/help/simpletextviewer/documentation/images/open.png b/examples/help/simpletextviewer/documentation/images/open.png Binary files differdeleted file mode 100644 index 1e5bba3c8..000000000 --- a/examples/help/simpletextviewer/documentation/images/open.png +++ /dev/null diff --git a/examples/help/simpletextviewer/documentation/images/wildcard.png b/examples/help/simpletextviewer/documentation/images/wildcard.png Binary files differdeleted file mode 100644 index 6e83a56cc..000000000 --- a/examples/help/simpletextviewer/documentation/images/wildcard.png +++ /dev/null diff --git a/examples/help/simpletextviewer/documentation/index.html b/examples/help/simpletextviewer/documentation/index.html deleted file mode 100644 index 5a7b1d5fa..000000000 --- a/examples/help/simpletextviewer/documentation/index.html +++ /dev/null @@ -1,41 +0,0 @@ -<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 deleted file mode 100644 index 2e2aa40de..000000000 --- a/examples/help/simpletextviewer/documentation/intro.html +++ /dev/null @@ -1,28 +0,0 @@ -<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 deleted file mode 100644 index e172de95e..000000000 --- a/examples/help/simpletextviewer/documentation/openfile.html +++ /dev/null @@ -1,36 +0,0 @@ -<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 Binary files differdeleted file mode 100644 index c40132803..000000000 --- a/examples/help/simpletextviewer/documentation/simpletextviewer.qch +++ /dev/null diff --git a/examples/help/simpletextviewer/documentation/simpletextviewer.qhc b/examples/help/simpletextviewer/documentation/simpletextviewer.qhc Binary files differdeleted file mode 100644 index db380cabf..000000000 --- a/examples/help/simpletextviewer/documentation/simpletextviewer.qhc +++ /dev/null diff --git a/examples/help/simpletextviewer/documentation/simpletextviewer.qhcp b/examples/help/simpletextviewer/documentation/simpletextviewer.qhcp deleted file mode 100644 index e7c23210b..000000000 --- a/examples/help/simpletextviewer/documentation/simpletextviewer.qhcp +++ /dev/null @@ -1,30 +0,0 @@ -<?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 deleted file mode 100644 index 4cb83a5f3..000000000 --- a/examples/help/simpletextviewer/documentation/simpletextviewer.qhp +++ /dev/null @@ -1,49 +0,0 @@ -<?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 deleted file mode 100644 index eb1839a06..000000000 --- a/examples/help/simpletextviewer/documentation/wildcardmatching.html +++ /dev/null @@ -1,57 +0,0 @@ -<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 deleted file mode 100644 index 66b2d8282..000000000 --- a/examples/help/simpletextviewer/findfiledialog.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia Plc 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 <QtWidgets/QLayout> -#include <QtWidgets/QComboBox> -#include <QtWidgets/QTreeWidget> -#include <QtWidgets/QLayout> -#include <QtWidgets/QFileDialog> -#include <QtWidgets/QDialogButtonBox> -#include <QtWidgets/QToolButton> -#include <QtWidgets/QPushButton> -#include <QtWidgets/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 deleted file mode 100644 index e0212c263..000000000 --- a/examples/help/simpletextviewer/findfiledialog.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia Plc 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 <QtWidgets/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 deleted file mode 100644 index 9ef1b3f58..000000000 --- a/examples/help/simpletextviewer/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia Plc 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 <QtWidgets/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 deleted file mode 100644 index 447a76446..000000000 --- a/examples/help/simpletextviewer/mainwindow.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia Plc 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 <QtWidgets/QApplication> -#include <QtWidgets/QAction> -#include <QtWidgets/QMenu> -#include <QtWidgets/QMenuBar> -#include <QtWidgets/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 deleted file mode 100644 index 962680eb4..000000000 --- a/examples/help/simpletextviewer/mainwindow.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia Plc 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 <QtWidgets/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 deleted file mode 100644 index 2b0a1ace6..000000000 --- a/examples/help/simpletextviewer/simpletextviewer.pro +++ /dev/null @@ -1,14 +0,0 @@ -HEADERS = mainwindow.h \ - findfiledialog.h \ - assistant.h \ - textedit.h -SOURCES = main.cpp \ - mainwindow.cpp \ - findfiledialog.cpp \ - assistant.cpp \ - textedit.cpp - -QT += widgets - -target.path = $$[QT_INSTALL_EXAMPLES]/help/simpletextviewer -INSTALLS += target diff --git a/examples/help/simpletextviewer/textedit.cpp b/examples/help/simpletextviewer/textedit.cpp deleted file mode 100644 index 05b6d1095..000000000 --- a/examples/help/simpletextviewer/textedit.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia Plc 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 deleted file mode 100644 index e24e689a1..000000000 --- a/examples/help/simpletextviewer/textedit.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia Plc 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 <QtWidgets/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 |