forked from qt-creator/qt-creator
Sync the active target on the projects page with the active target
This commit is contained in:
@@ -43,7 +43,6 @@ void TargetSelector::insertTarget(int index, const QString &name)
|
|||||||
Target target;
|
Target target;
|
||||||
target.name = name;
|
target.name = name;
|
||||||
target.currentSubIndex = 0;
|
target.currentSubIndex = 0;
|
||||||
target.isActive = false;
|
|
||||||
|
|
||||||
m_targets.insert(index, target);
|
m_targets.insert(index, target);
|
||||||
|
|
||||||
@@ -54,15 +53,6 @@ void TargetSelector::insertTarget(int index, const QString &name)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetSelector::markActive(int index)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(index >= 0 && index < m_targets.count(), return);
|
|
||||||
|
|
||||||
for (int i = 0; i < m_targets.count(); ++i)
|
|
||||||
m_targets[i].isActive = (i == index);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TargetSelector::removeTarget(int index)
|
void TargetSelector::removeTarget(int index)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(index >= 0 && index < m_targets.count(), return);
|
QTC_ASSERT(index >= 0 && index < m_targets.count(), return);
|
||||||
@@ -218,13 +208,8 @@ void TargetSelector::paintEvent(QPaintEvent *event)
|
|||||||
p.setPen(QColor(0, 0, 0));
|
p.setPen(QColor(0, 0, 0));
|
||||||
}
|
}
|
||||||
p.drawPixmap(x, 1, *pixmap);
|
p.drawPixmap(x, 1, *pixmap);
|
||||||
QString targetName;
|
p.drawText(x + (TARGET_WIDTH - fm.width(target.name))/2 + 1, 7 + fm.ascent(),
|
||||||
if (target.isActive)
|
target.name);
|
||||||
targetName = QChar('*') + target.name + QChar('*');
|
|
||||||
else
|
|
||||||
targetName = target.name;
|
|
||||||
p.drawText(x + (TARGET_WIDTH - fm.width(targetName))/2 + 1, 7 + fm.ascent(),
|
|
||||||
targetName);
|
|
||||||
x += TARGET_WIDTH;
|
x += TARGET_WIDTH;
|
||||||
p.drawLine(x, 1, x, TARGET_HEIGHT);
|
p.drawLine(x, 1, x, TARGET_HEIGHT);
|
||||||
++x;
|
++x;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ public:
|
|||||||
struct Target {
|
struct Target {
|
||||||
QString name;
|
QString name;
|
||||||
int currentSubIndex;
|
int currentSubIndex;
|
||||||
bool isActive;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit TargetSelector(QWidget *parent = 0);
|
explicit TargetSelector(QWidget *parent = 0);
|
||||||
@@ -32,7 +31,6 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void addTarget(const QString &name);
|
void addTarget(const QString &name);
|
||||||
void insertTarget(int index, const QString &name);
|
void insertTarget(int index, const QString &name);
|
||||||
void markActive(int index);
|
|
||||||
void removeTarget(int index);
|
void removeTarget(int index);
|
||||||
void setCurrentIndex(int index);
|
void setCurrentIndex(int index);
|
||||||
void setCurrentSubIndex(int subindex);
|
void setCurrentSubIndex(int subindex);
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ void TargetSettingsPanelWidget::setupUi()
|
|||||||
this, SLOT(removeTarget()));
|
this, SLOT(removeTarget()));
|
||||||
|
|
||||||
if (m_project->activeTarget()) {
|
if (m_project->activeTarget()) {
|
||||||
m_selector->markActive(m_targets.indexOf(m_project->activeTarget()));
|
|
||||||
m_selector->setCurrentIndex(m_targets.indexOf(m_project->activeTarget()));
|
m_selector->setCurrentIndex(m_targets.indexOf(m_project->activeTarget()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +136,7 @@ void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subInd
|
|||||||
if (subIndex < -1 || subIndex >= 2)
|
if (subIndex < -1 || subIndex >= 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Target *target(m_targets.at(targetIndex));
|
Target *target = m_targets.at(targetIndex);
|
||||||
|
|
||||||
// Target was not actually changed:
|
// Target was not actually changed:
|
||||||
if (m_currentTarget == target) {
|
if (m_currentTarget == target) {
|
||||||
@@ -156,8 +155,8 @@ void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subInd
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PanelsWidget *buildPanel(new PanelsWidget(m_centralWidget));
|
PanelsWidget *buildPanel = new PanelsWidget(m_centralWidget);
|
||||||
PanelsWidget *runPanel(new PanelsWidget(m_centralWidget));
|
PanelsWidget *runPanel = new PanelsWidget(m_centralWidget);
|
||||||
|
|
||||||
foreach (ITargetPanelFactory *panelFactory, ExtensionSystem::PluginManager::instance()->getObjects<ITargetPanelFactory>()) {
|
foreach (ITargetPanelFactory *panelFactory, ExtensionSystem::PluginManager::instance()->getObjects<ITargetPanelFactory>()) {
|
||||||
if (panelFactory->id() == QLatin1String(BUILDSETTINGS_PANEL_ID)) {
|
if (panelFactory->id() == QLatin1String(BUILDSETTINGS_PANEL_ID)) {
|
||||||
@@ -180,6 +179,9 @@ void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subInd
|
|||||||
m_panelWidgets[0] = buildPanel;
|
m_panelWidgets[0] = buildPanel;
|
||||||
delete m_panelWidgets[1];
|
delete m_panelWidgets[1];
|
||||||
m_panelWidgets[1] = runPanel;
|
m_panelWidgets[1] = runPanel;
|
||||||
|
|
||||||
|
|
||||||
|
m_project->setActiveTarget(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetSettingsPanelWidget::addTarget()
|
void TargetSettingsPanelWidget::addTarget()
|
||||||
@@ -238,8 +240,8 @@ void TargetSettingsPanelWidget::activeTargetChanged(ProjectExplorer::Target *tar
|
|||||||
Q_ASSERT(m_project == target->project());
|
Q_ASSERT(m_project == target->project());
|
||||||
Q_ASSERT(m_selector);
|
Q_ASSERT(m_selector);
|
||||||
|
|
||||||
int index(m_targets.indexOf(target));
|
int index = m_targets.indexOf(target);
|
||||||
m_selector->markActive(index);
|
m_selector->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetSettingsPanelWidget::updateTargetAddAndRemoveButtons()
|
void TargetSettingsPanelWidget::updateTargetAddAndRemoveButtons()
|
||||||
|
|||||||
@@ -41,11 +41,6 @@ void TargetSettingsWidget::insertTarget(int index, const QString &name)
|
|||||||
updateTargetSelector();
|
updateTargetSelector();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetSettingsWidget::markActive(int index)
|
|
||||||
{
|
|
||||||
m_targetSelector->markActive(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TargetSettingsWidget::removeTarget(int index)
|
void TargetSettingsWidget::removeTarget(int index)
|
||||||
{
|
{
|
||||||
m_targetSelector->removeTarget(index);
|
m_targetSelector->removeTarget(index);
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void addTarget(const QString &name);
|
void addTarget(const QString &name);
|
||||||
void insertTarget(int index, const QString &name);
|
void insertTarget(int index, const QString &name);
|
||||||
void markActive(int index);
|
|
||||||
void removeTarget(int index);
|
void removeTarget(int index);
|
||||||
void setCurrentIndex(int index);
|
void setCurrentIndex(int index);
|
||||||
void setCurrentSubIndex(int index);
|
void setCurrentSubIndex(int index);
|
||||||
|
|||||||
Reference in New Issue
Block a user