diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2017-02-10 11:16:18 +0100 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2017-02-22 16:00:49 +0000 |
commit | f9eab73dad4f56934b12e9f5593bc7d84119217a (patch) | |
tree | 651582bfe9e40ac6e3cbbb730f5ff01a187a500e /src/plugins/qmakeandroidsupport | |
parent | 62726c3f7793e7e24b0c4b947db78f55e98ac312 (diff) | |
download | qt-creator-f9eab73dad4f56934b12e9f5593bc7d84119217a.tar.gz |
qmake: move over from QmakeProjectNodes to QmakeParserNodes
Change-Id: Iab87e0c248b0f651a1774336c3bddf83baa9d057
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/plugins/qmakeandroidsupport')
8 files changed, 78 insertions, 77 deletions
diff --git a/src/plugins/qmakeandroidsupport/androidextralibrarylistmodel.cpp b/src/plugins/qmakeandroidsupport/androidextralibrarylistmodel.cpp index a96f601a6e..96b5df6e39 100644 --- a/src/plugins/qmakeandroidsupport/androidextralibrarylistmodel.cpp +++ b/src/plugins/qmakeandroidsupport/androidextralibrarylistmodel.cpp @@ -86,20 +86,20 @@ QVariant AndroidExtraLibraryListModel::data(const QModelIndex &index, int role) void AndroidExtraLibraryListModel::activeRunConfigurationChanged() { - const QmakeProjectManager::QmakeProFileNode *node = activeNode(); - if (!node || node->parseInProgress()) { + QmakeProjectManager::QmakeProFile *pro = activeProFile(); + if (!pro || pro->parseInProgress()) { emit enabledChanged(false); return; } m_scope = QLatin1String("contains(ANDROID_TARGET_ARCH,") - + node->singleVariableValue(QmakeProjectManager::Variable::AndroidArch) + + pro->singleVariableValue(QmakeProjectManager::Variable::AndroidArch) + QLatin1Char(')'); bool enabled; beginResetModel(); - if (node->validParse() && node->projectType() == QmakeProjectManager::ProjectType::ApplicationTemplate) { - m_entries = node->variableValue(QmakeProjectManager::Variable::AndroidExtraLibs); + if (pro->validParse() && pro->projectType() == QmakeProjectManager::ProjectType::ApplicationTemplate) { + m_entries = pro->variableValue(QmakeProjectManager::Variable::AndroidExtraLibs); enabled = true; } else { // parsing error or not a application template @@ -111,50 +111,44 @@ void AndroidExtraLibraryListModel::activeRunConfigurationChanged() emit enabledChanged(enabled); } -QmakeProjectManager::QmakeProFileNode *AndroidExtraLibraryListModel::activeNode() const +QmakeProjectManager::QmakeProFile *AndroidExtraLibraryListModel::activeProFile() const { ProjectExplorer::RunConfiguration *rc = m_target->activeRunConfiguration(); QmakeAndroidRunConfiguration *qarc = qobject_cast<QmakeAndroidRunConfiguration *>(rc); if (!qarc) return 0; auto project = static_cast<QmakeProject *>(m_target->project()); - return project->rootProjectNode()->findProFileFor(qarc->proFilePath()); + return project->rootProFile()->findProFile(qarc->proFilePath()); } -void AndroidExtraLibraryListModel::proFileUpdated(QmakeProjectManager::QmakeProFileNode *node) +void AndroidExtraLibraryListModel::proFileUpdated(QmakeProjectManager::QmakeProFile *pro) { - if (node != activeNode()) + if (activeProFile() != pro) return; activeRunConfigurationChanged(); } bool AndroidExtraLibraryListModel::isEnabled() const { - QmakeProjectManager::QmakeProFileNode *node = activeNode(); - if (!node) - return false; - if (node->parseInProgress()) - return false; - if (node->projectType() != QmakeProjectManager::ProjectType::ApplicationTemplate) - return false; - return true; + QmakeProjectManager::QmakeProFile *pro = activeProFile(); + return pro && !pro->parseInProgress() && pro->projectType() == QmakeProjectManager::ProjectType::ApplicationTemplate; } void AndroidExtraLibraryListModel::addEntries(const QStringList &list) { - QmakeProjectManager::QmakeProFileNode *node = activeNode(); - if (!node || node->projectType() != QmakeProjectManager::ProjectType::ApplicationTemplate) + QmakeProjectManager::QmakeProFile *pro = activeProFile(); + if (!pro || pro->projectType() != QmakeProjectManager::ProjectType::ApplicationTemplate) return; beginInsertRows(QModelIndex(), m_entries.size(), m_entries.size() + list.size()); foreach (const QString &path, list) m_entries += QLatin1String("$$PWD/") - + node->filePath().toFileInfo().absoluteDir().relativeFilePath(path); + + pro->filePath().toFileInfo().absoluteDir().relativeFilePath(path); - node->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries, m_scope, - QmakeProjectManager::Internal::ProWriter::ReplaceValues - | QmakeProjectManager::Internal::ProWriter::MultiLine); + pro->setProVariable("ANDROID_EXTRA_LIBS", m_entries, m_scope, + QmakeProjectManager::Internal::ProWriter::ReplaceValues + | QmakeProjectManager::Internal::ProWriter::MultiLine); endInsertRows(); } @@ -166,8 +160,10 @@ bool greaterModelIndexByRow(const QModelIndex &a, const QModelIndex &b) void AndroidExtraLibraryListModel::removeEntries(QModelIndexList list) { - QmakeProjectManager::QmakeProFileNode *node = activeNode(); - if (list.isEmpty() || !node || node->projectType() != QmakeProjectManager::ProjectType::ApplicationTemplate) + QmakeProjectManager::QmakeProFile *pro = activeProFile(); + if (!pro) + return; + if (list.isEmpty() || !pro || pro->projectType() != QmakeProjectManager::ProjectType::ApplicationTemplate) return; std::sort(list.begin(), list.end(), greaterModelIndexByRow); @@ -186,5 +182,5 @@ void AndroidExtraLibraryListModel::removeEntries(QModelIndexList list) endRemoveRows(); } - node->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries, m_scope); + pro->setProVariable(QLatin1String("ANDROID_EXTRA_LIBS"), m_entries, m_scope); } diff --git a/src/plugins/qmakeandroidsupport/androidextralibrarylistmodel.h b/src/plugins/qmakeandroidsupport/androidextralibrarylistmodel.h index f9959d556a..e0b401d473 100644 --- a/src/plugins/qmakeandroidsupport/androidextralibrarylistmodel.h +++ b/src/plugins/qmakeandroidsupport/androidextralibrarylistmodel.h @@ -34,7 +34,7 @@ class RunConfiguration; class Target; } -namespace QmakeProjectManager { class QmakeProFileNode; } +namespace QmakeProjectManager { class QmakeProFile; } namespace QmakeAndroidSupport { @@ -61,9 +61,9 @@ signals: void enabledChanged(bool); private: - void proFileUpdated(QmakeProjectManager::QmakeProFileNode *node); + void proFileUpdated(QmakeProjectManager::QmakeProFile *pro); void activeRunConfigurationChanged(); - QmakeProjectManager::QmakeProFileNode *activeNode() const; + QmakeProjectManager::QmakeProFile *activeProFile() const; ProjectExplorer::Target *m_target; QStringList m_entries; diff --git a/src/plugins/qmakeandroidsupport/createandroidmanifestwizard.cpp b/src/plugins/qmakeandroidsupport/createandroidmanifestwizard.cpp index 2191422681..f1cf7cbdae 100644 --- a/src/plugins/qmakeandroidsupport/createandroidmanifestwizard.cpp +++ b/src/plugins/qmakeandroidsupport/createandroidmanifestwizard.cpp @@ -35,7 +35,6 @@ #include <projectexplorer/target.h> #include <qmakeprojectmanager/qmakeproject.h> -#include <qmakeprojectmanager/qmakenodes.h> #include <proparser/prowriter.h> @@ -55,7 +54,7 @@ using namespace QmakeAndroidSupport::Internal; using namespace Utils; using QmakeProjectManager::QmakeProject; -using QmakeProjectManager::QmakeProFileNode; +using QmakeProjectManager::QmakeProFile; // // NoApplicationProFilePage @@ -74,8 +73,10 @@ NoApplicationProFilePage::NoApplicationProFilePage(CreateAndroidManifestWizard * // // ChooseProFilePage // -ChooseProFilePage::ChooseProFilePage(CreateAndroidManifestWizard *wizard, const QList<QmakeProFileNode *> &nodes, const QmakeProFileNode *select) - : m_wizard(wizard) +ChooseProFilePage::ChooseProFilePage(CreateAndroidManifestWizard *wizard, + const QList<QmakeProFile *> &files, + const QmakeProFile *select) : + m_wizard(wizard) { QFormLayout *fl = new QFormLayout(this); QLabel *label = new QLabel(this); @@ -84,9 +85,9 @@ ChooseProFilePage::ChooseProFilePage(CreateAndroidManifestWizard *wizard, const fl->addRow(label); m_comboBox = new QComboBox(this); - foreach (QmakeProFileNode *node, nodes) { - m_comboBox->addItem(node->displayName(), QVariant::fromValue(static_cast<void *>(node))); // TODO something more? - if (node == select) + for (QmakeProFile *file : files) { + m_comboBox->addItem(file->displayName(), QVariant::fromValue(static_cast<void *>(file))); // TODO something more? + if (file == select) m_comboBox->setCurrentIndex(m_comboBox->count() - 1); } @@ -101,7 +102,7 @@ ChooseProFilePage::ChooseProFilePage(CreateAndroidManifestWizard *wizard, const void ChooseProFilePage::nodeSelected(int index) { Q_UNUSED(index) - m_wizard->setNode(static_cast<QmakeProFileNode *>(m_comboBox->itemData(m_comboBox->currentIndex()).value<void *>())); + m_wizard->setProFile(static_cast<QmakeProFile *>(m_comboBox->itemData(m_comboBox->currentIndex()).value<void *>())); } @@ -152,7 +153,7 @@ ChooseDirectoryPage::ChooseDirectoryPage(CreateAndroidManifestWizard *wizard) void ChooseDirectoryPage::checkPackageSourceDir() { - QString projectDir = m_wizard->node()->filePath().toFileInfo().absolutePath(); + QString projectDir = m_wizard->proFile()->filePath().toFileInfo().absolutePath(); QString newDir = m_androidPackageSourceDir->path(); bool isComplete = QFileInfo(projectDir) != QFileInfo(newDir); @@ -172,13 +173,13 @@ bool ChooseDirectoryPage::isComplete() const void ChooseDirectoryPage::initializePage() { - QString androidPackageDir = m_wizard->node()->singleVariableValue(QmakeProjectManager::Variable::AndroidPackageSourceDir); + QString androidPackageDir = m_wizard->proFile()->singleVariableValue(QmakeProjectManager::Variable::AndroidPackageSourceDir); if (androidPackageDir.isEmpty()) { m_label->setText(tr("Select the Android package source directory.\n\n" "The files in the Android package source directory are copied to the build directory's " "Android directory and the default files are overwritten.")); - m_androidPackageSourceDir->setPath(m_wizard->node()->filePath().toFileInfo().absolutePath().append(QLatin1String("/android"))); + m_androidPackageSourceDir->setPath(m_wizard->proFile()->filePath().toFileInfo().absolutePath().append(QLatin1String("/android"))); connect(m_androidPackageSourceDir, &PathChooser::rawPathChanged, this, &ChooseDirectoryPage::checkPackageSourceDir); } else { @@ -195,40 +196,40 @@ void ChooseDirectoryPage::initializePage() // CreateAndroidManifestWizard // CreateAndroidManifestWizard::CreateAndroidManifestWizard(ProjectExplorer::Target *target) - : m_target(target), m_node(0), m_copyState(Ask) + : m_target(target), m_proFile(0), m_copyState(Ask) { setWindowTitle(tr("Create Android Template Files Wizard")); QmakeProject *project = static_cast<QmakeProject *>(target->project()); - QList<QmakeProFileNode *> nodes = project->applicationProFiles(); + QList<QmakeProFile *> files = project->applicationProFiles(); QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target->kit()); m_copyGradle = version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 4, 0); - const QmakeProFileNode *currentRunNode = 0; + const QmakeProFile *currentRunNode = nullptr; ProjectExplorer::RunConfiguration *rc = target->activeRunConfiguration(); if (auto qrc = qobject_cast<QmakeAndroidRunConfiguration *>(rc)) - currentRunNode = project->rootProjectNode()->findProFileFor(qrc->proFilePath()); + currentRunNode = project->rootProFile()->findProFile(qrc->proFilePath()); - if (nodes.isEmpty()) { + if (files.isEmpty()) { // oh uhm can't create anything addPage(new NoApplicationProFilePage(this)); - } else if (nodes.size() == 1) { - setNode(nodes.first()); + } else if (files.size() == 1) { + setProFile(files.first()); addPage(new ChooseDirectoryPage(this)); } else { - addPage(new ChooseProFilePage(this, nodes, currentRunNode)); + addPage(new ChooseProFilePage(this, files, currentRunNode)); addPage(new ChooseDirectoryPage(this)); } } -QmakeProjectManager::QmakeProFileNode *CreateAndroidManifestWizard::node() const +QmakeProjectManager::QmakeProFile *CreateAndroidManifestWizard::proFile() const { - return m_node; + return m_proFile; } -void CreateAndroidManifestWizard::setNode(QmakeProjectManager::QmakeProFileNode *node) +void CreateAndroidManifestWizard::setProFile(QmakeProjectManager::QmakeProFile *node) { - m_node = node; + m_proFile = node; } void CreateAndroidManifestWizard::setDirectory(const QString &directory) @@ -334,19 +335,19 @@ void CreateAndroidManifestWizard::createAndroidTemplateFiles() AndroidManager::updateGradleProperties(m_target); } - m_node->addFiles(addedFiles); + m_proFile->addFiles(addedFiles); - if (m_node->singleVariableValue(QmakeProjectManager::Variable::AndroidPackageSourceDir).isEmpty()) { + if (m_proFile->singleVariableValue(QmakeProjectManager::Variable::AndroidPackageSourceDir).isEmpty()) { // and now time for some magic QString value = QLatin1String("$$PWD/") - + m_node->filePath().toFileInfo().absoluteDir().relativeFilePath(m_directory); + + m_proFile->filePath().toFileInfo().absoluteDir().relativeFilePath(m_directory); bool result = - m_node->setProVariable(QLatin1String("ANDROID_PACKAGE_SOURCE_DIR"), QStringList(value)); + m_proFile->setProVariable(QLatin1String("ANDROID_PACKAGE_SOURCE_DIR"), QStringList(value)); if (!result) { QMessageBox::warning(this, tr("Project File not Updated"), tr("Could not update the .pro file %1.") - .arg(m_node->filePath().toUserOutput())); + .arg(m_proFile->filePath().toUserOutput())); } } Core::EditorManager::openEditor(m_directory + QLatin1String("/AndroidManifest.xml")); diff --git a/src/plugins/qmakeandroidsupport/createandroidmanifestwizard.h b/src/plugins/qmakeandroidsupport/createandroidmanifestwizard.h index 96d23a1615..cdd49b247f 100644 --- a/src/plugins/qmakeandroidsupport/createandroidmanifestwizard.h +++ b/src/plugins/qmakeandroidsupport/createandroidmanifestwizard.h @@ -36,7 +36,7 @@ class QFormLayout; QT_END_NAMESPACE namespace ProjectExplorer { class Target; } -namespace QmakeProjectManager { class QmakeProFileNode; } +namespace QmakeProjectManager { class QmakeProFile; } namespace QmakeAndroidSupport { namespace Internal { @@ -56,7 +56,9 @@ class ChooseProFilePage : public QWizardPage { Q_OBJECT public: - ChooseProFilePage(CreateAndroidManifestWizard *wizard, const QList<QmakeProjectManager::QmakeProFileNode *> &nodes, const QmakeProjectManager::QmakeProFileNode *select); + ChooseProFilePage(CreateAndroidManifestWizard *wizard, + const QList<QmakeProjectManager::QmakeProFile *> &nodes, + const QmakeProjectManager::QmakeProFile *select); private: void nodeSelected(int index); private: @@ -90,8 +92,8 @@ class CreateAndroidManifestWizard : public Utils::Wizard public: CreateAndroidManifestWizard(ProjectExplorer::Target *target); - QmakeProjectManager::QmakeProFileNode *node() const; - void setNode(QmakeProjectManager::QmakeProFileNode *node); + QmakeProjectManager::QmakeProFile *proFile() const; + void setProFile(QmakeProjectManager::QmakeProFile *proFile); void accept(); bool copyGradle(); @@ -110,7 +112,7 @@ private: void createAndroidManifestFile(); void createAndroidTemplateFiles(); ProjectExplorer::Target *m_target; - QmakeProjectManager::QmakeProFileNode *m_node; + QmakeProjectManager::QmakeProFile *m_proFile; QString m_directory; CopyState m_copyState; bool m_copyGradle; diff --git a/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp b/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp index 49f1013018..ece47f031a 100644 --- a/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp +++ b/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp @@ -141,7 +141,8 @@ QString QmakeAndroidRunConfiguration::buildSystemTarget() const return qmakeProject()->mapProFilePathToTarget(m_proFilePath); } -void QmakeAndroidRunConfiguration::proFileUpdated(QmakeProjectManager::QmakeProFileNode *pro, bool success, bool parseInProgress) +void QmakeAndroidRunConfiguration::proFileUpdated(QmakeProjectManager::QmakeProFile *pro, + bool success, bool parseInProgress) { QmakeProject *project = qmakeProject(); if (m_proFilePath.isEmpty() && project->rootProjectNode()) diff --git a/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.h b/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.h index 4fbaf29590..f7ff72987c 100644 --- a/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.h +++ b/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.h @@ -30,9 +30,9 @@ #include <utils/fileutils.h> namespace QmakeProjectManager { -class QmakeProFileNode; +class QmakeProFile; class QmakeProject; -} +} // namespace QmakeProjectManager namespace QmakeAndroidSupport { namespace Internal { @@ -61,7 +61,7 @@ protected: QString defaultDisplayName(); private: - void proFileUpdated(QmakeProjectManager::QmakeProFileNode *pro, bool success, bool parseInProgress); + void proFileUpdated(QmakeProjectManager::QmakeProFile *pro, bool success, bool parseInProgress); QmakeProjectManager::QmakeProject *qmakeProject() const; void init(); diff --git a/src/plugins/qmakeandroidsupport/qmakeandroidrunfactories.cpp b/src/plugins/qmakeandroidsupport/qmakeandroidrunfactories.cpp index 6c4a609cfd..74d4f158e9 100644 --- a/src/plugins/qmakeandroidsupport/qmakeandroidrunfactories.cpp +++ b/src/plugins/qmakeandroidsupport/qmakeandroidrunfactories.cpp @@ -84,14 +84,14 @@ QList<Core::Id> QmakeAndroidRunConfigurationFactory::availableCreationIds(Target return QList<Core::Id>(); QmakeProject *project = static_cast<QmakeProject *>(parent->project()); - QList<QmakeProFileNode *> nodes = project->allProFiles({ ProjectType::ApplicationTemplate, - ProjectType::SharedLibraryTemplate }); + QList<QmakeProFile *> files = project->allProFiles({ ProjectType::ApplicationTemplate, + ProjectType::SharedLibraryTemplate }); if (mode == AutoCreate) - nodes = QmakeProject::nodesWithQtcRunnable(nodes); + files = QmakeProject::proFilesWithQtcRunnable(files); const Core::Id base = Core::Id(ANDROID_RC_ID_PREFIX); - return QmakeProject::idsForNodes(base, nodes); + return QmakeProject::idsForProFiles(base, files); } RunConfiguration *QmakeAndroidRunConfigurationFactory::doCreate(Target *parent, Core::Id id) diff --git a/src/plugins/qmakeandroidsupport/qmakeandroidsupport.cpp b/src/plugins/qmakeandroidsupport/qmakeandroidsupport.cpp index 7f961a655e..08cf8d5708 100644 --- a/src/plugins/qmakeandroidsupport/qmakeandroidsupport.cpp +++ b/src/plugins/qmakeandroidsupport/qmakeandroidsupport.cpp @@ -53,14 +53,15 @@ QStringList QmakeAndroidSupport::soLibSearchPath(const ProjectExplorer::Target * if (!project) return res; - foreach (QmakeProFileNode *node, project->allProFiles()) { - TargetInformation info = node->targetInformation(); + foreach (QmakeProFile *file, project->allProFiles()) { + TargetInformation info = file->targetInformation(); res << info.buildDir.toString(); - QString destDir = info.destDir.toString(); + Utils::FileName destDir = info.destDir; if (!destDir.isEmpty()) { - if (QFileInfo(destDir).isRelative()) - destDir = QDir::cleanPath(info.buildDir.toString() + '/' + destDir); - res << destDir; + if (destDir.toFileInfo().isRelative()) + destDir = Utils::FileName::fromString(QDir::cleanPath(info.buildDir.toString() + + '/' + destDir.toString())); + res << destDir.toString(); } } @@ -84,7 +85,7 @@ QStringList QmakeAndroidSupport::projectTargetApplications(const ProjectExplorer QmakeProject *qmakeProject = qobject_cast<QmakeProject *>(target->project()); if (!qmakeProject) return apps; - foreach (QmakeProFileNode *proFile, qmakeProject->applicationProFiles()) { + for (QmakeProFile *proFile : qmakeProject->applicationProFiles()) { if (proFile->projectType() == ProjectType::ApplicationTemplate) { if (proFile->targetInformation().target.startsWith(QLatin1String("lib")) && proFile->targetInformation().target.endsWith(QLatin1String(".so"))) |