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