forked from qt-creator/qt-creator
Utils: Let registered aspects know about their containers
Will help to set up macroexpanders with less boiler plate. Change-Id: I521af3dc9d49524cf855e82eecc0132d1bcc40db Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -52,6 +52,8 @@ namespace Internal {
|
|||||||
class BaseAspectPrivate
|
class BaseAspectPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
explicit BaseAspectPrivate(AspectContainer *container) : m_container(container) {}
|
||||||
|
|
||||||
Id m_id;
|
Id m_id;
|
||||||
std::function<QVariant(const QVariant &)> m_toSettings;
|
std::function<QVariant(const QVariant &)> m_toSettings;
|
||||||
std::function<QVariant(const QVariant &)> m_fromSettings;
|
std::function<QVariant(const QVariant &)> m_fromSettings;
|
||||||
@@ -64,6 +66,7 @@ public:
|
|||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
QPointer<QLabel> m_label; // Owned by configuration widget
|
QPointer<QLabel> m_label; // Owned by configuration widget
|
||||||
QPointer<QAction> m_action; // Owned by us.
|
QPointer<QAction> m_action; // Owned by us.
|
||||||
|
AspectContainer *m_container = nullptr; // Not owned by us.
|
||||||
|
|
||||||
bool m_visible = true;
|
bool m_visible = true;
|
||||||
bool m_enabled = true;
|
bool m_enabled = true;
|
||||||
@@ -106,7 +109,7 @@ public:
|
|||||||
If \a container is non-null, the aspect is made known to the container.
|
If \a container is non-null, the aspect is made known to the container.
|
||||||
*/
|
*/
|
||||||
BaseAspect::BaseAspect(AspectContainer *container)
|
BaseAspect::BaseAspect(AspectContainer *container)
|
||||||
: d(new Internal::BaseAspectPrivate)
|
: d(new Internal::BaseAspectPrivate(container))
|
||||||
{
|
{
|
||||||
if (container)
|
if (container)
|
||||||
container->registerAspect(this);
|
container->registerAspect(this);
|
||||||
@@ -438,6 +441,11 @@ QAction *BaseAspect::action()
|
|||||||
return d->m_action;
|
return d->m_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AspectContainer *BaseAspect::container() const
|
||||||
|
{
|
||||||
|
return d->m_container;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Adds the visual representation of this aspect to the layout with the
|
Adds the visual representation of this aspect to the layout with the
|
||||||
specified \a parent using a layout builder.
|
specified \a parent using a layout builder.
|
||||||
|
@@ -94,6 +94,8 @@ public:
|
|||||||
|
|
||||||
virtual QAction *action();
|
virtual QAction *action();
|
||||||
|
|
||||||
|
AspectContainer *container() const;
|
||||||
|
|
||||||
virtual void fromMap(const QVariantMap &map);
|
virtual void fromMap(const QVariantMap &map);
|
||||||
virtual void toMap(QVariantMap &map) const;
|
virtual void toMap(QVariantMap &map) const;
|
||||||
virtual void toActiveMap(QVariantMap &map) const { toMap(map); }
|
virtual void toActiveMap(QVariantMap &map) const { toMap(map); }
|
||||||
|
Reference in New Issue
Block a user