diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-03-12 00:25:31 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-12 18:19:07 +0300 |
commit | 59e602447b951cfdfabd8f0a067dfb8c804ee506 (patch) | |
tree | 0c36803d41b76951058999db481100f131198936 /qt-models/divelocationmodel.cpp | |
parent | 84f7179367e4638a323f4bd14990711c84b56ffb (diff) | |
download | subsurface-59e602447b951cfdfabd8f0a067dfb8c804ee506.tar.gz |
Dive site: inform model of dive site addition / deletion
Introduce two DiveListNotifier signals which are sent by
the undo commands if dives are added to / removed from the
core.
The signal has the dive site and the index in the global
dive site table as payload. Thus, the model has only to
remove the appropriate rows.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divelocationmodel.cpp')
-rw-r--r-- | qt-models/divelocationmodel.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index 03c07a5e0..0a0eacaaf 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -25,6 +25,8 @@ LocationInformationModel *LocationInformationModel::instance() LocationInformationModel::LocationInformationModel(QObject *obj) : QAbstractTableModel(obj) { connect(&diveListNotifier, &DiveListNotifier::diveSiteDiveCountChanged, this, &LocationInformationModel::diveSiteDiveCountChanged); + connect(&diveListNotifier, &DiveListNotifier::diveSiteAdded, this, &LocationInformationModel::diveSiteAdded); + connect(&diveListNotifier, &DiveListNotifier::diveSiteDeleted, this, &LocationInformationModel::diveSiteDeleted); } int LocationInformationModel::columnCount(const QModelIndex &) const @@ -163,6 +165,24 @@ void LocationInformationModel::diveSiteDiveCountChanged(dive_site *ds) dataChanged(createIndex(idx, NUM_DIVES), createIndex(idx, NUM_DIVES)); } +void LocationInformationModel::diveSiteAdded(struct dive_site *, int idx) +{ + if (idx < 0) + return; + beginInsertRows(QModelIndex(), idx, idx); + // Row has already been added by Undo-Command. + endInsertRows(); +} + +void LocationInformationModel::diveSiteDeleted(struct dive_site *, int idx) +{ + if (idx < 0) + return; + beginRemoveRows(QModelIndex(), idx, idx); + // Row has already been added by Undo-Command. + endRemoveRows(); +} + GeoReferencingOptionsModel *GeoReferencingOptionsModel::instance() { static GeoReferencingOptionsModel *self = new GeoReferencingOptionsModel(); |