diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-06-17 11:48:58 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-06-17 11:48:58 -0700 |
commit | cb50d6bf6cc52b9c42af9dd514bbe07fa9eff767 (patch) | |
tree | 0f3ba47b1caa52fca429c3baae7715c5089e4231 /qt-gui.cpp | |
parent | f465230263c4d1827feafedfce1b648cc035e49a (diff) | |
download | subsurface-cb50d6bf6cc52b9c42af9dd514bbe07fa9eff767.tar.gz |
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-gui.cpp')
-rw-r--r-- | qt-gui.cpp | 36 |
1 files 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) |