From faebb539091ca5550bb6b60280d692c50d547bc0 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 25 Oct 2020 07:53:40 +0100 Subject: undo: add device related undo commands Add commands for deleting devices and editing device nicknames to include the device-handling in the undo system. Signed-off-by: Berthold Stoeger --- core/device.cpp | 7 +++++++ core/device.h | 1 + core/subsurface-qt/divelistnotifier.h | 1 + 3 files changed, 9 insertions(+) (limited to 'core') diff --git a/core/device.cpp b/core/device.cpp index bd1d75416..47ce72b17 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -392,6 +392,13 @@ extern "C" const struct device *get_device(const struct device_table *table, int return &table->devices[i]; } +extern "C" struct device *get_device_mutable(struct device_table *table, int i) +{ + if (i < 0 || i > nr_devices(table)) + return NULL; + return &table->devices[i]; +} + extern "C" const char *device_get_model(const struct device *dev) { return dev ? dev->model.c_str() : NULL; diff --git a/core/device.h b/core/device.h index 0de299060..0ef0d4c92 100644 --- a/core/device.h +++ b/core/device.h @@ -23,6 +23,7 @@ extern void add_devices_of_dive(const struct dive *dive, struct device_table *ta extern void create_device_node(struct device_table *table, const char *model, uint32_t deviceid, const char *serial, const char *firmware, const char *nickname); extern int nr_devices(const struct device_table *table); extern const struct device *get_device(const struct device_table *table, int i); +extern struct device *get_device_mutable(struct device_table *table, int i); extern void clear_device_table(struct device_table *table); const char *get_dc_nickname(const struct divecomputer *dc); extern bool device_used_by_selected_dive(const struct device *dev); diff --git a/core/subsurface-qt/divelistnotifier.h b/core/subsurface-qt/divelistnotifier.h index 7f7162dac..07750de90 100644 --- a/core/subsurface-qt/divelistnotifier.h +++ b/core/subsurface-qt/divelistnotifier.h @@ -130,6 +130,7 @@ signals: // Devices related signals void deviceAdded(int index); void deviceDeleted(int index); + void deviceEdited(int index); // Filter related signals void filterPresetAdded(int index); -- cgit v1.2.3-70-g09d2