aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--device.c5
-rw-r--r--device.h1
-rw-r--r--gtk-gui.c5
-rw-r--r--qt-ui/models.cpp12
-rw-r--r--qt-ui/models.h3
5 files changed, 21 insertions, 5 deletions
diff --git a/device.c b/device.c
index 660cfc1ab..52c49a5bd 100644
--- a/device.c
+++ b/device.c
@@ -9,6 +9,11 @@ struct device_info *head_of_device_info_list(void)
return device_info_list;
}
+void remove_dive_computer(const char *model, uint32_t deviceid)
+{
+ free(remove_device_info(model, deviceid));
+}
+
static int match_device_info(struct device_info *entry, const char *model, uint32_t deviceid)
{
return !strcmp(entry->model, model) && entry->deviceid == deviceid;
diff --git a/device.h b/device.h
index 636eb73c6..3efa42900 100644
--- a/device.h
+++ b/device.h
@@ -20,6 +20,7 @@ extern struct device_info *get_different_device_info(const char *model, uint32_t
extern struct device_info *create_device_info(const char *model, uint32_t deviceid);
extern struct device_info *remove_device_info(const char *model, uint32_t deviceid);
extern struct device_info *head_of_device_info_list(void);
+extern void remove_dive_computer(const char *model, uint32_t deviceid);
#ifdef __cplusplus
}
diff --git a/gtk-gui.c b/gtk-gui.c
index 666438c33..e873fc622 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -101,11 +101,6 @@ static void remember_dc(const char *model, uint32_t deviceid, const char *nickna
nn_entry->nickname = strdup(nickname);
}
-static void remove_dc(const char *model, uint32_t deviceid)
-{
- free(remove_device_info(model, deviceid));
-}
-
static GtkWidget *dive_profile;
GtkActionGroup *action_group;
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 6cb1fa079..868cba952 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -8,6 +8,7 @@
#include "../helpers.h"
#include "../dive.h"
#include "../device.h"
+
#include <QCoreApplication>
#include <QDebug>
#include <QColor>
@@ -1203,7 +1204,18 @@ bool DiveComputerModel::setData(const QModelIndex& index, const QVariant& value,
nnl = nnl->next;
}
+
QByteArray v = value.toByteArray();
nnl->nickname = strdup(v.data()); // how should I free this before setting a new one?
// set_dc_nickname(dive); -> should this be used instead?
+
+ return true;
+}
+
+void DiveComputerModel::remove(const QModelIndex& i)
+{
+ QByteArray model = data(index(i.row(), (int)MODEL)).toByteArray();
+ uint32_t deviceid = data(index(i.row(), (int) ID)).toUInt();
+ remove_dive_computer(model.data(), deviceid);
+ update();
}
diff --git a/qt-ui/models.h b/qt-ui/models.h
index 7a32998ce..5a7d2b214 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -180,6 +180,9 @@ public:
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
void update();
+
+public slots:
+ void remove(const QModelIndex& index);
private:
int numRows;