mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-11 09:24:50 +01:00
parent
789c4924f4
commit
00c96f7334
@ -1309,6 +1309,18 @@ bool Playlist::CompareItems(int column, Qt::SortOrder order,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Playlist::ComparePathDepths(Qt::SortOrder order,
|
||||
shared_ptr<PlaylistItem> _a,
|
||||
shared_ptr<PlaylistItem> _b) {
|
||||
shared_ptr<PlaylistItem> a = order == Qt::AscendingOrder ? _a : _b;
|
||||
shared_ptr<PlaylistItem> b = order == Qt::AscendingOrder ? _b : _a;
|
||||
|
||||
int a_dir_level = a->Url().path().count('/');
|
||||
int b_dir_level = b->Url().path().count('/');
|
||||
|
||||
return a_dir_level < b_dir_level;
|
||||
}
|
||||
|
||||
QString Playlist::column_name(Column column) {
|
||||
switch (column) {
|
||||
case Column_Title:
|
||||
@ -1410,6 +1422,14 @@ void Playlist::sort(int column, Qt::SortOrder order) {
|
||||
std::bind(&Playlist::CompareItems, Column_Disc, order, _1, _2));
|
||||
qStableSort(begin, new_items.end(), std::bind(&Playlist::CompareItems,
|
||||
Column_Album, order, _1, _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.
|
||||
qStableSort(
|
||||
begin, new_items.end(),
|
||||
std::bind(&Playlist::CompareItems, Column_Filename, order, _1, _2));
|
||||
qStableSort(begin, new_items.end(),
|
||||
std::bind(&Playlist::ComparePathDepths, order, _1, _2));
|
||||
} else {
|
||||
qStableSort(begin, new_items.end(),
|
||||
std::bind(&Playlist::CompareItems, column, order, _1, _2));
|
||||
|
@ -306,6 +306,9 @@ class Playlist : public QAbstractListModel {
|
||||
bool removeRows(int row, int count,
|
||||
const QModelIndex& parent = QModelIndex());
|
||||
|
||||
static bool ComparePathDepths(Qt::SortOrder, PlaylistItemPtr,
|
||||
PlaylistItemPtr);
|
||||
|
||||
public slots:
|
||||
void set_current_row(int index, bool is_stopping = false);
|
||||
void Paused();
|
||||
|
Loading…
Reference in New Issue
Block a user