diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-02-11 06:32:04 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-02-11 06:32:04 (GMT) |
commit | 8e72075b8333dcefaa7ddbaeb0bc7ae45d42ff1e (patch) | |
tree | b8b69f812095df8bf780f88302c7784c4d2e18e0 /examples | |
parent | 34450eb48e56677395601bf155a6a05752b326ad (diff) | |
parent | dbfe5f81e300de3a43311197826f23ff031b4b23 (diff) | |
download | Qt-8e72075b8333dcefaa7ddbaeb0bc7ae45d42ff1e.zip Qt-8e72075b8333dcefaa7ddbaeb0bc7ae45d42ff1e.tar.gz Qt-8e72075b8333dcefaa7ddbaeb0bc7ae45d42ff1e.tar.bz2 |
Merge remote branch 'origin/master' into bearermanagement/integration
Conflicts:
configure
Diffstat (limited to 'examples')
55 files changed, 524 insertions, 1362 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 1f11f69..0000000 --- a/examples/assistant/simpletextviewer/findfiledialog.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 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(QLatin1String(".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 (const 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 aac27f1..0000000 --- a/examples/assistant/simpletextviewer/findfiledialog.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 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 6e38406..0000000 --- a/examples/assistant/simpletextviewer/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 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 03eab02..0000000 --- a/examples/assistant/simpletextviewer/mainwindow.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 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 14f0679..0000000 --- a/examples/assistant/simpletextviewer/mainwindow.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 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/dbus/dbus-chat/chat_adaptor.cpp b/examples/dbus/dbus-chat/chat_adaptor.cpp index dc07e1c..77e7ab0 100644 --- a/examples/dbus/dbus-chat/chat_adaptor.cpp +++ b/examples/dbus/dbus-chat/chat_adaptor.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -i chat_adaptor.h -a :chat_adaptor.cpp com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i chat_adaptor.h -a :chat_adaptor.cpp com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. diff --git a/examples/dbus/dbus-chat/chat_adaptor.h b/examples/dbus/dbus-chat/chat_adaptor.h index b1e66ad..47b7f8f 100644 --- a/examples/dbus/dbus-chat/chat_adaptor.h +++ b/examples/dbus/dbus-chat/chat_adaptor.h @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -a chat_adaptor.h: com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -a chat_adaptor.h: com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments @@ -49,8 +49,8 @@ ** ****************************************************************************/ -#ifndef CHAT_ADAPTOR_H_142741156243605 -#define CHAT_ADAPTOR_H_142741156243605 +#ifndef CHAT_ADAPTOR_H_1257535021 +#define CHAT_ADAPTOR_H_1257535021 #include <QtCore/QObject> #include <QtDBus/QtDBus> @@ -72,14 +72,14 @@ class ChatAdaptor: public QDBusAbstractAdaptor Q_OBJECT Q_CLASSINFO("D-Bus Interface", "com.trolltech.chat") Q_CLASSINFO("D-Bus Introspection", "" -" <interface name=\"com.trolltech.chat\" >\n" -" <signal name=\"message\" >\n" -" <arg direction=\"out\" type=\"s\" name=\"nickname\" />\n" -" <arg direction=\"out\" type=\"s\" name=\"text\" />\n" +" <interface name=\"com.trolltech.chat\">\n" +" <signal name=\"message\">\n" +" <arg direction=\"out\" type=\"s\" name=\"nickname\"/>\n" +" <arg direction=\"out\" type=\"s\" name=\"text\"/>\n" " </signal>\n" -" <signal name=\"action\" >\n" -" <arg direction=\"out\" type=\"s\" name=\"nickname\" />\n" -" <arg direction=\"out\" type=\"s\" name=\"text\" />\n" +" <signal name=\"action\">\n" +" <arg direction=\"out\" type=\"s\" name=\"nickname\"/>\n" +" <arg direction=\"out\" type=\"s\" name=\"text\"/>\n" " </signal>\n" " </interface>\n" "") diff --git a/examples/dbus/dbus-chat/chat_interface.cpp b/examples/dbus/dbus-chat/chat_interface.cpp index f187ee0..3aba098 100644 --- a/examples/dbus/dbus-chat/chat_interface.cpp +++ b/examples/dbus/dbus-chat/chat_interface.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -i chat_interface.h -p :chat_interface.cpp chat/com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i chat_interface.h -p :chat_interface.cpp com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments diff --git a/examples/dbus/dbus-chat/chat_interface.h b/examples/dbus/dbus-chat/chat_interface.h index 3bf427b..a6aa2df 100644 --- a/examples/dbus/dbus-chat/chat_interface.h +++ b/examples/dbus/dbus-chat/chat_interface.h @@ -38,18 +38,18 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -p chat_interface.h: com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -p chat_interface.h: com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. ** ****************************************************************************/ -#ifndef CHAT_INTERFACE_H_143021156243606 -#define CHAT_INTERFACE_H_143021156243606 +#ifndef CHAT_INTERFACE_H_1257535021 +#define CHAT_INTERFACE_H_1257535021 #include <QtCore/QObject> #include <QtCore/QByteArray> diff --git a/examples/dbus/remotecontrolledcar/car/car.pro b/examples/dbus/remotecontrolledcar/car/car.pro index 9b426d3..d362dc9 100644 --- a/examples/dbus/remotecontrolledcar/car/car.pro +++ b/examples/dbus/remotecontrolledcar/car/car.pro @@ -10,7 +10,7 @@ CONFIG += qdbus # Input # DBUS_ADAPTORS += car.xml -HEADERS += car.h car_adaptor_p.h +HEADERS += car.h car_adaptor.h SOURCES += car.cpp main.cpp car_adaptor.cpp # install diff --git a/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp b/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp index bd4832e..da7505b 100644 --- a/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp +++ b/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp @@ -38,17 +38,17 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i car_adaptor.h -a :car_adaptor.cpp car.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. ** ****************************************************************************/ -#include "car_adaptor_p.h" +#include "car_adaptor.h" #include <QtCore/QMetaObject> #include <QtCore/QByteArray> #include <QtCore/QList> @@ -58,40 +58,40 @@ #include <QtCore/QVariant> /* - * Implementation of adaptor class CarAdaptor + * Implementation of adaptor class CarInterfaceAdaptor */ -CarAdaptor::CarAdaptor(QObject *parent) +CarInterfaceAdaptor::CarInterfaceAdaptor(QObject *parent) : QDBusAbstractAdaptor(parent) { // constructor setAutoRelaySignals(true); } -CarAdaptor::~CarAdaptor() +CarInterfaceAdaptor::~CarInterfaceAdaptor() { // destructor } -void CarAdaptor::accelerate() +void CarInterfaceAdaptor::accelerate() { // handle method call com.trolltech.Examples.CarInterface.accelerate QMetaObject::invokeMethod(parent(), "accelerate"); } -void CarAdaptor::decelerate() +void CarInterfaceAdaptor::decelerate() { // handle method call com.trolltech.Examples.CarInterface.decelerate QMetaObject::invokeMethod(parent(), "decelerate"); } -void CarAdaptor::turnLeft() +void CarInterfaceAdaptor::turnLeft() { // handle method call com.trolltech.Examples.CarInterface.turnLeft QMetaObject::invokeMethod(parent(), "turnLeft"); } -void CarAdaptor::turnRight() +void CarInterfaceAdaptor::turnRight() { // handle method call com.trolltech.Examples.CarInterface.turnRight QMetaObject::invokeMethod(parent(), "turnRight"); diff --git a/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h b/examples/dbus/remotecontrolledcar/car/car_adaptor.h index 5f769cd..d16972e 100644 --- a/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h +++ b/examples/dbus/remotecontrolledcar/car/car_adaptor.h @@ -1,17 +1,17 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** 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. +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -25,23 +25,23 @@ ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -a car_adaptor.h: car.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments @@ -49,8 +49,8 @@ ** ****************************************************************************/ -#ifndef CAR_ADAPTOR_P_H_1157030132 -#define CAR_ADAPTOR_P_H_1157030132 +#ifndef CAR_ADAPTOR_H_1264773009 +#define CAR_ADAPTOR_H_1264773009 #include <QtCore/QObject> #include <QtDBus/QtDBus> @@ -67,22 +67,22 @@ QT_END_NAMESPACE /* * Adaptor class for interface com.trolltech.Examples.CarInterface */ -class CarAdaptor: public QDBusAbstractAdaptor +class CarInterfaceAdaptor: public QDBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "com.trolltech.Examples.CarInterface") Q_CLASSINFO("D-Bus Introspection", "" -" <interface name=\"com.trolltech.Examples.CarInterface\" >\n" -" <method name=\"accelerate\" />\n" -" <method name=\"decelerate\" />\n" -" <method name=\"turnLeft\" />\n" -" <method name=\"turnRight\" />\n" -" <signal name=\"crashed\" />\n" +" <interface name=\"com.trolltech.Examples.CarInterface\">\n" +" <method name=\"accelerate\"/>\n" +" <method name=\"decelerate\"/>\n" +" <method name=\"turnLeft\"/>\n" +" <method name=\"turnRight\"/>\n" +" <signal name=\"crashed\"/>\n" " </interface>\n" "") public: - CarAdaptor(QObject *parent); - virtual ~CarAdaptor(); + CarInterfaceAdaptor(QObject *parent); + virtual ~CarInterfaceAdaptor(); public: // PROPERTIES public Q_SLOTS: // METHODS diff --git a/examples/dbus/remotecontrolledcar/car/main.cpp b/examples/dbus/remotecontrolledcar/car/main.cpp index 85b206c..eab82a7 100644 --- a/examples/dbus/remotecontrolledcar/car/main.cpp +++ b/examples/dbus/remotecontrolledcar/car/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "car.h" -#include "car_adaptor_p.h" +#include "car_adaptor.h" #include <QtGui/QApplication> #include <QtGui/QGraphicsView> #include <QtGui/QGraphicsScene> @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) view.resize(400, 300); view.show(); - new CarAdaptor(car); + new CarInterfaceAdaptor(car); QDBusConnection connection = QDBusConnection::sessionBus(); connection.registerObject("/Car", car); connection.registerService("com.trolltech.CarExample"); diff --git a/examples/dbus/remotecontrolledcar/controller/car_interface.cpp b/examples/dbus/remotecontrolledcar/controller/car_interface.cpp index 01be1bf..21662b4 100644 --- a/examples/dbus/remotecontrolledcar/controller/car_interface.cpp +++ b/examples/dbus/remotecontrolledcar/controller/car_interface.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarInterface -p car_interface_p.h:car_interface.cpp car.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i car_interface.h -p :car_interface.cpp car.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qqdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments @@ -49,18 +49,17 @@ ** ****************************************************************************/ -#include "car_interface_p.h" - +#include "car_interface.h" /* - * Implementation of interface class CarInterface + * Implementation of interface class ComTrolltechExamplesCarInterfaceInterface */ -CarInterface::CarInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) +ComTrolltechExamplesCarInterfaceInterface::ComTrolltechExamplesCarInterfaceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) { } -CarInterface::~CarInterface() +ComTrolltechExamplesCarInterfaceInterface::~ComTrolltechExamplesCarInterfaceInterface() { } diff --git a/examples/dbus/remotecontrolledcar/controller/car_interface_p.h b/examples/dbus/remotecontrolledcar/controller/car_interface.h index 8a5a907..c2d281a 100644 --- a/examples/dbus/remotecontrolledcar/controller/car_interface_p.h +++ b/examples/dbus/remotecontrolledcar/controller/car_interface.h @@ -1,17 +1,17 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** 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. +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -25,31 +25,31 @@ ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarInterface -p car_interface_p.h:car_interface.cpp car.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -p car_interface.h: car.xml ** -** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. ** ****************************************************************************/ -#ifndef CAR_INTERFACE_P_H_1156853585 -#define CAR_INTERFACE_P_H_1156853585 +#ifndef CAR_INTERFACE_H_1264772826 +#define CAR_INTERFACE_H_1264772826 #include <QtCore/QObject> #include <QtCore/QByteArray> @@ -63,7 +63,7 @@ /* * Proxy class for interface com.trolltech.Examples.CarInterface */ -class CarInterface: public QDBusAbstractInterface +class ComTrolltechExamplesCarInterfaceInterface: public QDBusAbstractInterface { Q_OBJECT public: @@ -71,33 +71,33 @@ public: { return "com.trolltech.Examples.CarInterface"; } public: - CarInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + ComTrolltechExamplesCarInterfaceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - ~CarInterface(); + ~ComTrolltechExamplesCarInterfaceInterface(); public Q_SLOTS: // METHODS - inline QDBusReply<void> accelerate() + inline QDBusPendingReply<> accelerate() { QList<QVariant> argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("accelerate"), argumentList); + return asyncCallWithArgumentList(QLatin1String("accelerate"), argumentList); } - inline QDBusReply<void> decelerate() + inline QDBusPendingReply<> decelerate() { QList<QVariant> argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("decelerate"), argumentList); + return asyncCallWithArgumentList(QLatin1String("decelerate"), argumentList); } - inline QDBusReply<void> turnLeft() + inline QDBusPendingReply<> turnLeft() { QList<QVariant> argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("turnLeft"), argumentList); + return asyncCallWithArgumentList(QLatin1String("turnLeft"), argumentList); } - inline QDBusReply<void> turnRight() + inline QDBusPendingReply<> turnRight() { QList<QVariant> argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("turnRight"), argumentList); + return asyncCallWithArgumentList(QLatin1String("turnRight"), argumentList); } Q_SIGNALS: // SIGNALS @@ -107,7 +107,7 @@ Q_SIGNALS: // SIGNALS namespace com { namespace trolltech { namespace Examples { - typedef ::CarInterface CarInterface; + typedef ::ComTrolltechExamplesCarInterfaceInterface CarInterface; } } } diff --git a/examples/dbus/remotecontrolledcar/controller/controller.cpp b/examples/dbus/remotecontrolledcar/controller/controller.cpp index 00a8875..5fca9e3 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.cpp +++ b/examples/dbus/remotecontrolledcar/controller/controller.cpp @@ -42,13 +42,13 @@ #include <QtGui> #include "controller.h" -#include "car_interface_p.h" +#include "car_interface.h" Controller::Controller(QWidget *parent) : QWidget(parent) { ui.setupUi(this); - car = new CarInterface("com.trolltech.CarExample", "/Car", + car = new com::trolltech::Examples::CarInterface("com.trolltech.CarExample", "/Car", QDBusConnection::sessionBus(), this); startTimer(1000); } diff --git a/examples/dbus/remotecontrolledcar/controller/controller.h b/examples/dbus/remotecontrolledcar/controller/controller.h index 07a1355..caadff9 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.h +++ b/examples/dbus/remotecontrolledcar/controller/controller.h @@ -43,8 +43,7 @@ #define CONTROLLER_H #include "ui_controller.h" - -class CarInterface; +#include "car_interface.h" class Controller : public QWidget { @@ -64,7 +63,7 @@ private slots: private: Ui::Controller ui; - CarInterface *car; + com::trolltech::Examples::CarInterface *car; }; #endif diff --git a/examples/dbus/remotecontrolledcar/controller/controller.pro b/examples/dbus/remotecontrolledcar/controller/controller.pro index 159e3b1..375b9d7 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.pro +++ b/examples/dbus/remotecontrolledcar/controller/controller.pro @@ -11,7 +11,7 @@ CONFIG += qdbus # Input # DBUS_INTERFACES += car.xml FORMS += controller.ui -HEADERS += car_interface_p.h controller.h +HEADERS += car_interface.h controller.h SOURCES += main.cpp car_interface.cpp controller.cpp # install diff --git a/examples/dialogs/standarddialogs/dialog.cpp b/examples/dialogs/standarddialogs/dialog.cpp index 9001619..92ed334 100644 --- a/examples/dialogs/standarddialogs/dialog.cpp +++ b/examples/dialogs/standarddialogs/dialog.cpp @@ -239,7 +239,12 @@ void Dialog::setText() void Dialog::setColor() { - QColor color = QColorDialog::getColor(Qt::green, this); + QColor color; + if (native->isChecked()) + color = QColorDialog::getColor(Qt::green, this); + else + color = QColorDialog::getColor(Qt::green, this, "Select Color", QColorDialog::DontUseNativeDialog); + if (color.isValid()) { colorLabel->setText(color.name()); colorLabel->setPalette(QPalette(color)); diff --git a/examples/draganddrop/draggabletext/dragwidget.cpp b/examples/draganddrop/draggabletext/dragwidget.cpp index 0ada3ac..1fd40be 100644 --- a/examples/draganddrop/draggabletext/dragwidget.cpp +++ b/examples/draganddrop/draggabletext/dragwidget.cpp @@ -82,7 +82,7 @@ DragWidget::DragWidget(QWidget *parent) void DragWidget::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasText()) { - if (children().contains(event->source())) { + if (event->source() == this) { event->setDropAction(Qt::MoveAction); event->accept(); } else { 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 2492298..b51d8f7 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 7d779f3..3acc193 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/itemviews/dirview/main.cpp b/examples/itemviews/dirview/main.cpp index f26e2f0..5f33810 100644 --- a/examples/itemviews/dirview/main.cpp +++ b/examples/itemviews/dirview/main.cpp @@ -45,7 +45,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - QDirModel model; + QFileSystemModel model; + model.setRootPath(""); QTreeView tree; tree.setModel(&model); diff --git a/examples/opengl/hellogl_es/cl_helper.h b/examples/opengl/hellogl_es/cl_helper.h deleted file mode 100644 index 4f4c2bd..0000000 --- a/examples/opengl/hellogl_es/cl_helper.h +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 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$ -** -****************************************************************************/ - -#ifdef QT_OPENGL_ES_1_CL - -//! [0] -#define FLOAT2X(f) ((int) ( (f) * (65536))) -#define X2FLOAT(x) ((float)(x) / 65536.0f) - -#define f2vt(f) FLOAT2X(f) -#define vt2f(x) X2FLOAT(x) - -#define q_vertexType GLfixed -#define q_vertexTypeEnum GL_FIXED - -#define q_glFog glFogx -#define q_glFogv glFogxv -//! [0] - -#define q_glLight glLightx -#define q_glLightv glLightxv -#define q_glLightModel glLightModelx -#define q_glLightModelv glLightModelxv - -#define q_glAlphaFunc glAlphaFuncx - -#define q_glMaterial glMaterialx -#define q_glMaterialv glMaterialxv -#define q_glColor4 glColor4x - -#define q_glTexParameter glTexParameterx -#define q_glTexEnv glTexEnvx - -#define q_glOrtho glOrthox -#define q_glFrustum glFrustumx - -#define q_glTranslate glTranslatex -#define q_glScale glScalex -#define q_glRotate glRotatex -#define q_glLoadMatrix glLoadMatrixx - -#define q_glClearColor glClearColorx - -#define q_glMultMatrix glMultMatrixx - -#define q_glNormal3 glNormal3x - -#define q_glPolygonOffset glPolygonOffsetx -#define q_glPointSize glPointSizex - -//! [1] -#else - -#define f2vt(f) (f) -#define vt2f(x) (x) - -#define q_vertexType GLfloat -#define q_vertexTypeEnum GL_FLOAT - -#define q_glFog glFogf -#define q_glFogv glFogfv -//! [1] - -#define q_glLight glLightf -#define q_glLightv glLightfv -#define q_glLightModel glLightModelf -#define q_glLightModelv glLightModelfv - -#define q_glAlphaFunc glAlphaFuncf - -#define q_glMaterial glMaterialf -#define q_glMaterialv glMaterialfv -#define q_glColor4 glColor4f - -#define q_glTexParameter glTexParameterf -#define q_glTexEnv glTexEnvf - -#define q_glOrtho glOrthof -#define q_glFrustum glFrustumf - -#define q_glTranslate glTranslatef -#define q_glScale glScalef -#define q_glRotate glRotatef -#define q_glLoadMatrix glLoadMatrixf - -#define q_glClearColor glClearColor - -#define q_glMultMatrix glMultMatrixf - -#define q_glNormal3 glNormal3f - -#define q_glPolygonOffset glPolygonOffsetf -#define q_glPointSize glPointSizef - -#endif diff --git a/examples/opengl/hellogl_es/glwidget.cpp b/examples/opengl/hellogl_es/glwidget.cpp index 9a45a11..8a6543d 100644 --- a/examples/opengl/hellogl_es/glwidget.cpp +++ b/examples/opengl/hellogl_es/glwidget.cpp @@ -44,7 +44,6 @@ #include <math.h> #include "bubble.h" -#include "cl_helper.h" const int bubbleNum = 8; @@ -114,9 +113,9 @@ void GLWidget::paintQtLogo() { glDisable(GL_TEXTURE_2D); glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3,q_vertexTypeEnum,0, createdVertices); + glVertexPointer(3,GL_FLOAT,0, createdVertices); glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(q_vertexTypeEnum,0,createdNormals); + glNormalPointer(GL_FLOAT,0,createdNormals); glDrawArrays(GL_TRIANGLES, 0, m_vertexNumber / 3); } //! [2] @@ -125,83 +124,83 @@ void GLWidget::paintTexturedCube() { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_uiTexture); - q_vertexType afVertices[] = { - f2vt(-0.5), f2vt(0.5), f2vt(0.5), f2vt(0.5),f2vt(-0.5),f2vt(0.5),f2vt(-0.5),f2vt(-0.5),f2vt(0.5), - f2vt(0.5), f2vt(-0.5), f2vt(0.5), f2vt(-0.5),f2vt(0.5),f2vt(0.5),f2vt(0.5),f2vt(0.5),f2vt(0.5), - f2vt(-0.5), f2vt(-0.5), f2vt(-0.5), f2vt(0.5),f2vt(-0.5),f2vt(-0.5),f2vt(-0.5),f2vt(0.5),f2vt(-0.5), - f2vt(0.5), f2vt(0.5), f2vt(-0.5), f2vt(-0.5),f2vt(0.5),f2vt(-0.5),f2vt(0.5),f2vt(-0.5),f2vt(-0.5), - - f2vt(0.5), f2vt(-0.5), f2vt(-0.5), f2vt(0.5),f2vt(-0.5),f2vt(0.5),f2vt(0.5),f2vt(0.5),f2vt(-0.5), - f2vt(0.5), f2vt(0.5), f2vt(0.5), f2vt(0.5),f2vt(0.5),f2vt(-0.5),f2vt(0.5),f2vt(-0.5),f2vt(0.5), - f2vt(-0.5), f2vt(0.5), f2vt(-0.5), f2vt(-0.5),f2vt(-0.5),f2vt(0.5),f2vt(-0.5),f2vt(-0.5),f2vt(-0.5), - f2vt(-0.5), f2vt(-0.5), f2vt(0.5), f2vt(-0.5),f2vt(0.5),f2vt(-0.5),f2vt(-0.5),f2vt(0.5),f2vt(0.5), - - f2vt(0.5), f2vt(0.5), f2vt(-0.5), f2vt(-0.5), f2vt(0.5), f2vt(0.5), f2vt(-0.5), f2vt(0.5), f2vt(-0.5), - f2vt(-0.5), f2vt(0.5), f2vt(0.5), f2vt(0.5), f2vt(0.5), f2vt(-0.5), f2vt(0.5), f2vt(0.5), f2vt(0.5), - f2vt(-0.5), f2vt(-0.5), f2vt(-0.5), f2vt(-0.5), f2vt(-0.5), f2vt(0.5), f2vt(0.5), f2vt(-0.5), f2vt(-0.5), - f2vt(0.5), f2vt(-0.5), f2vt(0.5), f2vt(0.5), f2vt(-0.5), f2vt(-0.5), f2vt(-0.5), f2vt(-0.5), f2vt(0.5) + GLfloat afVertices[] = { + -0.5, 0.5, 0.5, 0.5,-0.5,0.5,-0.5,-0.5,0.5, + 0.5, -0.5, 0.5, -0.5,0.5,0.5,0.5,0.5,0.5, + -0.5, -0.5, -0.5, 0.5,-0.5,-0.5,-0.5,0.5,-0.5, + 0.5, 0.5, -0.5, -0.5,0.5,-0.5,0.5,-0.5,-0.5, + + 0.5, -0.5, -0.5, 0.5,-0.5,0.5,0.5,0.5,-0.5, + 0.5, 0.5, 0.5, 0.5,0.5,-0.5,0.5,-0.5,0.5, + -0.5, 0.5, -0.5, -0.5,-0.5,0.5,-0.5,-0.5,-0.5, + -0.5, -0.5, 0.5, -0.5,0.5,-0.5,-0.5,0.5,0.5, + + 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, + -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, + -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, + 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5 }; glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3,q_vertexTypeEnum,0,afVertices); - - q_vertexType afTexCoord[] = { - f2vt(0.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f), - f2vt(1.0f),f2vt(1.0f), f2vt(0.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f), - f2vt(1.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f), - f2vt(0.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f), - - f2vt(1.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f), - f2vt(0.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f), - f2vt(0.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f), - f2vt(1.0f),f2vt(1.0f), f2vt(0.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f), - - f2vt(0.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f), - f2vt(1.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f), f2vt(0.0f),f2vt(0.0f), - f2vt(1.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f), f2vt(0.0f),f2vt(0.0f), - f2vt(0.0f),f2vt(1.0f), f2vt(0.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f) + glVertexPointer(3,GL_FLOAT,0,afVertices); + + GLfloat afTexCoord[] = { + 0.0f,0.0f, 1.0f,1.0f, 1.0f,0.0f, + 1.0f,1.0f, 0.0f,0.0f, 0.0f,1.0f, + 1.0f,1.0f, 1.0f,0.0f, 0.0f,1.0f, + 0.0f,0.0f, 0.0f,1.0f, 1.0f,0.0f, + + 1.0f,1.0f, 1.0f,0.0f, 0.0f,1.0f, + 0.0f,0.0f, 0.0f,1.0f, 1.0f,0.0f, + 0.0f,0.0f, 1.0f,1.0f, 1.0f,0.0f, + 1.0f,1.0f, 0.0f,0.0f, 0.0f,1.0f, + + 0.0f,1.0f, 1.0f,0.0f, 1.0f,1.0f, + 1.0f,0.0f, 0.0f,1.0f, 0.0f,0.0f, + 1.0f,0.0f, 1.0f,1.0f, 0.0f,0.0f, + 0.0f,1.0f, 0.0f,0.0f, 1.0f,1.0f }; glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(2,q_vertexTypeEnum,0,afTexCoord); + glTexCoordPointer(2,GL_FLOAT,0,afTexCoord); - q_vertexType afNormals[] = { + GLfloat afNormals[] = { - f2vt(0),f2vt(0),f2vt(-1), f2vt(0),f2vt(0),f2vt(-1), f2vt(0),f2vt(0),f2vt(-1), - f2vt(0),f2vt(0),f2vt(-1), f2vt(0),f2vt(0),f2vt(-1), f2vt(0),f2vt(0),f2vt(-1), - f2vt(0),f2vt(0),f2vt(1), f2vt(0),f2vt(0),f2vt(1), f2vt(0),f2vt(0),f2vt(1), - f2vt(0),f2vt(0),f2vt(1), f2vt(0),f2vt(0),f2vt(1), f2vt(0),f2vt(0),f2vt(1), + 0,0,-1, 0,0,-1, 0,0,-1, + 0,0,-1, 0,0,-1, 0,0,-1, + 0,0,1, 0,0,1, 0,0,1, + 0,0,1, 0,0,1, 0,0,1, - f2vt(-1),f2vt(0),f2vt(0), f2vt(-1),f2vt(0),f2vt(0), f2vt(-1),f2vt(0),f2vt(0), - f2vt(-1),f2vt(0),f2vt(0), f2vt(-1),f2vt(0),f2vt(0), f2vt(-1),f2vt(0),f2vt(0), - f2vt(1),f2vt(0),f2vt(0), f2vt(1),f2vt(0),f2vt(0), f2vt(1),f2vt(0),f2vt(0), - f2vt(1),f2vt(0),f2vt(0), f2vt(1),f2vt(0),f2vt(0), f2vt(1),f2vt(0),f2vt(0), + -1,0,0, -1,0,0, -1,0,0, + -1,0,0, -1,0,0, -1,0,0, + 1,0,0, 1,0,0, 1,0,0, + 1,0,0, 1,0,0, 1,0,0, - f2vt(0),f2vt(-1),f2vt(0), f2vt(0),f2vt(-1),f2vt(0), f2vt(0),f2vt(-1),f2vt(0), - f2vt(0),f2vt(-1),f2vt(0), f2vt(0),f2vt(-1),f2vt(0), f2vt(0),f2vt(-1),f2vt(0), - f2vt(0),f2vt(1),f2vt(0), f2vt(0),f2vt(1),f2vt(0), f2vt(0),f2vt(1),f2vt(0), - f2vt(0),f2vt(1),f2vt(0), f2vt(0),f2vt(1),f2vt(0), f2vt(0),f2vt(1),f2vt(0) + 0,-1,0, 0,-1,0, 0,-1,0, + 0,-1,0, 0,-1,0, 0,-1,0, + 0,1,0, 0,1,0, 0,1,0, + 0,1,0, 0,1,0, 0,1,0 }; glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(q_vertexTypeEnum,0,afNormals); + glNormalPointer(GL_FLOAT,0,afNormals); glDrawArrays(GL_TRIANGLES, 0, 36); } void GLWidget::initializeGL () { - q_glClearColor(f2vt(0.1f), f2vt(0.1f), f2vt(0.2f), f2vt(1.0f)); + glClearColor(0.1f, 0.1f, 0.2f, 1.0f); glEnable(GL_TEXTURE_2D); glGenTextures(1, &m_uiTexture); m_uiTexture = bindTexture(QImage(":/qt.png")); - q_glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - q_glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); - q_vertexType aLightPosition[] = {f2vt(0.0f),f2vt(0.3f),f2vt(1.0f),f2vt(0.0f)}; + GLfloat aLightPosition[] = {0.0f,0.3f,1.0f,0.0f}; - q_glLightv(GL_LIGHT0, GL_SPOT_DIRECTION, aLightPosition); + glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, aLightPosition); m_fAngle = 0; m_fScale = 1; createGeometry(); @@ -230,12 +229,12 @@ void GLWidget::paintGL() //Since OpenGL ES does not support glPush/PopAttrib(GL_ALL_ATTRIB_BITS) //we have to take care of the states ourselves - q_glClearColor(f2vt(0.1f), f2vt(0.1f), f2vt(0.2f), f2vt(1.0f)); + glClearColor(0.1f, 0.1f, 0.2f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_TEXTURE_2D); - q_glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - q_glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); @@ -248,14 +247,14 @@ void GLWidget::paintGL() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - q_glRotate(f2vt(m_fAngle), f2vt(0.0), f2vt(1.0), f2vt(0.0)); - q_glRotate(f2vt(m_fAngle), f2vt(1.0), f2vt(0.0), f2vt(0.0)); - q_glRotate(f2vt(m_fAngle), f2vt(0.0), f2vt(0.0), f2vt(1.0)); - q_glScale(f2vt(m_fScale), f2vt(m_fScale),f2vt(m_fScale)); - q_glTranslate(f2vt(0),f2vt(-0.2),f2vt(0)); + glRotatef(m_fAngle, 0.0f, 1.0f, 0.0f); + glRotatef(m_fAngle, 1.0f, 0.0f, 0.0f); + glRotatef(m_fAngle, 0.0f, 0.0f, 1.0f); + glScalef(m_fScale, m_fScale,m_fScale); + glTranslatef(0.0f,-0.2f,0.0f); - q_vertexType matDiff[] = {f2vt(0.40), f2vt(1.0), f2vt(0.0), f2vt(1.0)}; - q_glMaterialv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiff); + GLfloat matDiff[] = {0.40f, 1.0f, 0.0f, 1.0f}; + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiff); if (qtLogo) paintQtLogo(); @@ -376,11 +375,11 @@ void GLWidget::createGeometry() //! [1] m_vertexNumber = vertices.size(); - createdVertices = new q_vertexType[m_vertexNumber]; - createdNormals = new q_vertexType[m_vertexNumber]; + createdVertices = new GLfloat[m_vertexNumber]; + createdNormals = new GLfloat[m_vertexNumber]; for (int i = 0;i < m_vertexNumber;i++) { - createdVertices[i] = f2vt(vertices.at(i) * 2); - createdNormals[i] = f2vt(normals.at(i)); + createdVertices[i] = vertices.at(i) * 2; + createdNormals[i] = normals.at(i); } vertices.clear(); normals.clear(); diff --git a/examples/opengl/hellogl_es/glwidget.h b/examples/opengl/hellogl_es/glwidget.h index 7a8df53..3b2b5d4 100644 --- a/examples/opengl/hellogl_es/glwidget.h +++ b/examples/opengl/hellogl_es/glwidget.h @@ -45,7 +45,6 @@ #include <QGLWidget> #include <QTime> -#include "cl_helper.h" class Bubble; @@ -76,8 +75,8 @@ private: void extrude(qreal x1, qreal y1, qreal x2, qreal y2); QList<qreal> vertices; QList<qreal> normals; - q_vertexType *createdVertices; - q_vertexType *createdNormals; + GLfloat *createdVertices; + GLfloat *createdNormals; int m_vertexNumber; bool qtLogo; QList<Bubble*> bubbles; diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro index eaac9b8..c3fbc77 100644 --- a/examples/opengl/opengl.pro +++ b/examples/opengl/opengl.pro @@ -1,14 +1,12 @@ TEMPLATE = subdirs -contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles1cl)|contains(QT_CONFIG, opengles2){ +contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2){ contains(QT_CONFIG, opengles2) { SUBDIRS = hellogl_es2 } else { SUBDIRS = hellogl_es } - !contains(QT_CONFIG, opengles1cl) { - SUBDIRS += textures - } + SUBDIRS += textures contains(QT_CONFIG, opengles1) { SUBDIRS += hellogl } diff --git a/examples/qtestlib/tutorial5/containers.cpp b/examples/qtestlib/tutorial5/containers.cpp new file mode 100644 index 0000000..fe68c85 --- /dev/null +++ b/examples/qtestlib/tutorial5/containers.cpp @@ -0,0 +1,269 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite 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$ +** +****************************************************************************/ +// This file contains benchmarks for comparing QVector against std::vector + +#include <QtCore> +#include <QVector> +#include <vector> + +#include <qtest.h> + +template <typename T> // T is the item type +class UseCases { +public: + virtual ~UseCases() {} + + // Use case: Insert \a size items into the vector. + virtual void insert(int size) = 0; + + // Use case: Lookup \a size items from the vector. + virtual void lookup(int size) = 0; +}; + +template <typename T> +T * f(T *ts) // dummy function to prevent code from being optimized away by the compiler +{ + return ts; +} + +// This subclass implements the use cases using QVector as efficiently as possible. +template <typename T> +class UseCases_QVector : public UseCases<T> +{ + void insert(int size) + { + QVector<T> v; + T t; + QBENCHMARK { + for (int i = 0; i < size; ++i) + v.append(t); + } + } + + void lookup(int size) + { + QVector<T> v; + + T t; + for (int i = 0; i < size; ++i) + v.append(t); + + T *ts = new T[size]; + QBENCHMARK { + for (int i = 0; i < size; ++i) + ts[i] = v.value(i); + } + f<T>(ts); + delete[] ts; + } +}; + +// This subclass implements the use cases using std::vector as efficiently as possible. +template <typename T> +class UseCases_stdvector : public UseCases<T> +{ + void insert(int size) + { + std::vector<T> v; + T t; + QBENCHMARK { + for (int i = 0; i < size; ++i) + v.push_back(t); + } + } + + void lookup(int size) + { + std::vector<T> v; + + T t; + for (int i = 0; i < size; ++i) + v.push_back(t); + + T *ts = new T[size]; + QBENCHMARK { + for (int i = 0; i < size; ++i) + ts[i] = v[i]; + } + f<T>(ts); + delete[] ts; + } +}; + +struct Large { // A "large" item type + int x[1000]; +}; + +// Symbian devices typically have limited memory +#ifdef Q_OS_SYMBIAN +# define LARGE_MAX_SIZE 2000 +#else +# define LARGE_MAX_SIZE 20000 +#endif + +class tst_vector_vs_std : public QObject +{ + Q_OBJECT +public: + tst_vector_vs_std() + { + useCases_QVector_int = new UseCases_QVector<int>; + useCases_stdvector_int = new UseCases_stdvector<int>; + + useCases_QVector_Large = new UseCases_QVector<Large>; + useCases_stdvector_Large = new UseCases_stdvector<Large>; + } + +private: + UseCases<int> *useCases_QVector_int; + UseCases<int> *useCases_stdvector_int; + UseCases<Large> *useCases_QVector_Large; + UseCases<Large> *useCases_stdvector_Large; + +private slots: + void insert_int_data(); + void insert_int(); + void insert_Large_data(); + void insert_Large(); + void lookup_int_data(); + void lookup_int(); + void lookup_Large_data(); + void lookup_Large(); +}; + +void tst_vector_vs_std::insert_int_data() +{ + QTest::addColumn<bool>("useStd"); + QTest::addColumn<int>("size"); + + for (int size = 10; size < 20000; size += 100) { + const QByteArray sizeString = QByteArray::number(size); + QTest::newRow(("std::vector-int--" + sizeString).constData()) << true << size; + QTest::newRow(("QVector-int--" + sizeString).constData()) << false << size; + } +} + +void tst_vector_vs_std::insert_int() +{ + QFETCH(bool, useStd); + QFETCH(int, size); + + if (useStd) + useCases_stdvector_int->insert(size); + else + useCases_QVector_int->insert(size); +} + +void tst_vector_vs_std::insert_Large_data() +{ + QTest::addColumn<bool>("useStd"); + QTest::addColumn<int>("size"); + + for (int size = 10; size < LARGE_MAX_SIZE; size += 100) { + const QByteArray sizeString = QByteArray::number(size); + QTest::newRow(("std::vector-Large--" + sizeString).constData()) << true << size; + QTest::newRow(("QVector-Large--" + sizeString).constData()) << false << size; + } +} + +void tst_vector_vs_std::insert_Large() +{ + QFETCH(bool, useStd); + QFETCH(int, size); + + if (useStd) + useCases_stdvector_Large->insert(size); + else + useCases_QVector_Large->insert(size); +} + +//! [1] +void tst_vector_vs_std::lookup_int_data() +{ + QTest::addColumn<bool>("useStd"); + QTest::addColumn<int>("size"); + + for (int size = 10; size < 20000; size += 100) { + const QByteArray sizeString = QByteArray::number(size); + QTest::newRow(("std::vector-int--" + sizeString).constData()) << true << size; + QTest::newRow(("QVector-int--" + sizeString).constData()) << false << size; + } +} +//! [1] + +//! [2] +void tst_vector_vs_std::lookup_int() +{ + QFETCH(bool, useStd); + QFETCH(int, size); + + if (useStd) + useCases_stdvector_int->lookup(size); // Create a std::vector and run the benchmark. + else + useCases_QVector_int->lookup(size); // Create a QVector and run the benchmark. +} +//! [2] + +void tst_vector_vs_std::lookup_Large_data() +{ + QTest::addColumn<bool>("useStd"); + QTest::addColumn<int>("size"); + + for (int size = 10; size < LARGE_MAX_SIZE; size += 100) { + const QByteArray sizeString = QByteArray::number(size); + QTest::newRow(("std::vector-Large--" + sizeString).constData()) << true << size; + QTest::newRow(("QVector-Large--" + sizeString).constData()) << false << size; + } +} + +void tst_vector_vs_std::lookup_Large() +{ + QFETCH(bool, useStd); + QFETCH(int, size); + + if (useStd) + useCases_stdvector_Large->lookup(size); + else + useCases_QVector_Large->lookup(size); +} + +QTEST_MAIN(tst_vector_vs_std) +#include "main.moc" diff --git a/examples/tools/completer/completer.pro b/examples/tools/completer/completer.pro index 96d3734..14521b2 100644 --- a/examples/tools/completer/completer.pro +++ b/examples/tools/completer/completer.pro @@ -1,6 +1,6 @@ -HEADERS = dirmodel.h \ +HEADERS = fsmodel.h \ mainwindow.h -SOURCES = dirmodel.cpp \ +SOURCES = fsmodel.cpp \ main.cpp \ mainwindow.cpp RESOURCES = completer.qrc diff --git a/examples/tools/completer/dirmodel.cpp b/examples/tools/completer/fsmodel.cpp index 6279547..9a5a772 100644 --- a/examples/tools/completer/dirmodel.cpp +++ b/examples/tools/completer/fsmodel.cpp @@ -39,17 +39,17 @@ ** ****************************************************************************/ -#include "dirmodel.h" +#include "fsmodel.h" //! [0] -DirModel::DirModel(QObject *parent) - : QDirModel(parent) +FileSystemModel::FileSystemModel(QObject *parent) + : QFileSystemModel(parent) { } //! [0] //! [1] -QVariant DirModel::data(const QModelIndex &index, int role) const +QVariant FileSystemModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole && index.column() == 0) { QString path = QDir::toNativeSeparators(filePath(index)); @@ -58,6 +58,7 @@ QVariant DirModel::data(const QModelIndex &index, int role) const return path; } - return QDirModel::data(index, role); + return QFileSystemModel::data(index, role); } + //! [1] diff --git a/examples/tools/completer/dirmodel.h b/examples/tools/completer/fsmodel.h index 5fbb4a2..0ec9ce9 100644 --- a/examples/tools/completer/dirmodel.h +++ b/examples/tools/completer/fsmodel.h @@ -39,21 +39,21 @@ ** ****************************************************************************/ -#ifndef DIRMODEL_H -#define DIRMODEL_H +#ifndef FILESYSTEMMODEL_H +#define FILESYSTEMMODEL_H -#include <QDirModel> +#include <QFileSystemModel> -// With a QDirModel, set on a view, you will see "Program Files" in the view +// With a QFileSystemModel, set on a view, you will see "Program Files" in the view // But with this model, you will see "C:\Program Files" in the view. // We acheive this, by having the data() return the entire file path for // the display role. Note that the Qt::EditRole over which the QCompleter // looks for matches is left unchanged //! [0] -class DirModel : public QDirModel +class FileSystemModel : public QFileSystemModel { public: - DirModel(QObject *parent = 0); + FileSystemModel(QObject *parent = 0); QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; }; //! [0] diff --git a/examples/tools/completer/mainwindow.cpp b/examples/tools/completer/mainwindow.cpp index f386497..b1f6759 100644 --- a/examples/tools/completer/mainwindow.cpp +++ b/examples/tools/completer/mainwindow.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include <QtGui> -#include "dirmodel.h" +#include "fsmodel.h" #include "mainwindow.h" //! [0] @@ -55,8 +55,8 @@ MainWindow::MainWindow(QWidget *parent) modelLabel->setText(tr("Model")); modelCombo = new QComboBox; - modelCombo->addItem(tr("QDirModel")); - modelCombo->addItem(tr("QDirModel that shows full path")); + modelCombo->addItem(tr("QFileSytemModel")); + modelCombo->addItem(tr("QFileSytemModel that shows full path")); modelCombo->addItem(tr("Country list")); modelCombo->addItem(tr("Word list")); modelCombo->setCurrentIndex(0); @@ -218,17 +218,19 @@ void MainWindow::changeModel() switch (modelCombo->currentIndex()) { default: case 0: - { // Unsorted QDirModel - QDirModel *dirModel = new QDirModel(completer); - completer->setModel(dirModel); + { // Unsorted QFileSystemModel + QFileSystemModel *fsModel = new QFileSystemModel(completer); + fsModel->setRootPath(""); + completer->setModel(fsModel); contentsLabel->setText(tr("Enter file path")); } break; //! [11] //! [12] case 1: - { // DirModel that shows full paths - DirModel *dirModel = new DirModel(completer); - completer->setModel(dirModel); + { // FileSystemModel that shows full paths + FileSystemModel *fsModel = new FileSystemModel(completer); + completer->setModel(fsModel); + fsModel->setRootPath(""); contentsLabel->setText(tr("Enter file path")); } break; diff --git a/examples/webkit/fancybrowser/main.cpp b/examples/webkit/fancybrowser/main.cpp index cf98b51..23f9713 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; - browser.show(); + 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 852d981..6499831 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,24 @@ 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()); + reply->deleteLater(); +} + //! [4] void MainWindow::adjustLocation() { diff --git a/examples/webkit/fancybrowser/mainwindow.h b/examples/webkit/fancybrowser/mainwindow.h index 08439c1..d3f8e7e 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(); |