mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
models: update DiveComputerModel when core data is reset
To implement undo-semantics, we want a longer-lived dive-computer-model (currently, it is regenerated when the dialog is opened). Therefore, it must be reloaded when the core data is reset. Do this like for other models: listen to the dataReset() signal of DiveListNotifier. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3a2f1b17b6
commit
4467477389
3 changed files with 11 additions and 1 deletions
|
@ -2,11 +2,21 @@
|
||||||
#include "qt-models/divecomputermodel.h"
|
#include "qt-models/divecomputermodel.h"
|
||||||
#include "core/dive.h"
|
#include "core/dive.h"
|
||||||
#include "core/divelist.h"
|
#include "core/divelist.h"
|
||||||
|
#include "core/subsurface-qt/divelistnotifier.h"
|
||||||
|
|
||||||
DiveComputerModel::DiveComputerModel(QObject *parent) : CleanerTableModel(parent),
|
DiveComputerModel::DiveComputerModel(QObject *parent) : CleanerTableModel(parent),
|
||||||
dcs(device_table.devices)
|
dcs(device_table.devices)
|
||||||
{
|
{
|
||||||
|
connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &DiveComputerModel::update);
|
||||||
setHeaderDataStrings(QStringList() << "" << tr("Model") << tr("Device ID") << tr("Nickname"));
|
setHeaderDataStrings(QStringList() << "" << tr("Model") << tr("Device ID") << tr("Nickname"));
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiveComputerModel::update()
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
dcs = device_table.devices;
|
||||||
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DiveComputerModel::data(const QModelIndex &index, int role) const
|
QVariant DiveComputerModel::data(const QModelIndex &index, int role) const
|
||||||
|
|
|
@ -25,6 +25,7 @@ public:
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void remove(const QModelIndex &index);
|
void remove(const QModelIndex &index);
|
||||||
|
void update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<device> dcs;
|
std::vector<device> dcs;
|
||||||
|
|
|
@ -67,4 +67,3 @@ GpsListModel *GpsListModel::instance()
|
||||||
static GpsListModel self;
|
static GpsListModel self;
|
||||||
return &self;
|
return &self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue