mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 19:23:24 +00:00
Clear the Dive model before repopulating it
Otherwise we could get duplicate dives in the dive list. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9d62258316
commit
2f2e9da2cd
3 changed files with 9 additions and 0 deletions
|
@ -117,6 +117,7 @@ void QMLManager::loadDives()
|
|||
int i;
|
||||
struct dive *d;
|
||||
|
||||
DiveListModel::instance()->clear();
|
||||
for_each_dive(i, d) {
|
||||
DiveListModel::instance()->addDive(d);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,13 @@ void DiveListModel::addDive(dive *d)
|
|||
endInsertRows();
|
||||
}
|
||||
|
||||
void DiveListModel::clear()
|
||||
{
|
||||
beginRemoveRows(QModelIndex(), 0, m_dives.count() - 1);
|
||||
m_dives.clear();
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
int DiveListModel::rowCount(const QModelIndex &) const
|
||||
{
|
||||
return m_dives.count();
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
static DiveListModel *instance();
|
||||
DiveListModel(QObject *parent = 0);
|
||||
void addDive(dive *d);
|
||||
void clear();
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue