Don't resort the playlist when reloading

This commit is contained in:
David Sansome 2009-12-26 15:21:36 +00:00
parent 9430a8fd2f
commit bd30d815d1
3 changed files with 7 additions and 5 deletions

View File

@ -45,7 +45,10 @@ MainWindow::MainWindow(QWidget *parent)
playlist_->Restore();
playlist_->IgnoreSorting(true);
ui_.playlist->setModel(playlist_);
playlist_->IgnoreSorting(false);
ui_.library_view->setModel(library_sort_model_);
ui_.library_view->SetLibrary(library_);

View File

@ -17,7 +17,7 @@ const char* Playlist::kSettingsGroup = "Playlist";
Playlist::Playlist(QObject *parent) :
QAbstractListModel(parent),
current_is_paused_(false),
ignore_next_sort_(true)
ignore_sorting_(false)
{
}
@ -273,10 +273,8 @@ bool Playlist::CompareItems(int column, Qt::SortOrder order,
}
void Playlist::sort(int column, Qt::SortOrder order) {
if (ignore_next_sort_) {
ignore_next_sort_ = false;
if (ignore_sorting_)
return;
}
layoutAboutToBeChanged();

View File

@ -70,6 +70,7 @@ class Playlist : public QAbstractListModel {
void Paused();
void Playing();
void Stopped();
void IgnoreSorting(bool value) { ignore_sorting_ = value; }
private:
void SetCurrentIsPaused(bool paused);
@ -82,7 +83,7 @@ class Playlist : public QAbstractListModel {
bool current_is_paused_;
// Hack to stop QTreeView::setModel sorting the playlist
bool ignore_next_sort_;
bool ignore_sorting_;
};
#endif // PLAYLIST_H