diff --git a/src/plugins/android/androidbuildapkwidget.cpp b/src/plugins/android/androidbuildapkwidget.cpp index 9742d18222d..a7d90e5cade 100644 --- a/src/plugins/android/androidbuildapkwidget.cpp +++ b/src/plugins/android/androidbuildapkwidget.cpp @@ -272,7 +272,7 @@ QWidget *AndroidBuildApkWidget::createAdditionalLibrariesGroup() auto group = new QGroupBox(tr("Additional Libraries")); group->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - auto libsModel = new AndroidExtraLibraryListModel(m_step->target(), this); + auto libsModel = new AndroidExtraLibraryListModel(m_step->buildSystem(), this); connect(libsModel, &AndroidExtraLibraryListModel::enabledChanged, this, [this, group](const bool enabled) { group->setEnabled(enabled); diff --git a/src/plugins/android/androidextralibrarylistmodel.cpp b/src/plugins/android/androidextralibrarylistmodel.cpp index 50400a49c1e..1bbcbc17472 100644 --- a/src/plugins/android/androidextralibrarylistmodel.cpp +++ b/src/plugins/android/androidextralibrarylistmodel.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -40,19 +41,20 @@ using namespace ProjectExplorer; namespace Android { -AndroidExtraLibraryListModel::AndroidExtraLibraryListModel(ProjectExplorer::Target *target, +AndroidExtraLibraryListModel::AndroidExtraLibraryListModel(BuildSystem *buildSystem, QObject *parent) : QAbstractItemModel(parent), - m_target(target) + m_buildSystem(buildSystem) { updateModel(); - connect(target, &Target::parsingStarted, + connect(buildSystem, &BuildSystem::parsingStarted, this, &AndroidExtraLibraryListModel::updateModel); - connect(target, &Target::parsingFinished, + connect(buildSystem, &BuildSystem::parsingFinished, this, &AndroidExtraLibraryListModel::updateModel); - // Causes target()->activeBuildKey() result to change. - connect(target, &Target::activeRunConfigurationChanged, + // Causes target()->activeBuildKey() result and consequently the node data + // extracted below to change. + connect(buildSystem->target(), &Target::activeRunConfigurationChanged, this, &AndroidExtraLibraryListModel::updateModel); } @@ -86,8 +88,8 @@ QVariant AndroidExtraLibraryListModel::data(const QModelIndex &index, int role) void AndroidExtraLibraryListModel::updateModel() { - const QString buildKey = m_target->activeBuildKey(); - const ProjectNode *node = m_target->project()->findNodeForBuildKey(buildKey); + const QString buildKey = m_buildSystem->target()->activeBuildKey(); + const ProjectNode *node = m_buildSystem->target()->project()->findNodeForBuildKey(buildKey); QTC_ASSERT(node, return); if (node->parseInProgress()) { @@ -112,8 +114,8 @@ void AndroidExtraLibraryListModel::updateModel() void AndroidExtraLibraryListModel::addEntries(const QStringList &list) { - const QString buildKey = m_target->activeBuildKey(); - const ProjectNode *node = m_target->project()->findNodeForBuildKey(buildKey); + const QString buildKey = m_buildSystem->target()->activeBuildKey(); + const ProjectNode *node = m_buildSystem->target()->project()->findNodeForBuildKey(buildKey); QTC_ASSERT(node, return); beginInsertRows(QModelIndex(), m_entries.size(), m_entries.size() + list.size()); @@ -122,7 +124,7 @@ void AndroidExtraLibraryListModel::addEntries(const QStringList &list) for (const QString &path : list) m_entries += "$$PWD/" + dir.relativeFilePath(path); - node->setData(Constants::AndroidExtraLibs, m_entries); + m_buildSystem->setExtraData(buildKey, Constants::AndroidExtraLibs, m_entries); endInsertRows(); } @@ -152,10 +154,8 @@ void AndroidExtraLibraryListModel::removeEntries(QModelIndexList list) endRemoveRows(); } - const QString buildKey = m_target->activeBuildKey(); - const ProjectNode *node = m_target->project()->findNodeForBuildKey(buildKey); - QTC_ASSERT(node, return); - node->setData(Constants::AndroidExtraLibs, m_entries); + const QString buildKey = m_buildSystem->target()->activeBuildKey(); + m_buildSystem->setExtraData(buildKey, Constants::AndroidExtraLibs, m_entries); } } // Android diff --git a/src/plugins/android/androidextralibrarylistmodel.h b/src/plugins/android/androidextralibrarylistmodel.h index bbd21ce8153..0856b32ce7d 100644 --- a/src/plugins/android/androidextralibrarylistmodel.h +++ b/src/plugins/android/androidextralibrarylistmodel.h @@ -31,19 +31,16 @@ #include #include -namespace ProjectExplorer { -class RunConfiguration; -class Target; -} +namespace ProjectExplorer { class BuildSystem; } namespace Android { class ANDROID_EXPORT AndroidExtraLibraryListModel : public QAbstractItemModel { Q_OBJECT + public: - explicit AndroidExtraLibraryListModel(ProjectExplorer::Target *target, - QObject *parent = nullptr); + AndroidExtraLibraryListModel(ProjectExplorer::BuildSystem *buildSystem, QObject *parent); QModelIndex index(int row, int column, const QModelIndex &parent) const override; QModelIndex parent(const QModelIndex &child) const override; @@ -60,7 +57,7 @@ signals: private: void updateModel(); - ProjectExplorer::Target *m_target; + ProjectExplorer::BuildSystem *m_buildSystem; QStringList m_entries; };