From 19d651a36b8f5c955ef3e147bbb3efa93028f959 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 9 Oct 2018 09:18:08 +0200 Subject: Dive sites: remove internalRowCount from LocationInformationModel This was redundant. Directly use dive_site_table.nr instead. Signed-off-by: Berthold Stoeger --- qt-models/divelocationmodel.cpp | 9 +++------ qt-models/divelocationmodel.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index ffe5e501f..ba9dede0d 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -18,8 +18,7 @@ LocationInformationModel *LocationInformationModel::instance() return self; } -LocationInformationModel::LocationInformationModel(QObject *obj) : QAbstractTableModel(obj), - internalRowCount(0) +LocationInformationModel::LocationInformationModel(QObject *obj) : QAbstractTableModel(obj) { } @@ -30,7 +29,7 @@ int LocationInformationModel::columnCount(const QModelIndex&) const int LocationInformationModel::rowCount(const QModelIndex&) const { - return internalRowCount; + return dive_site_table.nr; } QVariant LocationInformationModel::data(const QModelIndex &index, int role) const @@ -74,10 +73,9 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons void LocationInformationModel::update() { beginResetModel(); - internalRowCount = dive_site_table.nr; qSort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than); locationNames.clear(); - for (int i = 0; i < internalRowCount; i++) + for (int i = 0; i < dive_site_table.nr; i++) locationNames << QString(dive_site_table.dive_sites[i]->name); endResetModel(); } @@ -96,7 +94,6 @@ bool LocationInformationModel::removeRows(int row, int, const QModelIndex&) struct dive_site *ds = get_dive_site(row); if (ds) delete_dive_site(ds->uuid); - internalRowCount = dive_site_table.nr; endRemoveRows(); return true; } diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h index debbdf871..47164d2d4 100644 --- a/qt-models/divelocationmodel.h +++ b/qt-models/divelocationmodel.h @@ -30,7 +30,6 @@ public slots: void update(); QStringList allSiteNames() const; private: - int internalRowCount; QStringList locationNames; }; -- cgit v1.2.3-70-g09d2