diff options
author | Casper van Donderen <casper.vandonderen@nokia.com> | 2012-05-09 12:35:30 +0200 |
---|---|---|
committer | Marius Storm-Olsen <marius.storm-olsen@nokia.com> | 2012-05-09 22:43:31 +0200 |
commit | 47799adc0d1bfb9e0e592dbc9af3eb4680e0c81b (patch) | |
tree | a2518897dda5c9634ac2d9ff8a667743d08cb179 /src/corelib | |
parent | a4d07f6c0bc71b3e0abd109325b3be4683e0d243 (diff) |
Doc: Move some remaining files over for modularization.
The files in this change were still in qtbase/doc/src or required for
it. qtbase/doc/src should now only contain example documentation and
images for the example documentation.
Change-Id: Ia7ca8e7fd2b316e77c706a08df71303bc8294213
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/doc/images/resources.png | bin | 0 -> 49998 bytes | |||
-rw-r--r-- | src/corelib/doc/snippets/code/doc_src_resources.cpp | 54 | ||||
-rw-r--r-- | src/corelib/doc/snippets/code/doc_src_resources.qdoc | 65 | ||||
-rw-r--r-- | src/corelib/doc/src/io.qdoc | 39 | ||||
-rw-r--r-- | src/corelib/doc/src/resource-system.qdoc | 202 | ||||
-rw-r--r-- | src/corelib/global/qlogging.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qfiledevice.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qurlquery.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qhash.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstringlist.cpp | 8 |
10 files changed, 371 insertions, 11 deletions
diff --git a/src/corelib/doc/images/resources.png b/src/corelib/doc/images/resources.png Binary files differnew file mode 100644 index 0000000000..eb7af96d77 --- /dev/null +++ b/src/corelib/doc/images/resources.png diff --git a/src/corelib/doc/snippets/code/doc_src_resources.cpp b/src/corelib/doc/snippets/code/doc_src_resources.cpp new file mode 100644 index 0000000000..f401add728 --- /dev/null +++ b/src/corelib/doc/snippets/code/doc_src_resources.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [4] +QResource::registerResource("/path/to/myresource.rcc"); +//! [4] + + +//! [5] +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Q_INIT_RESOURCE(graphlib); + ... + return app.exec(); +} +//! [5] diff --git a/src/corelib/doc/snippets/code/doc_src_resources.qdoc b/src/corelib/doc/snippets/code/doc_src_resources.qdoc new file mode 100644 index 0000000000..c51dbbcbf3 --- /dev/null +++ b/src/corelib/doc/snippets/code/doc_src_resources.qdoc @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +<file alias="cut-img.png">images/cut.png</file> +//! [0] + + +//! [1] +<qresource prefix="/myresources"> + <file alias="cut-img.png">images/cut.png</file> +</qresource> +//! [1] + + +//! [2] +<qresource> + <file>cut.jpg</file> +</qresource> +<qresource lang="fr"> + <file alias="cut.jpg">cut_fr.jpg</file> +</qresource> +//! [2] + + +//! [3] +rcc -binary myresource.qrc -o myresource.rcc +//! [3] diff --git a/src/corelib/doc/src/io.qdoc b/src/corelib/doc/src/io.qdoc new file mode 100644 index 0000000000..dfe9be2b3c --- /dev/null +++ b/src/corelib/doc/src/io.qdoc @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms +** and conditions contained in a signed written agreement between you +** and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \group io + \title Input/Output and Networking + \ingroup groups + + \brief Classes providing file input and output along with directory and + network handling. + + These classes are used to handle input and output to and from external + devices, processes, files etc. as well as manipulating files and directories. +*/ + diff --git a/src/corelib/doc/src/resource-system.qdoc b/src/corelib/doc/src/resource-system.qdoc new file mode 100644 index 0000000000..89a099a1c1 --- /dev/null +++ b/src/corelib/doc/src/resource-system.qdoc @@ -0,0 +1,202 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms +** and conditions contained in a signed written agreement between you +** and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page resources.html + \title The Qt Resource System + \ingroup qt-network + \brief A platform-independent mechanism for storing binary files in an application. + + \keyword resource system + + The Qt resource system is a platform-independent mechanism for + storing binary files in the application's executable. This is + useful if your application always needs a certain set of files + (icons, translation files, etc.) and you don't want to run the + risk of losing the files. + + The resource system is based on tight cooperation between \l qmake, + \l rcc (Qt's resource compiler), and QFile. It obsoletes Qt 3's + \c qembed tool and the + \l{http://qt.nokia.com/doc/qq/qq05-iconography.html#imagestorage}{image + collection} mechanism. + + \section1 Resource Collection Files (\c{.qrc}) + + The resources associated with an application are specified in a + \c .qrc file, an XML-based file format that lists files on the + disk and optionally assigns them a resource name that the + application must use to access the resource. + + Here's an example \c .qrc file: + + \quotefile mainwindows/application/application.qrc + + The resource files listed in the \c .qrc file are files that are + part of the application's source tree. The specified paths are + relative to the directory containing the \c .qrc file. Note that + the listed resource files must be located in the same directory as + the \c .qrc file, or one of its subdirectories. + + Resource data can either be compiled into the binary and thus accessed + immediately in application code, or a binary resource can be created + and at a later point in application code registered with the resource + system. + + By default, resources are accessible in the application under the + same file name as they have in the source tree, with a \c :/ prefix, + or by a \link QUrl URL\endlink with a \c qrc scheme. + + For example, the file path \c :/images/cut.png or the URL + \c qrc:///images/cut.png would give access to the + \c cut.png file, whose location in the application's source tree + is \c images/cut.png. This can be changed using the \c file tag's + \c alias attribute: + + \snippet code/doc_src_resources.qdoc 0 + + The file is then accessible as \c :/cut-img.png from the + application. It is also possible to specify a path prefix for all + files in the \c .qrc file using the \c qresource tag's \c prefix + attribute: + + \snippet code/doc_src_resources.qdoc 1 + + In this case, the file is accessible as \c + :/myresources/cut-img.png. + + Some resources need to change based on the user's locale, + such as translation files or icons. This is done by adding a \c lang + attribute to the \c qresource tag, specifying a suitable locale + string. For example: + + \snippet code/doc_src_resources.qdoc 2 + + If the user's locale is French (i.e., QLocale::system().name() returns + "fr_FR"), \c :/cut.jpg becomes a reference to the \c cut_fr.jpg + image. For other locales, \c cut.jpg is used. + + See the QLocale documentation for a description of the format to use + for locale strings. + + + \section2 External Binary Resources + + For an external binary resource to be created you must create the resource + data (commonly given the \c .rcc extension) by passing the -binary switch to + \l rcc. Once the binary resource is created you can register the resource + with the QResource API. + + For example, a set of resource data specified in a \c .qrc file can be + compiled in the following way: + + \snippet code/doc_src_resources.qdoc 3 + + In the application, this resource would be registered with code like this: + + \snippet code/doc_src_resources.cpp 4 + + \section2 Compiled-In Resources + + For a resource to be compiled into the binary the \c .qrc file must be + mentioned in the application's \c .pro file so that \c qmake knows + about it. For example: + + \snippet mainwindows/application/application.pro 0 + + \c qmake will produce make rules to generate a file called \c + qrc_application.cpp that is linked into the application. This + file contains all the data for the images and other resources as + static C++ arrays of compressed binary data. The \c + qrc_application.cpp file is automatically regenerated whenever + the \c .qrc file changes or one of the files that it refers to + changes. If you don't use \c .pro files, you can either invoke + \c rcc manually or add build rules to your build system. + + \image resources.png Building resources into an application + + Currently, Qt always stores the data directly in the executable, + even on Windows and Mac OS X, where the operating system provides + native support for resources. This might change in a future Qt + release. + + \section1 Compression + + Resources are compressed by default (in the \c ZIP format). It is + possible to turn off compression. This can be useful if your + resources already contain a compressed format, such as \c .png + files. You do this by giving the \c {-no-compress} command line + argument. + + \code + rcc -no-compress myresources.qrc + \endcode + + \c rcc also gives you some control over the compression. You can + specify the compression level and the threshold level to consider + while compressing files, for example: + + \code + rcc -compress 2 -threshold 3 myresources.qrc + \endcode + + \section1 Using Resources in the Application + + In the application, resource paths can be used in most places + instead of ordinary file system paths. In particular, you can + pass a resource path instead of a file name to the QIcon, QImage, + or QPixmap constructor: + + \snippet mainwindows/application/mainwindow.cpp 21 + + See the \l{mainwindows/application}{Application} example for an + actual application that uses Qt's resource system to store its + icons. + + In memory, resources are represented by a tree of resource + objects. The tree is automatically built at startup and used by + QFile for resolving paths to resources. You can use a QDir initialized + with ":/" to navigate through the resource tree from the root. + + Qt's resources support the concept of a search path list. If you then + refer to a resource with \c : instead of \c :/ as the prefix, the + resource will be looked up using the search path list. The search + path list is empty at startup; call QDir::addSearchPath() to + add paths to it. + + If you have resources in a static library, you might need to + force initialization of your resources by calling \l + Q_INIT_RESOURCE() with the base name of the \c .qrc file. For + example: + + \snippet code/doc_src_resources.cpp 5 + + Similarly, if you must unload a set of resources explicitly + (because a plugin is being unloaded or the resources are not valid + any longer), you can force removal of your resources by calling + Q_CLEANUP_RESOURCE() with the same base name as above. +*/ diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 52ffae5f98..ed845745be 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -737,7 +737,7 @@ void qWinMessageHandler2(QtMsgType t, const QMessageLogContext &context, This is a typedef for a pointer to a function with the following signature: - \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 7 + \snippet code/src_corelib_global_qglobal.cpp 7 This typedef is deprecated, you should use QtMessageHandler instead. \sa QtMsgType, QtMessageHandler, qInstallMsgHandler(), qInstallMessageHandler() @@ -751,7 +751,7 @@ void qWinMessageHandler2(QtMsgType t, const QMessageLogContext &context, This is a typedef for a pointer to a function with the following signature: - \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 49 + \snippet code/src_corelib_global_qglobal.cpp 49 \sa QtMsgType, qInstallMessageHandler() */ @@ -785,7 +785,7 @@ void qWinMessageHandler2(QtMsgType t, const QMessageLogContext &context, Example: - \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 23 + \snippet code/src_corelib_global_qglobal.cpp 23 \sa QtMessageHandler, QtMsgType, qDebug(), qWarning(), qCritical(), qFatal(), {Debugging Techniques} diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp index 17eedb0bdd..e1f1db9ead 100644 --- a/src/corelib/io/qfiledevice.cpp +++ b/src/corelib/io/qfiledevice.cpp @@ -146,12 +146,12 @@ void QFileDevicePrivate::setError(QFileDevice::FileError err, int errNum) handling considerably. It is possible to force permission checking on NTFS by including the following code in your source: - \snippet doc/src/snippets/ntfsp.cpp 0 + \snippet ntfsp.cpp 0 Permission checking is then turned on and off by incrementing and decrementing \c qt_ntfs_permission_lookup by 1. - \snippet doc/src/snippets/ntfsp.cpp 1 + \snippet ntfsp.cpp 1 */ //************* QFileDevice diff --git a/src/corelib/io/qurlquery.cpp b/src/corelib/io/qurlquery.cpp index 2e2db11558..5625aebd3c 100644 --- a/src/corelib/io/qurlquery.cpp +++ b/src/corelib/io/qurlquery.cpp @@ -511,7 +511,7 @@ QString QUrlQuery::query(QUrl::ComponentFormattingOptions encoding) const If \a valueDelimiter is set to '(' and \a pairDelimiter is ')', the above query string would instead be represented like this: - \snippet doc/src/snippets/code/src_corelib_io_qurl.cpp 4 + \snippet code/src_corelib_io_qurl.cpp 4 \note Non-standard delimiters should be chosen from among what RFC 3986 calls "sub-delimiters". They are: diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 10dcff92c7..3172014363 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -838,7 +838,7 @@ void QHashData::checkSanity() operator==() and a qHash() implementation. Example: - \snippet doc/src/snippets/code/src_corelib_tools_qhash.cpp 13 + \snippet code/src_corelib_tools_qhash.cpp 13 In the example above, we've relied on Qt's global qHash(const QString &, uint) to give us a hash value for the employee's name, and diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index c25d326b9d..0b0aeb50c0 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -404,8 +404,8 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegExp &r For example: - \snippet doc/src/snippets/qstringlist/main.cpp 5 - \snippet doc/src/snippets/qstringlist/main.cpp 16 + \snippet qstringlist/main.cpp 5 + \snippet qstringlist/main.cpp 16 For regular expressions that contain capturing groups, occurrences of \b{\\1}, \b{\\2}, ..., in \a after are @@ -413,8 +413,8 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegExp &r For example: - \snippet doc/src/snippets/qstringlist/main.cpp 5 - \snippet doc/src/snippets/qstringlist/main.cpp 17 + \snippet qstringlist/main.cpp 5 + \snippet qstringlist/main.cpp 17 */ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegularExpression &re, const QString &after) { |