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"));
|
auto group = new QGroupBox(tr("Additional Libraries"));
|
||||||
group->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
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,
|
connect(libsModel, &AndroidExtraLibraryListModel::enabledChanged, this,
|
||||||
[this, group](const bool enabled) {
|
[this, group](const bool enabled) {
|
||||||
group->setEnabled(enabled);
|
group->setEnabled(enabled);
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include <android/androidconstants.h>
|
#include <android/androidconstants.h>
|
||||||
#include <android/androidmanager.h>
|
#include <android/androidmanager.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/buildsystem.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectnodes.h>
|
#include <projectexplorer/projectnodes.h>
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
@@ -40,19 +41,20 @@ using namespace ProjectExplorer;
|
|||||||
|
|
||||||
namespace Android {
|
namespace Android {
|
||||||
|
|
||||||
AndroidExtraLibraryListModel::AndroidExtraLibraryListModel(ProjectExplorer::Target *target,
|
AndroidExtraLibraryListModel::AndroidExtraLibraryListModel(BuildSystem *buildSystem,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: QAbstractItemModel(parent),
|
: QAbstractItemModel(parent),
|
||||||
m_target(target)
|
m_buildSystem(buildSystem)
|
||||||
{
|
{
|
||||||
updateModel();
|
updateModel();
|
||||||
|
|
||||||
connect(target, &Target::parsingStarted,
|
connect(buildSystem, &BuildSystem::parsingStarted,
|
||||||
this, &AndroidExtraLibraryListModel::updateModel);
|
this, &AndroidExtraLibraryListModel::updateModel);
|
||||||
connect(target, &Target::parsingFinished,
|
connect(buildSystem, &BuildSystem::parsingFinished,
|
||||||
this, &AndroidExtraLibraryListModel::updateModel);
|
this, &AndroidExtraLibraryListModel::updateModel);
|
||||||
// Causes target()->activeBuildKey() result to change.
|
// Causes target()->activeBuildKey() result and consequently the node data
|
||||||
connect(target, &Target::activeRunConfigurationChanged,
|
// extracted below to change.
|
||||||
|
connect(buildSystem->target(), &Target::activeRunConfigurationChanged,
|
||||||
this, &AndroidExtraLibraryListModel::updateModel);
|
this, &AndroidExtraLibraryListModel::updateModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +88,8 @@ QVariant AndroidExtraLibraryListModel::data(const QModelIndex &index, int role)
|
|||||||
|
|
||||||
void AndroidExtraLibraryListModel::updateModel()
|
void AndroidExtraLibraryListModel::updateModel()
|
||||||
{
|
{
|
||||||
const QString buildKey = m_target->activeBuildKey();
|
const QString buildKey = m_buildSystem->target()->activeBuildKey();
|
||||||
const ProjectNode *node = m_target->project()->findNodeForBuildKey(buildKey);
|
const ProjectNode *node = m_buildSystem->target()->project()->findNodeForBuildKey(buildKey);
|
||||||
QTC_ASSERT(node, return);
|
QTC_ASSERT(node, return);
|
||||||
|
|
||||||
if (node->parseInProgress()) {
|
if (node->parseInProgress()) {
|
||||||
@@ -112,8 +114,8 @@ void AndroidExtraLibraryListModel::updateModel()
|
|||||||
|
|
||||||
void AndroidExtraLibraryListModel::addEntries(const QStringList &list)
|
void AndroidExtraLibraryListModel::addEntries(const QStringList &list)
|
||||||
{
|
{
|
||||||
const QString buildKey = m_target->activeBuildKey();
|
const QString buildKey = m_buildSystem->target()->activeBuildKey();
|
||||||
const ProjectNode *node = m_target->project()->findNodeForBuildKey(buildKey);
|
const ProjectNode *node = m_buildSystem->target()->project()->findNodeForBuildKey(buildKey);
|
||||||
QTC_ASSERT(node, return);
|
QTC_ASSERT(node, return);
|
||||||
|
|
||||||
beginInsertRows(QModelIndex(), m_entries.size(), m_entries.size() + list.size());
|
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)
|
for (const QString &path : list)
|
||||||
m_entries += "$$PWD/" + dir.relativeFilePath(path);
|
m_entries += "$$PWD/" + dir.relativeFilePath(path);
|
||||||
|
|
||||||
node->setData(Constants::AndroidExtraLibs, m_entries);
|
m_buildSystem->setExtraData(buildKey, Constants::AndroidExtraLibs, m_entries);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,10 +154,8 @@ void AndroidExtraLibraryListModel::removeEntries(QModelIndexList list)
|
|||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString buildKey = m_target->activeBuildKey();
|
const QString buildKey = m_buildSystem->target()->activeBuildKey();
|
||||||
const ProjectNode *node = m_target->project()->findNodeForBuildKey(buildKey);
|
m_buildSystem->setExtraData(buildKey, Constants::AndroidExtraLibs, m_entries);
|
||||||
QTC_ASSERT(node, return);
|
|
||||||
node->setData(Constants::AndroidExtraLibs, m_entries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Android
|
} // Android
|
||||||
|
@@ -31,19 +31,16 @@
|
|||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer { class BuildSystem; }
|
||||||
class RunConfiguration;
|
|
||||||
class Target;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Android {
|
namespace Android {
|
||||||
|
|
||||||
class ANDROID_EXPORT AndroidExtraLibraryListModel : public QAbstractItemModel
|
class ANDROID_EXPORT AndroidExtraLibraryListModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AndroidExtraLibraryListModel(ProjectExplorer::Target *target,
|
AndroidExtraLibraryListModel(ProjectExplorer::BuildSystem *buildSystem, QObject *parent);
|
||||||
QObject *parent = nullptr);
|
|
||||||
|
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
|
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
|
||||||
QModelIndex parent(const QModelIndex &child) const override;
|
QModelIndex parent(const QModelIndex &child) const override;
|
||||||
@@ -60,7 +57,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
void updateModel();
|
void updateModel();
|
||||||
|
|
||||||
ProjectExplorer::Target *m_target;
|
ProjectExplorer::BuildSystem *m_buildSystem;
|
||||||
QStringList m_entries;
|
QStringList m_entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user