forked from qt-creator/qt-creator
Simplify KitAspectWidget interface
Not really a widget anyways. Change-Id: I404cef102d6a6f4d3bd60860fe2bf2d58e3ca365 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -722,15 +722,10 @@ void KitAspect::notifyAboutUpdate(Kit *k)
|
|||||||
k->kitUpdated();
|
k->kitUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
KitAspectWidget::KitAspectWidget(Kit *kit, const KitAspect *ki) : m_kit(kit),
|
KitAspectWidget::KitAspectWidget(Kit *kit, const KitAspect *ki)
|
||||||
m_kitInformation(ki), m_isSticky(kit->isSticky(ki->id()))
|
: m_kit(kit), m_kitInformation(ki)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Utils::Id KitAspectWidget::kitInformationId() const
|
|
||||||
{
|
|
||||||
return m_kitInformation->id();
|
|
||||||
}
|
|
||||||
|
|
||||||
void KitAspectWidget::addToLayout(LayoutBuilder &builder)
|
void KitAspectWidget::addToLayout(LayoutBuilder &builder)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!m_label, delete m_label);
|
QTC_ASSERT(!m_label, delete m_label);
|
||||||
|
|||||||
@@ -132,11 +132,8 @@ class PROJECTEXPLORER_EXPORT KitAspectWidget : public QObject
|
|||||||
public:
|
public:
|
||||||
KitAspectWidget(Kit *kit, const KitAspect *ki);
|
KitAspectWidget(Kit *kit, const KitAspect *ki);
|
||||||
|
|
||||||
Utils::Id kitInformationId() const;
|
|
||||||
|
|
||||||
virtual void makeReadOnly() = 0;
|
virtual void makeReadOnly() = 0;
|
||||||
virtual void refresh() = 0;
|
virtual void refresh() = 0;
|
||||||
bool visibleInKit() { return m_kitInformation->isApplicableToKit(m_kit); }
|
|
||||||
|
|
||||||
virtual QWidget *mainWidget() const = 0;
|
virtual QWidget *mainWidget() const = 0;
|
||||||
virtual QWidget *buttonWidget() const { return nullptr; }
|
virtual QWidget *buttonWidget() const { return nullptr; }
|
||||||
@@ -144,16 +141,14 @@ public:
|
|||||||
void addToLayout(Utils::LayoutBuilder &builder);
|
void addToLayout(Utils::LayoutBuilder &builder);
|
||||||
void setVisible(bool visible);
|
void setVisible(bool visible);
|
||||||
|
|
||||||
bool isSticky() const { return m_isSticky; }
|
|
||||||
|
|
||||||
static QString msgManage();
|
static QString msgManage();
|
||||||
|
|
||||||
Kit *kit() const { return m_kit; }
|
Kit *kit() const { return m_kit; }
|
||||||
|
const KitAspect *kitInformation() const { return m_kitInformation; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Kit *m_kit;
|
Kit *m_kit;
|
||||||
const KitAspect *m_kitInformation;
|
const KitAspect *m_kitInformation;
|
||||||
bool m_isSticky;
|
|
||||||
QLabel *m_label = nullptr;
|
QLabel *m_label = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ void KitManagerConfigWidget::addAspectToWorkingCopy(KitAspect *aspect)
|
|||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
action->setChecked(workingCopy()->isMutable(aspect->id()));
|
action->setChecked(workingCopy()->isMutable(aspect->id()));
|
||||||
|
|
||||||
action->setEnabled(!widget->isSticky());
|
action->setEnabled(!workingCopy()->isSticky(aspect->id()));
|
||||||
widget->mainWidget()->addAction(action);
|
widget->mainWidget()->addAction(action);
|
||||||
widget->mainWidget()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
widget->mainWidget()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
connect(action, &QAction::toggled, this, [this, aspect, action] {
|
connect(action, &QAction::toggled, this, [this, aspect, action] {
|
||||||
@@ -243,9 +243,10 @@ void KitManagerConfigWidget::updateVisibility()
|
|||||||
int count = m_widgets.count();
|
int count = m_widgets.count();
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
KitAspectWidget *widget = m_widgets.at(i);
|
KitAspectWidget *widget = m_widgets.at(i);
|
||||||
const bool visible = widget->visibleInKit()
|
const KitAspect *ki = widget->kitInformation();
|
||||||
&& !m_modifiedKit->irrelevantAspects().contains(widget->kitInformationId());
|
const bool visibleInKit = ki->isApplicableToKit(m_modifiedKit.get());
|
||||||
widget->setVisible(visible);
|
const bool irrelevant = m_modifiedKit->irrelevantAspects().contains(ki->id());
|
||||||
|
widget->setVisible(visibleInKit && !irrelevant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +258,7 @@ void KitManagerConfigWidget::setHasUniqueName(bool unique)
|
|||||||
void KitManagerConfigWidget::makeStickySubWidgetsReadOnly()
|
void KitManagerConfigWidget::makeStickySubWidgetsReadOnly()
|
||||||
{
|
{
|
||||||
foreach (KitAspectWidget *w, m_widgets) {
|
foreach (KitAspectWidget *w, m_widgets) {
|
||||||
if (w->isSticky())
|
if (w->kit()->isSticky(w->kitInformation()->id()))
|
||||||
w->makeReadOnly();
|
w->makeReadOnly();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -611,16 +611,17 @@ private:
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
bool addedMutables = false;
|
bool addedMutables = false;
|
||||||
QList<Utils::Id> knownIdList = Utils::transform(m_widgets, &KitAspectWidget::kitInformationId);
|
QList<const KitAspect *> knownList
|
||||||
|
= Utils::transform(m_widgets, &KitAspectWidget::kitInformation);
|
||||||
|
|
||||||
for (KitAspect *aspect : KitManager::kitAspects()) {
|
for (KitAspect *aspect : KitManager::kitAspects()) {
|
||||||
const Utils::Id currentId = aspect->id();
|
const Utils::Id currentId = aspect->id();
|
||||||
if (m_kit->isMutable(currentId) && !knownIdList.removeOne(currentId)) {
|
if (m_kit->isMutable(currentId) && !knownList.removeOne(aspect)) {
|
||||||
addedMutables = true;
|
addedMutables = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const bool removedMutables = !knownIdList.isEmpty();
|
const bool removedMutables = !knownList.isEmpty();
|
||||||
|
|
||||||
if (addedMutables || removedMutables) {
|
if (addedMutables || removedMutables) {
|
||||||
// Redo whole setup if the number of mutable settings did change
|
// Redo whole setup if the number of mutable settings did change
|
||||||
|
|||||||
Reference in New Issue
Block a user