BaseQtVersion: Make sourcePath calculation available as static method

Change-Id: I7a4c4d4ad2cdf1c36d1bc3eb046725e29716bba3
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Tobias Hunger
2013-07-29 17:03:25 +02:00
parent 3aa37f2e07
commit 772c9f72e2
2 changed files with 25 additions and 19 deletions

View File

@@ -613,25 +613,7 @@ void BaseQtVersion::updateSourcePath() const
if (!m_sourcePath.isEmpty())
return;
updateVersionInfo();
const QString installData = qmakeProperty("QT_INSTALL_PREFIX");
QString sourcePath = installData;
QFile qmakeCache(installData + QLatin1String("/.qmake.cache"));
if (qmakeCache.exists()) {
qmakeCache.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream stream(&qmakeCache);
while (!stream.atEnd()) {
QString line = stream.readLine().trimmed();
if (line.startsWith(QLatin1String("QT_SOURCE_TREE"))) {
sourcePath = line.split(QLatin1Char('=')).at(1).trimmed();
if (sourcePath.startsWith(QLatin1String("$$quote("))) {
sourcePath.remove(0, 8);
sourcePath.chop(1);
}
break;
}
}
}
m_sourcePath = FileName::fromUserInput(sourcePath);
m_sourcePath = sourcePath(m_versionInfo);
}
FileName BaseQtVersion::sourcePath() const
@@ -1441,6 +1423,29 @@ FileName BaseQtVersion::mkspecFromVersionInfo(const QHash<QString, QString> &ver
return mkspecFullPath;
}
FileName BaseQtVersion::sourcePath(const QHash<QString, QString> &versionInfo)
{
const QString installData = qmakeProperty(versionInfo, "QT_INSTALL_PREFIX");
QString sourcePath = installData;
QFile qmakeCache(installData + QLatin1String("/.qmake.cache"));
if (qmakeCache.exists()) {
qmakeCache.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream stream(&qmakeCache);
while (!stream.atEnd()) {
QString line = stream.readLine().trimmed();
if (line.startsWith(QLatin1String("QT_SOURCE_TREE"))) {
sourcePath = line.split(QLatin1Char('=')).at(1).trimmed();
if (sourcePath.startsWith(QLatin1String("$$quote("))) {
sourcePath.remove(0, 8);
sourcePath.chop(1);
}
break;
}
}
}
return FileName::fromUserInput(sourcePath);
}
bool BaseQtVersion::isQmlDebuggingSupported(ProjectExplorer::Kit *k, QString *reason)
{
QTC_ASSERT(k, return false);

View File

@@ -185,6 +185,7 @@ public:
QHash<QString, QString> *versionInfo, QString *error = 0);
static Utils::FileName mkspecDirectoryFromVersionInfo(const QHash<QString, QString> &versionInfo);
static Utils::FileName mkspecFromVersionInfo(const QHash<QString, QString> &versionInfo);
static Utils::FileName sourcePath(const QHash<QString, QString> &versionInfo);
static bool isQmlDebuggingSupported(ProjectExplorer::Kit *k, QString *reason = 0);
bool isQmlDebuggingSupported(QString *reason = 0) const;