summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-07 22:23:09 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-07 22:23:09 -0800
commit9e6991a0e16799cbd0205536e23654dce1153c30 (patch)
treec65dd022e4c4c7313c518190bf9fb74213ff686b /qt-models
parent803f5f9fbf710279ced115e480427e8159e552b0 (diff)
downloadsubsurface-9e6991a0e16799cbd0205536e23654dce1153c30.tar.gz
QML-UI: we need a way to update the dive model
Otherwise our UI will get out of sync with our dive list. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divelistmodel.cpp11
-rw-r--r--qt-models/divelistmodel.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp
index 86c977fc9..ccd5b8afd 100644
--- a/qt-models/divelistmodel.cpp
+++ b/qt-models/divelistmodel.cpp
@@ -15,6 +15,17 @@ void DiveListModel::addDive(dive *d)
endInsertRows();
}
+void DiveListModel::updateDive(dive *d)
+{
+ for (int i = 0; i < m_dives.count(); i++) {
+ if (m_dives.at(i).id() == d->id) {
+ Dive newDive(d);
+ m_dives.replace(i, newDive);
+ break;
+ }
+ }
+}
+
void DiveListModel::clear()
{
if (m_dives.count()) {
diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h
index fbeb13486..a19d1b365 100644
--- a/qt-models/divelistmodel.h
+++ b/qt-models/divelistmodel.h
@@ -35,6 +35,7 @@ public:
static DiveListModel *instance();
DiveListModel(QObject *parent = 0);
void addDive(dive *d);
+ void updateDive(dive *d);
void clear();
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;