-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselectioncontroller.h
81 lines (75 loc) · 2.95 KB
/
selectioncontroller.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#pragma once
#include <QObject>
#include <QPoint>
#include <QRect>
#include <subtablemodel.h>
class PrivateSelectionController;
class SelectionController : public QObject
{
Q_OBJECT
Q_PROPERTY(int startRow READ startRow WRITE setStartRow NOTIFY startRowChanged)
Q_PROPERTY(int startColumn READ startColumn WRITE setStartColumn NOTIFY startColumnChanged)
Q_PROPERTY(int endRow READ endRow WRITE setEndRow NOTIFY endRowChanged)
Q_PROPERTY(int endColumn READ endColumn WRITE setEndColumn NOTIFY endColumnChanged)
Q_PROPERTY(int activeRow READ activeRow WRITE setActiveRow NOTIFY activeRowChanged)
Q_PROPERTY(int activeColumn READ activeColumn WRITE setActiveColumn NOTIFY activeColumnChanged)
Q_PROPERTY(bool mouseSelection READ mouseSelection WRITE setMouseSelection NOTIFY mouseSelectionChanged)
Q_PROPERTY(bool disable READ disable WRITE setDisable NOTIFY disableChanged)
Q_PROPERTY(QPoint activeCell READ activeCell WRITE setActiveCell NOTIFY activeCellChanged)
Q_PROPERTY(QRect selectedArea READ selectedArea WRITE setSelectedArea NOTIFY selectedAreaChanged)
Q_PROPERTY(QAbstractItemModel* model READ model WRITE setModel NOTIFY modelChanged)
public:
static const QString ITEM_NAME; // SelectionController
static const bool IS_QML_REG;
SelectionController(QObject *parent = nullptr);
SelectionController(QAbstractItemModel *model, QObject *parent = nullptr);
virtual ~SelectionController() = default;
Q_INVOKABLE void normalizeBounds();
Q_INVOKABLE void collapseToActive();
int startRow() const;
void setStartRow(int startRow);
int startColumn() const;
void setStartColumn(int startColumn);
int endRow() const;
void setEndRow(int endRow);
int endColumn() const;
void setEndColumn(int endColumn);
int activeRow() const;
void setActiveRow(int activeRow);
int activeColumn() const;
void setActiveColumn(int activeColumn);
bool mouseSelection() const;
void setMouseSelection(bool mouseSelection);
bool disable() const;
void setDisable(bool disable);
QPoint activeCell() const;
void setActiveCell(const QPoint &active);
QRect selectedArea() const;
void setSelectedArea(const QRect &selectedArea);
QAbstractItemModel *model() const;
void setModel(QAbstractItemModel *model);
QString toString() const;
signals:
void startRowChanged();
void startColumnChanged();
void endRowChanged();
void endColumnChanged();
void activeRowChanged();
void activeColumnChanged();
void mouseSelectionChanged();
void disableChanged();
void activeCellChanged();
void selectedAreaChanged();
void modelChanged();
private:
int _startRow = -1;
int _startColumn = -1;
int _endRow = -1;
int _endColumn = -1;
int _activeRow = -1;
int _activeColumn = -1;
bool _mouseSelection = false;
bool _disable = false;
QAbstractItemModel *_model = nullptr;
PrivateSelectionController *_private = nullptr;
};