VR-Engage  2.2
Loading...
Searching...
No Matches
spectatorItemDelegate.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file spectatorItemDelegate.h
7//! \ingroup vreManager
8//! \brief Spectator mode item delegate for VREngage Manager
9//!
10//! This file defines the DtSpectatorItemDelegate class, which is responsible for
11//! providing a customized checkbox editor for spectator mode selection in the VREngage Manager.
12
13#pragma once
14
15#include "vreManager/export.h"
16
17#include <QStyledItemDelegate>
18#include <QCheckBox>
19
20//! \brief Custom item delegate for spectator mode selection
21//!
22//! This delegate provides a checkbox editor for toggling spectator mode in the VREngage
23//! Manager interface. It handles the creation, display, and manipulation of the
24//! checkbox editor for spectator mode cells in the manager's table view.
25class VREMANAGER_DLL DtSpectatorItemDelegate : public QStyledItemDelegate
26{
27 Q_OBJECT
28public:
29 //! \brief Constructor
30 //! \param parent The parent object
31 //!
32 //! Initializes a new spectator item delegate with the specified parent.
33 DtSpectatorItemDelegate(QObject* parent = 0);
34
35 //! \brief Destructor
36 //!
37 //! Cleans up resources used by the spectator item delegate.
38 virtual ~DtSpectatorItemDelegate() override;
39
40 //! \brief Creates a checkbox editor for spectator mode selection
41 //! \param parent The parent widget
42 //! \param option The style options to use when drawing the editor
43 //! \param index The model index of the item being edited
44 //! \return A checkbox widget configured for spectator mode selection
45 //!
46 //! Creates and configures a checkbox editor for toggling spectator mode.
47 virtual QWidget* createEditor(
48 QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
49
50 //! \brief Destroys the editor when editing is finished
51 //! \param editor The editor widget to destroy
52 //! \param index The model index of the item that was being edited
53 //!
54 //! Handles cleanup of the editor widget when editing is complete.
55 virtual void destroyEditor(QWidget* editor, const QModelIndex& index) const override;
56
57 //! \brief Sets the editor data based on the model index
58 //! \param editor The editor widget to update
59 //! \param index The model index containing the data to edit
60 //!
61 //! Populates the checkbox with data from the model (checked/unchecked state).
62 virtual void setEditorData(QWidget* editor, const QModelIndex& index) const override;
63
64 //! \brief Updates the model with data from the editor
65 //! \param editor The editor widget containing the updated data
66 //! \param model The model to update
67 //! \param index The model index to update
68 //!
69 //! Transfers the checkbox state back to the model when editing is complete.
70 virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
71
72 //! \brief Custom painting for the checkbox in the view
73 //! \param painter The painter to use for drawing
74 //! \param option The style options to use when drawing
75 //! \param index The model index of the item to draw
76 //!
77 //! Handles custom drawing of the checkbox in the view when not being edited.
78 virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
79
80 //! \brief Updates the editor's geometry
81 //! \param editor The editor widget to update
82 //! \param option The style options to use when positioning
83 //! \param index The model index of the item being edited
84 //!
85 //! Positions the checkbox editor appropriately in the cell.
87 QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
88
89protected slots:
90 //! \brief Handles checkbox state changes
91 //! \param state The new state of the checkbox
92 //!
93 //! Called when the checkbox state changes between checked and unchecked.
94 virtual void onStateChanged(int state);
95
96protected:
97 //! \brief The checkbox editor widget
98 //!
99 //! Maintains a reference to the currently active checkbox editor.
100 //! Declared mutable to allow modification in const methods.
101 mutable QCheckBox* myEditor;
102};
virtual ~DtSpectatorItemDelegate() override
Destructor.
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Custom painting for the checkbox in the view.
DtSpectatorItemDelegate(QObject *parent=0)
Constructor.
virtual void destroyEditor(QWidget *editor, const QModelIndex &index) const override
Destroys the editor when editing is finished.
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const override
Sets the editor data based on the model index.
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Updates the model with data from the editor.
QCheckBox * myEditor
The checkbox editor widget.
Definition spectatorItemDelegate.h:101
virtual void onStateChanged(int state)
Handles checkbox state changes.
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Updates the editor's geometry.
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Creates a checkbox editor for spectator mode selection.
Export macros for the VREngage Manager library.
#define VREMANAGER_DLL
Platform-specific export/import macro for VREngage Manager library.
Definition export.h:28