summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer/targetselector.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@nokia.com>2010-02-08 15:50:06 +0100
committerTobias Hunger <tobias.hunger@nokia.com>2010-02-09 16:57:37 +0100
commitd1bdfcc363970eca53077cdab79de2d3cf24218a (patch)
tree100cc0dc41f660b72277fa018c8a46454d0686b4 /src/plugins/projectexplorer/targetselector.cpp
parent8ee2521fe53cec55534b079b0d5b21b6b028676f (diff)
downloadqt-creator-d1bdfcc363970eca53077cdab79de2d3cf24218a.tar.gz
Integrate target support
* Ease cross device development by introducing 'targets' which group build- and runsettings that are valid for this one target Most of the kudos for the code review go to dt. Con, thorbjorn, ckandler and others did also review parts of this patch. Reviewed-by: dt
Diffstat (limited to 'src/plugins/projectexplorer/targetselector.cpp')
-rw-r--r--src/plugins/projectexplorer/targetselector.cpp56
1 files changed, 50 insertions, 6 deletions
diff --git a/src/plugins/projectexplorer/targetselector.cpp b/src/plugins/projectexplorer/targetselector.cpp
index 6771eec101..8c1286a558 100644
--- a/src/plugins/projectexplorer/targetselector.cpp
+++ b/src/plugins/projectexplorer/targetselector.cpp
@@ -14,10 +14,10 @@ TargetSelector::TargetSelector(QWidget *parent) :
QWidget(parent),
m_currentTargetIndex(-1)
{
- QFont f = font();
- f.setPixelSize(10);
- f.setBold(true);
- setFont(f);
+ QFont f = font();
+ f.setPixelSize(10);
+ f.setBold(true);
+ setFont(f);
}
void TargetSelector::addTarget(const QString &name)
@@ -25,16 +25,55 @@ void TargetSelector::addTarget(const QString &name)
Target target;
target.name = name;
target.currentSubIndex = 0;
+ target.isActive = false;
m_targets.append(target);
if (m_currentTargetIndex == -1)
- m_currentTargetIndex = m_targets.size() - 1;
+ setCurrentIndex(m_targets.size() - 1);
+ update();
+}
+
+void TargetSelector::markActive(int index)
+{
+ if (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)
{
m_targets.removeAt(index);
+ if (m_currentTargetIndex == index)
+ setCurrentIndex(m_targets.size() - 1);
+ update();
+}
+
+void TargetSelector::setCurrentIndex(int index)
+{
+ if (index < -1 ||
+ index >= m_targets.count() ||
+ index == m_currentTargetIndex)
+ return;
+
+ m_currentTargetIndex = index;
+
+ update();
+ emit currentIndexChanged(m_currentTargetIndex,
+ m_currentTargetIndex >= 0 ? m_targets.at(m_currentTargetIndex).currentSubIndex : -1);
+}
+
+void TargetSelector::setCurrentSubIndex(int subindex)
+{
+ if (subindex < 0 ||
+ subindex >= 2 ||
+ subindex == m_targets.at(m_currentTargetIndex).currentSubIndex)
+ return;
+ m_targets[m_currentTargetIndex].currentSubIndex = subindex;
+
update();
+ emit currentIndexChanged(m_currentTargetIndex,
+ m_targets.at(m_currentTargetIndex).currentSubIndex);
}
TargetSelector::Target TargetSelector::targetAt(int index) const
@@ -117,8 +156,13 @@ void TargetSelector::paintEvent(QPaintEvent *event)
p.setPen(QColor(0, 0, 0));
}
p.drawPixmap(x, 1, *pixmap);
+ QString targetName;
+ if (target.isActive)
+ targetName = QChar('*') + target.name + QChar('*');
+ else
+ targetName = target.name;
p.drawText(x + (TARGET_WIDTH - fm.width(target.name))/2 + 1, 7 + fm.ascent(),
- target.name);
+ targetName);
x += TARGET_WIDTH;
p.drawLine(x, 1, x, TARGET_HEIGHT);
++x;