From cb50d6bf6cc52b9c42af9dd514bbe07fa9eff767 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 17 Jun 2013 11:48:58 -0700 Subject: Process dive computers as they are read in When doing the early port from the Gtk code to Qt this function was just stubbed out. Now we are correctly filling the internal data structures with ALL the dive computers that we see. Instead of the silly dialog asking the user for a nickname we simply create one from the deviceid. The user can then use the device name editing dialog to create more intuitive nicknames. Signed-off-by: Dirk Hohndel --- qt-gui.cpp | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/qt-gui.cpp b/qt-gui.cpp index d85198d68..e15e4128e 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -154,10 +154,42 @@ const char *get_dc_nickname(const char *model, uint32_t deviceid) return NULL; } +void remember_dc(const char *model, uint32_t deviceid, const char *nickname) +{ + struct device_info *nn_entry; + + nn_entry = create_device_info(model, deviceid); + if (!nn_entry) + return; + if (!nickname || !*nickname) { + nn_entry->nickname = NULL; + return; + } + nn_entry->nickname = strdup(nickname); +} + void set_dc_nickname(struct dive *dive) { - /* needs Qt implementation */ - /*well, I don't know how to do this here... = ( */ + if (!dive) + return; + + struct divecomputer *dc = &dive->dc; + + while (dc) { + if (get_dc_nickname(dc->model, dc->deviceid) == NULL) { + // we don't have this one, yet + struct device_info *nn_entry = get_different_device_info(dc->model, dc->deviceid); + if (nn_entry) { + // we already have this model but a different deviceid + QString simpleNick(dc->model); + simpleNick.append(" (").append(QString::number(dc->deviceid, 16)).append(")"); + remember_dc(dc->model, dc->deviceid, simpleNick.toUtf8().data()); + } else { + remember_dc(dc->model, dc->deviceid, NULL); + } + } + dc = dc->next; + } } QString get_depth_string(depth_t depth, bool showunit) -- cgit v1.2.3-70-g09d2