CCIMXDesktop
 
Loading...
Searching...
No Matches
HomeCardManager Class Reference

Manages a collection of QWidget instances displayed within a QStackedWidget. More...

#include <HomeCardManager.h>

Public Member Functions

 HomeCardManager (QStackedWidget *widget)
 Constructs a HomeCardManager instance.
 
 Q_DISABLE_COPY_MOVE (HomeCardManager)
 Disables copy construction and copy assignment for HomeCardManager.
 
virtual void installWidget (QWidget *widget)
 Installs a new widget into the managed QStackedWidget.
 
virtual void removeWidget (QWidget *widget)
 Removes a widget from the managed QStackedWidget.
 
virtual int accessible_card_cnt () const
 Returns the number of accessible cards (widgets) currently managed.
 

Protected Attributes

QStackedWidget * stacked_widget
 A pointer to the QStackedWidget managed by this class.
 
std::shared_ptr< QMutex > mutex
 A shared pointer to a QMutex for thread-safe access.
 

Detailed Description

Manages a collection of QWidget instances displayed within a QStackedWidget.

This class provides an interface for adding, removing, and querying the number of "cards" (widgets) managed by a QStackedWidget. It ensures thread-safe operations on the managed widgets through the use of a QMutex.

Note
This class is non-copyable and non-movable to ensure a single, controlled instance managing the QStackedWidget.

Constructor & Destructor Documentation

◆ HomeCardManager()

HomeCardManager::HomeCardManager ( QStackedWidget *  widget)
explicit

Constructs a HomeCardManager instance.

Parameters
widgetA pointer to the QStackedWidget that this manager will control. The manager does not take ownership of the QStackedWidget.

Member Function Documentation

◆ accessible_card_cnt()

int HomeCardManager::accessible_card_cnt ( ) const
virtual

Returns the number of accessible cards (widgets) currently managed.

  • This method provides a count of the widgets that are currently part of the QStackedWidget managed by this class. It ensures thread-safe access to this count.
    Returns
    The integer count of accessible widgets.

◆ installWidget()

void HomeCardManager::installWidget ( QWidget *  widget)
virtual

Installs a new widget into the managed QStackedWidget.

  • This method adds the provided widget to the QStackedWidget, making it available for display. It handles thread-safe access to the stacked widget.
    Parameters
    widgetA pointer to the QWidget to be installed. The manager takes ownership of the widget if the QStackedWidget takes ownership.

◆ Q_DISABLE_COPY_MOVE()

HomeCardManager::Q_DISABLE_COPY_MOVE ( HomeCardManager  )

Disables copy construction and copy assignment for HomeCardManager.

  • This macro ensures that instances of HomeCardManager cannot be copied, enforcing a single point of control over the managed QStackedWidget.

◆ removeWidget()

void HomeCardManager::removeWidget ( QWidget *  widget)
virtual

Removes a widget from the managed QStackedWidget.

  • This method removes the specified widget from the QStackedWidget. It handles thread-safe access. The caller is responsible for deleting the widget if the QStackedWidget does not manage its lifetime.
    Parameters
    widgetA pointer to the QWidget to be removed.

Member Data Documentation

◆ mutex

std::shared_ptr<QMutex> HomeCardManager::mutex
protected

A shared pointer to a QMutex for thread-safe access.

  • This mutex is used to protect concurrent access to the stacked_widget and its operations, ensuring data integrity in multithreaded environments.

◆ stacked_widget

QStackedWidget* HomeCardManager::stacked_widget
protected

A pointer to the QStackedWidget managed by this class.

  • This member holds the reference to the QStackedWidget where the "cards" (individual widgets) are displayed.

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