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