Refactoring: findSystemQt can now be called for any environemnt

and returns the full path to qmake. This is step 1 towards the cmake
plugin not using its own code to find the dumper.
This commit is contained in:
dt
2009-04-23 16:05:51 +02:00
parent a8cf650e73
commit fe78b08864
2 changed files with 23 additions and 11 deletions

View File

@@ -230,9 +230,19 @@ void QtVersionManager::addNewVersionsFromInstaller()
void QtVersionManager::updateSystemVersion() void QtVersionManager::updateSystemVersion()
{ {
bool haveSystemVersion = false; bool haveSystemVersion = false;
QString systemQMakePath = findSystemQt(Environment::systemEnvironment());
QString systemQtPath;
if (systemQMakePath.isNull()) {
systemQtPath = tr("<not found>");
} else {
QDir dir(QFileInfo(systemQMakePath).absoluteDir());
dir.cdUp();
systemQtPath = dir.absolutePath();
}
foreach (QtVersion *version, m_versions) { foreach (QtVersion *version, m_versions) {
if (version->isSystemVersion()) { if (version->isSystemVersion()) {
version->setPath(findSystemQt()); version->setPath(systemQtPath);
version->setName(tr("Auto-detected Qt")); version->setName(tr("Auto-detected Qt"));
haveSystemVersion = true; haveSystemVersion = true;
} }
@@ -240,7 +250,7 @@ void QtVersionManager::updateSystemVersion()
if (haveSystemVersion) if (haveSystemVersion)
return; return;
QtVersion *version = new QtVersion(tr("Auto-detected Qt"), QtVersion *version = new QtVersion(tr("Auto-detected Qt"),
findSystemQt(), systemQtPath,
getUniqueId(), getUniqueId(),
true); true);
m_versions.prepend(version); m_versions.prepend(version);
@@ -278,23 +288,20 @@ QString QtVersionManager::qtVersionForQMake(const QString &qmakePath)
return QString(); return QString();
} }
QString QtVersionManager::findSystemQt() const QString QtVersionManager::findSystemQt(const Environment &env)
{ {
Environment env = Environment::systemEnvironment();
QStringList paths = env.path(); QStringList paths = env.path();
foreach (const QString &path, paths) { foreach (const QString &path, paths) {
foreach (const QString &possibleCommand, possibleQMakeCommands()) { foreach (const QString &possibleCommand, possibleQMakeCommands()) {
QFileInfo qmake(path + "/" + possibleCommand); QFileInfo qmake(path + "/" + possibleCommand);
if (qmake.exists()) { if (qmake.exists()) {
if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) { if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) {
QDir dir(qmake.absoluteDir()); return qmake.absoluteFilePath();
dir.cdUp();
return dir.absolutePath();
} }
} }
} }
} }
return tr("<not found>"); return QString::null;
} }
QtVersion *QtVersionManager::currentQtVersion() const QtVersion *QtVersionManager::currentQtVersion() const

View File

@@ -40,6 +40,7 @@ namespace ProjectExplorer {
namespace Internal { namespace Internal {
class QtOptionsPageWidget; class QtOptionsPageWidget;
class QtOptionsPage;
} }
class PROJECTEXPLORER_EXPORT QtVersion class PROJECTEXPLORER_EXPORT QtVersion
@@ -77,6 +78,7 @@ public:
void addToEnvironment(ProjectExplorer::Environment &env); void addToEnvironment(ProjectExplorer::Environment &env);
bool hasDebuggingHelper() const; bool hasDebuggingHelper() const;
QString dumperLibrary() const;
// Builds a debugging library // Builds a debugging library
// returns the output of the commands // returns the output of the commands
QString buildDebuggingHelperLibrary(); QString buildDebuggingHelperLibrary();
@@ -91,7 +93,6 @@ public:
}; };
QmakeBuildConfig defaultBuildConfig() const; QmakeBuildConfig defaultBuildConfig() const;
QString dumperLibrary() const;
private: private:
static int getUniqueId(); static int getUniqueId();
// Also used by QtOptionsPageWidget // Also used by QtOptionsPageWidget
@@ -128,7 +129,7 @@ class PROJECTEXPLORER_EXPORT QtVersionManager : public QObject
Q_OBJECT Q_OBJECT
// for getUniqueId(); // for getUniqueId();
friend class QtVersion; friend class QtVersion;
friend class QtOptionsPage; friend class Internal::QtOptionsPage;
public: public:
static QtVersionManager *instance(); static QtVersionManager *instance();
QtVersionManager(); QtVersionManager();
@@ -150,6 +151,10 @@ public:
static QString qtVersionForQMake(const QString &qmakePath); static QString qtVersionForQMake(const QString &qmakePath);
static QtVersion::QmakeBuildConfig scanMakefileForQmakeConfig(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig); static QtVersion::QmakeBuildConfig scanMakefileForQmakeConfig(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig);
static QString findQtVersionFromMakefile(const QString &directory); static QString findQtVersionFromMakefile(const QString &directory);
// returns the full path to the first qmake, qmake-qt4, qmake4 that has
// at least version 2.0.0 and thus is a qt4 qmake
static QString findSystemQt(const Environment &env);
signals: signals:
void defaultQtVersionChanged(); void defaultQtVersionChanged();
void qtVersionsChanged(); void qtVersionsChanged();
@@ -162,7 +167,7 @@ private:
void addNewVersionsFromInstaller(); void addNewVersionsFromInstaller();
void updateSystemVersion(); void updateSystemVersion();
void updateDocumentation(); void updateDocumentation();
QString findSystemQt() const;
static int indexOfVersionInList(const QtVersion * const version, const QList<QtVersion *> &list); static int indexOfVersionInList(const QtVersion * const version, const QList<QtVersion *> &list);
void updateUniqueIdToIndexMap(); void updateUniqueIdToIndexMap();