diff options
Diffstat (limited to 'examples')
30 files changed, 39 insertions, 1017 deletions
diff --git a/examples/assistant/README b/examples/assistant/README deleted file mode 100644 index 85f5a43..0000000 --- a/examples/assistant/README +++ /dev/null @@ -1,38 +0,0 @@ -Support for interactive help is provided by the Qt Assistant application. -Developers can take advantages of the facilities it offers to display -specially-prepared documentation to users of their applications. - - -The example launcher provided with Qt can be used to explore each of the -examples in this directory. - -Documentation for these examples can be found via the Tutorial and Examples -link in the main Qt documentation. - - -Finding the Qt Examples and Demos launcher -========================================== - -On Windows: - -The launcher can be accessed via the Windows Start menu. Select the menu -entry entitled "Qt Examples and Demos" entry in the submenu containing -the Qt tools. - -On Mac OS X: - -For the binary distribution, the qtdemo executable is installed in the -/Developer/Applications/Qt directory. For the source distribution, it is -installed alongside the other Qt tools on the path specified when Qt is -configured. - -On Unix/Linux: - -The qtdemo executable is installed alongside the other Qt tools on the path -specified when Qt is configured. - -On all platforms: - -The source code for the launcher can be found in the demos/qtdemo directory -in the Qt package. This example is built at the same time as the Qt libraries, -tools, examples, and demonstrations. diff --git a/examples/assistant/assistant.pro b/examples/assistant/assistant.pro deleted file mode 100644 index ff1f947..0000000 --- a/examples/assistant/assistant.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = simpletextviewer - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/assistant -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS assistant.pro README -sources.path = $$[QT_INSTALL_EXAMPLES]/assistant -INSTALLS += target sources - -symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/assistant/simpletextviewer/documentation/about.txt b/examples/assistant/simpletextviewer/documentation/about.txt deleted file mode 100644 index eeab35f..0000000 --- a/examples/assistant/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/assistant/simpletextviewer/documentation/browse.html b/examples/assistant/simpletextviewer/documentation/browse.html deleted file mode 100644 index 987abf3..0000000 --- a/examples/assistant/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/assistant/simpletextviewer/documentation/filedialog.html b/examples/assistant/simpletextviewer/documentation/filedialog.html deleted file mode 100644 index afa65ed..0000000 --- a/examples/assistant/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/assistant/simpletextviewer/documentation/findfile.html b/examples/assistant/simpletextviewer/documentation/findfile.html deleted file mode 100644 index 32e0147..0000000 --- a/examples/assistant/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/assistant/simpletextviewer/documentation/images/browse.png b/examples/assistant/simpletextviewer/documentation/images/browse.png Binary files differdeleted file mode 100644 index 86db6b1..0000000 --- a/examples/assistant/simpletextviewer/documentation/images/browse.png +++ /dev/null diff --git a/examples/assistant/simpletextviewer/documentation/images/fadedfilemenu.png b/examples/assistant/simpletextviewer/documentation/images/fadedfilemenu.png Binary files differdeleted file mode 100644 index fde0e43..0000000 --- a/examples/assistant/simpletextviewer/documentation/images/fadedfilemenu.png +++ /dev/null diff --git a/examples/assistant/simpletextviewer/documentation/images/filedialog.png b/examples/assistant/simpletextviewer/documentation/images/filedialog.png Binary files differdeleted file mode 100644 index 883a33a..0000000 --- a/examples/assistant/simpletextviewer/documentation/images/filedialog.png +++ /dev/null diff --git a/examples/assistant/simpletextviewer/documentation/images/handbook.png b/examples/assistant/simpletextviewer/documentation/images/handbook.png Binary files differdeleted file mode 100644 index 3bd2b92..0000000 --- a/examples/assistant/simpletextviewer/documentation/images/handbook.png +++ /dev/null diff --git a/examples/assistant/simpletextviewer/documentation/images/mainwindow.png b/examples/assistant/simpletextviewer/documentation/images/mainwindow.png Binary files differdeleted file mode 100644 index c28d5e9..0000000 --- a/examples/assistant/simpletextviewer/documentation/images/mainwindow.png +++ /dev/null diff --git a/examples/assistant/simpletextviewer/documentation/images/open.png b/examples/assistant/simpletextviewer/documentation/images/open.png Binary files differdeleted file mode 100644 index 1e5bba3..0000000 --- a/examples/assistant/simpletextviewer/documentation/images/open.png +++ /dev/null diff --git a/examples/assistant/simpletextviewer/documentation/images/wildcard.png b/examples/assistant/simpletextviewer/documentation/images/wildcard.png Binary files differdeleted file mode 100644 index 6e83a56..0000000 --- a/examples/assistant/simpletextviewer/documentation/images/wildcard.png +++ /dev/null diff --git a/examples/assistant/simpletextviewer/documentation/index.html b/examples/assistant/simpletextviewer/documentation/index.html deleted file mode 100644 index 5a7b1d5..0000000 --- a/examples/assistant/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/assistant/simpletextviewer/documentation/intro.html b/examples/assistant/simpletextviewer/documentation/intro.html deleted file mode 100644 index 2e2aa40..0000000 --- a/examples/assistant/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/assistant/simpletextviewer/documentation/openfile.html b/examples/assistant/simpletextviewer/documentation/openfile.html deleted file mode 100644 index e172de9..0000000 --- a/examples/assistant/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/assistant/simpletextviewer/documentation/simpletextviewer.adp b/examples/assistant/simpletextviewer/documentation/simpletextviewer.adp deleted file mode 100644 index 660df4f..0000000 --- a/examples/assistant/simpletextviewer/documentation/simpletextviewer.adp +++ /dev/null @@ -1,40 +0,0 @@ -<!DOCTYPE DCF> - -<assistantconfig version="3.2.0"> - -<profile> - <property name="name">simpletextviewer</property> - <property name="title">Simple Text Viewer</property> - <property name="applicationicon">images/handbook.png</property> - <property name="startpage">index.html</property> - <property name="aboutmenutext">About Simple Text Viewer</property> - <property name="abouturl">about.txt</property> - <property name="assistantdocs">.</property> -</profile> - -<DCF ref="index.html" icon="images/handbook.png" title="Simple Text Viewer"> - <section ref="./findfile.html" title="Find File"> - <keyword ref="./index.html">Display</keyword> - <keyword ref="./index.html">Rich text</keyword> - <keyword ref="./index.html">Plain text</keyword> - <keyword ref="./findfile.html">Find</keyword> - <keyword ref="./findfile.html">File menu</keyword> - <keyword ref="./filedialog.html">File name</keyword> - <keyword ref="./filedialog.html">File dialog</keyword> - <keyword ref="./wildcardmatching.html">File globbing</keyword> - <keyword ref="./wildcardmatching.html">Wildcard matching</keyword> - <keyword ref="./wildcardmatching.html">Wildcard syntax</keyword> - <keyword ref="./browse.html">Browse</keyword> - <keyword ref="./browse.html">Directory</keyword> - <keyword ref="./openfile.html">Open</keyword> - <keyword ref="./openfile.html">Select</keyword> - - <section ref="./filedialog.html" title="File Dialog" /> - <section ref="./wildcardmatching.html" title="Wildcard Matching" /> - <section ref="./browse.html" title="Browse" /> - </section> - <section ref="./openfile.html" title="Open File" /> -</DCF> - -</assistantconfig> - diff --git a/examples/assistant/simpletextviewer/documentation/wildcardmatching.html b/examples/assistant/simpletextviewer/documentation/wildcardmatching.html deleted file mode 100644 index eb1839a..0000000 --- a/examples/assistant/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/assistant/simpletextviewer/findfiledialog.cpp b/examples/assistant/simpletextviewer/findfiledialog.cpp deleted file mode 100644 index 0720111..0000000 --- a/examples/assistant/simpletextviewer/findfiledialog.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui> - -#include "findfiledialog.h" - -//! [0] -FindFileDialog::FindFileDialog(QTextEdit *editor, QAssistantClient *assistant, - QWidget *parent) - : QDialog(parent) -{ - currentAssistantClient = 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() -{ - currentAssistantClient->showPage(QLibraryInfo::location(QLibraryInfo::ExamplesPath) + - QDir::separator() + "assistant/simpletextviewer/documentation/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(); - - QFile file(path + fileName); - if (file.open(QIODevice::ReadOnly)) { - QString data(file.readAll()); - - if (fileName.endsWith(".html")) - currentEditor->setHtml(data); - else - currentEditor->setPlainText(data); - } - 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/assistant/simpletextviewer/findfiledialog.h b/examples/assistant/simpletextviewer/findfiledialog.h deleted file mode 100644 index 1f429af..0000000 --- a/examples/assistant/simpletextviewer/findfiledialog.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef FINDFILEDIALOG_H -#define FINDFILEDIALOG_H - -#include <QAssistantClient> -#include <QDialog> - -QT_BEGIN_NAMESPACE -class QComboBox; -class QDialogButtonBox; -class QLabel; -class QTextEdit; -class QToolButton; -class QTreeWidget; -class QTreeWidgetItem; -QT_END_NAMESPACE - -//! [0] -class FindFileDialog : public QDialog -{ - Q_OBJECT - -public: - FindFileDialog(QTextEdit *editor, QAssistantClient *assistant, - QWidget *parent = 0); - -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(); - - QAssistantClient *currentAssistantClient; - QTextEdit *currentEditor; - QTreeWidget *foundFilesTree; - - QComboBox *directoryComboBox; - QComboBox *fileNameComboBox; - - QLabel *directoryLabel; - QLabel *fileNameLabel; - - QDialogButtonBox *buttonBox; - - QToolButton *browseButton; -}; -//! [0] - -#endif diff --git a/examples/assistant/simpletextviewer/main.cpp b/examples/assistant/simpletextviewer/main.cpp deleted file mode 100644 index 82c7104..0000000 --- a/examples/assistant/simpletextviewer/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QApplication> - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - MainWindow window; - window.show(); - return app.exec(); -} diff --git a/examples/assistant/simpletextviewer/mainwindow.cpp b/examples/assistant/simpletextviewer/mainwindow.cpp deleted file mode 100644 index 99849bb..0000000 --- a/examples/assistant/simpletextviewer/mainwindow.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui> - -#include "mainwindow.h" -#include "findfiledialog.h" - -//! [0] -MainWindow::MainWindow() -{ - textViewer = new QTextEdit; - textViewer->setReadOnly(true); - QFile file("documentation/intro.html"); - if (file.open(QIODevice::ReadOnly)) - textViewer->setHtml(file.readAll()); - - setCentralWidget(textViewer); - - createActions(); - createMenus(); - - initializeAssistant(); - - setWindowTitle(tr("Simple Text Viewer")); - resize(750, 400); -} -//! [0] - -//! [1] -void MainWindow::closeEvent(QCloseEvent *) -{ - if (assistantClient) - assistantClient->closeAssistant(); -} -//! [1] - -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.")); -} - -//! [2] -void MainWindow::assistant() -{ - assistantClient->showPage(QLibraryInfo::location(QLibraryInfo::ExamplesPath) + - QDir::separator() + - "assistant/simpletextviewer/documentation/index.html"); -} -//! [2] - -//! [3] -void MainWindow::open() -{ - FindFileDialog dialog(textViewer, assistantClient); - dialog.exec(); -} -//! [3] - -void MainWindow::createActions() -{ - assistantAct = new QAction(tr("Help Contents"), this); - assistantAct->setShortcuts(QKeySequence::HelpContents); - connect(assistantAct, SIGNAL(triggered()), this, SLOT(assistant())); - - openAct = new QAction(tr("&Open..."), this); - openAct->setShortcuts(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())); -} - -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); -} - -//! [4] -void MainWindow::initializeAssistant() -{ - assistantClient = new QAssistantClient(QLibraryInfo::location(QLibraryInfo::BinariesPath), this); - - QStringList arguments; - arguments << "-profile" << QString("documentation") + QDir::separator() + QString("simpletextviewer.adp"); - assistantClient->setArguments(arguments); -} -//! [4] diff --git a/examples/assistant/simpletextviewer/mainwindow.h b/examples/assistant/simpletextviewer/mainwindow.h deleted file mode 100644 index 98f9a67..0000000 --- a/examples/assistant/simpletextviewer/mainwindow.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include <QAssistantClient> -#include <QMainWindow> -#include <QTextEdit> - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -private slots: - void about(); -//! [0] - void assistant(); -//! [0] - void open(); - -protected: -//! [1] - void closeEvent(QCloseEvent *event); -//! [1] - -private: - void createActions(); - void createMenus(); -//! [2] - void initializeAssistant(); -//! [2] - -//! [3] - QAssistantClient *assistantClient; -//! [3] - QTextEdit *textViewer; - - QMenu *fileMenu; - QMenu *helpMenu; - - QAction *assistantAct; - QAction *clearAct; - QAction *openAct; - QAction *exitAct; - QAction *aboutAct; - QAction *aboutQtAct; -}; - -#endif diff --git a/examples/assistant/simpletextviewer/simpletextviewer.pro b/examples/assistant/simpletextviewer/simpletextviewer.pro deleted file mode 100644 index 2c0eada..0000000 --- a/examples/assistant/simpletextviewer/simpletextviewer.pro +++ /dev/null @@ -1,18 +0,0 @@ -CONFIG += assistant - -QT += network - -HEADERS = mainwindow.h \ - findfiledialog.h -SOURCES = main.cpp \ - mainwindow.cpp \ - findfiledialog.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/assistant/simpletextviewer -sources.files = $$SOURCES $$HEADERS $$RESOURCES documentation *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/assistant/simpletextviewer -INSTALLS += target sources - -symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - diff --git a/examples/examples.pro b/examples/examples.pro index d11e36b..3678cc0 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -48,10 +48,10 @@ contains(QT_CONFIG, phonon):!static: SUBDIRS += phonon contains(QT_CONFIG, webkit): SUBDIRS += webkit embedded:SUBDIRS += qws !wince*:!symbian: { - !contains(QT_EDITION, Console):contains(QT_BUILD_PARTS, tools):SUBDIRS += designer - contains(QT_BUILD_PARTS, tools):SUBDIRS += assistant qtestlib help + !contains(QT_EDITION, Console):contains(QT_BUILD_PARTS, tools):SUBDIRS += designer + contains(QT_BUILD_PARTS, tools):SUBDIRS += qtestlib help } else { - contains(QT_BUILD_PARTS, tools):SUBDIRS += qtestlib + contains(QT_BUILD_PARTS, tools):SUBDIRS += qtestlib } contains(QT_CONFIG, opengl): SUBDIRS += opengl contains(QT_CONFIG, openvg): SUBDIRS += openvg diff --git a/examples/help/remotecontrol/remotecontrol.cpp b/examples/help/remotecontrol/remotecontrol.cpp index 84f81df..8d47ca8 100644 --- a/examples/help/remotecontrol/remotecontrol.cpp +++ b/examples/help/remotecontrol/remotecontrol.cpp @@ -123,7 +123,7 @@ void RemoteControl::sendCommand(const QString &cmd) { if (process->state() != QProcess::Running) return; - process->write(cmd.toLocal8Bit() + '\0'); + process->write(cmd.toLocal8Bit() + '\n'); } void RemoteControl::on_indexButton_clicked() diff --git a/examples/help/simpletextviewer/assistant.cpp b/examples/help/simpletextviewer/assistant.cpp index ab20f3e..2807365 100644 --- a/examples/help/simpletextviewer/assistant.cpp +++ b/examples/help/simpletextviewer/assistant.cpp @@ -73,7 +73,7 @@ void Assistant::showDocumentation(const QString &page) QByteArray ba("SetSource "); ba.append("qthelp://com.trolltech.examples.simpletextviewer/doc/"); - proc->write(ba + page.toLocal8Bit() + '\0'); + proc->write(ba + page.toLocal8Bit() + '\n'); } //! [1] diff --git a/examples/webkit/fancybrowser/main.cpp b/examples/webkit/fancybrowser/main.cpp index 7f3c983..2245788 100644 --- a/examples/webkit/fancybrowser/main.cpp +++ b/examples/webkit/fancybrowser/main.cpp @@ -45,7 +45,12 @@ int main(int argc, char * argv[]) { QApplication app(argc, argv); - MainWindow *browser = new MainWindow; + QUrl url; + if (argc > 1) + url = QUrl(argv[1]); + else + url = QUrl("http://www.google.com/ncr"); + MainWindow *browser = new MainWindow(url); browser->show(); return app.exec(); } diff --git a/examples/webkit/fancybrowser/mainwindow.cpp b/examples/webkit/fancybrowser/mainwindow.cpp index 844106f..cfc5500 100644 --- a/examples/webkit/fancybrowser/mainwindow.cpp +++ b/examples/webkit/fancybrowser/mainwindow.cpp @@ -45,7 +45,7 @@ //! [1] -MainWindow::MainWindow() +MainWindow::MainWindow(const QUrl& url) { progress = 0; @@ -60,7 +60,7 @@ MainWindow::MainWindow() //! [2] view = new QWebView(this); - view->load(QUrl("http://www.google.com/ncr")); + view->load(url); connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); connect(view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle())); connect(view, SIGNAL(loadProgress(int)), SLOT(setProgress(int))); @@ -78,6 +78,11 @@ MainWindow::MainWindow() toolBar->addWidget(locationEdit); //! [2] + QMenu *viewMenu = menuBar()->addMenu(tr("&View")); + QAction* viewSourceAction = new QAction("Page Source", this); + connect(viewSourceAction, SIGNAL(triggered()), SLOT(viewSource())); + viewMenu->addAction(viewSourceAction); + //! [3] QMenu *effectMenu = menuBar()->addMenu(tr("&Effect")); effectMenu->addAction("Highlight all links", this, SLOT(highlightAllLinks())); @@ -100,6 +105,23 @@ MainWindow::MainWindow() } //! [3] +void MainWindow::viewSource() +{ + QNetworkAccessManager* accessManager = view->page()->networkAccessManager(); + QNetworkRequest request(view->url()); + QNetworkReply* reply = accessManager->get(request); + connect(reply, SIGNAL(finished()), this, SLOT(slotSourceDownloaded())); +} + +void MainWindow::slotSourceDownloaded() +{ + QNetworkReply* reply = qobject_cast<QNetworkReply*>(const_cast<QObject*>(sender())); + QTextEdit* textEdit = new QTextEdit(NULL); + textEdit->setAttribute(Qt::WA_DeleteOnClose); + textEdit->show(); + textEdit->setPlainText(reply->readAll()); +} + //! [4] void MainWindow::adjustLocation() { diff --git a/examples/webkit/fancybrowser/mainwindow.h b/examples/webkit/fancybrowser/mainwindow.h index 214d84b..3afd0be 100644 --- a/examples/webkit/fancybrowser/mainwindow.h +++ b/examples/webkit/fancybrowser/mainwindow.h @@ -52,7 +52,7 @@ class MainWindow : public QMainWindow Q_OBJECT public: - MainWindow(); + MainWindow(const QUrl& url); protected slots: @@ -62,6 +62,9 @@ protected slots: void setProgress(int p); void finishLoading(bool); + void viewSource(); + void slotSourceDownloaded(); + void highlightAllLinks(); void rotateImages(bool invert); void removeGifImages(); |