mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +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();
|
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()
|
void DiveListModel::clear()
|
||||||
{
|
{
|
||||||
if (m_dives.count()) {
|
if (m_dives.count()) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
static DiveListModel *instance();
|
static DiveListModel *instance();
|
||||||
DiveListModel(QObject *parent = 0);
|
DiveListModel(QObject *parent = 0);
|
||||||
void addDive(dive *d);
|
void addDive(dive *d);
|
||||||
|
void updateDive(dive *d);
|
||||||
void clear();
|
void clear();
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue