summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfileselector.cpp
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2018-09-03 14:02:13 +0200
committerCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2018-10-15 10:55:18 +0000
commit1f6bfc220774e9407fe88916843b76ed103cff72 (patch)
tree8d6157d5b974e6045d75a716f8eb0db4daefa35f /src/corelib/io/qfileselector.cpp
parent02a214442781bf112c1cc85d2470c6fcec8ed207 (diff)
Doc: Move literal code block to a separate file
We need to override this snippet for the documentation we generate for Qt for Python, and it is easier to have it on a separate file. Task-number: PYSIDE-801 Task-number: PYSIDE-691 Change-Id: Ideb5b6af25024279f167137d3b65660bb9c96a7e Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/corelib/io/qfileselector.cpp')
-rw-r--r--src/corelib/io/qfileselector.cpp44
1 files changed, 6 insertions, 38 deletions
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index 0ba8b124f7..ce06c8e00b 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -81,27 +81,11 @@ QFileSelectorPrivate::QFileSelectorPrivate()
Consider the following example usage, where you want to use different settings files on
different locales. You might select code between locales like this:
- \code
- QString defaultsBasePath = "data/";
- QString defaultsPath = defaultsBasePath + "defaults.conf";
- QString localizedPath = defaultsBasePath
- + QString("%1/defaults.conf").arg(QLocale().name());
- if (QFile::exists(localizedPath))
- defaultsPath = localizedPath;
- QFile defaults(defaultsPath);
- \endcode
+ \snippet code/src_corelib_io_qfileselector.cpp 0
Similarly, if you want to pick a different data file based on target platform,
your code might look something like this:
- \code
- QString defaultsPath = "data/defaults.conf";
-#if defined(Q_OS_ANDROID)
- defaultsPath = "data/android/defaults.conf";
-#elif defined(Q_OS_IOS)
- defaultsPath = "data/ios/defaults.conf";
-#endif
- QFile defaults(defaultsPath);
- \endcode
+ \snippet code/src_corelib_io_qfileselector.cpp 1
QFileSelector provides a convenient alternative to writing such boilerplate code, and in the
latter case it allows you to start using an platform-specific configuration without a recompile.
@@ -109,27 +93,17 @@ QFileSelectorPrivate::QFileSelectorPrivate()
selecting a different file only on certain combinations of platform and locale. For example, to
select based on platform and/or locale, the code is as follows:
- \code
- QFileSelector selector;
- QFile defaultsFile(selector.select("data/defaults.conf"));
- \endcode
+ \snippet code/src_corelib_io_qfileselector.cpp 2
The files to be selected are placed in directories named with a \c'+' and a selector name. In the above
example you could have the platform configurations selected by placing them in the following locations:
- \code
- data/defaults.conf
- data/+android/defaults.conf
- data/+ios/+en_GB/defaults.conf
- \endcode
+ \snippet code/src_corelib_io_qfileselector.cpp 3
To find selected files, QFileSelector looks in the same directory as the base file. If there are
any directories of the form +<selector> with an active selector, QFileSelector will prefer a file
with the same file name from that directory over the base file. These directories can be nested to
check against multiple selectors, for example:
- \code
- images/background.png
- images/+android/+en_GB/background.png
- \endcode
+ \snippet code/src_corelib_io_qfileselector.cpp 4
With those files available, you would select a different file on the android platform,
but only if the locale was en_GB.
@@ -178,13 +152,7 @@ QFileSelectorPrivate::QFileSelectorPrivate()
credentials. The example is sorted so that the lowest matching file would be chosen if all
selectors were present:
- \code
- images/background.png
- images/+linux/background.png
- images/+windows/background.png
- images/+admin/background.png
- images/+admin/+linux/background.png
- \endcode
+ \snippet code/src_corelib_io_qfileselector.cpp 5
Because extra selectors are checked before platform the \c{+admin/background.png} will be chosen
on Windows when the admin selector is set, and \c{+windows/background.png} will be chosen on