Use locale aware sorting for the lists of artists and albums in the album cover manager. Fixes issue 1952
This commit is contained in:
parent
195f618bf2
commit
7e1b6ef6c4
@ -19,6 +19,7 @@
|
|||||||
#include "albumcoversearcher.h"
|
#include "albumcoversearcher.h"
|
||||||
#include "iconloader.h"
|
#include "iconloader.h"
|
||||||
#include "ui_albumcovermanager.h"
|
#include "ui_albumcovermanager.h"
|
||||||
|
#include "core/logging.h"
|
||||||
#include "core/utilities.h"
|
#include "core/utilities.h"
|
||||||
#include "covers/albumcoverfetcher.h"
|
#include "covers/albumcoverfetcher.h"
|
||||||
#include "covers/coverproviders.h"
|
#include "covers/coverproviders.h"
|
||||||
@ -243,6 +244,15 @@ void AlbumCoverManager::CancelRequests() {
|
|||||||
ResetFetchCoversButton();
|
ResetFetchCoversButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool CompareNocase(const QString& left, const QString& right) {
|
||||||
|
return QString::localeAwareCompare(left, right) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool CompareAlbumNameNocase(const LibraryBackend::Album& left,
|
||||||
|
const LibraryBackend::Album& right) {
|
||||||
|
return CompareNocase(left.album_name, right.album_name);
|
||||||
|
}
|
||||||
|
|
||||||
void AlbumCoverManager::Reset() {
|
void AlbumCoverManager::Reset() {
|
||||||
ResetFetchCoversButton();
|
ResetFetchCoversButton();
|
||||||
|
|
||||||
@ -253,7 +263,10 @@ void AlbumCoverManager::Reset() {
|
|||||||
new QListWidgetItem(all_artists_icon_, tr("All artists"), ui_->artists, All_Artists);
|
new QListWidgetItem(all_artists_icon_, tr("All artists"), ui_->artists, All_Artists);
|
||||||
new QListWidgetItem(artist_icon_, tr("Various artists"), ui_->artists, Various_Artists);
|
new QListWidgetItem(artist_icon_, tr("Various artists"), ui_->artists, Various_Artists);
|
||||||
|
|
||||||
foreach (const QString& artist, backend_->GetAllArtistsWithAlbums()) {
|
QStringList artists(backend_->GetAllArtistsWithAlbums());
|
||||||
|
qStableSort(artists.begin(), artists.end(), CompareNocase);
|
||||||
|
|
||||||
|
foreach (const QString& artist, artists) {
|
||||||
if (artist.isEmpty())
|
if (artist.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -289,6 +302,10 @@ void AlbumCoverManager::ArtistChanged(QListWidgetItem* current) {
|
|||||||
default: albums = backend_->GetAllAlbums(); break;
|
default: albums = backend_->GetAllAlbums(); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort by album name. The list is already sorted by sqlite but it was done
|
||||||
|
// case sensitively.
|
||||||
|
qStableSort(albums.begin(), albums.end(), CompareAlbumNameNocase);
|
||||||
|
|
||||||
foreach (const LibraryBackend::Album& info, albums) {
|
foreach (const LibraryBackend::Album& info, albums) {
|
||||||
// Don't show songs without an album, obviously
|
// Don't show songs without an album, obviously
|
||||||
if (info.album_name.isEmpty())
|
if (info.album_name.isEmpty())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user