Playlist: Remove flawed sorting logic for filename

Possible fix for #1538
This commit is contained in:
Jonas Kvinge 2024-09-08 13:12:13 +02:00
parent 3238e295ba
commit af06f8e70a
2 changed files with 1 additions and 20 deletions

View File

@ -1342,7 +1342,7 @@ bool Playlist::CompareItems(const Column column, const Qt::SortOrder order, Play
case Column::Samplerate: cmp(samplerate);
case Column::Bitdepth: cmp(bitdepth);
case Column::Filename:
return (QString::localeAwareCompare(a->Url().path().toLower(), b->Url().path().toLower()) < 0);
return QString::localeAwareCompare(a->Url().path(), b->Url().path()) < 0;
case Column::BaseFilename: cmp(basefilename);
case Column::Filesize: cmp(filesize);
case Column::Filetype: cmp(filetype);
@ -1371,18 +1371,6 @@ bool Playlist::CompareItems(const Column column, const Qt::SortOrder order, Play
}
bool Playlist::ComparePathDepths(const Qt::SortOrder order, PlaylistItemPtr _a, PlaylistItemPtr _b) {
PlaylistItemPtr a = order == Qt::AscendingOrder ? _a : _b;
PlaylistItemPtr b = order == Qt::AscendingOrder ? _b : _a;
qint64 a_dir_level = a->Url().path().count(QLatin1Char('/'));
qint64 b_dir_level = b->Url().path().count(QLatin1Char('/'));
return a_dir_level < b_dir_level;
}
QString Playlist::column_name(const Column column) {
switch (column) {
@ -1471,11 +1459,6 @@ void Playlist::sort(const int column_number, const Qt::SortOrder order) {
std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column::Disc, order, std::placeholders::_1, std::placeholders::_2));
std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column::Album, order, std::placeholders::_1, std::placeholders::_2));
}
else if (column == Column::Filename) {
// When sorting by full paths we also expect a hierarchical order. This returns a breath-first ordering of paths.
std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column::Filename, order, std::placeholders::_1, std::placeholders::_2));
std::stable_sort(begin, new_items.end(), std::bind(&Playlist::ComparePathDepths, order, std::placeholders::_1, std::placeholders::_2));
}
else {
std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, column, order, std::placeholders::_1, std::placeholders::_2));
}

View File

@ -259,8 +259,6 @@ class Playlist : public QAbstractListModel {
void sort(const int column_number, const Qt::SortOrder order) override;
bool removeRows(const int row, const int count, const QModelIndex &parent = QModelIndex()) override;
static bool ComparePathDepths(Qt::SortOrder, PlaylistItemPtr, PlaylistItemPtr);
static Columns ChangedColumns(const Song &metadata1, const Song &metadata2);
static bool MinorMetadataChange(const Song &old_metadata, const Song &new_metadata);
void UpdateItemMetadata(PlaylistItemPtr item, const Song &new_metadata, const bool temporary);