Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/library/basesqltablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class BaseSqlTableModel : public BaseTrackTableModel {

TrackCollectionManager* const m_pTrackCollectionManager;

protected:
QList<TrackRef> getTrackRefs(const QModelIndexList& indices) const;

QSqlDatabase m_database;
Expand Down
20 changes: 2 additions & 18 deletions src/library/basetracktablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,18 +462,6 @@ QVariant BaseTrackTableModel::data(
return roleValue(index, rawValue(index), role);
}

QVariant BaseTrackTableModel::rawValue(
const QModelIndex& index) const {
VERIFY_OR_DEBUG_ASSERT(index.isValid()) {
return QVariant();
}
const auto field = mapColumn(index.column());
if (field == ColumnCache::COLUMN_LIBRARYTABLE_INVALID) {
return QVariant();
}
return rawSiblingValue(index, field);
}

QVariant BaseTrackTableModel::rawSiblingValue(
const QModelIndex& index,
ColumnCache::Column siblingField) const {
Expand All @@ -483,17 +471,13 @@ QVariant BaseTrackTableModel::rawSiblingValue(
VERIFY_OR_DEBUG_ASSERT(siblingField != ColumnCache::COLUMN_LIBRARYTABLE_INVALID) {
return QVariant();
}
const auto siblingColumn = fieldIndex(siblingField);
const int siblingColumn = fieldIndex(siblingField);
if (siblingColumn < 0) {
// Unsupported or unknown column/field
// FIXME: This should never happen but it does. But why??
return QVariant();
}
VERIFY_OR_DEBUG_ASSERT(siblingColumn != index.column()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be replaced with a if instead of removing the condition check entirely like above? Reading the comment, since it seems the early return was here to prevent infinite recursion. Or is that comment incorrect/out of date?

// Prevent infinite recursion
return QVariant();
}
const auto siblingIndex = index.sibling(index.row(), siblingColumn);
const QModelIndex siblingIndex = index.sibling(index.row(), siblingColumn);
return rawValue(siblingIndex);
}

Expand Down
13 changes: 5 additions & 8 deletions src/library/basetracktablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel {
virtual Qt::ItemFlags readWriteFlags(
const QModelIndex& index) const;

/// At least one of the following functions must be overridden,
/// because each default implementation will call the other
/// function!!
///
/// Return the raw data value at the given index.
///
/// Expected types by ColumnCache field (pass-through = not validated):
Expand Down Expand Up @@ -211,10 +207,7 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel {
/// COLUMN_LIBRARYTABLE_LAST_PLAYED_AT: QDateTime
/// COLUMN_PLAYLISTTABLE_DATETIMEADDED: QDateTime
virtual QVariant rawValue(
const QModelIndex& index) const;
virtual QVariant rawSiblingValue(
const QModelIndex& index,
ColumnCache::Column siblingField) const;
const QModelIndex& index) const = 0;

QVariant roleValue(
const QModelIndex& index,
Expand Down Expand Up @@ -250,6 +243,10 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel {
const QPixmap& pixmap);

private:
QVariant rawSiblingValue(
const QModelIndex& index,
ColumnCache::Column siblingField) const;

// Track models may reference tracks by an external id
// TODO: TrackId should only be used for tracks from
// the internal database.
Expand Down