forked from qt-creator/qt-creator
Android: Use BuildSystem in AndroidExtraLibraryListModel
... instead of Target. The model is tied to an ApkBuildStep, i.e. already per-BuildConfiguration. Make the update depend on its BuildSystem parsing state, not any in the target. Change-Id: I72c00b9c40bfb7bee0375ae7b3f912f27bd18ca8 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -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);
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include <android/androidconstants.h>
|
||||
#include <android/androidmanager.h>
|
||||
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
@@ -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
|
||||
|
@@ -31,19 +31,16 @@
|
||||
#include <QAbstractItemModel>
|
||||
#include <QStringList>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user