blob: a72a4340d41734146460a2c379c14dc5fe2b85f3 (
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
|
// SPDX-License-Identifier: GPL-2.0
#include "command_device.h"
#include "core/subsurface-qt/divelistnotifier.h"
namespace Command {
EditDeviceNickname::EditDeviceNickname(const struct divecomputer *dc, const QString &nicknameIn) :
nickname(nicknameIn.toStdString())
{
index = get_or_add_device_for_dc(&device_table, dc);
if (index == -1)
return;
setText(Command::Base::tr("Set nickname of device %1 (serial %2) to %3").arg(dc->model, dc->serial, nicknameIn));
}
bool EditDeviceNickname::workToBeDone()
{
return get_device(&device_table, index) != nullptr;
}
void EditDeviceNickname::redo()
{
device *dev = get_device_mutable(&device_table, index);
if (!dev)
return;
std::swap(dev->nickName, nickname);
emit diveListNotifier.deviceEdited();
}
void EditDeviceNickname::undo()
{
redo(); // undo() and redo() do the same thing
}
} // namespace Command
|