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 <QWidget>
11
12#include <memory>
13#include <verdigris>
14
15class QAction;
16class QContextMenuEvent;
17class QProgressIndicator;
18class QStackedLayout;
19
20class QToolButton;
21class QComboBox;
22class QLineEdit;
23class QTableView;
24namespace score
25{
26struct GUIApplicationContext;
27}
28namespace Device
29{
30class ProtocolFactoryList;
31class AddressDialog;
32}
33
34namespace Explorer
35{
36class ExplorerSearchLineEdit;
37class AddressItemModel;
38class ListeningHandler;
39class DeviceEditDialog;
40class DeviceExplorerFilterProxyModel;
41class DeviceExplorerModel;
42class DeviceExplorerView;
43class SCORE_PLUGIN_DEVICEEXPLORER_EXPORT DeviceExplorerWidget final : public QWidget
44{
45 W_OBJECT(DeviceExplorerWidget)
46
47public:
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
65private:
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 importDevice();
79 void exportDevice();
80 void addChild();
81 void addSibling();
82
83 void removeNodes();
84 void learn();
85 void findUsage();
86
87 // Answer to user interaction
88 void updateActions();
89 void updateAddressView();
90
91 bool editable() const noexcept;
92
93 // Utilities
95
96 void buildGUI();
97 void populateColumnCBox();
98
99 void contextMenuEvent(QContextMenuEvent* event) override;
100
101 const Device::ProtocolFactoryList& m_protocolList;
102
103 DeviceExplorerView* m_ntView{};
104 DeviceExplorerFilterProxyModel* m_proxyModel{};
105 QPointer<DeviceEditDialog> m_deviceDialog{};
106 AddressItemModel* m_addressModel{};
107 QTableView* m_addressView{};
108
109 QAction* m_disconnect{};
110 QAction* m_reconnect{};
111
112 QAction* m_editAction{};
113 QAction* m_refreshAction{};
114 QAction* m_refreshValueAction{};
115 QAction* m_addDeviceAction{};
116 QAction* m_addSiblingAction{};
117 QAction* m_addChildAction{};
118 QAction* m_importDeviceAction{};
119 QAction* m_exportDeviceAction{};
120
121 QAction* m_removeNodeAction{};
122 QAction* m_learnAction{};
123 QAction* m_findUsageAction{};
124
125 QComboBox* m_columnCBox{};
126 ExplorerSearchLineEdit* m_nameLEdit{};
127
128 std::unique_ptr<CommandDispatcher<>> m_cmdDispatcher;
129
130 QProgressIndicator* m_refreshIndicator{};
131 QStackedLayout* m_lay{};
132
133 QToolButton* m_openMenu{};
134
135 std::unique_ptr<ListeningManager> m_listeningManager;
136 QMetaObject::Connection m_modelCon;
137
138 QMetaObject::Connection m_addressCon;
139
140public:
141 void findAddresses(QStringList strlst)
142 E_SIGNAL(SCORE_PLUGIN_DEVICEEXPLORER_EXPORT, findAddresses, strlst)
143
144private:
145 void do_addAddress(
146 InsertMode insert, QModelIndex index, Device::Node* parent,
148};
149
150SCORE_PLUGIN_DEVICEEXPLORER_EXPORT
152findDeviceExplorerWidgetInstance(const score::GUIApplicationContext& ctx) noexcept;
153}
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:115
Definition ListeningManager.hpp:15
Manipulation of Devices from Qt.
Definition AddressSettings.cpp:14
Base toolkit upon which the software is built.
Definition Application.cpp:113
Definition AddressSettings.hpp:49
Specializes ApplicationContext with the QMainWindow.
Definition GUIApplicationContext.hpp:15