Skip to content

Commit e1e6ec8

Browse files
committed
Resort playlist after adding files
1 parent ac6676f commit e1e6ec8

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/playlist.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1835,6 +1835,7 @@ void Playlist::addFiles(QStringList files, AutoGetInfo auto_get_info) {
18351835
MediaData data;
18361836
setCursor(Qt::WaitCursor);
18371837
#endif
1838+
listView->setSortingEnabled(false);
18381839

18391840
QString initial_file;
18401841
int new_current_item = -1;
@@ -1871,7 +1872,13 @@ void Playlist::addFiles(QStringList files, AutoGetInfo auto_get_info) {
18711872
#endif
18721873

18731874
if (new_current_item != -1) setCurrentItem(new_current_item);
1874-
if (shuffleAct->isChecked()) shuffle(true);
1875+
1876+
listView->setSortingEnabled(true);
1877+
if (shuffleAct->isChecked()) {
1878+
shuffle(true);
1879+
} else {
1880+
resort();
1881+
}
18751882
qDebug() << "Playlist::addFiles: latest_dir:" << latest_dir;
18761883
}
18771884

@@ -2694,4 +2701,11 @@ void Playlist::changeEvent(QEvent *e) {
26942701
}
26952702
}
26962703

2704+
void Playlist::resort() {
2705+
if (!listView->isSortingEnabled()) return;
2706+
int col = listView->horizontalHeader()->sortIndicatorSection();
2707+
Qt::SortOrder order = listView->horizontalHeader()->sortIndicatorOrder();
2708+
listView->sortByColumn(col, order);
2709+
}
2710+
26972711
#include "moc_playlist.cpp"

src/playlist.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ protected slots:
312312
void createTable();
313313
void createActions();
314314
void createToolbar();
315+
void resort();
315316

316317
protected:
317318
void retranslateStrings();

0 commit comments

Comments
 (0)