diff options
author | David Faure <faure@kde.org> | 2012-08-08 17:56:22 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-09 13:48:16 +0200 |
commit | 977441f61cc42b7f29e48980577105323fbd3b47 (patch) | |
tree | cba6cd58b3bbda03de0266fe3f903dbaa0be5ac2 /src/corelib/io/qstandardpaths_unix.cpp | |
parent | a23da5fd6bca918366cfe744270e590905e97412 (diff) |
Remove code duplication in QStandardPaths implementations
Using the new getter to access the "test mode" setting.
Change-Id: Id26a350cd3fab4bf2e5f58ba67bc7323f99c9cc3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'src/corelib/io/qstandardpaths_unix.cpp')
-rw-r--r-- | src/corelib/io/qstandardpaths_unix.cpp | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index f44ccd1c93..3939f1e968 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -63,18 +63,6 @@ static void appendOrganizationAndApp(QString &path) path += QLatin1Char('/') + appName; } -static bool qsp_testMode = false; - -void QStandardPaths::enableTestMode(bool testMode) -{ - qsp_testMode = testMode; -} - -bool QStandardPaths::isTestModeEnabled() -{ - return qsp_testMode; -} - QString QStandardPaths::writableLocation(StandardLocation type) { switch (type) { @@ -87,7 +75,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) { // http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html QString xdgCacheHome = QFile::decodeName(qgetenv("XDG_CACHE_HOME")); - if (qsp_testMode) + if (isTestModeEnabled()) xdgCacheHome = QDir::homePath() + QLatin1String("/.qttest/cache"); if (xdgCacheHome.isEmpty()) xdgCacheHome = QDir::homePath() + QLatin1String("/.cache"); @@ -99,7 +87,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) case GenericDataLocation: { QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME")); - if (qsp_testMode) + if (isTestModeEnabled()) xdgDataHome = QDir::homePath() + QLatin1String("/.qttest/share"); if (xdgDataHome.isEmpty()) xdgDataHome = QDir::homePath() + QLatin1String("/.local/share"); @@ -111,7 +99,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) { // http://standards.freedesktop.org/basedir-spec/latest/ QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME")); - if (qsp_testMode) + if (isTestModeEnabled()) xdgConfigHome = QDir::homePath() + QLatin1String("/.qttest/config"); if (xdgConfigHome.isEmpty()) xdgConfigHome = QDir::homePath() + QLatin1String("/.config"); @@ -158,7 +146,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) if (xdgConfigHome.isEmpty()) xdgConfigHome = QDir::homePath() + QLatin1String("/.config"); QFile file(xdgConfigHome + QLatin1String("/user-dirs.dirs")); - if (!qsp_testMode && file.open(QIODevice::ReadOnly)) { + if (!isTestModeEnabled() && file.open(QIODevice::ReadOnly)) { QHash<QString, QString> lines; QTextStream stream(&file); // Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop" |