diff --git a/src/plugins/projectexplorer/debugginghelper.cpp b/src/plugins/projectexplorer/debugginghelper.cpp index 3b1c1bf4a4170ff6cba057da16fc3aa0d4d8f83c..311418fc6e74988b49c6022393b52e529c9dcac4 100644 --- a/src/plugins/projectexplorer/debugginghelper.cpp +++ b/src/plugins/projectexplorer/debugginghelper.cpp @@ -62,10 +62,10 @@ bool DebuggingHelperLibrary::hasDebuggingHelperLibrary(const QString &qmakePath) return !debuggingHelperLibrary(qmakePath).isNull(); } -QStringList DebuggingHelperLibrary::debuggingHelperLibraryDirectories(const QString &qtInstallData, const QString &qtpath) +QStringList DebuggingHelperLibrary::debuggingHelperLibraryDirectories(const QString &qtInstallData) { const QChar slash = QLatin1Char('/'); - const uint hash = qHash(qtpath); + const uint hash = qHash(qtInstallData); QStringList directories; directories << (qtInstallData + QLatin1String("/qtc-debugging-helper/")) @@ -76,12 +76,12 @@ QStringList DebuggingHelperLibrary::debuggingHelperLibraryDirectories(const QStr QStringList DebuggingHelperLibrary::debuggingHelperLibraryLocations(const QString &qmakePath) { - return debuggingHelperLibraryLocations(qtInstallDataDir(qmakePath), qtDir(qmakePath)); + return debuggingHelperLibraryLocationsByInstallData(qtInstallDataDir(qmakePath)); } QString DebuggingHelperLibrary::debuggingHelperLibrary(const QString &qmakePath) { - return debuggingHelperLibrary(qtInstallDataDir(qmakePath), qtDir(qmakePath)); + return debuggingHelperLibraryByInstallData(qtInstallDataDir(qmakePath)); } QString DebuggingHelperLibrary::qtInstallDataDir(const QString &qmakePath) @@ -113,17 +113,17 @@ static inline QString helperFilePath(const QString &directory) #endif } -QStringList DebuggingHelperLibrary::debuggingHelperLibraryLocations(const QString &qtInstallData, const QString &qtpath) +QStringList DebuggingHelperLibrary::debuggingHelperLibraryLocationsByInstallData(const QString &qtInstallData) { QStringList result; - foreach(const QString &directory, debuggingHelperLibraryDirectories(qtInstallData, qtpath)) + foreach(const QString &directory, debuggingHelperLibraryDirectories(qtInstallData)) result << QFileInfo(helperFilePath(directory)).filePath(); return result; } -QString DebuggingHelperLibrary::debuggingHelperLibrary(const QString &qtInstallData, const QString &qtpath) +QString DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(const QString &qtInstallData) { - foreach(const QString &directory, debuggingHelperLibraryDirectories(qtInstallData, qtpath)) { + foreach(const QString &directory, debuggingHelperLibraryDirectories(qtInstallData)) { const QFileInfo fi(helperFilePath(directory)); if (fi.exists()) return fi.filePath(); @@ -134,7 +134,7 @@ QString DebuggingHelperLibrary::debuggingHelperLibrary(const QString &qtInstallD QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &qmakePath, const QString &make, const Environment &env) { QString errorMessage; - const QString directory = copyDebuggingHelperLibrary(qtInstallDataDir(qmakePath), qtDir(qmakePath), &errorMessage); + const QString directory = copyDebuggingHelperLibrary(qtInstallDataDir(qmakePath), &errorMessage); if (directory.isEmpty()) return errorMessage; return buildDebuggingHelperLibrary(directory, make, qmakePath, QString::null, env); @@ -171,14 +171,13 @@ static bool copyDebuggingHelperFiles(const QStringList &files, } QString DebuggingHelperLibrary::copyDebuggingHelperLibrary(const QString &qtInstallData, - const QString &qtdir, QString *errorMessage) { // Locations to try: // $QTDIR/qtc-debugging-helper // $APPLICATION-DIR/qtc-debugging-helper/$hash // $USERDIR/qtc-debugging-helper/$hash - const QStringList directories = DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData, qtdir); + const QStringList directories = DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData); QStringList files; files << QLatin1String("gdbmacros.cpp") << QLatin1String("gdbmacros_p.h") << QLatin1String("gdbmacros.h") << QLatin1String("gdbmacros.pro") @@ -241,13 +240,18 @@ QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &direc } return output; } - +#include <QDebug> QString DebuggingHelperLibrary::qtVersionForQMake(const QString &qmakePath) { + QString binary = qmakePath.mid(qmakePath.lastIndexOf('/')+1); + qDebug() << qmakePath << binary; + if (!possibleQMakeCommands().contains(binary)) + return QString(); + QProcess qmake; qmake.start(qmakePath, QStringList(QLatin1String("--version"))); if (!qmake.waitForFinished()) - return false; + return QString::null; QString output = qmake.readAllStandardOutput(); QRegExp regexp(QLatin1String("(QMake version|QMake version:)[\\s]*([\\d.]*)"), Qt::CaseInsensitive); regexp.indexIn(output); diff --git a/src/plugins/projectexplorer/debugginghelper.h b/src/plugins/projectexplorer/debugginghelper.h index 63d1880b407ada91208812c972486b39109a7228..03b67037d0700dd2e7a1fced02c1f2730bb5cba5 100644 --- a/src/plugins/projectexplorer/debugginghelper.h +++ b/src/plugins/projectexplorer/debugginghelper.h @@ -51,20 +51,20 @@ public: static bool hasDebuggingHelperLibrary(const QString &qmakePath); static QString debuggingHelperLibrary(const QString &qmakePath); - static QString debuggingHelperLibrary(const QString &qtInstallData, const QString &qtpath); + static QString debuggingHelperLibraryByInstallData(const QString &qtInstallData); static QString buildDebuggingHelperLibrary(const QString &qmakePath, const QString &make, const Environment &env); static QString buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand, const QString &qmakeCommand, const QString &mkspec, const Environment &env); // Build the helpers and return the output log/errormessage. static QStringList debuggingHelperLibraryLocations(const QString &qmakePath); - static QStringList debuggingHelperLibraryLocations(const QString &qtInstallData, const QString &qtpath); + static QStringList debuggingHelperLibraryLocationsByInstallData(const QString &qtInstallData); // Copy the source files to a target location and return the chosen target location. - static QString copyDebuggingHelperLibrary(const QString &qtInstallData, const QString &qtdir, QString *errorMessage); + static QString copyDebuggingHelperLibrary(const QString &qtInstallData, QString *errorMessage); private: - static QStringList debuggingHelperLibraryDirectories(const QString &qtInstallData, const QString &qtpath); + static QStringList debuggingHelperLibraryDirectories(const QString &qtInstallData); static QString qtInstallDataDir(const QString &qmakePath); static QString qtDir(const QString &qmakePath); }; diff --git a/src/plugins/qt4projectmanager/projectloadwizard.cpp b/src/plugins/qt4projectmanager/projectloadwizard.cpp index 91e155e68db9a870070576cf3216e3cc8bf8ad5e..74125f4a6ab19c31f887cc5e038cb5c1907c3dc4 100644 --- a/src/plugins/qt4projectmanager/projectloadwizard.cpp +++ b/src/plugins/qt4projectmanager/projectloadwizard.cpp @@ -50,15 +50,15 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W { QtVersionManager * vm = QtVersionManager::instance(); QString directory = QFileInfo(project->file()->fileName()).absolutePath(); - QString importVersion = QtVersionManager::findQtVersionFromMakefile(directory); + QString importVersion = QtVersionManager::findQMakeBinaryFromMakefile(directory); if (!importVersion.isNull()) { // This also means we have a build in there // First get the qt version - m_importVersion = vm->qtVersionForDirectory(importVersion); + m_importVersion = vm->qtVersionForQMakeBinary(importVersion); // Okay does not yet exist, create if (!m_importVersion) { - m_importVersion = new QtVersion(QFileInfo(importVersion).baseName(), importVersion); + m_importVersion = new QtVersion(importVersion); m_temporaryVersion = true; } @@ -209,7 +209,7 @@ void ProjectLoadWizard::setupImportPage(QtVersion *version, QtVersion::QmakeBuil QVBoxLayout *importLayout = new QVBoxLayout(importPage); importLabel = new QLabel(importPage); - QString versionString = version->name() + " (" + QDir::toNativeSeparators(version->path()) + ")"; + QString versionString = version->name() + " (" + QDir::toNativeSeparators(version->qmakeCommand()) + ")"; QString buildConfigString = (buildConfig & QtVersion::BuildAll) ? QLatin1String("debug_and_release ") : QLatin1String(""); buildConfigString.append((buildConfig & QtVersion::DebugBuild) ? QLatin1String("debug") : QLatin1String("release")); importLabel->setTextFormat(Qt::RichText); @@ -231,8 +231,8 @@ void ProjectLoadWizard::setupImportPage(QtVersion *version, QtVersion::QmakeBuil import2Label = new QLabel(importPage); import2Label->setTextFormat(Qt::RichText); if (m_temporaryVersion) - import2Label->setText(tr("<b>Note:</b> Importing the settings will automatically add the Qt Version from:<br><b>%1</b> to the list of Qt versions.") - .arg(QDir::toNativeSeparators(m_importVersion->path()))); + import2Label->setText(tr("<b>Note:</b> Importing the settings will automatically add the Qt Version identified by <br><b>%1</b> to the list of Qt versions.") + .arg(QDir::toNativeSeparators(m_importVersion->qmakeCommand()))); importLayout->addWidget(import2Label); addPage(importPage); } diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp index 3731516d73d9fd18ba1861e81b077ddbe6d16b03..8ef04206e3ce45e084fe98dab5a767a595335df8 100644 --- a/src/plugins/qt4projectmanager/qmakestep.cpp +++ b/src/plugins/qt4projectmanager/qmakestep.cpp @@ -114,8 +114,8 @@ bool QMakeStep::init(const QString &name) // Check wheter we need to run qmake bool needToRunQMake = true; if (QDir(workingDirectory).exists(QLatin1String("Makefile"))) { - QString qtPath = QtVersionManager::findQtVersionFromMakefile(workingDirectory); - if (qtVersion->path() == qtPath) { + QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(workingDirectory); + if (qtVersion->qmakeCommand() == qmakePath) { needToRunQMake = !m_pro->compareBuildConfigurationToImportFrom(name, workingDirectory); } } diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index 7d5a8e4f8f878d074fa3693c03a7473af82679b6..3488a25f49f56cac33af4e37afd8d2160db9dfe9 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -552,7 +552,7 @@ void S60DeviceRunControl::start() m_targetName = rc->targetName(); m_baseFileName = rc->basePackageFilePath(); m_workingDirectory = QFileInfo(m_baseFileName).absolutePath(); - m_qtDir = project->qtVersion(project->activeBuildConfiguration())->path(); + m_qtDir = project->qtVersion(project->activeBuildConfiguration())->versionInfo().value("QT_INSTALL_DATA"); m_useCustomSignature = (rc->signingMode() == S60DeviceRunConfiguration::SignCustom); m_customSignaturePath = rc->customSignaturePath(); m_customKeyPath = rc->customKeyPath(); diff --git a/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp b/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp index c13886923dc1b0164d8ddadc16cbd11dca35b6b9..bd14470ee4d5c68fcbfeaa2d1c96f16a20c1fad5 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp @@ -124,7 +124,7 @@ void S60Manager::updateQtVersions() } if (deviceVersion) { deviceVersion->setName(QString("%1 (Qt %2)").arg(device.id, deviceVersion->qtVersionString())); - deviceVersion->setPath(device.qt); + deviceVersion->setQMakeCommand(device.qt+"/bin/qmake.exe"); handledVersions.append(deviceVersion); } else { deviceVersion = new QtVersion(QString("%1 (Qt %2)").arg(device.id), device.qt, @@ -171,8 +171,9 @@ S60Devices::Device S60Manager::deviceForQtVersion(const Qt4ProjectManager::QtVer deviceId = deviceIdFromDetectionSource(version->autodetectionSource()); if (deviceId.isEmpty()) { // it's not an s60 autodetected version // have a look if we find the device root anyhow - if (QFile::exists(QString::fromLatin1("%1/epoc32").arg(version->path()))) { - device.epocRoot = version->path(); + QString qtPath = version->versionInfo().value("QT_INSTALL_DATA"); + if (QFile::exists(QString::fromLatin1("%1/epoc32").arg(qtPath))) { + device.epocRoot = qtPath; device.toolsRoot = device.epocRoot; device.qt = device.epocRoot; device.isDefault = false; diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 653804dd0d1c139ead4692d5ab322b22b7abc853..62180399af8d8b32e7af573c64fbeabffb75e5e2 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -831,7 +831,7 @@ QString Qt4Project::qtDir(const QString &buildConfiguration) const { QtVersion *version = qtVersion(buildConfiguration); if (version) - return version->path(); + return version->versionInfo().value("QT_INSTALL_DATA"); return QString::null; } @@ -1151,9 +1151,9 @@ bool Qt4Project::compareBuildConfigurationToImportFrom(const QString &buildConfi { QMakeStep *qs = qmakeStep(); if (QDir(workingDirectory).exists(QLatin1String("Makefile")) && qs) { - QString qtPath = QtVersionManager::findQtVersionFromMakefile(workingDirectory); + QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(workingDirectory); QtVersion *version = qtVersion(buildConfiguration); - if (version->path() == qtPath) { + if (version->qmakeCommand() == qmakePath) { // same qtversion QPair<QtVersion::QmakeBuildConfig, QStringList> result = QtVersionManager::scanMakeFile(workingDirectory, version->defaultBuildConfig()); diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp index 6f35b8901461bf0558970db48d1ee2b95a1bccbc..0d9c79159a99bdd880ecc87942bdcb0782475da4 100644 --- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp @@ -257,12 +257,12 @@ void Qt4ProjectConfigWidget::updateImportLabel() // we only show if we actually have a qmake and makestep if (m_pro->qmakeStep() && m_pro->makeStep()) { - QString qtPath = QtVersionManager::findQtVersionFromMakefile(m_pro->buildDirectory(m_buildConfiguration)); + QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(m_pro->buildDirectory(m_buildConfiguration)); QtVersion *version = m_pro->qtVersion(m_buildConfiguration); // check that there's a makefile - if (!qtPath.isEmpty()) { - // and that the makefile path is different from the current version - if (qtPath != (version ? version->path() : QString())) { + if (!qmakePath.isEmpty()) { + // and that the qmake path is different from the current version + if (qmakePath != (version ? version->qmakeCommand() : QString())) { // import enable visible = true; } else { @@ -297,12 +297,12 @@ void Qt4ProjectConfigWidget::importLabelClicked() return; QString directory = m_pro->buildDirectory(m_buildConfiguration); if (!directory.isEmpty()) { - QString qtPath = QtVersionManager::findQtVersionFromMakefile(directory); - if (!qtPath.isEmpty()) { + QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(directory); + if (!qmakePath.isEmpty()) { QtVersionManager *vm = QtVersionManager::instance(); - QtVersion *version = vm->qtVersionForDirectory(qtPath); + QtVersion *version = vm->qtVersionForQMakeBinary(qmakePath); if (!version) { - version = new QtVersion(QFileInfo(qtPath).baseName(), qtPath); + version = new QtVersion(qmakePath); vm->addVersion(version); } diff --git a/src/plugins/qt4projectmanager/qtoptionspage.cpp b/src/plugins/qt4projectmanager/qtoptionspage.cpp index 47bc6668469a5a3de12135d2b78ad089613bb772..dea944b087b310f1b2e859b912e49d57575b70f7 100644 --- a/src/plugins/qt4projectmanager/qtoptionspage.cpp +++ b/src/plugins/qt4projectmanager/qtoptionspage.cpp @@ -4,6 +4,7 @@ #include "qt4projectmanagerconstants.h" #include "qtversionmanager.h" +#include <projectexplorer/debugginghelper.h> #include <coreplugin/coreconstants.h> #include <coreplugin/icore.h> #include <coreplugin/progressmanager/progressmanager.h> @@ -102,7 +103,7 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver , m_debuggingHelperOkIcon(m_debuggingHelperOkPixmap) , m_debuggingHelperErrorIcon(m_debuggingHelperErrorPixmap) , m_specifyNameString(tr("<specify a name>")) - , m_specifyPathString(tr("<specify a path>")) + , m_specifyPathString(tr("<specify a qmake location>")) , m_ui(new Internal::Ui::QtVersionManager()) , m_defaultVersion(versions.indexOf(defaultVersion)) { @@ -111,10 +112,10 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver m_versions.push_back(QSharedPointerQtVersion(new QtVersion(*version))); m_ui->setupUi(this); - m_ui->qtPath->setExpectedKind(Core::Utils::PathChooser::Directory); - m_ui->qtPath->setPromptDialogTitle(tr("Select QTDIR")); + m_ui->qmakePath->setExpectedKind(Core::Utils::PathChooser::File); + m_ui->qmakePath->setPromptDialogTitle(tr("Select QMake Executable")); m_ui->mingwPath->setExpectedKind(Core::Utils::PathChooser::Directory); - m_ui->qtPath->setPromptDialogTitle(tr("Select the Qt Directory")); + m_ui->mingwPath->setPromptDialogTitle(tr("Select the MinGW Directory")); m_ui->mwcPath->setExpectedKind(Core::Utils::PathChooser::Directory); m_ui->mwcPath->setPromptDialogTitle(tr("Select \"x86build\" Directory from Carbide Install")); @@ -136,7 +137,7 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver const QtVersion * const version = m_versions.at(i).data(); QTreeWidgetItem *item = new QTreeWidgetItem(version->isAutodetected()? autoItem : manualItem); item->setText(0, version->name()); - item->setText(1, QDir::toNativeSeparators(version->path())); + item->setText(1, QDir::toNativeSeparators(version->qmakeCommand())); item->setData(0, Qt::UserRole, version->uniqueId()); if (version->isValid()) { @@ -155,8 +156,8 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver this, SLOT(updateCurrentQtName())); - connect(m_ui->qtPath, SIGNAL(changed(QString)), - this, SLOT(updateCurrentQtPath())); + connect(m_ui->qmakePath, SIGNAL(changed(QString)), + this, SLOT(updateCurrentQMakeLocation())); connect(m_ui->mingwPath, SIGNAL(changed(QString)), this, SLOT(updateCurrentMingwDirectory())); #ifdef QTCREATOR_WITH_S60 @@ -169,7 +170,7 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver connect(m_ui->delButton, SIGNAL(clicked()), this, SLOT(removeQtDir())); - connect(m_ui->qtPath, SIGNAL(browsingFinished()), + connect(m_ui->qmakePath, SIGNAL(browsingFinished()), this, SLOT(onQtBrowsed())); connect(m_ui->mingwPath, SIGNAL(browsingFinished()), this, SLOT(onMingwBrowsed())); @@ -284,14 +285,14 @@ void QtOptionsPageWidget::addQtDir() QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->qtdirList->topLevelItem(1)); item->setText(0, newVersion->name()); - item->setText(1, QDir::toNativeSeparators(newVersion->path())); + item->setText(1, QDir::toNativeSeparators(newVersion->qmakeCommand())); item->setData(0, Qt::UserRole, newVersion->uniqueId()); item->setData(2, Qt::DecorationRole, QIcon()); m_ui->qtdirList->setCurrentItem(item); m_ui->nameEdit->setText(newVersion->name()); - m_ui->qtPath->setPath(newVersion->path()); + m_ui->qmakePath->setPath(newVersion->qmakeCommand()); m_ui->defaultCombo->addItem(newVersion->name()); m_ui->nameEdit->setFocus(); m_ui->nameEdit->selectAll(); @@ -355,7 +356,7 @@ void QtOptionsPageWidget::updateState() const bool isAutodetected = enabled && version->isAutodetected(); m_ui->delButton->setEnabled(enabled && !isAutodetected); m_ui->nameEdit->setEnabled(enabled && !isAutodetected); - m_ui->qtPath->setEnabled(enabled && !isAutodetected); + m_ui->qmakePath->setEnabled(enabled && !isAutodetected); m_ui->mingwPath->setEnabled(enabled); const bool hasLog = enabled && !m_ui->qtdirList->currentItem()->data(2, Qt::UserRole).toString().isEmpty(); @@ -433,10 +434,10 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item) makeMingwVisible(false); makeMWCVisible(false); if (!m_versions.at(index)->isInstalled()) - m_ui->errorLabel->setText(tr("The Qt Version %1 is not installed. Run make install") - .arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); + m_ui->errorLabel->setText(tr("The Qt Version identified by %1 is not installed. Run make install") + .arg(QDir::toNativeSeparators(m_versions.at(index)->qmakeCommand()))); else - m_ui->errorLabel->setText(tr("%1 is not a valid Qt directory").arg(QDir::toNativeSeparators(m_versions.at(index)->path()))); + m_ui->errorLabel->setText(tr("%1 does not specify a valid Qt installation").arg(QDir::toNativeSeparators(m_versions.at(index)->qmakeCommand()))); } else { //ProjectExplorer::ToolChain::GCC makeMSVCVisible(false); makeMingwVisible(false); @@ -487,10 +488,10 @@ void QtOptionsPageWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem int itemIndex = indexForTreeItem(item); if (itemIndex >= 0) { m_ui->nameEdit->setText(item->text(0)); - m_ui->qtPath->setPath(item->text(1)); + m_ui->qmakePath->setPath(item->text(1)); } else { m_ui->nameEdit->clear(); - m_ui->qtPath->setPath(QString()); // clear() + m_ui->qmakePath->setPath(QString()); // clear() } showEnvironmentPage(item); updateState(); @@ -498,15 +499,15 @@ void QtOptionsPageWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem void QtOptionsPageWidget::onQtBrowsed() { - const QString dir = m_ui->qtPath->path(); + const QString dir = m_ui->qmakePath->path(); if (dir.isEmpty()) return; - updateCurrentQtPath(); + updateCurrentQMakeLocation(); if (m_ui->nameEdit->text().isEmpty() || m_ui->nameEdit->text() == m_specifyNameString) { - QStringList dirSegments = dir.split(QDir::separator(), QString::SkipEmptyParts); - if (!dirSegments.isEmpty()) - m_ui->nameEdit->setText(dirSegments.last()); + QString name = ProjectExplorer::DebuggingHelperLibrary::qtVersionForQMake(QDir::cleanPath(dir)); + if (!name.isEmpty()) + m_ui->nameEdit->setText(name); updateCurrentQtName(); } updateState(); @@ -587,7 +588,7 @@ void QtOptionsPageWidget::fixQtVersionName(int index) } } -void QtOptionsPageWidget::updateCurrentQtPath() +void QtOptionsPageWidget::updateCurrentQMakeLocation() { QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); Q_ASSERT(currentItem); @@ -595,10 +596,10 @@ void QtOptionsPageWidget::updateCurrentQtPath() if (currentItemIndex < 0) return; QtVersion *version = m_versions.at(currentItemIndex).data(); - if (version->path() == m_ui->qtPath->path()) + if (version->qmakeCommand() == m_ui->qmakePath->path()) return; - version->setPath(m_ui->qtPath->path()); - currentItem->setText(1, QDir::toNativeSeparators(version->path())); + version->setQMakeCommand(m_ui->qmakePath->path()); + currentItem->setText(1, QDir::toNativeSeparators(version->qmakeCommand())); showEnvironmentPage(currentItem); if (version->isValid()) { diff --git a/src/plugins/qt4projectmanager/qtoptionspage.h b/src/plugins/qt4projectmanager/qtoptionspage.h index acddd5c8fb283f9a6c4c121cdb30b2ce2ff089e7..4ddeb98d53779813e0653881258daa47f35c964a 100644 --- a/src/plugins/qt4projectmanager/qtoptionspage.h +++ b/src/plugins/qt4projectmanager/qtoptionspage.h @@ -113,7 +113,7 @@ private slots: void onMingwBrowsed(); void defaultChanged(int index); void updateCurrentQtName(); - void updateCurrentQtPath(); + void updateCurrentQMakeLocation(); void updateCurrentMingwDirectory(); #ifdef QTCREATOR_WITH_S60 void updateCurrentMwcDirectory(); diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index 7ff67797661faf7d63149535f81eebb8bb59a8f7..153059097793d292b42937ebdca5da1eb143f55d 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -102,8 +102,15 @@ QtVersionManager::QtVersionManager() if (isAutodetected) autodetectionSource = QLatin1String(PATH_AUTODETECTION_SOURCE); } + + QString qmakePath = s->value("QMakePath").toString(); + if (qmakePath.isEmpty()) { + QString path = s->value("Path").toString(); + if (!path.isEmpty()) + qmakePath = + "/bin/qmake.exe"; + } QtVersion *version = new QtVersion(s->value("Name").toString(), - s->value("Path").toString(), + qmakePath, id, isAutodetected, autodetectionSource); @@ -215,7 +222,9 @@ void QtVersionManager::writeVersionsIntoSettings() const QtVersion *version = m_versions.at(i); s->setArrayIndex(i); s->setValue("Name", version->name()); - s->setValue("Path", version->path()); + // for downwards compat + s->setValue("Path", version->versionInfo().value("QT_INSTALL_DATA")); + s->setValue("QMakePath", version->qmakeCommand()); s->setValue("Id", version->uniqueId()); s->setValue("MingwDirectory", version->mingwDirectory()); s->setValue("msvcVersion", version->msvcVersion()); @@ -249,8 +258,8 @@ QtVersion *QtVersionManager::version(int id) const void QtVersionManager::addNewVersionsFromInstaller() { // Add new versions which may have been installed by the WB installer in the form: - // NewQtVersions="qt 4.3.2=c:\\qt\\qt432;qt embedded=c:\\qtembedded;" - // or NewQtVersions="qt 4.3.2=c:\\qt\\qt432=c:\\qtcreator\\mingw\\=prependToPath; + // NewQtVersions="qt 4.3.2=c:\\qt\\qt432\bin\qmake.exe;qt embedded=c:\\qtembedded;" + // or NewQtVersions="qt 4.3.2=c:\\qt\\qt432bin\qmake.exe=c:\\qtcreator\\mingw\\=prependToPath; // Duplicate entries are not added, the first new version is set as default. QSettings *settings = Core::ICore::instance()->settings(); @@ -276,7 +285,7 @@ void QtVersionManager::addNewVersionsFromInstaller() bool versionWasAlreadyInList = false; foreach(const QtVersion * const it, m_versions) { - if (QDir(version->path()).canonicalPath() == QDir(it->path()).canonicalPath()) { + if (QDir(version->qmakeCommand()).canonicalPath() == QDir(it->qmakeCommand()).canonicalPath()) { versionWasAlreadyInList = true; break; } @@ -304,19 +313,13 @@ void QtVersionManager::updateSystemVersion() { bool haveSystemVersion = false; QString systemQMakePath = DebuggingHelperLibrary::findSystemQt(ProjectExplorer::Environment::systemEnvironment()); - QString systemQtPath; - if (systemQMakePath.isNull()) { - systemQtPath = tr("<not found>"); - } else { - QDir dir(QFileInfo(systemQMakePath).absoluteDir()); - dir.cdUp(); - systemQtPath = dir.absolutePath(); - } + if (systemQMakePath.isNull()) + systemQMakePath = tr("<not found>"); foreach (QtVersion *version, m_versions) { if (version->isAutodetected() && version->autodetectionSource() == PATH_AUTODETECTION_SOURCE) { - version->setPath(systemQtPath); + version->setQMakeCommand(systemQMakePath); version->setName(tr("Qt in PATH")); haveSystemVersion = true; } @@ -324,7 +327,7 @@ void QtVersionManager::updateSystemVersion() if (haveSystemVersion) return; QtVersion *version = new QtVersion(tr("Qt in PATH"), - systemQtPath, + systemQMakePath, getUniqueId(), true, PATH_AUTODETECTION_SOURCE); @@ -347,7 +350,7 @@ void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions, int newD bool versionPathsChanged = m_versions.size() != newVersions.size(); if (!versionPathsChanged) { for (int i = 0; i < m_versions.size(); ++i) { - if (m_versions.at(i)->path() != newVersions.at(i)->path()) { + if (m_versions.at(i)->qmakeCommand() != newVersions.at(i)->qmakeCommand()) { versionPathsChanged = true; break; } @@ -382,12 +385,14 @@ void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions, int newD /// QtVersion /// -QtVersion::QtVersion(const QString &name, const QString &path, int id, +QtVersion::QtVersion(const QString &name, const QString &qmakeCommand, int id, bool isAutodetected, const QString &autodetectionSource) : m_name(name), m_isAutodetected(isAutodetected), m_autodetectionSource(autodetectionSource), m_hasDebuggingHelper(false), + m_mkspecUpToDate(false), + m_versionInfoUpToDate(false), m_notInstalled(false), m_defaultConfigIsDebug(true), m_defaultConfigIsDebugAndRelease(true), @@ -399,20 +404,45 @@ QtVersion::QtVersion(const QString &name, const QString &path, int id, m_id = getUniqueId(); else m_id = id; - setPath(path); + setQMakeCommand(qmakeCommand); } -QtVersion::QtVersion(const QString &name, const QString &path, +QtVersion::QtVersion(const QString &name, const QString &qmakeCommand, bool isAutodetected, const QString &autodetectionSource) : m_name(name), m_isAutodetected(isAutodetected), m_autodetectionSource(autodetectionSource), m_hasDebuggingHelper(false), m_mkspecUpToDate(false), - m_versionInfoUpToDate(false) + m_versionInfoUpToDate(false), + m_notInstalled(false), + m_defaultConfigIsDebug(true), + m_defaultConfigIsDebugAndRelease(true), + m_hasExamples(false), + m_hasDemos(false), + m_hasDocumentation(false) +{ + m_id = getUniqueId(); + setQMakeCommand(qmakeCommand); +} + + +QtVersion::QtVersion(const QString &qmakeCommand, bool isAutodetected, const QString &autodetectionSource) + : m_isAutodetected(isAutodetected), + m_autodetectionSource(autodetectionSource), + m_hasDebuggingHelper(false), + m_mkspecUpToDate(false), + m_versionInfoUpToDate(false), + m_notInstalled(false), + m_defaultConfigIsDebug(true), + m_defaultConfigIsDebugAndRelease(true), + m_hasExamples(false), + m_hasDemos(false), + m_hasDocumentation(false) { m_id = getUniqueId(); - setPath(path); + setQMakeCommand(qmakeCommand); + m_name = qtVersionString(); } QtVersion::~QtVersion() @@ -425,9 +455,9 @@ QString QtVersion::name() const return m_name; } -QString QtVersion::path() const +QString QtVersion::qmakeCommand() const { - return m_path; + return m_qmakeCommand; } QString QtVersion::sourcePath() const @@ -449,7 +479,6 @@ QString QtVersion::mkspecPath() const QString QtVersion::qtVersionString() const { - qmakeCommand(); return m_qtVersionString; } @@ -471,26 +500,35 @@ void QtVersion::setName(const QString &name) m_name = name; } -void QtVersion::setPath(const QString &path) +void QtVersion::setQMakeCommand(const QString& qmakeCommand) { - m_path = QDir::cleanPath(path); + m_qmakeCommand = qmakeCommand; #ifdef Q_OS_WIN - m_path = m_path.toLower(); + m_qmakeCommand = m_qmakeCommand.toLower(); #endif - updateSourcePath(); - m_versionInfoUpToDate = false; + m_designerCommand = m_linguistCommand = m_uicCommand = QString::null; m_mkspecUpToDate = false; - m_designerCommand = m_linguistCommand = m_qmakeCommand = m_uicCommand = QString::null; - // TODO do i need to optimize this? - m_hasDebuggingHelper = !debuggingHelperLibrary().isEmpty(); m_qmakeCXX = QString::null; m_qmakeCXXUpToDate = false; + // TODO do i need to optimize this? + m_versionInfoUpToDate = false; + m_hasDebuggingHelper = !debuggingHelperLibrary().isEmpty(); + + QFileInfo qmake(qmakeCommand); + if (qmake.exists() && qmake.isExecutable()) { + m_qtVersionString = DebuggingHelperLibrary::qtVersionForQMake(qmake.absoluteFilePath()); + } else { + m_qtVersionString = QString::null; + } + updateSourcePath(); } void QtVersion::updateSourcePath() { - m_sourcePath = m_path; - QFile qmakeCache(m_path + QLatin1String("/.qmake.cache")); + updateVersionInfo(); + const QString installData = m_versionInfo["QT_INSTALL_DATA"]; + m_sourcePath = installData; + QFile qmakeCache(installData + QLatin1String("/.qmake.cache")); if (qmakeCache.exists()) { qmakeCache.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream stream(&qmakeCache); @@ -513,7 +551,7 @@ void QtVersion::updateSourcePath() // That is returns the directory // To find out wheter we already have a qtversion for that directory call // QtVersion *QtVersionManager::qtVersionForDirectory(const QString directory); -QString QtVersionManager::findQtVersionFromMakefile(const QString &directory) +QString QtVersionManager::findQMakeBinaryFromMakefile(const QString &directory) { bool debugAdding = false; QFile makefile(directory + "/Makefile" ); @@ -526,14 +564,11 @@ QString QtVersionManager::findQtVersionFromMakefile(const QString &directory) if (debugAdding) qDebug()<<"#~~ QMAKE is:"<<r1.cap(1).trimmed(); QFileInfo qmake(r1.cap(1).trimmed()); - QFileInfo binDir(qmake.absolutePath()); - QString qtDir = binDir.absolutePath(); + QString qmakePath = qmake.filePath(); #ifdef Q_OS_WIN - qtDir = qtDir.toLower(); + qmakePath = qmakePath.toLower(); #endif - if (debugAdding) - qDebug() << "#~~ QtDir:"<<qtDir; - return qtDir; + return qmakePath; } } makefile.close(); @@ -541,10 +576,10 @@ QString QtVersionManager::findQtVersionFromMakefile(const QString &directory) return QString::null; } -QtVersion *QtVersionManager::qtVersionForDirectory(const QString &directory) +QtVersion *QtVersionManager::qtVersionForQMakeBinary(const QString &qmakePath) { foreach(QtVersion *v, versions()) { - if (v->path() == directory) { + if (v->qmakeCommand() == qmakePath) { return v; break; } @@ -768,8 +803,10 @@ void QtVersion::updateVersionInfo() const m_notInstalled = false; m_hasExamples = false; m_hasDocumentation = false; + QFileInfo qmake(qmakeCommand()); - if (qmake.exists()) { + if (ProjectExplorer::DebuggingHelperLibrary::possibleQMakeCommands().contains(qmake.fileName()) + && qmake.exists()) { static const char * const variables[] = { "QT_VERSION", "QT_INSTALL_DATA", @@ -831,9 +868,7 @@ void QtVersion::updateVersionInfo() const } // Parse qconfigpri - QString baseDir = m_versionInfo.contains("QT_INSTALL_DATA") ? - m_versionInfo.value("QT_INSTALL_DATA") : - m_path; + QString baseDir = m_versionInfo.value("QT_INSTALL_DATA"); QFile qconfigpri(baseDir + QLatin1String("/mkspecs/qconfig.pri")); if (qconfigpri.exists()) { qconfigpri.open(QIODevice::ReadOnly | QIODevice::Text); @@ -874,7 +909,7 @@ void QtVersion::updateMkSpec() const // no .qmake.cache so look at the default mkspec QString mkspecPath = versionInfo().value("QMAKE_MKSPECS"); if (mkspecPath.isEmpty()) - mkspecPath = path() + "/mkspecs/default"; + mkspecPath = versionInfo().value("QT_INSTALL_DATA") + "/mkspecs/default"; else mkspecPath = mkspecPath + "/default"; // qDebug() << "default mkspec is located at" << mkspecPath; @@ -930,36 +965,13 @@ void QtVersion::updateMkSpec() const int index = mkspec.lastIndexOf('/'); if (index == -1) index = mkspec.lastIndexOf('\\'); - QString mkspecDir = QDir(m_path + "/mkspecs/").canonicalPath(); + QString mkspecDir = QDir(versionInfo().value("QT_INSTALL_DATA") + "/mkspecs/").canonicalPath(); if (index >= 0 && QDir(mkspec.left(index)).canonicalPath() == mkspecDir) mkspec = mkspec.mid(index+1).trimmed(); m_mkspec = mkspec; m_mkspecUpToDate = true; -// qDebug()<<"mkspec for "<<m_path<<" is "<<mkspec; -} - -QString QtVersion::qmakeCommand() const -{ - // We can't use versionInfo QT_INSTALL_BINS here - // because that functions calls us to find out the values for versionInfo - if (!m_qmakeCommand.isNull()) - return m_qmakeCommand; - - QDir qtDir = path() + QLatin1String("/bin/"); - foreach (const QString &possibleCommand, DebuggingHelperLibrary::possibleQMakeCommands()) { - QString s = qtDir.absoluteFilePath(possibleCommand); - QFileInfo qmake(s); - if (qmake.exists() && qmake.isExecutable()) { - QString qtVersion = DebuggingHelperLibrary::qtVersionForQMake(qmake.absoluteFilePath()); - if (!qtVersion.isNull()) { - m_qtVersionString = qtVersion; - m_qmakeCommand = qmake.absoluteFilePath(); - return qmake.absoluteFilePath(); - } - } - } - return QString::null; +// qDebug()<<"mkspec for "<<versionInfo().value("QT_INSTALL_DATA")<<" is "<<mkspec; } void QtVersion::updateQMakeCXX() const @@ -1158,7 +1170,7 @@ void QtVersion::setMsvcVersion(const QString &version) void QtVersion::addToEnvironment(ProjectExplorer::Environment &env) const { - env.set("QTDIR", m_path); + env.set("QTDIR", versionInfo().value("QT_INSTALL_DATA")); QString qtdirbin = versionInfo().value("QT_INSTALL_BINS"); env.prependOrSetPath(qtdirbin); } @@ -1175,7 +1187,7 @@ int QtVersion::getUniqueId() bool QtVersion::isValid() const { - return (!(m_id == -1 || m_path == QString::null || m_name == QString::null || mkspec() == QString::null) && !m_notInstalled); + return (!(m_id == -1 || m_qmakeCommand == QString::null || m_name == QString::null || mkspec() == QString::null) && !m_notInstalled); } QtVersion::QmakeBuildConfig QtVersion::defaultBuildConfig() const @@ -1198,16 +1210,16 @@ QString QtVersion::debuggingHelperLibrary() const { QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); if (qtInstallData.isEmpty()) - qtInstallData = path(); - return DebuggingHelperLibrary::debuggingHelperLibrary(qtInstallData, path()); + return QString::null; + return DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData); } QStringList QtVersion::debuggingHelperLibraryLocations() const { QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); if (qtInstallData.isEmpty()) - qtInstallData = path(); - return DebuggingHelperLibrary::debuggingHelperLibraryLocations(qtInstallData, path()); + QString::null; + return DebuggingHelperLibrary::debuggingHelperLibraryLocations(qtInstallData); } bool QtVersion::hasDocumentation() const @@ -1271,7 +1283,7 @@ QString QtVersion::buildDebuggingHelperLibrary() { QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); if (qtInstallData.isEmpty()) - qtInstallData = path(); + return QString::null; ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment(); addToEnvironment(env); @@ -1279,7 +1291,7 @@ QString QtVersion::buildDebuggingHelperLibrary() ProjectExplorer::ToolChain *tc = createToolChain(defaultToolchainType()); tc->addToEnvironment(env); QString output; - QString directory = DebuggingHelperLibrary::copyDebuggingHelperLibrary(qtInstallData, path(), &output); + QString directory = DebuggingHelperLibrary::copyDebuggingHelperLibrary(qtInstallData, &output); if (!directory.isEmpty()) output += DebuggingHelperLibrary::buildDebuggingHelperLibrary(directory, tc->makeCommand(), qmakeCommand(), mkspec(), env); m_hasDebuggingHelper = !debuggingHelperLibrary().isEmpty(); diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index 0dcc1fcb611aac1bd3fb710f4cf06c1cffd358af..d657fb14a90a8ec6c0c6c012822ac99bdf4a216d 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -50,11 +50,14 @@ class QtVersion public: QtVersion(const QString &name, const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); + + QtVersion(const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); + QtVersion(const QString &name, const QString &path, int id, bool isAutodetected = false, const QString &autodetectionSource = QString()); QtVersion() :m_name(QString::null), m_id(-1) - { setPath(QString::null); } + { setQMakeCommand(QString::null); } ~QtVersion(); bool isValid() const; //TOOD check that the dir exists and the name is non empty @@ -63,7 +66,6 @@ public: QString autodetectionSource() const { return m_autodetectionSource; } QString name() const; - QString path() const; QString sourcePath() const; QString mkspecPath() const; QString qmakeCommand() const; @@ -77,7 +79,7 @@ public: ProjectExplorer::ToolChain *createToolChain(ProjectExplorer::ToolChain::ToolChainType type) const; void setName(const QString &name); - void setPath(const QString &path); + void setQMakeCommand(const QString &path); QString qtVersionString() const; // Returns the PREFIX, BINPREFIX, DOCPREFIX and similar information @@ -132,7 +134,6 @@ private: QString qmakeCXX() const; QString findQtBinary(const QStringList &possibleName) const; QString m_name; - QString m_path; QString m_sourcePath; QString m_mingwDirectory; QString m_msvcVersion; @@ -190,14 +191,14 @@ public: QtVersion *version(int id) const; QtVersion *defaultVersion() const; - QtVersion *qtVersionForDirectory(const QString &directory); + QtVersion *qtVersionForQMakeBinary(const QString &qmakePath); // Used by the projectloadwizard void addVersion(QtVersion *version); void removeVersion(QtVersion *version); // Static Methods static QPair<QtVersion::QmakeBuildConfig, QStringList> scanMakeFile(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig); - static QString findQtVersionFromMakefile(const QString &directory); + static QString findQMakeBinaryFromMakefile(const QString &directory); signals: void defaultQtVersionChanged(); void qtVersionsChanged(); diff --git a/src/plugins/qt4projectmanager/qtversionmanager.ui b/src/plugins/qt4projectmanager/qtversionmanager.ui index bc716ab3cd8386dd18352fa58181a7cfe6e08697..ed7aedf3b8eea614a13e53c611b226d6ccbf4e78 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.ui +++ b/src/plugins/qt4projectmanager/qtversionmanager.ui @@ -146,7 +146,7 @@ p, li { white-space: pre-wrap; } </column> <column> <property name="text"> - <string>Path</string> + <string>QMake Location</string> </property> </column> <column> @@ -169,12 +169,12 @@ p, li { white-space: pre-wrap; } <item row="2" column="0"> <widget class="QLabel" name="pathLabel"> <property name="text"> - <string>Path:</string> + <string>Path to QMake:</string> </property> </widget> </item> <item row="2" column="1"> - <widget class="Core::Utils::PathChooser" name="qtPath"/> + <widget class="Core::Utils::PathChooser" name="qmakePath" native="true"/> </item> <item row="3" column="0"> <widget class="QLabel" name="mingwLabel"> @@ -184,7 +184,7 @@ p, li { white-space: pre-wrap; } </widget> </item> <item row="3" column="1"> - <widget class="Core::Utils::PathChooser" name="mingwPath"/> + <widget class="Core::Utils::PathChooser" name="mingwPath" native="true"/> </item> <item row="4" column="0"> <widget class="QLabel" name="msvcLabel"> @@ -215,21 +215,9 @@ p, li { white-space: pre-wrap; } </widget> </item> <item row="5" column="1"> - <widget class="Core::Utils::PathChooser" name="mwcPath"/> + <widget class="Core::Utils::PathChooser" name="mwcPath" native="true"/> </item> </layout> - <zorder>qtdirList</zorder> - <zorder>versionNameLabel</zorder> - <zorder>nameEdit</zorder> - <zorder>pathLabel</zorder> - <zorder>qtPath</zorder> - <zorder>mingwLabel</zorder> - <zorder>mingwPath</zorder> - <zorder>msvcLabel</zorder> - <zorder>debuggingHelperLabel</zorder> - <zorder>errorLabel</zorder> - <zorder>mwcLabel</zorder> - <zorder>mwcPath</zorder> </widget> </item> <item> @@ -268,7 +256,7 @@ p, li { white-space: pre-wrap; } <tabstop>addButton</tabstop> <tabstop>delButton</tabstop> <tabstop>nameEdit</tabstop> - <tabstop>qtPath</tabstop> + <tabstop>qmakePath</tabstop> <tabstop>mingwPath</tabstop> <tabstop>msvcComboBox</tabstop> <tabstop>showLogButton</tabstop>