mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-17 20:16:16 +00:00
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 <tcanabrava@kde.org>
This commit is contained in:
parent
478c24d797
commit
54128aa52f
5 changed files with 21 additions and 5 deletions
5
device.c
5
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;
|
||||
|
|
1
device.h
1
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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue