diff options
Diffstat (limited to 'qt-models/divelocationmodel.cpp')
-rw-r--r-- | qt-models/divelocationmodel.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index 42f283f1e..edf15b707 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -39,16 +39,10 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons void LocationInformationModel::update() { - if (rowCount()) { - beginRemoveRows(QModelIndex(), 0, rowCount()-1); - endRemoveRows(); - } - if (dive_site_table.nr) { - beginInsertRows(QModelIndex(), 0, dive_site_table.nr); - internalRowCount = dive_site_table.nr; - std::sort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than); - endInsertRows(); - } + beginResetModel(); + internalRowCount = dive_site_table.nr; + std::sort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than); + endResetModel(); } int32_t LocationInformationModel::addDiveSite(const QString& name, int lon, int lat) @@ -76,3 +70,14 @@ bool LocationInformationModel::setData(const QModelIndex &index, const QVariant emit dataChanged(index, index); return true; } + +bool LocationInformationModel::removeRows(int row, int count, const QModelIndex & parent) { + if(row >= rowCount()) + return false; + + beginRemoveRows(QModelIndex(), row, row); + struct dive_site *ds = get_dive_site(row); + delete_dive_site(ds->uuid); + endRemoveRows(); + return true; +} |