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 
14 class QComboBox;
15 class QFormLayout;
16 class QWidget;
17 class QListWidget;
18 class QTreeWidget;
19 class QLabel;
20 class QDialogButtonBox;
21 
22 namespace Device
23 {
24 class ProtocolFactoryList;
25 class ProtocolSettingsWidget;
26 class DeviceEnumerator;
27 }
28 namespace Explorer
29 {
30 class DeviceExplorerModel;
31 class SCORE_PLUGIN_DEVICEEXPLORER_EXPORT DeviceEditDialog final : public QDialog
32 {
33  W_OBJECT(DeviceEditDialog)
34 
35 public:
36  enum Mode
37  {
38  Creating,
39  Editing
40  };
41  explicit DeviceEditDialog(
42  const DeviceExplorerModel& model, const Device::ProtocolFactoryList& pl, Mode mode,
43  QWidget* parent);
45 
46  Device::DeviceSettings getSettings() const;
47  Device::Node getDevice() const;
48 
49  void setSettings(const Device::DeviceSettings& settings);
50 
51  // This mode will display a warning to
52  // the user if he has to edit the device again.
53  void setAcceptEnabled(bool);
54 
55  // enable protocol & device browsing
56  void setBrowserEnabled(bool);
57 
58  void updateValidity();
59 
60 private:
61  void selectedProtocolChanged();
62  void selectedDeviceChanged();
63  void initAvailableProtocols();
64 
65  const DeviceExplorerModel& m_model;
66  const Device::ProtocolFactoryList& m_protocolList;
67  Mode m_mode{};
68  std::vector<std::pair<QString, std::unique_ptr<Device::DeviceEnumerator>>>
69  m_enumerators;
70 
71  QSplitter* m_splitter{};
72  QDialogButtonBox* m_buttonBox{};
73  QPushButton* m_okButton{};
74  QPushButton* m_helpButton{};
75  QTreeWidget* m_protocols{};
76  QTreeWidget* m_devices{};
77  QWidget* m_main{};
78  QLabel* m_protocolsLabel{};
79  QLabel* m_devicesLabel{};
80  Device::ProtocolSettingsWidget* m_protocolWidget{};
81  QFormLayout* m_settingsFormLayout{};
82  QList<Device::DeviceSettings> m_previousSettings;
83  QLabel* m_invalidLabel{};
84  QLabel* m_protocolNameLabel{};
85 
86  QString m_originalName{};
87  int m_index{};
88 };
89 }
Definition: ProtocolList.hpp:10
Definition: ProtocolSettingsWidget.hpp:22
Definition: DeviceEditDialog.hpp:32
Definition: DeviceExplorerModel.hpp:67
Manipulation of Devices from Qt.
Definition: AddressSettings.cpp:14
Definition: DeviceSettings.hpp:20