KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
KDBindings::Property< T > Class Template Reference

A property represents a value that can be part of or the result of data binding. More...

#include <property.h>

Public Types

typedef T valuetype
 

Public Member Functions

 Property ()=default
 
 Property (Property< T > &&other) noexcept(std::is_nothrow_move_constructible< T >::value)
 Properties are movable.
 
 Property (Property< T > const &other)=delete
 
template<typename UpdaterT >
 Property (std::unique_ptr< UpdaterT > &&updater)
 
 Property (T value) noexcept(std::is_nothrow_move_constructible< T >::value)
 
 ~Property ()
 
Signaldestroyed () const
 
T const & get () const
 
T const & operator() () const
 
Propertyoperator= (Property< T > &&other) noexcept(std::is_nothrow_move_assignable< T >::value)
 
Propertyoperator= (Property< T > const &other)=delete
 
template<typename UpdaterT >
Propertyoperator= (std::unique_ptr< UpdaterT > &&updater)
 
Property< T > & operator= (T const &rhs)
 
void reset ()
 Disconnects the binding from this Property.
 
void set (T value)
 
Signal< const T &, const T & > & valueAboutToChange () const
 
Signal< const T & > & valueChanged () const
 

Detailed Description

template<typename T>
class KDBindings::Property< T >

A property represents a value that can be part of or the result of data binding.

Properties are at the basis of data binding. They can contain a value of any type T. The value can either represent the result of a data binding or a value that is used in the calculation of a binding expression.

If the value of a property is changed, either manually or because it is the result of a binding expression, the Property will emit the valueAboutToChange(), and valueChanged() Signal. If it is used as part of a binding expression, the expression will be marked as dirty and (unless a custom BindingEvaluator is used) updated immediately.

To create a property from a data binding expression, use the makeBoundProperty or makeBinding functions in the KDBindings namespace.

Examples:

Definition at line 137 of file property.h.

Member Typedef Documentation

◆ valuetype

template<typename T >
typedef T KDBindings::Property< T >::valuetype

Definition at line 140 of file property.h.

Constructor & Destructor Documentation

◆ Property() [1/5]

template<typename T >
KDBindings::Property< T >::Property ( )
default

Properties are default constructable.

The value of a default constructed property is then also default constructed.

◆ ~Property()

template<typename T >
KDBindings::Property< T >::~Property ( )
inline

If a Property is destroyed, it emits the destroyed() Signal.

Definition at line 152 of file property.h.

References KDBindings::Signal< Args >::emit().

◆ Property() [2/5]

template<typename T >
KDBindings::Property< T >::Property ( value)
inlineexplicitnoexcept

Constructs a Property from the provided value.

Definition at line 160 of file property.h.

◆ Property() [3/5]

template<typename T >
KDBindings::Property< T >::Property ( Property< T > const &  other)
delete

Properties are not copyable.

◆ Property() [4/5]

template<typename T >
KDBindings::Property< T >::Property ( Property< T > &&  other)
inlinenoexcept

Properties are movable.

All connections that were made to the signals of the original Property are moved over to the newly-constructed Property.

All data bindings that depend on the moved-from Property will update their references to the newly move-constructed Property.

Definition at line 180 of file property.h.

◆ Property() [5/5]

template<typename T >
template<typename UpdaterT >
KDBindings::Property< T >::Property ( std::unique_ptr< UpdaterT > &&  updater)
inlineexplicit

Construct a property that will be updated by the specified PropertyUpdater.

This constructor is usually called by the creation of a data binding and usually doesn't need to be called manually.

Definition at line 238 of file property.h.

Member Function Documentation

◆ destroyed()

template<typename T >
Signal & KDBindings::Property< T >::destroyed ( ) const
inline

Returns a Signal that will be emitted when this Property is destructed.

Definition at line 301 of file property.h.

◆ get()

template<typename T >
T const & KDBindings::Property< T >::get ( ) const
inline

Returns the value represented by this Property.

Definition at line 330 of file property.h.

Referenced by KDBindings::Private::PropertyNode< PropertyType >::evaluate(), and KDBindings::Property< T >::operator()().

◆ operator()()

template<typename T >
T const & KDBindings::Property< T >::operator() ( ) const
inline

Returns the value represented by this Property.

See: get().

Definition at line 351 of file property.h.

References KDBindings::Property< T >::get().

◆ operator=() [1/4]

template<typename T >
Property & KDBindings::Property< T >::operator= ( Property< T > &&  other)
inlinenoexcept

See: Property(Property<T> &&other)

Definition at line 206 of file property.h.

◆ operator=() [2/4]

template<typename T >
Property & KDBindings::Property< T >::operator= ( Property< T > const &  other)
delete

◆ operator=() [3/4]

template<typename T >
template<typename UpdaterT >
Property & KDBindings::Property< T >::operator= ( std::unique_ptr< UpdaterT > &&  updater)
inline

Assigns a Binding or other Updater to this Property.

In comparison to the move assignment operator, this does NOT change any of the existing Signal connections. They are all kept as-is. Only the source of the update is changed.

This will immediately set the value of this Property to the result of the updater and will call the valueAboutToChange or valueChanged Signals respectively if necessary.

Definition at line 255 of file property.h.

◆ operator=() [4/4]

template<typename T >
Property< T > & KDBindings::Property< T >::operator= ( T const &  rhs)
inline

Assigns a new value to this Property.

See: set().

Definition at line 340 of file property.h.

References KDBindings::Property< T >::set().

◆ reset()

template<typename T >
void KDBindings::Property< T >::reset ( )
inline

Disconnects the binding from this Property.

If this Property has a binding, it will no longer update it. Otherwise, this function does nothing.

The value of the property does not change when it is reset.

Definition at line 278 of file property.h.

◆ set()

template<typename T >
void KDBindings::Property< T >::set ( value)
inline

Assign a new value to this Property.

If the new value is equal_to the existing value, the value will not be changed and no Signal will be emitted.

Otherwise, the valueAboutToChange() Signal will be emitted before the value of the Property is changed. Then, the provided value will be assigned, and the valueChanged() Signal will be emitted.

Exceptions
ReadOnlyPropertyIf the Property has a PropertyUpdater associated with it (i.e. it is the result of a binding expression).

Definition at line 317 of file property.h.

Referenced by KDBindings::Property< T >::operator=(), and KDBindings::operator>>().

◆ valueAboutToChange()

template<typename T >
Signal< const T &, const T & > & KDBindings::Property< T >::valueAboutToChange ( ) const
inline

Returns a Signal that will be emitted before the value is changed.

The first emitted value is the current value of the Property.
The second emitted value is the new value of the Property.

Definition at line 289 of file property.h.

◆ valueChanged()

template<typename T >
Signal< const T & > & KDBindings::Property< T >::valueChanged ( ) const
inline

Returns a Signal that will be emitted after the value of the property changed.

The emitted value is the current (new) value of the Property.

Definition at line 296 of file property.h.


The documentation for this class was generated from the following file:

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated by doxygen 1.9.8