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