-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprivateselectioncontroller.cpp
57 lines (51 loc) · 2.6 KB
/
privateselectioncontroller.cpp
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
#include "privateselectioncontroller.h"
const QList<QPair<void (PrivateSelectionController::*)(),
void (SelectionController::*)()>> PrivateSelectionController::_signalsSelection {
{ &PrivateSelectionController::signalStartRowChanged, &SelectionController::startRowChanged },
{ &PrivateSelectionController::signalStartColumnChanged, &SelectionController::startColumnChanged },
{ &PrivateSelectionController::signalEndRowChanged, &SelectionController::endRowChanged },
{ &PrivateSelectionController::signalEndColumnChanged, &SelectionController::endColumnChanged },
{ &PrivateSelectionController::signalMouseSelectionChanged, &SelectionController::mouseSelectionChanged },
};
const QList<QPair<void (PrivateSelectionController::*)(),
void (SelectionController::*)()>> PrivateSelectionController::_signalsActive {
{ &PrivateSelectionController::signalActiveRowChanged, &SelectionController::activeRowChanged },
{ &PrivateSelectionController::signalActiveColumnChanged, &SelectionController::activeColumnChanged },
};
PrivateSelectionController::PrivateSelectionController(SelectionController *parent)
: QObject(parent), _parent(parent) {
for (const auto &sig: _signalsActive) {
connect(this, sig.first, _parent, sig.second);
}
for (const auto &sig: _signalsSelection) {
connect(this, sig.first, _parent, sig.second);
}
connect(this, &PrivateSelectionController::signalActiveCellChanged,
parent, &SelectionController::activeCellChanged);
connect(this, &PrivateSelectionController::signalSelectedAreaChanged,
parent, &SelectionController::selectedAreaChanged);
connect(this, &PrivateSelectionController::signalModelChanged,
parent, &SelectionController::modelChanged);
connectActiveCell();
connectSelectedArea();
}
void PrivateSelectionController::connectActiveCell() {
for (const auto &sig: _signalsActive) {
connect(this, sig.first, _parent, &SelectionController::activeCellChanged);
}
}
void PrivateSelectionController::disconnectActiveCell() {
for (const auto &sig: _signalsActive) {
disconnect(this, sig.first, _parent, &SelectionController::activeCellChanged);
}
}
void PrivateSelectionController::connectSelectedArea() {
for (const auto &sig: _signalsSelection) {
connect(this, sig.first, _parent, &SelectionController::selectedAreaChanged);
}
}
void PrivateSelectionController::disconnectSelectedArea() {
for (const auto &sig: _signalsSelection) {
disconnect(this, sig.first, _parent, &SelectionController::selectedAreaChanged);
}
}