mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: remove device C access code
This was used from C, so there was lots of access code, which is not necessary. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9e3e0a5a05
commit
73f2605ab1
13 changed files with 84 additions and 177 deletions
|
@ -9,7 +9,7 @@ namespace Command {
|
|||
EditDeviceNickname::EditDeviceNickname(const struct divecomputer *dc, const QString &nicknameIn) :
|
||||
nickname(nicknameIn.toStdString())
|
||||
{
|
||||
index = get_or_add_device_for_dc(divelog.devices.get(), dc);
|
||||
index = get_or_add_device_for_dc(divelog.devices, dc);
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
|
@ -18,15 +18,14 @@ EditDeviceNickname::EditDeviceNickname(const struct divecomputer *dc, const QStr
|
|||
|
||||
bool EditDeviceNickname::workToBeDone()
|
||||
{
|
||||
return get_device(divelog.devices.get(), index) != nullptr;
|
||||
return index >= 0;
|
||||
}
|
||||
|
||||
void EditDeviceNickname::redo()
|
||||
{
|
||||
device *dev = get_device_mutable(divelog.devices.get(), index);
|
||||
if (!dev)
|
||||
if (index < 0 || static_cast<size_t>(index) >= divelog.devices.size())
|
||||
return;
|
||||
std::swap(dev->nickName, nickname);
|
||||
std::swap(divelog.devices[index].nickName, nickname);
|
||||
emit diveListNotifier.deviceEdited();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue