Replace qSort/qStableSort/qSwap

This commit is contained in:
Jonas Kvinge
2018-10-19 20:18:46 +02:00
parent 0969e7f504
commit 0cda4e27aa
24 changed files with 115 additions and 35 deletions

View File

@@ -43,6 +43,8 @@
#include "coverprovider.h"
#include "coverproviders.h"
using std::stable_sort;
const int AlbumCoverFetcherSearch::kSearchTimeoutMs = 12000;
const int AlbumCoverFetcherSearch::kImageLoadTimeoutMs = 3000;
const int AlbumCoverFetcherSearch::kTargetSize = 500;
@@ -148,7 +150,7 @@ void AlbumCoverFetcherSearch::AllProvidersFinished() {
// Now we have to load some images and figure out which one is the best.
// We'll sort the list of results by category, then load the first few images from each category and use some heuristics to score them.
// If no images are good enough we'll keep loading more images until we find one that is or we run out of results.
qStableSort(results_.begin(), results_.end(), CompareProviders);
std::stable_sort(results_.begin(), results_.end(), CompareProviders);
FetchMoreImages();
}

View File

@@ -21,6 +21,7 @@
#include "config.h"
#include <memory>
#include <algorithm>
#include <QtGlobal>
#include <QObject>
@@ -81,6 +82,8 @@
#include "ui_albumcovermanager.h"
using std::stable_sort;
const char *AlbumCoverManager::kSettingsGroup = "CoverManager";
AlbumCoverManager::AlbumCoverManager(Application *app, CollectionBackend *collection_backend, QWidget *parent, QNetworkAccessManager *network)
@@ -286,7 +289,7 @@ void AlbumCoverManager::Reset() {
new QListWidgetItem(artist_icon_, tr("Various artists"), ui_->artists, Various_Artists);
QStringList artists(collection_backend_->GetAllArtistsWithAlbums());
qStableSort(artists.begin(), artists.end(), CompareNocase);
std::stable_sort(artists.begin(), artists.end(), CompareNocase);
for (const QString &artist : artists) {
if (artist.isEmpty()) continue;
@@ -326,7 +329,7 @@ void AlbumCoverManager::ArtistChanged(QListWidgetItem *current) {
}
// Sort by album name. The list is already sorted by sqlite but it was done case sensitively.
qStableSort(albums.begin(), albums.end(), CompareAlbumNameNocase);
std::stable_sort(albums.begin(), albums.end(), CompareAlbumNameNocase);
for (const CollectionBackend::Album &info : albums) {
// Don't show songs without an album, obviously

View File

@@ -20,6 +20,8 @@
#include "config.h"
#include <algorithm>
#include <QWidget>
#include <QMap>
#include <QString>
@@ -34,6 +36,8 @@
#include "coversearchstatisticsdialog.h"
#include "ui_coversearchstatisticsdialog.h"
using std::sort;
CoverSearchStatisticsDialog::CoverSearchStatisticsDialog(QWidget *parent)
: QDialog(parent), ui_(new Ui_CoverSearchStatisticsDialog) {
@@ -61,7 +65,7 @@ CoverSearchStatisticsDialog::~CoverSearchStatisticsDialog() { delete ui_; }
void CoverSearchStatisticsDialog::Show(const CoverSearchStatistics &statistics) {
QStringList providers(statistics.total_images_by_provider_.keys());
qSort(providers);
std::sort(providers.begin(), providers.end());
ui_->summary->setText(tr("Got %1 covers out of %2 (%3 failed)")
.arg(statistics.chosen_images_)