mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 22:35:27 +00:00
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:
parent
803f5f9fbf
commit
9e6991a0e1
2 changed files with 12 additions and 0 deletions
|
@ -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()) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue