diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-09-22 22:03:49 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-02 08:04:49 -0700 |
commit | a33f381dc6e71abc231992e95bfcf7b4d0cd145a (patch) | |
tree | badcfada60efe07b9d7110a5d9bd2eb1ecc2346d /qt-models/diveimportedmodel.cpp | |
parent | 5037fcdbdc867c542661b0b31debd8580777c30e (diff) | |
download | subsurface-a33f381dc6e71abc231992e95bfcf7b4d0cd145a.tar.gz |
Cleanup: remove DiveImportedModel::firstIndex
This index was never set to anything else than 0. Might as
well remove it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/diveimportedmodel.cpp')
-rw-r--r-- | qt-models/diveimportedmodel.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/qt-models/diveimportedmodel.cpp b/qt-models/diveimportedmodel.cpp index 10d1d74d2..ad2c804e8 100644 --- a/qt-models/diveimportedmodel.cpp +++ b/qt-models/diveimportedmodel.cpp @@ -3,7 +3,6 @@ #include "core/divelist.h" DiveImportedModel::DiveImportedModel(QObject *o) : QAbstractTableModel(o), - firstIndex(0), lastIndex(-1), diveTable({ 0 }), sitesTable({ 0 }) @@ -18,7 +17,7 @@ int DiveImportedModel::columnCount(const QModelIndex&) const int DiveImportedModel::rowCount(const QModelIndex&) const { - return lastIndex - firstIndex + 1; + return lastIndex + 1; } QVariant DiveImportedModel::headerData(int section, Qt::Orientation orientation, int role) const @@ -51,10 +50,10 @@ QVariant DiveImportedModel::data(const QModelIndex &index, int role) const if (!index.isValid()) return QVariant(); - if (index.row() + firstIndex > lastIndex) + if (index.row() > lastIndex) return QVariant(); - struct dive *d = get_dive_from_table(index.row() + firstIndex, &diveTable); + struct dive *d = get_dive_from_table(index.row(), &diveTable); if (!d) return QVariant(); @@ -93,7 +92,7 @@ void DiveImportedModel::changeSelected(QModelIndex clickedIndex) void DiveImportedModel::selectAll() { std::fill(checkStates.begin(), checkStates.end(), true); - dataChanged(index(0, 0), index(lastIndex - firstIndex, 0), QVector<int>() << Qt::CheckStateRole << Selected); + dataChanged(index(0, 0), index(lastIndex, 0), QVector<int>() << Qt::CheckStateRole << Selected); } void DiveImportedModel::selectRow(int row) @@ -105,7 +104,7 @@ void DiveImportedModel::selectRow(int row) void DiveImportedModel::selectNone() { std::fill(checkStates.begin(), checkStates.end(), false); - dataChanged(index(0, 0), index(lastIndex - firstIndex,0 ), QVector<int>() << Qt::CheckStateRole << Selected); + dataChanged(index(0, 0), index(lastIndex, 0 ), QVector<int>() << Qt::CheckStateRole << Selected); } Qt::ItemFlags DiveImportedModel::flags(const QModelIndex &index) const @@ -117,16 +116,14 @@ Qt::ItemFlags DiveImportedModel::flags(const QModelIndex &index) const void DiveImportedModel::clearTable() { - if (lastIndex < firstIndex) { + if (lastIndex < 0) { // just to be sure it's the right numbers // but don't call RemoveRows or Qt in debug mode with trigger an ASSERT lastIndex = -1; - firstIndex = 0; return; } - beginRemoveRows(QModelIndex(), 0, lastIndex - firstIndex); + beginRemoveRows(QModelIndex(), 0, lastIndex); lastIndex = -1; - firstIndex = 0; endRemoveRows(); } @@ -138,7 +135,6 @@ void DiveImportedModel::downloadThreadFinished() move_dive_table(&thread.downloadTable, &diveTable); move_dive_site_table(&thread.diveSiteTable, &sitesTable); - firstIndex = 0; lastIndex = diveTable.nr - 1; checkStates.resize(diveTable.nr); std::fill(checkStates.begin(), checkStates.end(), true); @@ -164,7 +160,6 @@ std::pair<struct dive_table, struct dive_site_table> DiveImportedModel::consumeT move_dive_site_table(&sitesTable, &sites); // Reset indexes - firstIndex = 0; lastIndex = -1; checkStates.clear(); |