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;
24
25namespace Device
26{
27class ProtocolFactoryList;
28class ProtocolSettingsWidget;
29class DeviceEnumerator;
30}
31namespace Explorer
32{
33class DeviceExplorerModel;
34class SCORE_PLUGIN_DEVICEEXPLORER_EXPORT DeviceEditDialog final : public QDialog
35{
36 W_OBJECT(DeviceEditDialog)
37
38public:
39 enum Mode
40 {
41 Creating,
42 Editing
43 };
44 explicit DeviceEditDialog(
45 const DeviceExplorerModel& model, const Device::ProtocolFactoryList& pl, Mode mode,
46 QWidget* parent);
48
49 Device::DeviceSettings getSettings() const;
50 Device::Node getDevice() const;
51
52 void setSettings(const Device::DeviceSettings& settings);
53
54 // This mode will display a warning to
55 // the user if he has to edit the device again.
56 void setAcceptEnabled(bool);
57
58 // enable protocol & device browsing
59 void setBrowserEnabled(bool);
60
61 void updateValidity();
62
66 QTreeWidget* devicesTree() const noexcept { return m_devices; }
67
68private:
69 void selectedProtocolChanged();
70 void selectedDeviceChanged();
71 void selectedPresetChanged();
72 QString editedDeviceName() const;
73 void initAvailableProtocols();
74 void initPresets();
75 void clearEnumerators();
76
77 const DeviceExplorerModel& m_model;
78 const Device::ProtocolFactoryList& m_protocolList;
79 Mode m_mode{};
80 std::vector<std::pair<QString, std::unique_ptr<Device::DeviceEnumerator>>>
81 m_enumerators;
82 // Receiver of every enumerator connection of the current selection: it is
83 // deleted before the QTreeWidgetItems those connections capture, which makes
84 // Qt discard the queued metacalls still posted to it.
85 QObject* m_enumeratorContext{};
86
87 QSplitter* m_splitter{};
88 QDialogButtonBox* m_buttonBox{};
89 QPushButton* m_okButton{};
90 QPushButton* m_helpButton{};
91
92 // Column 1: tab buttons + stacked protocols/presets
93 QPushButton* m_protocolsTabButton{};
94 QPushButton* m_presetsTabButton{};
95 QStackedWidget* m_column1Stack{};
96 QTreeWidget* m_protocols{};
97 QTreeWidget* m_presets{};
98
99 QTreeWidget* m_devices{};
100 // QWidget* m_main{};
101 QLabel* m_devicesLabel{};
102 Device::ProtocolSettingsWidget* m_protocolWidget{};
103 // QFormLayout* m_settingsFormLayout{};
104 QVBoxLayout* m_column3Layout{};
105 QList<Device::DeviceSettings> m_previousSettings;
106 QLabel* m_invalidLabel{};
107 QLabel* m_protocolNameLabel{};
108
109 // For presets: the loaded node with full address tree
110 Device::Node m_presetNode{};
111
112 QString m_originalName{};
113 int m_index{};
114};
115}
Definition ProtocolList.hpp:10
Definition ProtocolSettingsWidget.hpp:27
Definition DeviceEditDialog.hpp:35
QTreeWidget * devicesTree() const noexcept
Definition DeviceEditDialog.hpp:66
Definition DeviceExplorerModel.hpp:67
Manipulation of Devices from Qt.
Definition AddressSettings.cpp:14
Definition DeviceSettings.hpp:20