Loading...
Searching...
No Matches
DeviceEditDialog.hpp
1#pragma once
2
3#include <score/tools/RecursiveWatch.hpp>
4
5#include <Device/Node/DeviceNode.hpp>
6#include <Device/Protocol/DeviceSettings.hpp>
7
8#include <QDialog>
9#include <QList>
10#include <QSplitter>
11
12#include <score_plugin_deviceexplorer_export.h>
13
14#include <verdigris>
15
16class QComboBox;
17class QFormLayout;
18class QWidget;
19class QListWidget;
20class QTreeWidget;
21class QLineEdit;
22class QStackedWidget;
23class QVBoxLayout;
24class QLabel;
25class QDialogButtonBox;
26class QPushButton;
27class QTimer;
28
29namespace Device
30{
31class ProtocolFactoryList;
32class ProtocolSettingsWidget;
33class DeviceEnumerator;
34}
35namespace Explorer
36{
37class DeviceExplorerModel;
38class TreeSearchLineEdit;
39class SCORE_PLUGIN_DEVICEEXPLORER_EXPORT DeviceEditDialog final : public QDialog
40{
41 W_OBJECT(DeviceEditDialog)
42
43public:
44 enum Mode
45 {
46 Creating,
47 Editing
48 };
49 explicit DeviceEditDialog(
50 const DeviceExplorerModel& model, const Device::ProtocolFactoryList& pl, Mode mode,
51 QWidget* parent);
53
54 Device::DeviceSettings getSettings() const;
55 Device::Node getDevice() const;
56
57 void setSettings(const Device::DeviceSettings& settings);
58
59 // This mode will display a warning to
60 // the user if he has to edit the device again.
61 void setAcceptEnabled(bool);
62
63 // enable protocol & device browsing
64 void setBrowserEnabled(bool);
65
66 void updateValidity();
67
71 QTreeWidget* devicesTree() const noexcept { return m_devices; }
72
74 QTreeWidget* protocolsTree() const noexcept { return m_protocols; }
75
77 QLineEdit* protocolsFilter() const noexcept;
78
79protected:
80 void showEvent(QShowEvent* ev) override;
81
82private:
83 void selectedProtocolChanged();
84 void flushProtocolChange();
85 void selectedDeviceChanged();
86 void selectedPresetChanged();
87 QString editedDeviceName() const;
88 void initAvailableProtocols();
89 void initPresets();
90 void queuePresetSort();
91 void clearEnumerators();
92
93 const DeviceExplorerModel& m_model;
94 const Device::ProtocolFactoryList& m_protocolList;
95 Mode m_mode{};
96 std::vector<std::pair<QString, std::unique_ptr<Device::DeviceEnumerator>>>
97 m_enumerators;
98 // Receiver of every enumerator connection of the current selection: it is
99 // deleted before the QTreeWidgetItems those connections capture, which makes
100 // Qt discard the queued metacalls still posted to it.
101 QObject* m_enumeratorContext{};
102 score::RecursiveWatch m_presetWatch;
103
104 QSplitter* m_splitter{};
105 QDialogButtonBox* m_buttonBox{};
106 QPushButton* m_okButton{};
107 QPushButton* m_helpButton{};
108 QTimer* m_protocolChangeTimer{};
109
110 // Column 1: tab buttons + stacked protocols/presets
111 QPushButton* m_protocolsTabButton{};
112 QPushButton* m_presetsTabButton{};
113 QStackedWidget* m_column1Stack{};
114 QTreeWidget* m_protocols{};
115 QTreeWidget* m_presets{};
116 TreeSearchLineEdit* m_protocolsSearch{};
117 TreeSearchLineEdit* m_presetsSearch{};
118
119 QTreeWidget* m_devices{};
120 TreeSearchLineEdit* m_devicesSearch{};
121 // QWidget* m_main{};
122 QLabel* m_devicesLabel{};
123 Device::ProtocolSettingsWidget* m_protocolWidget{};
124 // QFormLayout* m_settingsFormLayout{};
125 QVBoxLayout* m_column3Layout{};
126 QList<Device::DeviceSettings> m_previousSettings;
127 QLabel* m_invalidLabel{};
128 QLabel* m_protocolNameLabel{};
129
130 // For presets: the loaded node with full address tree
131 Device::Node m_presetNode{};
132
133 QString m_originalName{};
134 int m_index{};
135 // The preset scan delivers in batches: sort once per batch, not per file.
136 bool m_presetSortQueued{};
137};
138}
Definition ProtocolList.hpp:10
Definition ProtocolSettingsWidget.hpp:29
Definition DeviceEditDialog.hpp:40
QTreeWidget * protocolsTree() const noexcept
The tree listing the available protocols.
Definition DeviceEditDialog.hpp:74
QTreeWidget * devicesTree() const noexcept
Definition DeviceEditDialog.hpp:71
Definition DeviceExplorerModel.hpp:67
Definition RecursiveWatch.hpp:20
Manipulation of Devices from Qt.
Definition AddressSettings.cpp:14
Definition DeviceSettings.hpp:20