XX CMake Package
Loading...
Searching...
No Matches
XXManagedTableView.h
Go to the documentation of this file.
1#ifndef XXManagedTableViewH
2#define XXManagedTableViewH
3
5#include <QTableView>
6
7namespace XX
8{
9 namespace Managed
10 {
14
15 class XXWIDGETS_DECLSPEC TableView : public QTableView
16 {
17 Q_OBJECT
18 public:
19 TableView(QWidget* parent);
20
21 public:
22 template <typename TargetClass>
23 void onSelected(TargetClass* instance, void (TargetClass::*memberFunction)(const QModelIndex&));
24
25 template <typename TargetClass>
26 void onDoubleClicked(TargetClass* instance, bool (TargetClass::*memberFunction)(const QModelIndex&));
27
28 template <typename TargetClass>
29 void onContextMenu(TargetClass* instance, QMenu* (TargetClass::*memberFunction)(const QModelIndex&));
30
31 void setModel(QAbstractItemModel* model) override;
32 QModelIndex currentSourceIndex() const;
33
34 private:
35 void selected(const QModelIndex& index);
36 void mouseDoubleClickEvent(QMouseEvent* event) override;
37 void contextMenuRequested(const QPoint& point);
38
39 private:
40 using SelectFunction = std::function<void(const QModelIndex&)>;
41 using DoubleClickFunction = std::function<bool(const QModelIndex&)>;
42 using MenuFunction = std::function<QMenu*(const QModelIndex&)>;
43
44 private:
45 QMetaObject::Connection selectConnetion;
46 SelectFunction selectedFunction;
47 DoubleClickFunction doubleClickFunction;
48 MenuFunction contextMenuFunction;
49 };
50 } // namespace Managed
51} // namespace XX
52
53#ifndef XXManagedTableViewHPP
54#include "XXManagedTableView.hpp"
55#endif // NOT XXManagedTableViewHPP
56
57#endif // NOT XXManagedTableViewH
#define XXWIDGETS_DECLSPEC
Definition XXWidgetsExportDef.h:11
void onDoubleClicked(TargetClass *instance, bool(TargetClass::*memberFunction)(const QModelIndex &))
TableView(QWidget *parent)
void setModel(QAbstractItemModel *model) override
void onSelected(TargetClass *instance, void(TargetClass::*memberFunction)(const QModelIndex &))
QModelIndex currentSourceIndex() const
void onContextMenu(TargetClass *instance, QMenu *(TargetClass::*memberFunction)(const QModelIndex &))
Definition XXManagedGraphicsView.h:10
Definition XXPopulatedAbstract.h:11