Skip to content

Commit

Permalink
replace maxFieldIndex by endFieldIndex pointing behind the maximum index
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer authored Oct 22, 2024
1 parent 80d69e5 commit d257b20
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/library/basesqltablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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->maxFieldIndex() : 0) - 1;

Check failure on line 634 in src/library/basesqltablemodel.cpp

View workflow job for this annotation

GitHub Actions / clazy

no member named 'maxFieldIndex' in 'BaseTrackCache'; did you mean 'endFieldIndex'?

Check failure on line 634 in src/library/basesqltablemodel.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04

‘class BaseTrackCache’ has no member named ‘maxFieldIndex’; did you mean ‘endFieldIndex’?

Check failure on line 634 in src/library/basesqltablemodel.cpp

View workflow job for this annotation

GitHub Actions / clang-tidy

no member named 'maxFieldIndex' in 'BaseTrackCache'; did you mean 'endFieldIndex'? [clang-diagnostic-error]

Check failure on line 634 in src/library/basesqltablemodel.cpp

View workflow job for this annotation

GitHub Actions / coverage

‘class BaseTrackCache’ has no member named ‘maxFieldIndex’; did you mean ‘endFieldIndex’?

Check failure on line 634 in src/library/basesqltablemodel.cpp

View workflow job for this annotation

GitHub Actions / macOS 12 x64

no member named 'maxFieldIndex' in 'BaseTrackCache'; did you mean 'endFieldIndex'?

Check failure on line 634 in src/library/basesqltablemodel.cpp

View workflow job for this annotation

GitHub Actions / macOS 12 arm64

no member named 'maxFieldIndex' in 'BaseTrackCache'; did you mean 'endFieldIndex'?

Check failure on line 634 in src/library/basesqltablemodel.cpp

View workflow job for this annotation

GitHub Actions / Windows 2019 (MSVC)

'maxFieldIndex': is not a member of 'BaseTrackCache'
}

QString BaseSqlTableModel::modelKey(bool noSearch) const {
Expand Down
2 changes: 1 addition & 1 deletion src/library/basesqltablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/library/basetrackcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/library/basetrackcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<TrackId>& trackIds,
const QString& query,
const QString& extraFilter,
Expand Down
2 changes: 1 addition & 1 deletion src/library/basetracktablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/library/basetracktablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

///////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions src/library/columncache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d257b20

Please sign in to comment.