KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
Public Member Functions | List of all members
KDBindings::ConnectionHandle Class Reference

A ConnectionHandle represents the connection of a Signal to a slot (i.e. a function that is called when the Signal is emitted). More...

#include <signal.h>

Public Member Functions

 ConnectionHandle ()=default
 
 ConnectionHandle (ConnectionHandle &&)=default
 
 ConnectionHandle (const ConnectionHandle &)=default
 
template<typename... Args>
bool belongsTo (const Signal< Args... > &signal) const
 
bool block (bool blocked)
 
void disconnect ()
 
bool isActive () const
 
bool isBlocked () const
 
ConnectionHandleoperator= (ConnectionHandle &&)=default
 
ConnectionHandleoperator= (const ConnectionHandle &)=default
 

Detailed Description

A ConnectionHandle represents the connection of a Signal to a slot (i.e. a function that is called when the Signal is emitted).

It is returned from a Signal when a connection is created and used to manage the connection by disconnecting, (un)blocking it and checking its state.

To make sure a Connection to an object is disconnected correctly, consider storing a ScopedConnection to its ConnectionHandle inside the object.

Definition at line 67 of file signal.h.

Constructor & Destructor Documentation

◆ ConnectionHandle() [1/3]

KDBindings::ConnectionHandle::ConnectionHandle ( )
default

A ConnectionHandle can be default constructed. In this case the ConnectionHandle will not reference any active connection (i.e. isActive() will return false), and not belong to any Signal.

◆ ConnectionHandle() [2/3]

KDBindings::ConnectionHandle::ConnectionHandle ( const ConnectionHandle )
default

A ConnectionHandle can be copied.

◆ ConnectionHandle() [3/3]

KDBindings::ConnectionHandle::ConnectionHandle ( ConnectionHandle &&  )
default

A ConnectionHandle can be moved.

Member Function Documentation

◆ belongsTo()

template<typename... Args>
bool KDBindings::ConnectionHandle::belongsTo ( const Signal< Args... > &  signal) const
inline

Check whether this ConnectionHandle belongs to the given Signal.

Returns
true if this ConnectionHandle refers to a connection within the given Signal

Definition at line 166 of file signal.h.

Referenced by KDBindings::Signal< Args >::blockConnection(), KDBindings::Signal< Args >::disconnect(), and KDBindings::Signal< Args >::isConnectionBlocked().

◆ block()

bool KDBindings::ConnectionHandle::block ( bool  blocked)
inline

Sets the block state of the connection. If a connection is blocked, emitting the Signal will no longer call this connections slot, until the connection is unblocked.

Behaves the same as calling Signal::blockConnection with this ConnectionHandle as argument.

To temporarily block a connection, consider using an instance of ConnectionBlocker, which offers a RAII-style implementation that makes sure the connection is always returned to its original state.

Parameters
blockedThe new blocked state of the connection.
Returns
whether the connection was previously blocked.
Exceptions
std::out_of_rangeThrows if the connection is not active (i.e. isActive() returns false).

Definition at line 137 of file signal.h.

Referenced by KDBindings::ConnectionBlocker::ConnectionBlocker().

◆ disconnect()

void KDBindings::ConnectionHandle::disconnect ( )
inline

Disconnect the slot.

When this function is called, the function that was passed to Signal::connect to create this ConnectionHandle will no longer be called when the Signal is emitted.

If the ConnectionHandle is not active or the connection has already been disconnected, nothing happens.

After this call, the ConnectionHandle will be inactive (i.e. isActive() returns false) and will no longer belong to any Signal (i.e. belongsTo returns false).

Definition at line 101 of file signal.h.

Referenced by KDBindings::Private::PropertyNode< PropertyType >::~PropertyNode(), and KDDockWidgets::Core::ViewGuard::clear().

◆ isActive()

bool KDBindings::ConnectionHandle::isActive ( ) const
inline

Check whether the connection of this ConnectionHandle is active.

Returns
true if the ConnectionHandle refers to an active Signal and the connection was not disconnected previously, false otherwise.

Definition at line 116 of file signal.h.

◆ isBlocked()

bool KDBindings::ConnectionHandle::isBlocked ( ) const
inline

Checks whether the connection is currently blocked.

To change the blocked state of a connection, call ConnectionHandle::block.

Returns
whether the connection is currently blocked.

Definition at line 152 of file signal.h.

◆ operator=() [1/2]

ConnectionHandle & KDBindings::ConnectionHandle::operator= ( ConnectionHandle &&  )
default

◆ operator=() [2/2]

ConnectionHandle & KDBindings::ConnectionHandle::operator= ( const ConnectionHandle )
default

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