summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divelocationmodel.cpp20
-rw-r--r--qt-models/divelocationmodel.h2
2 files changed, 22 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();
diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h
index 794056324..8f2e25190 100644
--- a/qt-models/divelocationmodel.h
+++ b/qt-models/divelocationmodel.h
@@ -34,6 +34,8 @@ public slots:
void update();
QStringList allSiteNames() const;
void diveSiteDiveCountChanged(struct dive_site *ds);
+ void diveSiteAdded(struct dive_site *ds, int idx);
+ void diveSiteDeleted(struct dive_site *ds, int idx);
private:
QStringList locationNames;
};