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>
This commit is contained in:
Dirk Hohndel 2015-12-07 22:23:09 -08:00
parent 803f5f9fbf
commit 9e6991a0e1
2 changed files with 12 additions and 0 deletions

View file

@ -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()) {

View file

@ -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;