-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommands.cpp
45 lines (36 loc) · 1.46 KB
/
commands.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
#include "commands.h"
AddMeasurementsAtPosition::AddMeasurementsAtPosition(
Measurements *measurements, Position position,
QVector<MeasurementEntry> values)
: mMeasurements(measurements), mPosition(position), mValues(values) {}
void AddMeasurementsAtPosition::redo() {
mMeasurements->addPosition(mPosition);
mMeasurements->newMeasurementsAtPosition(mPosition, mValues);
}
void AddMeasurementsAtPosition::undo() {
mMeasurements->removePosition(mPosition); // FIXME:
}
RemovePosition::RemovePosition(Measurements *measurements, Position position)
: mMeasurements(measurements), mPosition(position) {}
void RemovePosition::redo() {
mMeasurement = mMeasurements->removePosition(mPosition);
}
void RemovePosition::undo() {
QVector<MeasurementEntry> values;
for (auto measurement : mMeasurement) {
values.append(MeasurementEntry{measurement.bss, measurement.measurementType,
measurement.value});
}
mMeasurements->addPosition(mPosition);
mMeasurements->newMeasurementsAtPosition(mPosition, values);
}
UpdatePosition::UpdatePosition(Measurements *measurements, Position oldPosition,
Position newPosition)
: mMeasurements(measurements), mOldPosition(oldPosition),
mNewPosition(newPosition) {}
void UpdatePosition::redo() {
mMeasurements->updatePosition(mOldPosition, mNewPosition);
}
void UpdatePosition::undo() {
mMeasurements->updatePosition(mNewPosition, mOldPosition);
}