diff --git a/src/library/basesqltablemodel.cpp b/src/library/basesqltablemodel.cpp index 1dac90dbf2a..ee1dfd89528 100644 --- a/src/library/basesqltablemodel.cpp +++ b/src/library/basesqltablemodel.cpp @@ -629,9 +629,9 @@ int BaseSqlTableModel::fieldIndex(const QString& fieldName) const { return tableIndex; } -int BaseSqlTableModel::maxFieldIndex() const { +int BaseSqlTableModel::endFieldIndex() const { // Subtract one to remove the id column which is in both - return m_tableColumns.size() + (m_trackSource ? m_trackSource->maxFieldIndex() : 0); + return m_tableColumns.size() + (m_trackSource ? m_trackSource->endFieldIndex() - 1 : 0); } QString BaseSqlTableModel::modelKey(bool noSearch) const { diff --git a/src/library/basesqltablemodel.h b/src/library/basesqltablemodel.h index 5b924fde575..eeb41de509e 100644 --- a/src/library/basesqltablemodel.h +++ b/src/library/basesqltablemodel.h @@ -75,7 +75,7 @@ class BaseSqlTableModel : public BaseTrackTableModel { /////////////////////////////////////////////////////////////////////////// int fieldIndex( ColumnCache::Column column) const final; - int maxFieldIndex() const final; + int endFieldIndex() const final; QString modelKey(bool noSearch) const override; diff --git a/src/library/basetrackcache.cpp b/src/library/basetrackcache.cpp index 2be04358e78..05b447a337b 100644 --- a/src/library/basetrackcache.cpp +++ b/src/library/basetrackcache.cpp @@ -51,8 +51,8 @@ int BaseTrackCache::fieldIndex(const QString& columnName) const { return m_columnCache.fieldIndex(columnName); } -int BaseTrackCache::maxFieldIndex() const { - return m_columnCache.maxFieldIndex(); +int BaseTrackCache::endFieldIndex() const { + return m_columnCache.endFieldIndex(); } QString BaseTrackCache::columnNameForFieldIndex(int index) const { diff --git a/src/library/basetrackcache.h b/src/library/basetrackcache.h index 8cf7afc1a9f..96eef7c9677 100644 --- a/src/library/basetrackcache.h +++ b/src/library/basetrackcache.h @@ -64,7 +64,7 @@ class BaseTrackCache : public QObject { QString columnNameForFieldIndex(int index) const; QString columnSortForFieldIndex(int index) const; int fieldIndex(ColumnCache::Column column) const; - int maxFieldIndex() const; + int endFieldIndex() const; virtual void filterAndSort(const QSet& trackIds, const QString& query, const QString& extraFilter, diff --git a/src/library/basetracktablemodel.cpp b/src/library/basetracktablemodel.cpp index 0e1f803a081..52a3f827d5b 100644 --- a/src/library/basetracktablemodel.cpp +++ b/src/library/basetracktablemodel.cpp @@ -129,7 +129,7 @@ void BaseTrackTableModel::initTableColumnsAndHeaderProperties( return; } - m_columnHeaders.resize(maxFieldIndex() + 1); + m_columnHeaders.resize(endFieldIndex()); // Init the mapping of all columns, even for internal columns that are // hidden/invisible. Otherwise mapColumn() would not return a valid result diff --git a/src/library/basetracktablemodel.h b/src/library/basetracktablemodel.h index 510f615dd64..9701e0d29cd 100644 --- a/src/library/basetracktablemodel.h +++ b/src/library/basetracktablemodel.h @@ -44,8 +44,8 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel { return m_columnCache.fieldIndex(column); } - virtual int maxFieldIndex() const { - return m_columnCache.maxFieldIndex(); + virtual int endFieldIndex() const { + return m_columnCache.endFieldIndex(); } /////////////////////////////////////////////////////// diff --git a/src/library/columncache.h b/src/library/columncache.h index 534c79dd9df..235a8e7b75e 100644 --- a/src/library/columncache.h +++ b/src/library/columncache.h @@ -96,8 +96,8 @@ class ColumnCache : public QObject { return m_columnsByIndex.at(index); } - int maxFieldIndex() const { - return m_columnsByIndex.size() - 1; + int endFieldIndex() const { + return m_columnsByIndex.size(); } inline QString columnSortForFieldIndex(int index) const {