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
63private:
64 void selectedProtocolChanged();
65 void selectedDeviceChanged();
66 void selectedPresetChanged();
67 void initAvailableProtocols();
68 void initPresets();
69
70 const DeviceExplorerModel& m_model;
71 const Device::ProtocolFactoryList& m_protocolList;
72 Mode m_mode{};
73 std::vector<std::pair<QString, std::unique_ptr<Device::DeviceEnumerator>>>
74 m_enumerators;
75
76 QSplitter* m_splitter{};
77 QDialogButtonBox* m_buttonBox{};
78 QPushButton* m_okButton{};
79 QPushButton* m_helpButton{};
80
81 // Column 1: tab buttons + stacked protocols/presets
82 QPushButton* m_protocolsTabButton{};
83 QPushButton* m_presetsTabButton{};
84 QStackedWidget* m_column1Stack{};
85 QTreeWidget* m_protocols{};
86 QTreeWidget* m_presets{};
87
88 QTreeWidget* m_devices{};
89 // QWidget* m_main{};
90 QLabel* m_devicesLabel{};
91 Device::ProtocolSettingsWidget* m_protocolWidget{};
92 // QFormLayout* m_settingsFormLayout{};
93 QVBoxLayout* m_column3Layout{};
94 QList<Device::DeviceSettings> m_previousSettings;
95 QLabel* m_invalidLabel{};
96 QLabel* m_protocolNameLabel{};
97
98 // For presets: the loaded node with full address tree
99 Device::Node m_presetNode{};
100
101 QString m_originalName{};
102 int m_index{};
103};
104}
Definition ProtocolList.hpp:10
Definition ProtocolSettingsWidget.hpp:27
Definition DeviceEditDialog.hpp:35
Definition DeviceExplorerModel.hpp:67
Manipulation of Devices from Qt.
Definition AddressSettings.cpp:14
Definition DeviceSettings.hpp:20