blob: 316def49509d143e95b6e62b35b0be7038bbe5d2 (
plain) (
blame)
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
|
#include "undocommands.h"
#include "mainwindow.h"
#include "divelist.h"
UndoDeleteDive::UndoDeleteDive(QList<dive *> diveList)
{
dives = diveList;
setText("delete dive");
if (dives.count() > 1)
setText(QString("delete %1 dives").arg(QString::number(dives.count())));
}
void UndoDeleteDive::undo()
{
for (int i = 0; i < dives.count(); i++)
record_dive(dives.at(i));
mark_divelist_changed(true);
MainWindow::instance()->refreshDisplay();
}
void UndoDeleteDive::redo()
{
QList<struct dive*> newList;
for (int i = 0; i < dives.count(); i++) {
//make a copy of the dive before deleting it
struct dive* d = alloc_dive();
copy_dive(dives.at(i), d);
newList.append(d);
//delete the dive
delete_single_dive(get_divenr(dives.at(i)));
}
mark_divelist_changed(true);
MainWindow::instance()->refreshDisplay();
dives.clear();
dives = newList;
}
UndoShiftTime::UndoShiftTime(QList<int> diveList, int amount)
{
setText("shift time");
dives = diveList;
timeChanged = amount;
}
void UndoShiftTime::undo()
{
for (int i = 0; i < dives.count(); i++) {
struct dive* d = get_dive_by_uniq_id(dives.at(i));
d->when -= timeChanged;
}
mark_divelist_changed(true);
MainWindow::instance()->refreshDisplay();
}
void UndoShiftTime::redo()
{
for (int i = 0; i < dives.count(); i++) {
struct dive* d = get_dive_by_uniq_id(dives.at(i));
d->when += timeChanged;
}
mark_divelist_changed(true);
MainWindow::instance()->refreshDisplay();
}
|