Loading...
Searching...
No Matches
DeviceExplorerDelegate.hpp
1#pragma once
2#include <QPointer>
3#include <QTimer>
4#include <QSet>
5#include <QStyledItemDelegate>
6
7#include <score_plugin_deviceexplorer_export.h>
8
9namespace Device
10{
11struct AddressSettings;
12}
13
14namespace Explorer
15{
17class SCORE_PLUGIN_DEVICEEXPLORER_EXPORT DeviceExplorerDelegate final
18 : public QStyledItemDelegate
19{
20public:
21 explicit DeviceExplorerDelegate(QObject* parent = nullptr);
23
25 static QModelIndex sourceIndex(const QModelIndex& index) noexcept;
26 static const Device::AddressSettings* addressAt(const QModelIndex& index) noexcept;
27
28private:
29 QWidget* createEditor(
30 QWidget* parent, const QStyleOptionViewItem& option,
31 const QModelIndex& index) const override;
32 void setEditorData(QWidget* editor, const QModelIndex& index) const override;
33 void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index)
34 const override;
35
38 void destroyEditor(QWidget* editor, const QModelIndex& index) const override;
39
41 bool owns(QWidget* editor) const noexcept { return m_live.contains(editor); }
42 void paint(
43 QPainter* painter, const QStyleOptionViewItem& option,
44 const QModelIndex& index) const override;
45
47 bool editorEvent(
48 QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option,
49 const QModelIndex& index) override;
50
53 void flash(const QModelIndex& index);
54
57 void watch(const QAbstractItemModel* model) const;
58
59 mutable QSet<QWidget*> m_live;
60 QPersistentModelIndex m_pressed;
61 mutable QList<QPersistentModelIndex> m_lit;
62 mutable QPointer<QTimer> m_unlit;
63 mutable QPointer<const QAbstractItemModel> m_seen;
64 mutable QPointer<const QAbstractItemModel> m_watched;
65 mutable QMetaObject::Connection m_traffic;
66 mutable QPointer<QWidget> m_surface;
67 void updateEditorGeometry(
68 QWidget* editor, const QStyleOptionViewItem& option,
69 const QModelIndex& index) const override;
70};
71}
Per-type editors for the Value column of the device explorer tree.
Definition DeviceExplorerDelegate.hpp:19
Manipulation of Devices from Qt.
Definition AddressSettings.cpp:14
Definition AddressSettings.hpp:49