From b55851feec875f6be5ce1f6f28ccb21748226037 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sat, 18 Aug 2012 18:42:18 -0400 Subject: [PATCH] TWK-1045: Alphabetize spotify playlists in settings widget --- src/libtomahawk/accounts/spotify/SpotifyAccount.cpp | 1 - .../accounts/spotify/SpotifyAccountConfig.cpp | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp b/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp index 7e9792810..696d503cc 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp +++ b/src/libtomahawk/accounts/spotify/SpotifyAccount.cpp @@ -71,7 +71,6 @@ enum ActionType { }; } - Account* SpotifyAccountFactory::createAccount( const QString& accountId ) { diff --git a/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.cpp b/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.cpp index ec57e12e2..6a902d609 100644 --- a/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.cpp +++ b/src/libtomahawk/accounts/spotify/SpotifyAccountConfig.cpp @@ -30,6 +30,11 @@ using namespace Tomahawk; using namespace Accounts; +bool InfoSorter( const SpotifyPlaylistInfo* left, const SpotifyPlaylistInfo* right ) +{ + return left->name < right->name; +} + SpotifyAccountConfig::SpotifyAccountConfig( SpotifyAccount *account ) : QWidget( 0 ) , m_ui( new Ui::SpotifyConfig ) @@ -135,7 +140,11 @@ SpotifyAccountConfig::setPlaylists( const QList& playlist m_playlistsLoading->fadeOut(); m_ui->playlistList->clear(); - foreach ( SpotifyPlaylistInfo* pl, playlists ) + + QList myList = playlists; + qSort( myList.begin(), myList.end(), InfoSorter ); + + foreach ( SpotifyPlaylistInfo* pl, myList ) { QListWidgetItem* item = new QListWidgetItem( pl->name, m_ui->playlistList ); item->setData( Qt::UserRole, QVariant::fromValue< SpotifyPlaylistInfo* >( pl ) );