diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-10 09:42:53 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-10 09:42:53 (GMT) |
commit | ead7fd2fd4a4a9963335285cbe8405ac0b1da0e8 (patch) | |
tree | e2d3364e7db0f324d1e83ab812bc9201f503146d /doc | |
parent | 4765c892c122bf578083502ee0ce098db0bee48f (diff) | |
parent | 57f493c176ce62b249595e1f18cacd854c1562c4 (diff) | |
download | Qt-ead7fd2fd4a4a9963335285cbe8405ac0b1da0e8.zip Qt-ead7fd2fd4a4a9963335285cbe8405ac0b1da0e8.tar.gz Qt-ead7fd2fd4a4a9963335285cbe8405ac0b1da0e8.tar.bz2 |
Merge branch '4.6'
Diffstat (limited to 'doc')
-rw-r--r-- | doc/src/frameworks-technologies/model-view-programming.qdoc | 51 | ||||
-rw-r--r-- | doc/src/images/qt-colors.png | bin | 3711 -> 11701 bytes | |||
-rw-r--r-- | doc/src/images/shareddirmodel.png | bin | 33024 -> 45891 bytes | |||
-rw-r--r-- | doc/src/images/standard-views.png | bin | 78278 -> 44495 bytes | |||
-rw-r--r-- | doc/src/platforms/s60-introduction.qdoc | 28 | ||||
-rw-r--r-- | doc/src/porting/qt4-interview.qdoc | 8 | ||||
-rw-r--r-- | doc/src/snippets/colors/colors.pro | 2 | ||||
-rw-r--r-- | doc/src/snippets/colors/main.cpp | 52 | ||||
-rw-r--r-- | doc/src/snippets/colors/window.cpp | 131 | ||||
-rw-r--r-- | doc/src/snippets/colors/window.h | 53 | ||||
-rw-r--r-- | doc/src/snippets/shareddirmodel/main.cpp | 5 | ||||
-rw-r--r-- | doc/src/snippets/simplemodel-use/main.cpp | 2 |
12 files changed, 287 insertions, 45 deletions
diff --git a/doc/src/frameworks-technologies/model-view-programming.qdoc b/doc/src/frameworks-technologies/model-view-programming.qdoc index bc884df..f0f20b4 100644 --- a/doc/src/frameworks-technologies/model-view-programming.qdoc +++ b/doc/src/frameworks-technologies/model-view-programming.qdoc @@ -215,8 +215,8 @@ \o QStringListModel is used to store a simple list of QString items. \o QStandardItemModel manages more complex tree structures of items, each of which can contain arbitrary data. - \o QDirModel provides information about files and directories in the local - filing system. + \o QFileSystemModel provides information about files and directories in the + local filing system. \o QSqlQueryModel, QSqlTableModel, and QSqlRelationalTableModel are used to access databases using model/view conventions. \endlist @@ -313,14 +313,14 @@ \section1 Introduction Two of the standard models provided by Qt are QStandardItemModel and - QDirModel. QStandardItemModel is a multi-purpose model that can be used - to represent various different data structures needed by list, table, + QFileSystemModel. QStandardItemModel is a multi-purpose model that can be + used to represent various different data structures needed by list, table, and tree views. This model also holds the items of data. - QDirModel is a model that maintains information about the contents of a - directory. As a result, it does not hold any items of data itself, but + QFileSystemModel is a model that maintains information about the contents + of a directory. As a result, it does not hold any items of data itself, but simply represents files and directories on the local filing system. - QDirModel provides a ready-to-use model to experiment with, and can be + QFileSystemModel provides a ready-to-use model to experiment with, and can be easily configured to use existing data. Using this model, we can show how to set up a model for use with ready-made views, and explore how to manipulate data using model indexes. @@ -328,22 +328,25 @@ \section1 Using Views with an Existing Model The QListView and QTreeView classes are the most suitable views - to use with QDirModel. The example presented below displays the + to use with QFileSystemModel. The example presented below displays the contents of a directory in a tree view next to the same information in a list view. The views share the user's selection so that the selected items are highlighted in both views. \img shareddirmodel.png - We set up a QDirModel so that it is ready for use, and create some + We set up a QFileSystemModel so that it is ready for use, and create some views to display the contents of a directory. This shows the simplest way to use a model. The construction and use of the model is performed from within a single \c main() function: \snippet doc/src/snippets/shareddirmodel/main.cpp 0 - The model is set up to use data from a default directory. We create two - views so that we can examine the items held in the model in two + The model is set up to use data from a certain file system. The call to + \l{QFileSystemModel::}{setRootPath()} tell the model which drive on the + file system to expose to the views. + + We create two views so that we can examine the items held in the model in two different ways: \snippet doc/src/snippets/shareddirmodel/main.cpp 5 @@ -351,13 +354,13 @@ The views are constructed in the same way as other widgets. Setting up a view to display the items in the model is simply a matter of calling its \l{QAbstractItemView::setModel()}{setModel()} function with the directory - model as the argument. The calls to - \l{QAbstractItemView::setRootIndex()}{setRootIndex()} tell the views which - directory to display by supplying a \e{model index} that we obtain from - the directory model. + model as the argument. We filter the data supplied by the model by calling + the \l{QAbstractItemView::}{setRootIndex()} function on each view, passing + a suitable \e{model index} from the file system model for the current + directory. - The \c index() function used in this case is unique to QDirModel; we supply - it with a directory and it returns a model index. Model indexes are + The \c index() function used in this case is unique to QFileSystemModel; we + supply it with a directory and it returns a model index. Model indexes are discussed in the \l{Model Classes} chapter. The rest of the function just displays the views within a splitter @@ -556,19 +559,19 @@ \section2 Using Model Indexes To demonstrate how data can be retrieved from a model, using model - indexes, we set up a QDirModel without a view and display the + indexes, we set up a QFileSystemModel without a view and display the names of files and directories in a widget. Although this does not show a normal way of using a model, it demonstrates the conventions used by models when dealing with model indexes. - We construct a directory model in the following way: + We construct a file system model in the following way: \snippet doc/src/snippets/simplemodel-use/main.cpp 0 - In this case, we set up a default QDirModel, obtain a parent index using - a specific implementation of \l{QDirModel::index()}{index()} provided by - that model, and we count the number of rows in the model using the - \l{QDirModel::rowCount()}{rowCount()} function. + In this case, we set up a default QFileSystemModel, obtain a parent index + using a specific implementation of \l{QFileSystemModel::}{index()} + provided by that model, and we count the number of rows in the model using + the \l{QFileSystemModel::}{rowCount()} function. For simplicity, we are only interested in the items in the first column of the model. We examine each row in turn, obtaining a model index for @@ -581,7 +584,7 @@ for the first column), and the appropriate model index for the parent of all the items that we want. The text stored in each item is retrieved using the model's - \l{QDirModel::data()}{data()} function. We specify the model index and + \l{QFileSystemModel::}{data()} function. We specify the model index and the \l{Qt::ItemDataRole}{DisplayRole} to obtain data for the item in the form of a string. diff --git a/doc/src/images/qt-colors.png b/doc/src/images/qt-colors.png Binary files differindex 524123f..331c975 100644 --- a/doc/src/images/qt-colors.png +++ b/doc/src/images/qt-colors.png diff --git a/doc/src/images/shareddirmodel.png b/doc/src/images/shareddirmodel.png Binary files differindex 6daa9d3..7b9fded 100644 --- a/doc/src/images/shareddirmodel.png +++ b/doc/src/images/shareddirmodel.png diff --git a/doc/src/images/standard-views.png b/doc/src/images/standard-views.png Binary files differindex 836ae36..c804551 100644 --- a/doc/src/images/standard-views.png +++ b/doc/src/images/standard-views.png diff --git a/doc/src/platforms/s60-introduction.qdoc b/doc/src/platforms/s60-introduction.qdoc index d27eb39..5fd0cbe 100644 --- a/doc/src/platforms/s60-introduction.qdoc +++ b/doc/src/platforms/s60-introduction.qdoc @@ -50,12 +50,12 @@ \tableofcontents \section1 Required tools - + See \l{Qt for Symbian platform Requirements} to see what tools are -required to use Qt for Symbian platform. + required to use Qt for Symbian platform. \section1 Installing Qt and running demos - + Follow the instructions found in \l{Installing Qt on the Symbian platform using binary package} to learn how to install Qt using binary package and how to build and run Qt demos. @@ -69,7 +69,7 @@ required to use Qt for Symbian platform. Qt application on the Symbian platform compared to any of the other platforms supported by Qt is not that big. - Once you have crated a \c .pro file for your project, generate the + Once you have created a \c .pro file for your project, generate the Carbide specific \c Bld.inf and \c .mmp files this way: \snippet doc/src/snippets/code/doc_src_s60-introduction.qdoc 0 @@ -78,9 +78,9 @@ required to use Qt for Symbian platform. {qmake Tutorial}. Now you can build the Qt for the Symbian platform application with -standard build tools. By default, running \c make will produce binaries for -the emulator. However, the Symbian platform comes with several alternative -build targets, as shown in the table below: + standard build tools. By default, running \c make will produce binaries for + the emulator. However, the Symbian platform comes with several alternative + build targets, as shown in the table below: \table \row \o \c debug-winscw \o Build debug binaries for the emulator (default). @@ -111,18 +111,18 @@ build targets, as shown in the table below: target. For example, the following sequence will generate the needed makefiles, build the project for \c debug-winscw and \c release-armv5, and create self-signed \c .sis file for \c release-armv5 target: - + \snippet doc/src/snippets/code/doc_src_s60-introduction.qdoc 2 If you want to use different certificate information or override the default target for \c .sis file creation you can use the environment variables as shown in the table below: - + \table \row \o \c QT_SIS_OPTIONS \o Options accepted by \c .sis creation. -i, install the package right away using PC suite. -c=<file>, read certificate information from a file. - Execute \c{createpackage.pl} script without any + Execute the \c{createpackage.pl} script without any parameters for more information about options. By default no otions are given. \row \o \c QT_SIS_TARGET \o Target for which \c .sis file is created. @@ -135,15 +135,15 @@ build targets, as shown in the table below: \row \o \c QT_SIS_PASSPHRASE \o The certificate's private key file's passphrase. By default empty. \endtable - + For example: - + \snippet doc/src/snippets/code/doc_src_s60-introduction.qdoc 4 The environment variables for \c make can also be given as parameters: - + \snippet doc/src/snippets/code/doc_src_s60-introduction.qdoc 3 - + If you want to install the program immediately, make sure that the device is connected to the computer in "PC Suite" mode, and run \c sis target with the \c QT_SIS_OPTIONS=-i, like this: diff --git a/doc/src/porting/qt4-interview.qdoc b/doc/src/porting/qt4-interview.qdoc index 29d9f5c..fd3fb36 100644 --- a/doc/src/porting/qt4-interview.qdoc +++ b/doc/src/porting/qt4-interview.qdoc @@ -109,8 +109,8 @@ \list \o QStandardItemModel is a minimal convenience model that developers can use to manage items of data. - \o QDirModel provides directory information for use with QListView and - QTreeView. + \o QFileSystemModel provides directory information for use with QListView + and QTreeView. \o QStringListModel is a convenience model that can be used to hold strings for views such as QListView and QComboBox. \endlist @@ -153,7 +153,7 @@ In this example, we display the contents of a model using two different views, and share the user's selection between - them. We will use the QDirModel supplied with Qt because it + them. We will use the QFileSystemModel supplied with Qt because it requires very little configuration, and provides existing data to the views. @@ -174,7 +174,7 @@ \image interview-shareddirmodel.png - The model/view architecture allows us to replace the QDirModel in + The model/view architecture allows us to replace the QFileSystemModel in this example with a completely different model, one that will perhaps obtain data from a remote server, or from a database. diff --git a/doc/src/snippets/colors/colors.pro b/doc/src/snippets/colors/colors.pro new file mode 100644 index 0000000..b2cc87d --- /dev/null +++ b/doc/src/snippets/colors/colors.pro @@ -0,0 +1,2 @@ +HEADERS = window.h +SOURCES = main.cpp window.cpp diff --git a/doc/src/snippets/colors/main.cpp b/doc/src/snippets/colors/main.cpp new file mode 100644 index 0000000..4e09036 --- /dev/null +++ b/doc/src/snippets/colors/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** 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 documentation 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 "window.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Window window; + window.setFixedSize(640, 215); + window.show(); + return app.exec(); +} diff --git a/doc/src/snippets/colors/window.cpp b/doc/src/snippets/colors/window.cpp new file mode 100644 index 0000000..0cec5f5 --- /dev/null +++ b/doc/src/snippets/colors/window.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** 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 documentation 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 "window.h" + +Window::Window(QWidget *parent) + : QWidget(parent) +{ + QFont font; + font.setPixelSize(12); + setFont(font); +} + +void Window::closeEvent(QCloseEvent *event) +{ + QPixmap pixmap(size()); + render(&pixmap); + pixmap.save("qt-colors.png"); + + event->accept(); +} + +void Window::paintEvent(QPaintEvent *) +{ + QPainter painter; + painter.begin(this); + + int h = 216 / 5; + QRect r = QRect(0, 0, 160, h); + painter.fillRect(r, Qt::white); + painter.setPen(Qt::black); + painter.drawText(r, Qt::AlignCenter, QLatin1String("white")); + r = QRect(0, h, 160, h); + painter.fillRect(r, Qt::red); + painter.drawText(r, Qt::AlignCenter, QLatin1String("red")); + r = QRect(0, h*2, 160, h); + painter.fillRect(r, Qt::green); + painter.drawText(r, Qt::AlignCenter, QLatin1String("green")); + r = QRect(0, h*3, 160, h); + painter.fillRect(r, Qt::blue); + painter.setPen(Qt::white); + painter.drawText(r, Qt::AlignCenter, QLatin1String("blue")); + + r = QRect(160, 0, 160, h); + painter.fillRect(r, Qt::black); + painter.drawText(r, Qt::AlignCenter, QLatin1String("black")); + r = QRect(160, h, 160, h); + painter.fillRect(r, Qt::darkRed); + painter.drawText(r, Qt::AlignCenter, QLatin1String("darkRed")); + r = QRect(160, h*2, 160, h); + painter.fillRect(r, Qt::darkGreen); + painter.drawText(r, Qt::AlignCenter, QLatin1String("darkGreen")); + r = QRect(160, h*3, 160, h); + painter.fillRect(r, Qt::darkBlue); + painter.drawText(r, Qt::AlignCenter, QLatin1String("darkBlue")); + + r = QRect(320, 0, 160, h); + painter.fillRect(r, Qt::cyan); + painter.setPen(Qt::black); + painter.drawText(r, Qt::AlignCenter, QLatin1String("cyan")); + r = QRect(320, h, 160, h); + painter.fillRect(r, Qt::magenta); + painter.drawText(r, Qt::AlignCenter, QLatin1String("magenta")); + r = QRect(320, h*2, 160, h); + painter.fillRect(r, Qt::yellow); + painter.drawText(r, Qt::AlignCenter, QLatin1String("yellow")); + r = QRect(320, h*3, 160, h); + painter.fillRect(r, Qt::gray); + painter.setPen(Qt::white); + painter.drawText(r, Qt::AlignCenter, QLatin1String("gray")); + + r = QRect(480, 0, 160, h); + painter.fillRect(r, Qt::darkCyan); + painter.drawText(r, Qt::AlignCenter, QLatin1String("darkCyan")); + r = QRect(480, h, 160, h); + painter.fillRect(r, Qt::darkMagenta); + painter.drawText(r, Qt::AlignCenter, QLatin1String("darkMagenta")); + r = QRect(480, h*2, 160, h); + painter.fillRect(r, Qt::darkYellow); + painter.drawText(r, Qt::AlignCenter, QLatin1String("darkYellow")); + r = QRect(480, h*3, 160, h); + painter.fillRect(r, Qt::darkGray); + painter.drawText(r, Qt::AlignCenter, QLatin1String("darkGray")); + + r = QRect(0, h*4, 640, h); + painter.fillRect(r, Qt::lightGray); + painter.setPen(Qt::black); + painter.drawText(r, Qt::AlignCenter, QLatin1String("lightGray")); + + painter.end(); +} + diff --git a/doc/src/snippets/colors/window.h b/doc/src/snippets/colors/window.h new file mode 100644 index 0000000..3b08b90 --- /dev/null +++ b/doc/src/snippets/colors/window.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** 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 documentation 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 <QWidget> + +class Window : public QWidget +{ +public: + Window(QWidget *parent = 0); + +protected: + void closeEvent(QCloseEvent *event); + void paintEvent(QPaintEvent *event); +}; + diff --git a/doc/src/snippets/shareddirmodel/main.cpp b/doc/src/snippets/shareddirmodel/main.cpp index 82034b5..3cb63c9 100644 --- a/doc/src/snippets/shareddirmodel/main.cpp +++ b/doc/src/snippets/shareddirmodel/main.cpp @@ -55,7 +55,8 @@ int main(int argc, char *argv[]) QSplitter *splitter = new QSplitter; //! [2] //! [3] - QDirModel *model = new QDirModel; + QFileSystemModel *model = new QFileSystemModel; + model->setRootPath(QDir::currentPath()); //! [0] //! [2] //! [4] //! [5] QTreeView *tree = new QTreeView(splitter); //! [3] //! [6] @@ -74,7 +75,7 @@ int main(int argc, char *argv[]) list->setSelectionModel(selection); //! [8] - splitter->setWindowTitle("Two views onto the same directory model"); + splitter->setWindowTitle("Two views onto the same file system model"); splitter->show(); return app.exec(); } diff --git a/doc/src/snippets/simplemodel-use/main.cpp b/doc/src/snippets/simplemodel-use/main.cpp index a3bb0e7..d7fc755 100644 --- a/doc/src/snippets/simplemodel-use/main.cpp +++ b/doc/src/snippets/simplemodel-use/main.cpp @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) layout->addWidget(title); //! [0] - QDirModel *model = new QDirModel; + QFileSystemModel *model = new QFileSystemModel; QModelIndex parentIndex = model->index(QDir::currentPath()); int numRows = model->rowCount(parentIndex); //! [0] |