DeviceExplorerWidget.hpp
1 #pragma once
2 
3 #include <Device/Node/DeviceNode.hpp>
4 
5 #include <Explorer/Explorer/ListeningManager.hpp>
6 
7 #include <score/command/Dispatchers/CommandDispatcher.hpp>
8 #include <score/model/tree/TreePath.hpp>
9 
10 #include <QWidget>
11 
12 #include <memory>
13 #include <verdigris>
14 
15 class QAction;
16 class QContextMenuEvent;
17 class QProgressIndicator;
18 class QStackedLayout;
19 
20 class QToolButton;
21 class QComboBox;
22 class QLineEdit;
23 class QTableView;
24 namespace score
25 {
26 struct GUIApplicationContext;
27 }
28 namespace Device
29 {
30 class ProtocolFactoryList;
31 class AddressDialog;
32 }
33 
34 namespace Explorer
35 {
36 class ExplorerSearchLineEdit;
37 class AddressItemModel;
38 class ListeningHandler;
39 class DeviceEditDialog;
40 class DeviceExplorerFilterProxyModel;
41 class DeviceExplorerModel;
42 class DeviceExplorerView;
43 class SCORE_PLUGIN_DEVICEEXPLORER_EXPORT DeviceExplorerWidget final : public QWidget
44 {
45  W_OBJECT(DeviceExplorerWidget)
46 
47 public:
48  explicit DeviceExplorerWidget(const Device::ProtocolFactoryList&, QWidget* parent);
49 
50  void setModel(DeviceExplorerModel* model);
51  DeviceExplorerModel* model() const;
52  DeviceExplorerView* view() const;
53 
54  // Will block the GUI when refreshing.
55  void blockGUI(bool);
56 
57  // Enable / disable actions that may change the devices.
58  void setEditable(bool);
59 
60  QModelIndex sourceIndex(QModelIndex) const;
61  QModelIndex proxyIndex(QModelIndex) const;
62 
63  ListeningManager& listeningManager() const { return *m_listeningManager; }
64 
65 private:
66  friend class ExplorerSearchLineEdit;
67  QSize sizeHint() const override;
68  // User commands
69  void edit();
70  void refresh();
71  void refreshValue();
72 
73  void disconnect();
74  void reconnect();
75 
76  void addAddress(InsertMode insertType);
77  void addDevice();
78  void exportDevice();
79  void addChild();
80  void addSibling();
81 
82  void removeNodes();
83  void learn();
84  void findUsage();
85 
86  // Answer to user interaction
87  void updateActions();
88  void updateAddressView();
89 
90  bool editable() const noexcept;
91 
92  // Utilities
93  DeviceExplorerFilterProxyModel* proxyModel();
94 
95  void buildGUI();
96  void populateColumnCBox();
97 
98  void contextMenuEvent(QContextMenuEvent* event) override;
99 
100  const Device::ProtocolFactoryList& m_protocolList;
101 
102  DeviceExplorerView* m_ntView{};
103  DeviceExplorerFilterProxyModel* m_proxyModel{};
104  QPointer<DeviceEditDialog> m_deviceDialog{};
105  AddressItemModel* m_addressModel{};
106  QTableView* m_addressView{};
107 
108  QAction* m_disconnect{};
109  QAction* m_reconnect{};
110 
111  QAction* m_editAction{};
112  QAction* m_refreshAction{};
113  QAction* m_refreshValueAction{};
114  QAction* m_addDeviceAction{};
115  QAction* m_addSiblingAction{};
116  QAction* m_addChildAction{};
117  QAction* m_exportDeviceAction{};
118 
119  QAction* m_removeNodeAction{};
120  QAction* m_learnAction{};
121  QAction* m_findUsageAction{};
122 
123  QComboBox* m_columnCBox{};
124  ExplorerSearchLineEdit* m_nameLEdit{};
125 
126  std::unique_ptr<CommandDispatcher<>> m_cmdDispatcher;
127 
128  QProgressIndicator* m_refreshIndicator{};
129  QStackedLayout* m_lay{};
130 
131  QToolButton* m_openMenu{};
132 
133  std::unique_ptr<ListeningManager> m_listeningManager;
134  QMetaObject::Connection m_modelCon;
135 
136  QMetaObject::Connection m_addressCon;
137 
138 public:
139  void findAddresses(QStringList strlst)
140  E_SIGNAL(SCORE_PLUGIN_DEVICEEXPLORER_EXPORT, findAddresses, strlst)
141 
142 private:
143  void do_addAddress(
144  InsertMode insert, QModelIndex index, Device::Node* parent,
146 };
147 
148 SCORE_PLUGIN_DEVICEEXPLORER_EXPORT
150 findDeviceExplorerWidgetInstance(const score::GUIApplicationContext& ctx) noexcept;
151 }
Definition: ProtocolList.hpp:10
Displays an address.
Definition: AddressItemModel.hpp:34
Definition: DeviceExplorerFilterProxyModel.hpp:13
Definition: DeviceExplorerModel.hpp:67
Definition: DeviceExplorerView.hpp:18
Definition: DeviceExplorerWidget.hpp:44
Definition: DeviceExplorerWidget.cpp:114
Definition: ListeningManager.hpp:15
Manipulation of Devices from Qt.
Definition: AddressSettings.cpp:14
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: AddressSettings.hpp:49
Specializes ApplicationContext with the QMainWindow.
Definition: GUIApplicationContext.hpp:15