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