Skip to content

Commit

Permalink
Export CSV: fixing null values in export due to improper location of …
Browse files Browse the repository at this point in the history
…right-alignment role

fixed spelling in comment and added breaks to switch statements

Update src/library/basetracktablemodel.cpp

Rewording of comment improves clarity of M_FALLTHROUGH_INTENDED behaviour

Co-authored-by: ronso0 <ronso0@mixxx.org>

reverting unecessary breaks
  • Loading branch information
burnsak committed Jun 21, 2023
1 parent a18b0b9 commit 94a896b
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/library/basetracktablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,21 +590,9 @@ QVariant BaseTrackTableModel::roleValue(
break;
}
M_FALLTHROUGH_INTENDED;
// Right align BPM, duraation and bitrate so big/small values can easily be
// spotted by length (number of digits)
case Qt::TextAlignmentRole: {
switch (field) {
case ColumnCache::COLUMN_LIBRARYTABLE_BPM:
case ColumnCache::COLUMN_LIBRARYTABLE_DURATION:
case ColumnCache::COLUMN_LIBRARYTABLE_BITRATE: {
// We need to cast to int due to a bug similar to
// https://bugreports.qt.io/browse/QTBUG-67582
return static_cast<int>(Qt::AlignVCenter | Qt::AlignRight);
}
default:
return QVariant(); // default AlignLeft for all other columns
}
}
// NOTE: for export we need to fall through to Qt::DisplayRole,
// so do not add any other role cases here, or the export
// will be empty
case Qt::DisplayRole:
switch (field) {
case ColumnCache::COLUMN_LIBRARYTABLE_DURATION: {
Expand Down Expand Up @@ -873,6 +861,21 @@ QVariant BaseTrackTableModel::roleValue(
return Qt::PartiallyChecked;
}
}
// Right align BPM, duration and bitrate so big/small values can easily be
// spotted by length (number of digits)
case Qt::TextAlignmentRole: {
switch (field) {
case ColumnCache::COLUMN_LIBRARYTABLE_BPM:
case ColumnCache::COLUMN_LIBRARYTABLE_DURATION:
case ColumnCache::COLUMN_LIBRARYTABLE_BITRATE: {
// We need to cast to int due to a bug similar to
// https://bugreports.qt.io/browse/QTBUG-67582
return static_cast<int>(Qt::AlignVCenter | Qt::AlignRight);
}
default:
return QVariant(); // default AlignLeft for all other columns
}
}
default:
DEBUG_ASSERT(!"unexpected role");
break;
Expand Down

0 comments on commit 94a896b

Please sign in to comment.