Commit 0a02ce6a authored by Daniel Teske's avatar Daniel Teske

KitManager: Enable KitInformations to be invisible for Kits

This was only possible in theory but not in pratice.

Change-Id: Ia5100569c371134e3cabacfcd76084c8763f5ecc
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 61dc2936
......@@ -53,6 +53,7 @@ public:
virtual QString toolTip() const { return QString(); }
virtual void makeReadOnly() = 0;
virtual void refresh() = 0;
virtual bool visibleInKit() { return true; }
virtual QWidget *mainWidget() const = 0;
virtual QWidget *buttonWidget() const { return 0; }
......
......@@ -379,6 +379,8 @@ Internal::KitManagerConfigWidget *KitManager::createConfigWidget(Kit *k) const
foreach (KitInformation *ki, d->m_informationList)
result->addConfigWidget(ki->createConfigWidget(result->workingCopy()));
result->updateVisibility();
return result;
}
......
......@@ -72,7 +72,6 @@ public:
virtual unsigned int priority() const = 0; // the higher the closer to the top.
virtual bool visibleIn(Kit *) { return true; }
virtual QVariant defaultValue(Kit *) const = 0;
// called to find issues with the kit
......
......@@ -75,8 +75,11 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) :
mainLayout->setMargin(1);
mainLayout->addWidget(scroll, 0, 0);
static const Qt::Alignment alignment
= static_cast<Qt::Alignment>(style()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
QString toolTip = tr("Kit name and icon.");
setLabel(tr("Name:"), toolTip, 0);
QLabel *label = createLabel(tr("Name:"), toolTip);
m_layout->addWidget(label, 0, LabelColumn, alignment);
m_iconButton->setToolTip(toolTip);
discard();
......@@ -171,9 +174,26 @@ void KitManagerConfigWidget::addConfigWidget(ProjectExplorer::KitConfigWidget *w
m_layout->addWidget(widget->mainWidget(), row, WidgetColumn);
if (QWidget *button = widget->buttonWidget())
m_layout->addWidget(button, row, ButtonColumn);
setLabel(name, toolTip, row);
static const Qt::Alignment alignment
= static_cast<Qt::Alignment>(style()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
QLabel *label = createLabel(name, toolTip);
m_layout->addWidget(label, row, LabelColumn, alignment);
m_widgets.append(widget);
m_labels.append(label);
}
void KitManagerConfigWidget::updateVisibility()
{
int count = m_widgets.count();
for (int i = 0; i < count; ++i) {
KitConfigWidget *widget = m_widgets.at(i);
bool visible = widget->visibleInKit();
widget->mainWidget()->setVisible(visible);
if (widget->buttonWidget())
widget->buttonWidget()->setVisible(visible);
m_labels.at(i)->setVisible(visible);
}
}
void KitManagerConfigWidget::makeReadOnly()
......@@ -249,6 +269,7 @@ void KitManagerConfigWidget::workingCopyWasUpdated(Kit *k)
w->refresh();
m_nameEdit->setText(k->displayName());
m_iconButton->setIcon(k->icon());
updateVisibility();
emit dirty();
}
......@@ -256,15 +277,14 @@ void KitManagerConfigWidget::kitWasUpdated(Kit *k)
{
if (m_kit == k)
discard();
updateVisibility();
}
void KitManagerConfigWidget::setLabel(const QString &name, const QString &toolTip, int row)
QLabel *KitManagerConfigWidget::createLabel(const QString &name, const QString &toolTip)
{
static const Qt::Alignment alignment
= static_cast<Qt::Alignment>(style()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
QLabel *label = new QLabel(name);
label->setToolTip(toolTip);
m_layout->addWidget(label, row, LabelColumn, alignment);
return label;
}
void KitManagerConfigWidget::paintEvent(QPaintEvent *)
......
......@@ -36,6 +36,7 @@
QT_BEGIN_NAMESPACE
class QGridLayout;
class QLabel;
class QLineEdit;
class QToolButton;
QT_END_NAMESPACE
......@@ -68,6 +69,7 @@ public:
void setIsDefaultKit(bool d);
bool isDefaultKit() const;
void removeKit();
void updateVisibility();
signals:
void dirty();
......@@ -85,13 +87,14 @@ private:
ButtonColumn
};
void setLabel(const QString &name, const QString &toolTip, int row);
QLabel *createLabel(const QString &name, const QString &toolTip);
void paintEvent(QPaintEvent *ev);
QGridLayout *m_layout;
QToolButton *m_iconButton;
QLineEdit *m_nameEdit;
QList<KitConfigWidget *> m_widgets;
QList<QLabel *> m_labels;
Kit *m_kit;
Kit *m_modifiedKit;
bool m_isDefaultKit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment