From 54128aa52fe5c765ce6ced8bd05611e202195d6b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 7 Jun 2013 15:25:29 -0300 Subject: Added the code to remove a dive computer. Added the code to remove a dive computer, plus a few fixes Signed-off-by: Tomaz Canabrava --- qt-ui/models.cpp | 12 ++++++++++++ qt-ui/models.h | 3 +++ 2 files changed, 15 insertions(+) (limited to 'qt-ui') 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 #include #include @@ -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; -- cgit v1.2.3-70-g09d2