BaseAspect Class

class Utils::BaseAspect

The BaseAspect class provides a common base for classes implementing aspects. More...

Header: #include <BaseAspect>
Inherits: QObject
Inherited By:

Utils::AspectContainer and Utils::TextDisplay

Public Functions

BaseAspect(Utils::AspectContainer *container = nullptr)
virtual ~BaseAspect() override
virtual void addToLayout(Layouting::LayoutItem &parent)
virtual void apply()
virtual void cancel()
QString displayName() const
virtual void fromMap(const Utils::Store &map)
QString labelText() const
virtual void setAutoApply(bool on)
void setEnabler(Utils::BoolAspect *checker)
void setLabelPixmap(const QPixmap &labelPixmap)
void setLabelText(const QString &labelText)
void setSettingsKey(const Utils::Key &key)
void setSettingsKey(const Utils::Key &group, const Utils::Key &key)
void setToolTip(const QString &tooltip)
virtual void setVariantValue(const QVariant &value, Utils::BaseAspect::Announcement howToAnnounce = DoEmit)
void setVisible(bool visible)
Utils::Key settingsKey() const
virtual void toMap(Utils::Store &map) const
void writeToSettingsImmediatly() const

Detailed Description

An aspect is a hunk of data like a property or collection of related properties of some object, together with a description of its behavior for common operations like visualizing or persisting.

Simple aspects are for example a boolean property represented by a QCheckBox in the user interface, or a string property represented by a PathChooser, selecting directories in the filesystem.

While aspects implementations usually have the ability to visualize and to persist their data, or use an ID, neither of these is mandatory.

Member Function Documentation

BaseAspect::BaseAspect(Utils::AspectContainer *container = nullptr)

Constructs a base aspect.

If container is non-null, the aspect is made known to the container.

[override virtual noexcept] BaseAspect::~BaseAspect()

Destructs a BaseAspect.

[virtual] void BaseAspect::addToLayout(Layouting::LayoutItem &parent)

Adds the visual representation of this aspect to the layout with the specified parent using a layout builder.

[virtual] void BaseAspect::apply()

Updates this aspect's value from user-initiated changes in the widget.

Emits changed() if the value changed.

[virtual] void BaseAspect::cancel()

Discard user changes in the widget and restore widget contents from aspect's value.

This has only an effect if isAutoApply is false.

QString BaseAspect::displayName() const

Returns the string that should be used when this action appears in menus or other places that are typically used with Book style capitalization.

If no display name is set, the label text will be used as fallback.

[virtual] void BaseAspect::fromMap(const Utils::Store &map)

Retrieves the internal value of this BaseAspect from the Store map.

QString BaseAspect::labelText() const

Returns the current text for the separate label in the visual representation of this aspect.

See also setLabelText().

[virtual] void BaseAspect::setAutoApply(bool on)

Sets auto-apply mode. When auto-apply mode is on, user interaction to this aspect's widget will not modify the value of the aspect until apply() is called programmatically.

See also setSettingsKey().

void BaseAspect::setEnabler(Utils::BoolAspect *checker)

Makes the enabled state of this aspect depend on the checked state of checker.

void BaseAspect::setLabelPixmap(const QPixmap &labelPixmap)

Sets labelPixmap as pixmap for the separate label in the visual representation of this aspect.

void BaseAspect::setLabelText(const QString &labelText)

Sets labelText as text for the separate label in the visual representation of this aspect.

See also labelText().

void BaseAspect::setSettingsKey(const Utils::Key &key)

Sets the key to be used when accessing the settings.

See also settingsKey().

void BaseAspect::setSettingsKey(const Utils::Key &group, const Utils::Key &key)

Sets the key and group to be used when accessing the settings.

See also settingsKey().

void BaseAspect::setToolTip(const QString &tooltip)

Sets tooltip as tool tip for the visual representation of this aspect.

[virtual] void BaseAspect::setVariantValue(const QVariant &value, Utils::BaseAspect::Announcement howToAnnounce = DoEmit)

Sets value.

Prefer the typed setValue() of derived classes.

void BaseAspect::setVisible(bool visible)

Shows or hides the visual representation of this aspect depending on the value of visible. By default, it is visible.

Utils::Key BaseAspect::settingsKey() const

Returns the key to be used when accessing the settings.

See also setSettingsKey().

[virtual] void BaseAspect::toMap(Utils::Store &map) const

Stores the internal value of this BaseAspect into the Store map.

void BaseAspect::writeToSettingsImmediatly() const

Immediately writes the value of this aspect into its specified settings, taking a potential container's settings group specification into account.

Note: This is expensive, so it should only be used with good reason.

© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.