DeviceExplorerView.hpp
1 #pragma once
2 
3 #include <QAbstractItemModel>
4 #include <QList>
5 #include <QTreeView>
6 
7 #include <verdigris>
8 class QAction;
9 class QItemSelection;
10 class QPoint;
11 class QWidget;
12 
13 namespace Explorer
14 {
15 class DeviceExplorerFilterProxyModel;
16 class DeviceExplorerModel;
17 class DeviceExplorerView final : public QTreeView
18 {
19  W_OBJECT(DeviceExplorerView)
20 
21 public:
22  explicit DeviceExplorerView(QWidget* parent = nullptr);
23  ~DeviceExplorerView() override;
24 
25  void setModel(QAbstractItemModel* model) override;
26  void setModel(DeviceExplorerFilterProxyModel* model);
27 
28  DeviceExplorerModel* model();
29  const DeviceExplorerModel* model() const;
30 
31  void setSelectedIndex(const QModelIndex& index);
32 
33  QModelIndexList selectedIndexes() const override;
34  QModelIndex selectedIndex() const;
35 
36  bool hasProxy() const;
37 
38 public:
39  void selectionChanged() W_SIGNAL(selectionChanged, ());
40  void created(QModelIndex parent, int start, int end)
41  W_SIGNAL(created, parent, start, end);
42 
43 private:
44  void selectionChanged(
45  const QItemSelection& selected, const QItemSelection& deselected) override;
46  W_SLOT(selectionChanged, (const QItemSelection&, const QItemSelection&));
47 
48  void headerMenuRequested(const QPoint& pos);
49  W_SLOT(headerMenuRequested);
50  void columnVisibilityChanged(bool shown);
51  W_SLOT(columnVisibilityChanged);
52 
53 private:
54  void keyPressEvent(QKeyEvent*) override;
55 
56  QModelIndexList selectedDraggableIndexes() const;
57  void startDrag(Qt::DropActions supportedActions) override;
58  void rowsInserted(const QModelIndex& parent, int start, int end) override;
59  void saveSettings();
60  void restoreSettings();
61  void setInitialColumnsSizes();
62 
63  void initActions();
64 
65  QList<QAction*> m_actions;
66 
67  bool m_hasProxy{};
68 
69  // QWidget interface
70 protected:
71  void paintEvent(QPaintEvent* event) override;
72 };
73 }
Definition: DeviceExplorerFilterProxyModel.hpp:13
Definition: DeviceExplorerModel.hpp:67
Definition: DeviceExplorerView.hpp:18