Add bool QStandardPaths::isTestModeEnabled()

Library code might need to know this, e.g. when calling an external
process, to give it the right configuration. (For instance when
ksycoca code calls kbuildsycoca to recreate the DB at the right place).

Change-Id: I343ddefff816586f9d391973c08ff1e1ad86bf0e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
David Faure 2012-08-01 17:28:39 +02:00 committed by Qt by Nokia
parent d1bb10d9b8
commit a23da5fd6b
8 changed files with 37 additions and 0 deletions

View File

@ -333,6 +333,15 @@ QString QStandardPaths::displayName(StandardLocation type)
On Windows, everything goes to a "qttest" directory under Application Data.
*/
/*!
\fn void QStandardPaths::isTestModeEnabled()
\internal
Returns true if test mode is enabled in QStandardPaths; otherwise returns false.
*/
QT_END_NAMESPACE
#endif // QT_NO_STANDARDPATHS

View File

@ -92,6 +92,7 @@ public:
static QString findExecutable(const QString &executableName, const QStringList &paths = QStringList());
static void enableTestMode(bool testMode);
static bool isTestModeEnabled();
private:
// prevent construction

View File

@ -55,6 +55,11 @@ void QStandardPaths::enableTestMode(bool testMode)
qsp_testMode = testMode;
}
bool QStandardPaths::isTestModeEnabled()
{
return qsp_testMode;
}
static QString testModeInsert() {
if (qsp_testMode)
return QStringLiteral("/.qttest");

View File

@ -116,6 +116,11 @@ void QStandardPaths::enableTestMode(bool testMode)
qsp_testMode = testMode;
}
bool QStandardPaths::isTestModeEnabled()
{
return qsp_testMode;
}
static void appendOrganizationAndApp(QString &path)
{
const QString org = QCoreApplication::organizationName();

View File

@ -97,6 +97,11 @@ void QStandardPaths::enableTestMode(bool testMode)
qsp_testMode = testMode;
}
bool QStandardPaths::isTestModeEnabled()
{
return qsp_testMode;
}
/*
Constructs a full unicode path from a FSRef.
*/

View File

@ -70,6 +70,11 @@ void QStandardPaths::enableTestMode(bool testMode)
qsp_testMode = testMode;
}
bool QStandardPaths::isTestModeEnabled()
{
return qsp_testMode;
}
QString QStandardPaths::writableLocation(StandardLocation type)
{
switch (type) {

View File

@ -92,6 +92,11 @@ void QStandardPaths::enableTestMode(bool testMode)
qsp_testMode = testMode;
}
bool QStandardPaths::isTestModeEnabled()
{
return qsp_testMode;
}
QString QStandardPaths::writableLocation(StandardLocation type)
{
QString result;

View File

@ -159,7 +159,9 @@ void tst_qstandardpaths::testCustomLocations()
void tst_qstandardpaths::enableTestMode()
{
QVERIFY(!QStandardPaths::isTestModeEnabled());
QStandardPaths::enableTestMode(true);
QVERIFY(QStandardPaths::isTestModeEnabled());
#ifdef Q_XDG_PLATFORM
setCustomLocations(); // for the global config dir