forked from qt-creator/qt-creator
ProjectExplorer: Remove ProjectConfiguration base from Target
Targets are different from {Run,Build,Deployment}Configurations,
both regarding the level in the ProjectExplorer hierarchy, and
also by the set of supported operations (e.g. aspects).
Change-Id: Ia8490e2280a9ecc518395c5e48ce2fd5d6d58fd2
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -456,6 +456,10 @@ CMakeBuildStepConfigWidget::CMakeBuildStepConfigWidget(CMakeBuildStep *buildStep
|
||||
if (pc && pc->isActive())
|
||||
updateDetails();
|
||||
});
|
||||
connect(m_buildStep->project(), &Project::activeTargetChanged, this, [this](Target *target) {
|
||||
if (target && target->isActive())
|
||||
updateDetails();
|
||||
});
|
||||
}
|
||||
|
||||
void CMakeBuildStepConfigWidget::toolArgumentsEdited()
|
||||
|
||||
@@ -129,6 +129,10 @@ public:
|
||||
if (pc && pc->isActive())
|
||||
updateDetails();
|
||||
});
|
||||
connect(pro, &Project::activeTargetChanged, this, [this](Target *target) {
|
||||
if (target && target->isActive())
|
||||
updateDetails();
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -255,6 +255,10 @@ IosDsymBuildStepConfigWidget::IosDsymBuildStepConfigWidget(IosDsymBuildStep *bui
|
||||
if (pc && pc->isActive())
|
||||
updateDetails();
|
||||
});
|
||||
connect(pro, &Project::activeTargetChanged, this, [this](Target *target) {
|
||||
if (target && target->isActive())
|
||||
updateDetails();
|
||||
});
|
||||
}
|
||||
|
||||
IosDsymBuildStepConfigWidget::~IosDsymBuildStepConfigWidget()
|
||||
|
||||
@@ -150,7 +150,6 @@ private:
|
||||
Kit(const Kit &other);
|
||||
void operator=(const Kit &other);
|
||||
|
||||
void kitDisplayNameChanged();
|
||||
void kitUpdated();
|
||||
|
||||
QVariantMap toMap() const;
|
||||
|
||||
@@ -434,6 +434,10 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
|
||||
updateDetails();
|
||||
}
|
||||
});
|
||||
connect(pro, &Project::activeTargetChanged, this, [this](Target *target) {
|
||||
if (target && target->isActive())
|
||||
updateDetails();
|
||||
});
|
||||
|
||||
Core::VariableChooser::addSupportForChildWidgets(this, m_makeStep->macroExpander());
|
||||
}
|
||||
|
||||
@@ -97,6 +97,27 @@ static bool projectLesserThan(Project *p1, Project *p2)
|
||||
return p1 < p2;
|
||||
}
|
||||
|
||||
static QString displayNameFor(QObject *object)
|
||||
{
|
||||
if (auto t = qobject_cast<Target *>(object))
|
||||
return t->displayName();
|
||||
if (auto pc = qobject_cast<ProjectConfiguration *>(object))
|
||||
return pc->displayName();
|
||||
QTC_CHECK(false);
|
||||
return {};
|
||||
}
|
||||
|
||||
static QString toolTipFor(QObject *object)
|
||||
{
|
||||
if (auto t = qobject_cast<Target *>(object))
|
||||
return t->toolTip();
|
||||
if (auto pc = qobject_cast<ProjectConfiguration *>(object))
|
||||
return pc->toolTip();
|
||||
QTC_CHECK(false);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
////////
|
||||
// TargetSelectorDelegate
|
||||
////////
|
||||
@@ -407,22 +428,27 @@ GenericListWidget::GenericListWidget(QWidget *parent)
|
||||
this, &GenericListWidget::rowChanged);
|
||||
}
|
||||
|
||||
void GenericListWidget::setProjectConfigurations(const QList<ProjectConfiguration *> &list, ProjectConfiguration *active)
|
||||
void GenericListWidget::setProjectConfigurations(const QList<QObject *> &list, QObject *active)
|
||||
{
|
||||
m_ignoreIndexChange = true;
|
||||
clear();
|
||||
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
disconnect(p, &ProjectConfiguration::displayNameChanged,
|
||||
auto obj = objectAt(i);
|
||||
if (auto t = qobject_cast<Target *>(obj)) {
|
||||
disconnect(t, &Target::kitChanged,
|
||||
this, &GenericListWidget::displayNameChanged);
|
||||
} else if (auto pc = qobject_cast<ProjectConfiguration *>(obj)) {
|
||||
disconnect(pc, &ProjectConfiguration::displayNameChanged,
|
||||
this, &GenericListWidget::displayNameChanged);
|
||||
}
|
||||
}
|
||||
|
||||
QFontMetrics fn(font());
|
||||
int width = 0;
|
||||
foreach (ProjectConfiguration *pc, list) {
|
||||
for (QObject *pc : list) {
|
||||
addProjectConfiguration(pc);
|
||||
width = qMax(width, fn.horizontalAdvance(pc->displayName()) + padding());
|
||||
width = qMax(width, fn.horizontalAdvance(displayNameFor(pc)) + padding());
|
||||
}
|
||||
setOptimalWidth(width);
|
||||
setActiveProjectConfiguration(active);
|
||||
@@ -430,57 +456,77 @@ void GenericListWidget::setProjectConfigurations(const QList<ProjectConfiguratio
|
||||
m_ignoreIndexChange = false;
|
||||
}
|
||||
|
||||
void GenericListWidget::setActiveProjectConfiguration(ProjectConfiguration *active)
|
||||
QObject *GenericListWidget::objectAt(int row) const
|
||||
{
|
||||
return item(row)->data(Qt::UserRole).value<QObject *>();
|
||||
}
|
||||
|
||||
void GenericListWidget::setActiveProjectConfiguration(QObject *active)
|
||||
{
|
||||
QListWidgetItem *item = itemForProjectConfiguration(active);
|
||||
setCurrentItem(item);
|
||||
}
|
||||
|
||||
void GenericListWidget::addProjectConfiguration(ProjectConfiguration *pc)
|
||||
void GenericListWidget::addProjectConfiguration(QObject *obj)
|
||||
{
|
||||
const QString displayName = displayNameFor(obj);
|
||||
const QString toolTip = toolTipFor(obj);
|
||||
|
||||
m_ignoreIndexChange = true;
|
||||
auto lwi = new QListWidgetItem();
|
||||
lwi->setText(pc->displayName());
|
||||
lwi->setData(Qt::ToolTipRole, pc->toolTip());
|
||||
lwi->setData(Qt::UserRole + 1, pc->toolTip());
|
||||
lwi->setData(Qt::UserRole, QVariant::fromValue(pc));
|
||||
lwi->setText(displayName);
|
||||
lwi->setData(Qt::ToolTipRole, toolTip);
|
||||
lwi->setData(Qt::UserRole + 1, toolTip);
|
||||
lwi->setData(Qt::UserRole, QVariant::fromValue(obj));
|
||||
|
||||
// Figure out pos
|
||||
int pos = count();
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
if (caseFriendlyCompare(pc->displayName(), p->displayName()) < 0) {
|
||||
QObject *p = objectAt(i);
|
||||
if (caseFriendlyCompare(displayName, displayNameFor(p)) < 0) {
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
insertItem(pos, lwi);
|
||||
|
||||
if (auto t = qobject_cast<Target *>(obj)) {
|
||||
connect(t, &Target::kitChanged, this,
|
||||
&GenericListWidget::displayNameChanged);
|
||||
connect(t, &Target::kitChanged, this,
|
||||
&GenericListWidget::toolTipChanged);
|
||||
} else if (auto pc = qobject_cast<ProjectConfiguration *>(obj)) {
|
||||
connect(pc, &ProjectConfiguration::displayNameChanged,
|
||||
this, &GenericListWidget::displayNameChanged);
|
||||
connect(pc, &ProjectConfiguration::toolTipChanged, this, &GenericListWidget::toolTipChanged);
|
||||
connect(pc, &ProjectConfiguration::toolTipChanged,
|
||||
this, &GenericListWidget::toolTipChanged);
|
||||
}
|
||||
|
||||
QFontMetrics fn(font());
|
||||
int width = fn.horizontalAdvance(pc->displayName()) + padding();
|
||||
int width = fn.horizontalAdvance(displayName) + padding();
|
||||
if (width > optimalWidth())
|
||||
setOptimalWidth(width);
|
||||
|
||||
m_ignoreIndexChange = false;
|
||||
}
|
||||
|
||||
void GenericListWidget::removeProjectConfiguration(ProjectConfiguration *pc)
|
||||
void GenericListWidget::removeProjectConfiguration(QObject *obj)
|
||||
{
|
||||
m_ignoreIndexChange = true;
|
||||
if (auto t = qobject_cast<Target *>(obj)) {
|
||||
disconnect(t, &Target::kitChanged,
|
||||
this, &GenericListWidget::displayNameChanged);
|
||||
} else if (auto pc = qobject_cast<ProjectConfiguration *>(obj)) {
|
||||
disconnect(pc, &ProjectConfiguration::displayNameChanged,
|
||||
this, &GenericListWidget::displayNameChanged);
|
||||
delete itemForProjectConfiguration(pc);
|
||||
}
|
||||
delete itemForProjectConfiguration(obj);
|
||||
|
||||
QFontMetrics fn(font());
|
||||
int width = 0;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
width = qMax(width, fn.horizontalAdvance(p->displayName()) + padding());
|
||||
}
|
||||
for (int i = 0; i < count(); ++i)
|
||||
width = qMax(width, fn.horizontalAdvance(displayNameFor(objectAt(i))) + padding());
|
||||
|
||||
setOptimalWidth(width);
|
||||
|
||||
m_ignoreIndexChange = false;
|
||||
@@ -492,15 +538,15 @@ void GenericListWidget::rowChanged(int index)
|
||||
return;
|
||||
if (index < 0)
|
||||
return;
|
||||
emit changeActiveProjectConfiguration(item(index)->data(Qt::UserRole).value<ProjectConfiguration *>());
|
||||
emit changeActiveProjectConfiguration(objectAt(index));
|
||||
}
|
||||
|
||||
void GenericListWidget::displayNameChanged()
|
||||
{
|
||||
m_ignoreIndexChange = true;
|
||||
ProjectConfiguration *activeProjectConfiguration = nullptr;
|
||||
QObject *activeObject = nullptr;
|
||||
if (currentItem())
|
||||
activeProjectConfiguration = currentItem()->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
activeObject = currentItem()->data(Qt::UserRole).value<QObject *>();
|
||||
|
||||
auto *pc = qobject_cast<ProjectConfiguration *>(sender());
|
||||
int index = -1;
|
||||
@@ -518,22 +564,20 @@ void GenericListWidget::displayNameChanged()
|
||||
lwi->setText(pc->displayName());
|
||||
int pos = count();
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
if (caseFriendlyCompare(pc->displayName(), p->displayName()) < 0) {
|
||||
if (caseFriendlyCompare(displayNameFor(pc), displayNameFor(objectAt(i))) < 0) {
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
insertItem(pos, lwi);
|
||||
if (activeProjectConfiguration)
|
||||
setCurrentItem(itemForProjectConfiguration(activeProjectConfiguration));
|
||||
if (activeObject)
|
||||
setCurrentItem(itemForProjectConfiguration(activeObject));
|
||||
|
||||
QFontMetrics fn(font());
|
||||
int width = 0;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||
width = qMax(width, fn.horizontalAdvance(p->displayName()) + padding());
|
||||
}
|
||||
for (int i = 0; i < count(); ++i)
|
||||
width = qMax(width, fn.horizontalAdvance(displayNameFor(objectAt(i))) + padding());
|
||||
|
||||
setOptimalWidth(width);
|
||||
|
||||
m_ignoreIndexChange = false;
|
||||
@@ -548,11 +592,11 @@ void GenericListWidget::toolTipChanged()
|
||||
}
|
||||
}
|
||||
|
||||
QListWidgetItem *GenericListWidget::itemForProjectConfiguration(ProjectConfiguration *pc)
|
||||
QListWidgetItem *GenericListWidget::itemForProjectConfiguration(QObject *pc)
|
||||
{
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
QListWidgetItem *lwi = item(i);
|
||||
if (lwi->data(Qt::UserRole).value<ProjectConfiguration *>() == pc)
|
||||
if (lwi->data(Qt::UserRole).value<QObject *>() == pc)
|
||||
return lwi;
|
||||
}
|
||||
return nullptr;
|
||||
@@ -725,21 +769,21 @@ MiniProjectTargetSelector::MiniProjectTargetSelector(QAction *targetSelectorActi
|
||||
this, &MiniProjectTargetSelector::kitChanged);
|
||||
|
||||
connect(m_listWidgets[TARGET], &GenericListWidget::changeActiveProjectConfiguration,
|
||||
this, [this](ProjectConfiguration *pc) {
|
||||
this, [this](QObject *pc) {
|
||||
SessionManager::setActiveTarget(m_project, static_cast<Target *>(pc), SetActive::Cascade);
|
||||
});
|
||||
connect(m_listWidgets[BUILD], &GenericListWidget::changeActiveProjectConfiguration,
|
||||
this, [this](ProjectConfiguration *pc) {
|
||||
this, [this](QObject *pc) {
|
||||
SessionManager::setActiveBuildConfiguration(m_project->activeTarget(),
|
||||
static_cast<BuildConfiguration *>(pc), SetActive::Cascade);
|
||||
});
|
||||
connect(m_listWidgets[DEPLOY], &GenericListWidget::changeActiveProjectConfiguration,
|
||||
this, [this](ProjectConfiguration *pc) {
|
||||
this, [this](QObject *pc) {
|
||||
SessionManager::setActiveDeployConfiguration(m_project->activeTarget(),
|
||||
static_cast<DeployConfiguration *>(pc), SetActive::Cascade);
|
||||
});
|
||||
connect(m_listWidgets[RUN], &GenericListWidget::changeActiveProjectConfiguration,
|
||||
this, [this](ProjectConfiguration *pc) {
|
||||
this, [this](QObject *pc) {
|
||||
m_project->activeTarget()->setActiveRunConfiguration(static_cast<RunConfiguration *>(pc));
|
||||
});
|
||||
}
|
||||
@@ -979,9 +1023,13 @@ void MiniProjectTargetSelector::projectAdded(Project *project)
|
||||
{
|
||||
connect(project, &Project::addedProjectConfiguration,
|
||||
this, &MiniProjectTargetSelector::handleNewProjectConfiguration);
|
||||
connect(project, &Project::addedTarget,
|
||||
this, &MiniProjectTargetSelector::handleNewTarget);
|
||||
|
||||
connect(project, &Project::removedProjectConfiguration,
|
||||
this, &MiniProjectTargetSelector::handleRemovalOfProjectConfiguration);
|
||||
connect(project, &Project::removedTarget,
|
||||
this, &MiniProjectTargetSelector::handleRemovalOfTarget);
|
||||
|
||||
foreach (Target *t, project->targets())
|
||||
addedTarget(t);
|
||||
@@ -997,9 +1045,13 @@ void MiniProjectTargetSelector::projectRemoved(Project *project)
|
||||
{
|
||||
disconnect(project, &Project::addedProjectConfiguration,
|
||||
this, &MiniProjectTargetSelector::handleNewProjectConfiguration);
|
||||
disconnect(project, &Project::addedTarget,
|
||||
this, &MiniProjectTargetSelector::handleNewTarget);
|
||||
|
||||
disconnect(project, &Project::removedProjectConfiguration,
|
||||
this, &MiniProjectTargetSelector::handleRemovalOfProjectConfiguration);
|
||||
disconnect(project, &Project::removedTarget,
|
||||
this, &MiniProjectTargetSelector::handleRemovalOfTarget);
|
||||
|
||||
foreach (Target *t, project->targets())
|
||||
removedTarget(t);
|
||||
@@ -1011,16 +1063,17 @@ void MiniProjectTargetSelector::projectRemoved(Project *project)
|
||||
updateRunListVisible();
|
||||
}
|
||||
|
||||
void MiniProjectTargetSelector::handleNewProjectConfiguration(ProjectConfiguration *pc)
|
||||
void MiniProjectTargetSelector::handleNewTarget(Target *target)
|
||||
{
|
||||
if (auto t = qobject_cast<Target *>(pc)) {
|
||||
addedTarget(t);
|
||||
addedTarget(target);
|
||||
updateTargetListVisible();
|
||||
updateBuildListVisible();
|
||||
updateDeployListVisible();
|
||||
updateRunListVisible();
|
||||
return;
|
||||
}
|
||||
|
||||
void MiniProjectTargetSelector::handleNewProjectConfiguration(ProjectConfiguration *pc)
|
||||
{
|
||||
if (auto bc = qobject_cast<BuildConfiguration *>(pc)) {
|
||||
if (addedBuildConfiguration(bc))
|
||||
updateBuildListVisible();
|
||||
@@ -1038,17 +1091,18 @@ void MiniProjectTargetSelector::handleNewProjectConfiguration(ProjectConfigurati
|
||||
}
|
||||
}
|
||||
|
||||
void MiniProjectTargetSelector::handleRemovalOfProjectConfiguration(ProjectConfiguration *pc)
|
||||
void MiniProjectTargetSelector::handleRemovalOfTarget(Target *target)
|
||||
{
|
||||
if (auto t = qobject_cast<Target *>(pc)) {
|
||||
removedTarget(t);
|
||||
removedTarget(target);
|
||||
|
||||
updateTargetListVisible();
|
||||
updateBuildListVisible();
|
||||
updateDeployListVisible();
|
||||
updateRunListVisible();
|
||||
return;
|
||||
}
|
||||
|
||||
void MiniProjectTargetSelector::handleRemovalOfProjectConfiguration(ProjectConfiguration *pc)
|
||||
{
|
||||
if (auto bc = qobject_cast<BuildConfiguration *>(pc)) {
|
||||
if (removedBuildConfiguration(bc))
|
||||
updateBuildListVisible();
|
||||
@@ -1232,12 +1286,12 @@ void MiniProjectTargetSelector::changeStartupProject(Project *project)
|
||||
}
|
||||
|
||||
if (project) {
|
||||
QList<ProjectConfiguration *> list;
|
||||
QList<QObject *> list;
|
||||
foreach (Target *t, project->targets())
|
||||
list.append(t);
|
||||
m_listWidgets[TARGET]->setProjectConfigurations(list, project->activeTarget());
|
||||
} else {
|
||||
m_listWidgets[TARGET]->setProjectConfigurations(QList<ProjectConfiguration *>(), nullptr);
|
||||
m_listWidgets[TARGET]->setProjectConfigurations(QList<QObject *>(), nullptr);
|
||||
}
|
||||
|
||||
updateActionAndSummary();
|
||||
@@ -1246,9 +1300,7 @@ void MiniProjectTargetSelector::changeStartupProject(Project *project)
|
||||
void MiniProjectTargetSelector::activeTargetChanged(Target *target)
|
||||
{
|
||||
if (m_target) {
|
||||
disconnect(m_target, &ProjectConfiguration::displayNameChanged,
|
||||
this, &MiniProjectTargetSelector::updateActionAndSummary);
|
||||
disconnect(m_target, &Target::toolTipChanged,
|
||||
disconnect(m_target, &Target::kitChanged,
|
||||
this, &MiniProjectTargetSelector::updateActionAndSummary);
|
||||
disconnect(m_target, &Target::iconChanged,
|
||||
this, &MiniProjectTargetSelector::updateActionAndSummary);
|
||||
@@ -1278,17 +1330,17 @@ void MiniProjectTargetSelector::activeTargetChanged(Target *target)
|
||||
this, &MiniProjectTargetSelector::updateActionAndSummary);
|
||||
|
||||
if (m_target) {
|
||||
QList<ProjectConfiguration *> bl;
|
||||
QList<QObject *> bl;
|
||||
foreach (BuildConfiguration *bc, target->buildConfigurations())
|
||||
bl.append(bc);
|
||||
m_listWidgets[BUILD]->setProjectConfigurations(bl, target->activeBuildConfiguration());
|
||||
|
||||
QList<ProjectConfiguration *> dl;
|
||||
QList<QObject *> dl;
|
||||
foreach (DeployConfiguration *dc, target->deployConfigurations())
|
||||
dl.append(dc);
|
||||
m_listWidgets[DEPLOY]->setProjectConfigurations(dl, target->activeDeployConfiguration());
|
||||
|
||||
QList<ProjectConfiguration *> rl;
|
||||
QList<QObject *> rl;
|
||||
foreach (RunConfiguration *rc, target->runConfigurations())
|
||||
rl.append(rc);
|
||||
m_listWidgets[RUN]->setProjectConfigurations(rl, target->activeRunConfiguration());
|
||||
@@ -1306,9 +1358,7 @@ void MiniProjectTargetSelector::activeTargetChanged(Target *target)
|
||||
connect(m_runConfiguration, &ProjectConfiguration::displayNameChanged,
|
||||
this, &MiniProjectTargetSelector::updateActionAndSummary);
|
||||
|
||||
connect(m_target, &ProjectConfiguration::displayNameChanged,
|
||||
this, &MiniProjectTargetSelector::updateActionAndSummary);
|
||||
connect(m_target, &Target::toolTipChanged,
|
||||
connect(m_target, &Target::kitChanged,
|
||||
this, &MiniProjectTargetSelector::updateActionAndSummary);
|
||||
connect(m_target, &Target::iconChanged,
|
||||
this, &MiniProjectTargetSelector::updateActionAndSummary);
|
||||
@@ -1319,9 +1369,9 @@ void MiniProjectTargetSelector::activeTargetChanged(Target *target)
|
||||
connect(m_target, &Target::activeRunConfigurationChanged,
|
||||
this, &MiniProjectTargetSelector::activeRunConfigurationChanged);
|
||||
} else {
|
||||
m_listWidgets[BUILD]->setProjectConfigurations(QList<ProjectConfiguration *>(), nullptr);
|
||||
m_listWidgets[DEPLOY]->setProjectConfigurations(QList<ProjectConfiguration *>(), nullptr);
|
||||
m_listWidgets[RUN]->setProjectConfigurations(QList<ProjectConfiguration *>(), nullptr);
|
||||
m_listWidgets[BUILD]->setProjectConfigurations(QList<QObject *>(), nullptr);
|
||||
m_listWidgets[DEPLOY]->setProjectConfigurations(QList<QObject *>(), nullptr);
|
||||
m_listWidgets[RUN]->setProjectConfigurations(QList<QObject *>(), nullptr);
|
||||
m_buildConfiguration = nullptr;
|
||||
m_deployConfiguration = nullptr;
|
||||
m_runConfiguration = nullptr;
|
||||
|
||||
@@ -113,19 +113,21 @@ public:
|
||||
explicit GenericListWidget(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void changeActiveProjectConfiguration(ProjectExplorer::ProjectConfiguration *dc);
|
||||
void changeActiveProjectConfiguration(QObject *dc);
|
||||
|
||||
public:
|
||||
void setProjectConfigurations(const QList<ProjectConfiguration *> &list, ProjectConfiguration *active);
|
||||
void setActiveProjectConfiguration(ProjectConfiguration *active);
|
||||
void addProjectConfiguration(ProjectConfiguration *pc);
|
||||
void removeProjectConfiguration(ProjectConfiguration *pc);
|
||||
void setProjectConfigurations(const QList<QObject *> &list, QObject *active);
|
||||
void setActiveProjectConfiguration(QObject *active);
|
||||
void addProjectConfiguration(QObject *pc);
|
||||
void removeProjectConfiguration(QObject *pc);
|
||||
|
||||
private:
|
||||
QObject *objectAt(int row) const;
|
||||
|
||||
void rowChanged(int index);
|
||||
void displayNameChanged();
|
||||
void toolTipChanged();
|
||||
QListWidgetItem *itemForProjectConfiguration(ProjectConfiguration *pc);
|
||||
QListWidgetItem *itemForProjectConfiguration(QObject *pc);
|
||||
bool m_ignoreIndexChange;
|
||||
};
|
||||
|
||||
@@ -148,8 +150,10 @@ public:
|
||||
private:
|
||||
void projectAdded(ProjectExplorer::Project *project);
|
||||
void projectRemoved(ProjectExplorer::Project *project);
|
||||
void handleNewProjectConfiguration(ProjectConfiguration *pc);
|
||||
void handleRemovalOfProjectConfiguration(ProjectConfiguration *pc);
|
||||
void handleNewProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
|
||||
void handleNewTarget(Target *target);
|
||||
void handleRemovalOfProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
|
||||
void handleRemovalOfTarget(Target *pc);
|
||||
|
||||
void changeStartupProject(ProjectExplorer::Project *project);
|
||||
void activeTargetChanged(ProjectExplorer::Target *target);
|
||||
|
||||
@@ -258,15 +258,12 @@ void Project::addTarget(std::unique_ptr<Target> &&t)
|
||||
QTC_ASSERT(!target(t->kit()), return);
|
||||
Q_ASSERT(t->project() == this);
|
||||
|
||||
t->setDefaultDisplayName(t->displayName());
|
||||
|
||||
// add it
|
||||
d->m_targets.emplace_back(std::move(t));
|
||||
connect(pointer, &Target::addedProjectConfiguration, this, &Project::addedProjectConfiguration);
|
||||
connect(pointer, &Target::aboutToRemoveProjectConfiguration, this, &Project::aboutToRemoveProjectConfiguration);
|
||||
connect(pointer, &Target::removedProjectConfiguration, this, &Project::removedProjectConfiguration);
|
||||
connect(pointer, &Target::activeProjectConfigurationChanged, this, &Project::activeProjectConfigurationChanged);
|
||||
emit addedProjectConfiguration(pointer);
|
||||
emit addedTarget(pointer);
|
||||
|
||||
// check activeTarget:
|
||||
@@ -281,7 +278,6 @@ bool Project::removeTarget(Target *target)
|
||||
if (BuildManager::isBuilding(target))
|
||||
return false;
|
||||
|
||||
emit aboutToRemoveProjectConfiguration(target);
|
||||
emit aboutToRemoveTarget(target);
|
||||
auto keep = Utils::take(d->m_targets, target);
|
||||
if (target == d->m_activeTarget) {
|
||||
@@ -289,7 +285,6 @@ bool Project::removeTarget(Target *target)
|
||||
SessionManager::setActiveTarget(this, newActiveTarget, SetActive::Cascade);
|
||||
}
|
||||
emit removedTarget(target);
|
||||
emit removedProjectConfiguration(target);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -313,7 +308,6 @@ void Project::setActiveTarget(Target *target)
|
||||
if ((!target && d->m_targets.size() == 0) ||
|
||||
(target && Utils::contains(d->m_targets, target))) {
|
||||
d->m_activeTarget = target;
|
||||
emit activeProjectConfigurationChanged(d->m_activeTarget);
|
||||
emit activeTargetChanged(d->m_activeTarget);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,11 +92,7 @@ ProjectConfiguration::ProjectConfiguration(QObject *parent, Core::Id id)
|
||||
if (m_target != nullptr)
|
||||
break;
|
||||
}
|
||||
|
||||
// FIXME: Below triggers on 'real' Targets with this here a base class as it's
|
||||
// not a real Target at this point of time. Plan is to cut this dependency and
|
||||
// enable the check, for now the item is set manually in the Target ctor.
|
||||
// QTC_CHECK(m_target);
|
||||
QTC_CHECK(m_target);
|
||||
}
|
||||
|
||||
ProjectConfiguration::~ProjectConfiguration() = default;
|
||||
|
||||
@@ -53,21 +53,26 @@ void Subscription::subscribe(ProjectConfiguration *pc)
|
||||
return;
|
||||
|
||||
connectTo(pc);
|
||||
|
||||
if (auto t = qobject_cast<Target *>(pc)) {
|
||||
for (ProjectConfiguration *pc : t->projectConfigurations())
|
||||
connectTo(pc);
|
||||
}
|
||||
|
||||
void Subscription::subscribeTarget(Target *target)
|
||||
{
|
||||
if (!m_subscriber)
|
||||
return;
|
||||
|
||||
for (ProjectConfiguration *pc : target->projectConfigurations())
|
||||
connectTo(pc);
|
||||
}
|
||||
|
||||
void Subscription::unsubscribe(ProjectConfiguration *pc)
|
||||
{
|
||||
disconnectFrom(pc);
|
||||
|
||||
if (auto t = qobject_cast<Target *>(pc)) {
|
||||
for (ProjectConfiguration *pc : t->projectConfigurations())
|
||||
disconnectFrom(pc);
|
||||
}
|
||||
|
||||
void Subscription::unsubscribeTarget(Target *target)
|
||||
{
|
||||
for (ProjectConfiguration *pc : target->projectConfigurations())
|
||||
disconnectFrom(pc);
|
||||
}
|
||||
|
||||
void Subscription::unsubscribeAll()
|
||||
@@ -113,13 +118,15 @@ ProjectSubscription::ProjectSubscription(const Subscription::Connector &s, const
|
||||
QTC_ASSERT(m_subscriber, return);
|
||||
|
||||
for (Target *t : p->targets())
|
||||
subscribe(t);
|
||||
subscribeTarget(t);
|
||||
|
||||
// Disconnect on removal of a project, to make it save to remove/add a project:
|
||||
connect(SessionManager::instance(), &SessionManager::projectRemoved,
|
||||
this, [this, p](Project *reported) { if (p == reported) { destroy(); } });
|
||||
connect(p, &Project::addedProjectConfiguration, this, &ProjectSubscription::subscribe);
|
||||
connect(p, &Project::addedTarget, this, &ProjectSubscription::subscribeTarget);
|
||||
connect(p, &Project::removedProjectConfiguration, this, &ProjectSubscription::unsubscribe);
|
||||
connect(p, &Project::removedTarget, this, &ProjectSubscription::unsubscribeTarget);
|
||||
}
|
||||
|
||||
ProjectSubscription::~ProjectSubscription() = default;
|
||||
|
||||
@@ -51,7 +51,9 @@ public:
|
||||
|
||||
protected:
|
||||
void subscribe(ProjectConfiguration *pc);
|
||||
void subscribeTarget(Target *target);
|
||||
void unsubscribe(ProjectConfiguration *pc);
|
||||
void unsubscribeTarget(Target *target);
|
||||
|
||||
void unsubscribeAll();
|
||||
void connectTo(ProjectConfiguration *pc);
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
@@ -56,6 +57,8 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace {
|
||||
const char ACTIVE_BC_KEY[] = "ProjectExplorer.Target.ActiveBuildConfiguration";
|
||||
const char BC_KEY_PREFIX[] = "ProjectExplorer.Target.BuildConfiguration.";
|
||||
@@ -106,6 +109,7 @@ public:
|
||||
QVariantMap m_pluginSettings;
|
||||
|
||||
Kit *const m_kit;
|
||||
MacroExpander m_macroExpander;
|
||||
};
|
||||
|
||||
TargetPrivate::TargetPrivate(Kit *k) :
|
||||
@@ -113,12 +117,9 @@ TargetPrivate::TargetPrivate(Kit *k) :
|
||||
{ }
|
||||
|
||||
Target::Target(Project *project, Kit *k, _constructor_tag) :
|
||||
ProjectConfiguration(project, k->id()),
|
||||
QObject(project),
|
||||
d(std::make_unique<TargetPrivate>(k))
|
||||
{
|
||||
// FIXME: Remove, see comment in ProjectConfiguration ctor.
|
||||
m_target = this;
|
||||
|
||||
QTC_CHECK(d->m_kit);
|
||||
connect(DeviceManager::instance(), &DeviceManager::updated, this, &Target::updateDeviceState);
|
||||
connect(project, &Project::parsingFinished, this, [this](bool success) {
|
||||
@@ -128,9 +129,6 @@ Target::Target(Project *project, Kit *k, _constructor_tag) :
|
||||
}
|
||||
}, Qt::QueuedConnection); // Must wait for run configs to change their enabled state.
|
||||
|
||||
setDisplayName(d->m_kit->displayName());
|
||||
setToolTip(d->m_kit->toHtml());
|
||||
|
||||
KitManager *km = KitManager::instance();
|
||||
connect(km, &KitManager::kitUpdated, this, &Target::handleKitUpdates);
|
||||
connect(km, &KitManager::kitRemoved, this, &Target::handleKitRemoval);
|
||||
@@ -164,10 +162,8 @@ void Target::handleKitUpdates(Kit *k)
|
||||
if (k != d->m_kit)
|
||||
return;
|
||||
|
||||
setDisplayName(k->displayName());
|
||||
updateDefaultDeployConfigurations();
|
||||
updateDeviceState(); // in case the device changed...
|
||||
setToolTip(k->toHtml());
|
||||
|
||||
emit iconChanged();
|
||||
emit kitChanged();
|
||||
@@ -195,6 +191,21 @@ Kit *Target::kit() const
|
||||
return d->m_kit;
|
||||
}
|
||||
|
||||
Core::Id Target::id() const
|
||||
{
|
||||
return d->m_kit->id();
|
||||
}
|
||||
|
||||
QString Target::displayName() const
|
||||
{
|
||||
return d->m_kit->displayName();
|
||||
}
|
||||
|
||||
QString Target::toolTip() const
|
||||
{
|
||||
return d->m_kit->toHtml();
|
||||
}
|
||||
|
||||
void Target::addBuildConfiguration(BuildConfiguration *bc)
|
||||
{
|
||||
QTC_ASSERT(bc && !d->m_buildConfigurations.contains(bc), return);
|
||||
@@ -477,7 +488,18 @@ QVariantMap Target::toMap() const
|
||||
if (!d->m_kit) // Kit was deleted, target is only around to be copied.
|
||||
return QVariantMap();
|
||||
|
||||
QVariantMap map(ProjectConfiguration::toMap());
|
||||
QVariantMap map;
|
||||
|
||||
{
|
||||
// FIXME: For compatibility within the 4.11 cycle, remove this block later.
|
||||
// This is only read by older versions of Creator, but even there not actively used.
|
||||
const char CONFIGURATION_ID_KEY[] = "ProjectExplorer.ProjectConfiguration.Id";
|
||||
const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DisplayName";
|
||||
const char DEFAULT_DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DefaultDisplayName";
|
||||
map.insert(QLatin1String(CONFIGURATION_ID_KEY), id().toSetting());
|
||||
map.insert(QLatin1String(DISPLAY_NAME_KEY), displayName());
|
||||
map.insert(QLatin1String(DEFAULT_DISPLAY_NAME_KEY), displayName());
|
||||
}
|
||||
|
||||
const QList<BuildConfiguration *> bcs = buildConfigurations();
|
||||
map.insert(QLatin1String(ACTIVE_BC_KEY), bcs.indexOf(d->m_activeBuildConfiguration));
|
||||
@@ -701,6 +723,11 @@ MakeInstallCommand Target::makeInstallCommand(const QString &installRoot) const
|
||||
return project()->makeInstallCommand(this, installRoot);
|
||||
}
|
||||
|
||||
MacroExpander *Target::macroExpander() const
|
||||
{
|
||||
return &d->m_macroExpander;
|
||||
}
|
||||
|
||||
void Target::updateDeviceState()
|
||||
{
|
||||
IDevice::ConstPtr current = DeviceKitAspect::device(kit());
|
||||
@@ -746,14 +773,8 @@ void Target::setEnabled(bool enabled)
|
||||
|
||||
bool Target::fromMap(const QVariantMap &map)
|
||||
{
|
||||
if (!ProjectConfiguration::fromMap(map))
|
||||
return false;
|
||||
|
||||
QTC_ASSERT(d->m_kit == KitManager::kit(id()), return false);
|
||||
|
||||
setDisplayName(d->m_kit->displayName()); // Overwrite displayname read from file
|
||||
setDefaultDisplayName(d->m_kit->displayName());
|
||||
|
||||
bool ok;
|
||||
int bcCount = map.value(QLatin1String(BC_COUNT_KEY), 0).toInt(&ok);
|
||||
if (!ok || bcCount < 0)
|
||||
|
||||
@@ -46,7 +46,7 @@ class RunConfiguration;
|
||||
|
||||
class TargetPrivate;
|
||||
|
||||
class PROJECTEXPLORER_EXPORT Target : public ProjectConfiguration
|
||||
class PROJECTEXPLORER_EXPORT Target : public QObject
|
||||
{
|
||||
friend class SessionManager; // for setActiveBuild and setActiveDeployConfiguration
|
||||
Q_OBJECT
|
||||
@@ -57,13 +57,15 @@ public:
|
||||
Target(Project *parent, Kit *k, _constructor_tag);
|
||||
~Target() override;
|
||||
|
||||
bool isActive() const final;
|
||||
bool isActive() const;
|
||||
|
||||
Project *project() const;
|
||||
|
||||
// Kit:
|
||||
Kit *kit() const;
|
||||
|
||||
Core::Id id() const;
|
||||
QString displayName() const;
|
||||
QString toolTip() const;
|
||||
|
||||
// Build configuration
|
||||
void addBuildConfiguration(BuildConfiguration *bc);
|
||||
bool removeBuildConfiguration(BuildConfiguration *bc);
|
||||
@@ -107,7 +109,7 @@ public:
|
||||
void setOverlayIcon(const QIcon &icon);
|
||||
QString overlayIconToolTip();
|
||||
|
||||
QVariantMap toMap() const override;
|
||||
QVariantMap toMap() const;
|
||||
|
||||
void updateDefaultBuildConfigurations();
|
||||
void updateDefaultDeployConfigurations();
|
||||
@@ -119,6 +121,8 @@ public:
|
||||
QVariant additionalData(Core::Id id) const;
|
||||
MakeInstallCommand makeInstallCommand(const QString &installRoot) const;
|
||||
|
||||
Utils::MacroExpander *macroExpander() const;
|
||||
|
||||
signals:
|
||||
void targetEnabled(bool);
|
||||
void iconChanged();
|
||||
@@ -153,7 +157,7 @@ signals:
|
||||
private:
|
||||
void setEnabled(bool);
|
||||
|
||||
bool fromMap(const QVariantMap &map) override;
|
||||
bool fromMap(const QVariantMap &map);
|
||||
|
||||
void updateDeviceState();
|
||||
|
||||
|
||||
@@ -155,6 +155,10 @@ QmakeProjectConfigWidget::QmakeProjectConfigWidget(QmakeBuildConfiguration *bc)
|
||||
if (pc && pc->isActive())
|
||||
environmentChanged();
|
||||
});
|
||||
connect(project, &Project::activeTargetChanged, this, [this](Target *target) {
|
||||
if (target && target->isActive())
|
||||
environmentChanged();
|
||||
});
|
||||
|
||||
auto qmakeProject = static_cast<QmakeProject *>(bc->target()->project());
|
||||
connect(qmakeProject, &QmakeProject::buildDirectoryInitialized,
|
||||
|
||||
Reference in New Issue
Block a user