Replace qSort/qStableSort/qSwap
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
@@ -61,6 +62,8 @@
|
|||||||
#include "playlist/songmimedata.h"
|
#include "playlist/songmimedata.h"
|
||||||
#include "covermanager/albumcoverloader.h"
|
#include "covermanager/albumcoverloader.h"
|
||||||
|
|
||||||
|
using std::bind;
|
||||||
|
using std::sort;
|
||||||
using std::placeholders::_1;
|
using std::placeholders::_1;
|
||||||
using std::placeholders::_2;
|
using std::placeholders::_2;
|
||||||
|
|
||||||
@@ -1312,7 +1315,7 @@ void CollectionModel::GetChildSongs(CollectionItem *item, QList<QUrl> *urls, Son
|
|||||||
const_cast<CollectionModel*>(this)->LazyPopulate(item);
|
const_cast<CollectionModel*>(this)->LazyPopulate(item);
|
||||||
|
|
||||||
QList<CollectionItem*> children = item->children;
|
QList<CollectionItem*> children = item->children;
|
||||||
qSort(children.begin(), children.end(), std::bind(&CollectionModel::CompareItems, this, _1, _2));
|
std::sort(children.begin(), children.end(), std::bind(&CollectionModel::CompareItems, this, _1, _2));
|
||||||
|
|
||||||
for (CollectionItem *child : children)
|
for (CollectionItem *child : children)
|
||||||
GetChildSongs(child, urls, songs, song_ids);
|
GetChildSongs(child, urls, songs, song_ids);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
@@ -55,6 +56,8 @@
|
|||||||
|
|
||||||
#include "contextalbumsmodel.h"
|
#include "contextalbumsmodel.h"
|
||||||
|
|
||||||
|
using std::bind;
|
||||||
|
using std::sort;
|
||||||
using std::placeholders::_1;
|
using std::placeholders::_1;
|
||||||
using std::placeholders::_2;
|
using std::placeholders::_2;
|
||||||
|
|
||||||
@@ -479,7 +482,7 @@ void ContextAlbumsModel::GetChildSongs(CollectionItem *item, QList<QUrl> *urls,
|
|||||||
const_cast<ContextAlbumsModel*>(this)->LazyPopulate(item);
|
const_cast<ContextAlbumsModel*>(this)->LazyPopulate(item);
|
||||||
|
|
||||||
QList<CollectionItem*> children = item->children;
|
QList<CollectionItem*> children = item->children;
|
||||||
qSort(children.begin(), children.end(), std::bind(&ContextAlbumsModel::CompareItems, this, _1, _2));
|
std::sort(children.begin(), children.end(), std::bind(&ContextAlbumsModel::CompareItems, this, _1, _2));
|
||||||
|
|
||||||
for (CollectionItem *child : children)
|
for (CollectionItem *child : children)
|
||||||
GetChildSongs(child, urls, songs, song_ids);
|
GetChildSongs(child, urls, songs, song_ids);
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include "settings/settingsdialog.h"
|
#include "settings/settingsdialog.h"
|
||||||
|
|
||||||
|
using std::unique_ptr;
|
||||||
|
|
||||||
class TaskManager;
|
class TaskManager;
|
||||||
class ApplicationImpl;
|
class ApplicationImpl;
|
||||||
class TagReaderClient;
|
class TagReaderClient;
|
||||||
|
|||||||
@@ -152,6 +152,10 @@
|
|||||||
# include "core/macsystemtrayicon.h"
|
# include "core/macsystemtrayicon.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using std::bind;
|
||||||
|
using std::floor;
|
||||||
|
using std::stable_sort;
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
// Non exported mac-specific function.
|
// Non exported mac-specific function.
|
||||||
void qt_mac_set_dock_menu(QMenu*);
|
void qt_mac_set_dock_menu(QMenu*);
|
||||||
@@ -1547,6 +1551,7 @@ void MainWindow::EditTracks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::EditTagDialogAccepted() {
|
void MainWindow::EditTagDialogAccepted() {
|
||||||
|
|
||||||
for (PlaylistItemPtr item : edit_tag_dialog_->playlist_items()) {
|
for (PlaylistItemPtr item : edit_tag_dialog_->playlist_items()) {
|
||||||
item->Reload();
|
item->Reload();
|
||||||
}
|
}
|
||||||
@@ -1555,14 +1560,16 @@ void MainWindow::EditTagDialogAccepted() {
|
|||||||
ui_->playlist->view()->update();
|
ui_->playlist->view()->update();
|
||||||
|
|
||||||
app_->playlist_manager()->current()->Save();
|
app_->playlist_manager()->current()->Save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::RenumberTracks() {
|
void MainWindow::RenumberTracks() {
|
||||||
|
|
||||||
QModelIndexList indexes =ui_->playlist->view()->selectionModel()->selection().indexes();
|
QModelIndexList indexes =ui_->playlist->view()->selectionModel()->selection().indexes();
|
||||||
int track = 1;
|
int track = 1;
|
||||||
|
|
||||||
// Get the index list in order
|
// Get the index list in order
|
||||||
qStableSort(indexes);
|
std::stable_sort(indexes.begin(), indexes.end());
|
||||||
|
|
||||||
// if first selected song has a track number set, start from that offset
|
// if first selected song has a track number set, start from that offset
|
||||||
if (!indexes.isEmpty()) {
|
if (!indexes.isEmpty()) {
|
||||||
@@ -1587,6 +1594,7 @@ void MainWindow::RenumberTracks() {
|
|||||||
}
|
}
|
||||||
track++;
|
track++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::SongSaveComplete(TagReaderReply *reply,const QPersistentModelIndex &index) {
|
void MainWindow::SongSaveComplete(TagReaderReply *reply,const QPersistentModelIndex &index) {
|
||||||
|
|||||||
@@ -57,6 +57,8 @@
|
|||||||
#include "playlist/playlistitem.h"
|
#include "playlist/playlistitem.h"
|
||||||
#include "settings/settingsdialog.h"
|
#include "settings/settingsdialog.h"
|
||||||
|
|
||||||
|
using std::unique_ptr;
|
||||||
|
|
||||||
class About;
|
class About;
|
||||||
class AlbumCoverManager;;
|
class AlbumCoverManager;;
|
||||||
class Application;
|
class Application;
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <taglib/fileref.h>
|
#include <taglib/fileref.h>
|
||||||
#include <taglib/id3v1genres.h>
|
#include <taglib/id3v1genres.h>
|
||||||
|
|
||||||
@@ -66,6 +68,8 @@
|
|||||||
#include "covermanager/albumcoverloader.h"
|
#include "covermanager/albumcoverloader.h"
|
||||||
#include "tagreadermessages.pb.h"
|
#include "tagreadermessages.pb.h"
|
||||||
|
|
||||||
|
using std::sort;
|
||||||
|
|
||||||
const QStringList Song::kColumns = QStringList() << "title"
|
const QStringList Song::kColumns = QStringList() << "title"
|
||||||
<< "album"
|
<< "album"
|
||||||
<< "artist"
|
<< "artist"
|
||||||
@@ -495,7 +499,7 @@ int CompareSongsName(const Song &song1, const Song &song2) {
|
|||||||
|
|
||||||
void Song::SortSongsListAlphabetically(SongList *songs) {
|
void Song::SortSongsListAlphabetically(SongList *songs) {
|
||||||
Q_ASSERT(songs);
|
Q_ASSERT(songs);
|
||||||
qSort(songs->begin(), songs->end(), CompareSongsName);
|
std::sort(songs->begin(), songs->end(), CompareSongsName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Song::Init(const QString &title, const QString &artist, const QString &album, qint64 length_nanosec) {
|
void Song::Init(const QString &title, const QString &artist, const QString &album, qint64 length_nanosec) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#ifdef HAVE_GSTREAMER
|
#ifdef HAVE_GSTREAMER
|
||||||
# include <gst/gst.h>
|
# include <gst/gst.h>
|
||||||
@@ -65,6 +66,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::placeholders::_1;
|
using std::placeholders::_1;
|
||||||
|
using std::bind;
|
||||||
|
using std::stable_sort;
|
||||||
|
using std::shared_ptr;
|
||||||
|
|
||||||
QSet<QString> SongLoader::sRawUriSchemes;
|
QSet<QString> SongLoader::sRawUriSchemes;
|
||||||
const int SongLoader::kDefaultTimeout = 5000;
|
const int SongLoader::kDefaultTimeout = 5000;
|
||||||
@@ -323,7 +327,7 @@ void SongLoader::LoadLocalDirectory(const QString &filename) {
|
|||||||
LoadLocalPartial(it.next());
|
LoadLocalPartial(it.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
qStableSort(songs_.begin(), songs_.end(), CompareSongs);
|
std::stable_sort(songs_.begin(), songs_.end(), CompareSongs);
|
||||||
|
|
||||||
// Load the first song:
|
// Load the first song:
|
||||||
// all songs will be loaded async, but we want the first one in our list to be fully loaded,
|
// all songs will be loaded async, but we want the first one in our list to be fully loaded,
|
||||||
|
|||||||
@@ -43,6 +43,8 @@
|
|||||||
#include "coverprovider.h"
|
#include "coverprovider.h"
|
||||||
#include "coverproviders.h"
|
#include "coverproviders.h"
|
||||||
|
|
||||||
|
using std::stable_sort;
|
||||||
|
|
||||||
const int AlbumCoverFetcherSearch::kSearchTimeoutMs = 12000;
|
const int AlbumCoverFetcherSearch::kSearchTimeoutMs = 12000;
|
||||||
const int AlbumCoverFetcherSearch::kImageLoadTimeoutMs = 3000;
|
const int AlbumCoverFetcherSearch::kImageLoadTimeoutMs = 3000;
|
||||||
const int AlbumCoverFetcherSearch::kTargetSize = 500;
|
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.
|
// 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.
|
// 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.
|
// 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();
|
FetchMoreImages();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -81,6 +82,8 @@
|
|||||||
|
|
||||||
#include "ui_albumcovermanager.h"
|
#include "ui_albumcovermanager.h"
|
||||||
|
|
||||||
|
using std::stable_sort;
|
||||||
|
|
||||||
const char *AlbumCoverManager::kSettingsGroup = "CoverManager";
|
const char *AlbumCoverManager::kSettingsGroup = "CoverManager";
|
||||||
|
|
||||||
AlbumCoverManager::AlbumCoverManager(Application *app, CollectionBackend *collection_backend, QWidget *parent, QNetworkAccessManager *network)
|
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);
|
new QListWidgetItem(artist_icon_, tr("Various artists"), ui_->artists, Various_Artists);
|
||||||
|
|
||||||
QStringList artists(collection_backend_->GetAllArtistsWithAlbums());
|
QStringList artists(collection_backend_->GetAllArtistsWithAlbums());
|
||||||
qStableSort(artists.begin(), artists.end(), CompareNocase);
|
std::stable_sort(artists.begin(), artists.end(), CompareNocase);
|
||||||
|
|
||||||
for (const QString &artist : artists) {
|
for (const QString &artist : artists) {
|
||||||
if (artist.isEmpty()) continue;
|
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.
|
// 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) {
|
for (const CollectionBackend::Album &info : albums) {
|
||||||
// Don't show songs without an album, obviously
|
// Don't show songs without an album, obviously
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -34,6 +36,8 @@
|
|||||||
#include "coversearchstatisticsdialog.h"
|
#include "coversearchstatisticsdialog.h"
|
||||||
#include "ui_coversearchstatisticsdialog.h"
|
#include "ui_coversearchstatisticsdialog.h"
|
||||||
|
|
||||||
|
using std::sort;
|
||||||
|
|
||||||
CoverSearchStatisticsDialog::CoverSearchStatisticsDialog(QWidget *parent)
|
CoverSearchStatisticsDialog::CoverSearchStatisticsDialog(QWidget *parent)
|
||||||
: QDialog(parent), ui_(new Ui_CoverSearchStatisticsDialog) {
|
: QDialog(parent), ui_(new Ui_CoverSearchStatisticsDialog) {
|
||||||
|
|
||||||
@@ -61,7 +65,7 @@ CoverSearchStatisticsDialog::~CoverSearchStatisticsDialog() { delete ui_; }
|
|||||||
void CoverSearchStatisticsDialog::Show(const CoverSearchStatistics &statistics) {
|
void CoverSearchStatisticsDialog::Show(const CoverSearchStatistics &statistics) {
|
||||||
|
|
||||||
QStringList providers(statistics.total_images_by_provider_.keys());
|
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)")
|
ui_->summary->setText(tr("Got %1 covers out of %2 (%3 failed)")
|
||||||
.arg(statistics.chosen_images_)
|
.arg(statistics.chosen_images_)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QtConcurrentRun>
|
#include <QtConcurrentRun>
|
||||||
@@ -63,6 +64,9 @@
|
|||||||
#include "organiseerrordialog.h"
|
#include "organiseerrordialog.h"
|
||||||
#include "ui_organisedialog.h"
|
#include "ui_organisedialog.h"
|
||||||
|
|
||||||
|
using std::shared_ptr;
|
||||||
|
using std::stable_sort;
|
||||||
|
|
||||||
const char *OrganiseDialog::kDefaultFormat = "%artist/%album{ (Disc %disc)}/{%track - }%title.%extension";
|
const char *OrganiseDialog::kDefaultFormat = "%artist/%album{ (Disc %disc)}/{%track - }%title.%extension";
|
||||||
const char *OrganiseDialog::kSettingsGroup = "OrganiseDialog";
|
const char *OrganiseDialog::kSettingsGroup = "OrganiseDialog";
|
||||||
|
|
||||||
@@ -111,7 +115,7 @@ OrganiseDialog::OrganiseDialog(TaskManager *task_manager, QWidget *parent)
|
|||||||
|
|
||||||
// Get the titles of the tags to put in the insert menu
|
// Get the titles of the tags to put in the insert menu
|
||||||
QStringList tag_titles = tags.keys();
|
QStringList tag_titles = tags.keys();
|
||||||
qStableSort(tag_titles);
|
std::stable_sort(tag_titles.begin(), tag_titles.end());
|
||||||
|
|
||||||
// Build the insert menu
|
// Build the insert menu
|
||||||
QMenu *tag_menu = new QMenu(this);
|
QMenu *tag_menu = new QMenu(this);
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QtAlgorithms>
|
#include <QtAlgorithms>
|
||||||
@@ -33,6 +35,8 @@
|
|||||||
#include "organiseerrordialog.h"
|
#include "organiseerrordialog.h"
|
||||||
#include "ui_organiseerrordialog.h"
|
#include "ui_organiseerrordialog.h"
|
||||||
|
|
||||||
|
using std::stable_sort;
|
||||||
|
|
||||||
OrganiseErrorDialog::OrganiseErrorDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_OrganiseErrorDialog) {
|
OrganiseErrorDialog::OrganiseErrorDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_OrganiseErrorDialog) {
|
||||||
|
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
@@ -61,7 +65,7 @@ void OrganiseErrorDialog::Show(OperationType type, const SongList &songs_with_er
|
|||||||
void OrganiseErrorDialog::Show(OperationType type, const QStringList &files_with_errors) {
|
void OrganiseErrorDialog::Show(OperationType type, const QStringList &files_with_errors) {
|
||||||
|
|
||||||
QStringList sorted_files = files_with_errors;
|
QStringList sorted_files = files_with_errors;
|
||||||
qStableSort(sorted_files);
|
std::stable_sort(sorted_files.begin(), sorted_files.end());
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Type_Copy:
|
case Type_Copy:
|
||||||
|
|||||||
@@ -45,6 +45,8 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QTimerEvent>
|
#include <QTimerEvent>
|
||||||
|
|
||||||
|
using std::unique_ptr;
|
||||||
|
|
||||||
class GstEngine;
|
class GstEngine;
|
||||||
class GstBufferConsumer;
|
class GstBufferConsumer;
|
||||||
class GstElementDeleter;
|
class GstElementDeleter;
|
||||||
|
|||||||
@@ -50,6 +50,8 @@
|
|||||||
#include "internetservice.h"
|
#include "internetservice.h"
|
||||||
#include "internetmodel.h"
|
#include "internetmodel.h"
|
||||||
|
|
||||||
|
using std::advance;
|
||||||
|
|
||||||
const int InternetSearch::kDelayedSearchTimeoutMs = 200;
|
const int InternetSearch::kDelayedSearchTimeoutMs = 200;
|
||||||
const int InternetSearch::kMaxResultsPerEmission = 2000;
|
const int InternetSearch::kMaxResultsPerEmission = 2000;
|
||||||
const int InternetSearch::kArtHeight = 32;
|
const int InternetSearch::kArtHeight = 32;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@@ -46,6 +47,8 @@
|
|||||||
#include "core/network.h"
|
#include "core/network.h"
|
||||||
#include "core/timeconstants.h"
|
#include "core/timeconstants.h"
|
||||||
|
|
||||||
|
using std::stable_sort;
|
||||||
|
|
||||||
const char *AcoustidClient::kClientId = "0qjUoxbowg";
|
const char *AcoustidClient::kClientId = "0qjUoxbowg";
|
||||||
const char *AcoustidClient::kUrl = "http://api.acoustid.org/v2/lookup";
|
const char *AcoustidClient::kUrl = "http://api.acoustid.org/v2/lookup";
|
||||||
const int AcoustidClient::kDefaultTimeout = 5000; // msec
|
const int AcoustidClient::kDefaultTimeout = 5000; // msec
|
||||||
@@ -153,7 +156,7 @@ void AcoustidClient::RequestFinished(QNetworkReply *reply, int request_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qStableSort(id_source_list);
|
std::stable_sort(id_source_list.begin(), id_source_list.end());
|
||||||
|
|
||||||
QList<QString> id_list;
|
QList<QString> id_list;
|
||||||
for (const IdSource& is : id_source_list) {
|
for (const IdSource& is : id_source_list) {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
@@ -44,6 +46,9 @@
|
|||||||
#include "core/utilities.h"
|
#include "core/utilities.h"
|
||||||
#include "musicbrainzclient.h"
|
#include "musicbrainzclient.h"
|
||||||
|
|
||||||
|
using std::sort;
|
||||||
|
using std::stable_sort;
|
||||||
|
|
||||||
const char *MusicBrainzClient::kTrackUrl = "http://musicbrainz.org/ws/2/recording/";
|
const char *MusicBrainzClient::kTrackUrl = "http://musicbrainz.org/ws/2/recording/";
|
||||||
const char *MusicBrainzClient::kDiscUrl = "http://musicbrainz.org/ws/2/discid/";
|
const char *MusicBrainzClient::kDiscUrl = "http://musicbrainz.org/ws/2/discid/";
|
||||||
const char *MusicBrainzClient::kDateRegex = "^[12]\\d{3}";
|
const char *MusicBrainzClient::kDateRegex = "^[12]\\d{3}";
|
||||||
@@ -220,7 +225,7 @@ void MusicBrainzClient::RequestFinished(QNetworkReply *reply, int id, int reques
|
|||||||
// Merge the results we have
|
// Merge the results we have
|
||||||
ResultList ret;
|
ResultList ret;
|
||||||
QList<PendingResults> result_list_list = pending_results_.take(id);
|
QList<PendingResults> result_list_list = pending_results_.take(id);
|
||||||
qSort(result_list_list);
|
std::sort(result_list_list.begin(), result_list_list.end());
|
||||||
for (const PendingResults &result_list : result_list_list) {
|
for (const PendingResults &result_list : result_list_list) {
|
||||||
ret << result_list.results_;
|
ret << result_list.results_;
|
||||||
}
|
}
|
||||||
@@ -242,6 +247,7 @@ bool MusicBrainzClient::MediumHasDiscid(const QString &discid, QXmlStreamReader
|
|||||||
}
|
}
|
||||||
qLog(Debug) << "Reached end of xml stream without encountering </disc-list>";
|
qLog(Debug) << "Reached end of xml stream without encountering </disc-list>";
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MusicBrainzClient::ResultList MusicBrainzClient::ParseMedium(QXmlStreamReader *reader) {
|
MusicBrainzClient::ResultList MusicBrainzClient::ParseMedium(QXmlStreamReader *reader) {
|
||||||
@@ -330,7 +336,7 @@ MusicBrainzClient::ResultList MusicBrainzClient::ParseTrack(QXmlStreamReader *re
|
|||||||
ret << result;
|
ret << result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qStableSort(releases);
|
std::stable_sort(releases.begin(), releases.end());
|
||||||
for (const Release &release : releases) {
|
for (const Release &release : releases) {
|
||||||
ret << release.CopyAndMergeInto(result);
|
ret << release.CopyAndMergeInto(result);
|
||||||
}
|
}
|
||||||
@@ -401,7 +407,7 @@ MusicBrainzClient::ResultList MusicBrainzClient::UniqueResults(const ResultList&
|
|||||||
ResultList ret;
|
ResultList ret;
|
||||||
if (opt == SortResults) {
|
if (opt == SortResults) {
|
||||||
ret = QSet<Result>::fromList(results).toList();
|
ret = QSet<Result>::fromList(results).toList();
|
||||||
qSort(ret);
|
std::sort(ret.begin(), ret.end());
|
||||||
}
|
}
|
||||||
else { // KeepOriginalOrder
|
else { // KeepOriginalOrder
|
||||||
// Qt doesn't provide a ordered set (QSet "stores values in an unspecified order" according to Qt documentation).
|
// Qt doesn't provide a ordered set (QSet "stores values in an unspecified order" according to Qt documentation).
|
||||||
|
|||||||
@@ -94,6 +94,10 @@ using std::placeholders::_1;
|
|||||||
using std::placeholders::_2;
|
using std::placeholders::_2;
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
using std::unordered_map;
|
using std::unordered_map;
|
||||||
|
using std::sort;
|
||||||
|
using std::stable_sort;
|
||||||
|
using std::greater;
|
||||||
|
using std::swap;
|
||||||
|
|
||||||
const char *Playlist::kCddaMimeType = "x-content/audio-cdda";
|
const char *Playlist::kCddaMimeType = "x-content/audio-cdda";
|
||||||
const char *Playlist::kRowsMimetype = "application/x-strawberry-playlist-rows";
|
const char *Playlist::kRowsMimetype = "application/x-strawberry-playlist-rows";
|
||||||
@@ -684,7 +688,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
|
|||||||
pid = !own_pid;
|
pid = !own_pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
qStableSort(source_rows); // Make sure we take them in order
|
std::stable_sort(source_rows.begin(), source_rows.end()); // Make sure we take them in order
|
||||||
|
|
||||||
if (source_playlist == this) {
|
if (source_playlist == this) {
|
||||||
// Dragged from this playlist - rearrange the items
|
// Dragged from this playlist - rearrange the items
|
||||||
@@ -1194,17 +1198,17 @@ void Playlist::sort(int column, Qt::SortOrder order) {
|
|||||||
|
|
||||||
if (column == Column_Album) {
|
if (column == Column_Album) {
|
||||||
// When sorting by album, also take into account discs and tracks.
|
// When sorting by album, also take into account discs and tracks.
|
||||||
qStableSort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Track, order, _1, _2));
|
std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Track, order, _1, _2));
|
||||||
qStableSort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Disc, order, _1, _2));
|
std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Disc, order, _1, _2));
|
||||||
qStableSort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Album, order, _1, _2));
|
std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Album, order, _1, _2));
|
||||||
}
|
}
|
||||||
else if (column == Column_Filename) {
|
else if (column == Column_Filename) {
|
||||||
// When sorting by full paths we also expect a hierarchical order. This returns a breath-first ordering of paths.
|
// When sorting by full paths we also expect a hierarchical order. This returns a breath-first ordering of paths.
|
||||||
qStableSort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Filename, order, _1, _2));
|
std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Filename, order, _1, _2));
|
||||||
qStableSort(begin, new_items.end(), std::bind(&Playlist::ComparePathDepths, order, _1, _2));
|
std::stable_sort(begin, new_items.end(), std::bind(&Playlist::ComparePathDepths, order, _1, _2));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qStableSort(begin, new_items.end(), std::bind(&Playlist::CompareItems, column, order, _1, _2));
|
std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, column, order, _1, _2));
|
||||||
}
|
}
|
||||||
|
|
||||||
undo_stack_->push(new PlaylistUndoCommands::SortItems(this, column, order, new_items));
|
undo_stack_->push(new PlaylistUndoCommands::SortItems(this, column, order, new_items));
|
||||||
@@ -1321,7 +1325,7 @@ void Playlist::RemoveItemsWithoutUndo(const QList<int> &indicesIn) {
|
|||||||
|
|
||||||
// Sort the indices descending because removing elements 'backwards' is easier - indices don't 'move' in the process.
|
// Sort the indices descending because removing elements 'backwards' is easier - indices don't 'move' in the process.
|
||||||
QList<int> indices = indicesIn;
|
QList<int> indices = indicesIn;
|
||||||
qSort(indices.begin(), indices.end(), DescendingIntLessThan);
|
std::sort(indices.begin(), indices.end(), DescendingIntLessThan);
|
||||||
|
|
||||||
for (int j = 0; j < indices.count(); j++) {
|
for (int j = 0; j < indices.count(); j++) {
|
||||||
int beginning = indices[j], end = indices[j];
|
int beginning = indices[j], end = indices[j];
|
||||||
@@ -1367,7 +1371,7 @@ bool Playlist::removeRows(QList<int> &rows) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start from the end to be sure that indices won't 'move' during the removal process
|
// Start from the end to be sure that indices won't 'move' during the removal process
|
||||||
qSort(rows.begin(), rows.end(), qGreater<int>());
|
std::sort(rows.begin(), rows.end(), std::greater<int>());
|
||||||
|
|
||||||
QList<int> part;
|
QList<int> part;
|
||||||
while (!rows.isEmpty()) {
|
while (!rows.isEmpty()) {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -77,6 +78,8 @@
|
|||||||
#include "settings/playbacksettingspage.h"
|
#include "settings/playbacksettingspage.h"
|
||||||
#include "settings/playlistsettingspage.h"
|
#include "settings/playlistsettingspage.h"
|
||||||
|
|
||||||
|
using std::sort;
|
||||||
|
|
||||||
const int PlaylistView::kStateVersion = 6;
|
const int PlaylistView::kStateVersion = 6;
|
||||||
const int PlaylistView::kGlowIntensitySteps = 24;
|
const int PlaylistView::kGlowIntensitySteps = 24;
|
||||||
const int PlaylistView::kAutoscrollGraceTimeout = 30; // seconds
|
const int PlaylistView::kAutoscrollGraceTimeout = 30; // seconds
|
||||||
@@ -572,7 +575,7 @@ void PlaylistView::RemoveSelected(bool deleting_from_disk) {
|
|||||||
int last_row = selection.last().top();
|
int last_row = selection.last().top();
|
||||||
|
|
||||||
// Sort the selection so we remove the items at the *bottom* first, ensuring we don't have to mess around with changing row numbers
|
// Sort the selection so we remove the items at the *bottom* first, ensuring we don't have to mess around with changing row numbers
|
||||||
qSort(selection.begin(), selection.end(), CompareSelectionRanges);
|
std::sort(selection.begin(), selection.end(), CompareSelectionRanges);
|
||||||
|
|
||||||
for (const QItemSelectionRange &range : selection) {
|
for (const QItemSelectionRange &range : selection) {
|
||||||
if (range.top() < last_row) rows_removed += range.height();
|
if (range.top() < last_row) rows_removed += range.height();
|
||||||
@@ -613,7 +616,7 @@ QList<int> PlaylistView::GetEditableColumns() {
|
|||||||
QModelIndex index = model()->index(0, col);
|
QModelIndex index = model()->index(0, col);
|
||||||
if (index.flags() & Qt::ItemIsEditable) columns << h->visualIndex(col);
|
if (index.flags() & Qt::ItemIsEditable) columns << h->visualIndex(col);
|
||||||
}
|
}
|
||||||
qSort(columns);
|
std::sort(columns.begin(), columns.end());
|
||||||
return columns;
|
return columns;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
@@ -39,6 +41,8 @@
|
|||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
|
||||||
|
using std::stable_sort;
|
||||||
|
|
||||||
const char *Queue::kRowsMimetype = "application/x-strawberry-queue-rows";
|
const char *Queue::kRowsMimetype = "application/x-strawberry-queue-rows";
|
||||||
|
|
||||||
Queue::Queue(QObject *parent) : QAbstractProxyModel(parent) {}
|
Queue::Queue(QObject *parent) : QAbstractProxyModel(parent) {}
|
||||||
@@ -279,7 +283,9 @@ bool Queue::dropMimeData(const QMimeData *data, Qt::DropAction action, int row,
|
|||||||
QList<int> proxy_rows;
|
QList<int> proxy_rows;
|
||||||
QDataStream stream(data->data(kRowsMimetype));
|
QDataStream stream(data->data(kRowsMimetype));
|
||||||
stream >> proxy_rows;
|
stream >> proxy_rows;
|
||||||
qStableSort(proxy_rows); // Make sure we take them in order
|
|
||||||
|
// Make sure we take them in order
|
||||||
|
std::stable_sort(proxy_rows.begin(), proxy_rows.end());
|
||||||
|
|
||||||
Move(proxy_rows, row);
|
Move(proxy_rows, row);
|
||||||
}
|
}
|
||||||
@@ -355,7 +361,7 @@ QVariant Queue::headerData(int section, Qt::Orientation orientation, int role) c
|
|||||||
void Queue::Remove(QList<int> &proxy_rows) {
|
void Queue::Remove(QList<int> &proxy_rows) {
|
||||||
|
|
||||||
// Order the rows
|
// Order the rows
|
||||||
qStableSort(proxy_rows);
|
std::stable_sort(proxy_rows.begin(), proxy_rows.end());
|
||||||
|
|
||||||
// Reflects immediately changes in the playlist
|
// Reflects immediately changes in the playlist
|
||||||
layoutAboutToBeChanged();
|
layoutAboutToBeChanged();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
@@ -39,6 +40,8 @@
|
|||||||
#include "queuemanager.h"
|
#include "queuemanager.h"
|
||||||
#include "ui_queuemanager.h"
|
#include "ui_queuemanager.h"
|
||||||
|
|
||||||
|
using std::stable_sort;
|
||||||
|
|
||||||
QueueManager::QueueManager(QWidget *parent)
|
QueueManager::QueueManager(QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
ui_(new Ui_QueueManager),
|
ui_(new Ui_QueueManager),
|
||||||
@@ -105,7 +108,7 @@ void QueueManager::CurrentPlaylistChanged(Playlist *playlist) {
|
|||||||
void QueueManager::MoveUp() {
|
void QueueManager::MoveUp() {
|
||||||
|
|
||||||
QModelIndexList indexes = ui_->list->selectionModel()->selectedRows();
|
QModelIndexList indexes = ui_->list->selectionModel()->selectedRows();
|
||||||
qStableSort(indexes);
|
std::stable_sort(indexes.begin(), indexes.end());
|
||||||
|
|
||||||
if (indexes.isEmpty() || indexes.first().row() == 0) return;
|
if (indexes.isEmpty() || indexes.first().row() == 0) return;
|
||||||
|
|
||||||
@@ -118,7 +121,7 @@ void QueueManager::MoveUp() {
|
|||||||
void QueueManager::MoveDown() {
|
void QueueManager::MoveDown() {
|
||||||
|
|
||||||
QModelIndexList indexes = ui_->list->selectionModel()->selectedRows();
|
QModelIndexList indexes = ui_->list->selectionModel()->selectedRows();
|
||||||
qStableSort(indexes);
|
std::stable_sort(indexes.begin(), indexes.end());
|
||||||
|
|
||||||
if (indexes.isEmpty() || indexes.last().row() == current_playlist_->queue()->rowCount()-1)
|
if (indexes.isEmpty() || indexes.last().row() == current_playlist_->queue()->rowCount()-1)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -41,6 +41,8 @@
|
|||||||
#include "wplparser.h"
|
#include "wplparser.h"
|
||||||
#include "xspfparser.h"
|
#include "xspfparser.h"
|
||||||
|
|
||||||
|
using std::stable_sort;
|
||||||
|
|
||||||
const int PlaylistParser::kMagicSize = 512;
|
const int PlaylistParser::kMagicSize = 512;
|
||||||
|
|
||||||
PlaylistParser::PlaylistParser(CollectionBackendInterface *collection, QObject *parent)
|
PlaylistParser::PlaylistParser(CollectionBackendInterface *collection, QObject *parent)
|
||||||
@@ -66,7 +68,7 @@ QStringList PlaylistParser::file_extensions() const {
|
|||||||
ret << parser->file_extensions();
|
ret << parser->file_extensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
qStableSort(ret);
|
std::stable_sort(ret.begin(), ret.end());
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -79,7 +81,7 @@ QStringList PlaylistParser::mime_types() const {
|
|||||||
if (!parser->mime_type().isEmpty()) ret << parser->mime_type();
|
if (!parser->mime_type().isEmpty()) ret << parser->mime_type();
|
||||||
}
|
}
|
||||||
|
|
||||||
qStableSort(ret);
|
std::stable_sort(ret.begin(), ret.end());
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
@@ -62,6 +64,8 @@
|
|||||||
#undef AddJob
|
#undef AddJob
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using std::sort;
|
||||||
|
|
||||||
const char *TranscodeDialog::kSettingsGroup = "Transcoder";
|
const char *TranscodeDialog::kSettingsGroup = "Transcoder";
|
||||||
const int TranscodeDialog::kProgressInterval = 500;
|
const int TranscodeDialog::kProgressInterval = 500;
|
||||||
const int TranscodeDialog::kMaxDestinationItems = 10;
|
const int TranscodeDialog::kMaxDestinationItems = 10;
|
||||||
@@ -89,7 +93,7 @@ TranscodeDialog::TranscodeDialog(QWidget *parent)
|
|||||||
|
|
||||||
// Get presets
|
// Get presets
|
||||||
QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
|
QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
|
||||||
qSort(presets.begin(), presets.end(), ComparePresetsByName);
|
std::sort(presets.begin(), presets.end(), ComparePresetsByName);
|
||||||
for (const TranscoderPreset &preset : presets) {
|
for (const TranscoderPreset &preset : presets) {
|
||||||
ui_->format->addItem(QString("%1 (.%2)").arg(preset.name_, preset.extension_), QVariant::fromValue(preset));
|
ui_->format->addItem(QString("%1 (.%2)").arg(preset.name_, preset.extension_), QVariant::fromValue(preset));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <glib/gtypes.h>
|
#include <glib/gtypes.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <algorithm>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
@@ -47,10 +48,10 @@
|
|||||||
#include "transcoder.h"
|
#include "transcoder.h"
|
||||||
|
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
using std::sort;
|
||||||
|
|
||||||
int Transcoder::JobFinishedEvent::sEventType = -1;
|
int Transcoder::JobFinishedEvent::sEventType = -1;
|
||||||
|
|
||||||
|
|
||||||
TranscoderPreset::TranscoderPreset(Song::FileType type, const QString &name, const QString &extension, const QString &codec_mimetype, const QString &muxer_mimetype)
|
TranscoderPreset::TranscoderPreset(Song::FileType type, const QString &name, const QString &extension, const QString &codec_mimetype, const QString &muxer_mimetype)
|
||||||
: type_(type),
|
: type_(type),
|
||||||
name_(name),
|
name_(name),
|
||||||
@@ -145,7 +146,7 @@ GstElement *Transcoder::CreateElementForMimeType(const QString &element_type, co
|
|||||||
if (suitable_elements_.isEmpty()) return nullptr;
|
if (suitable_elements_.isEmpty()) return nullptr;
|
||||||
|
|
||||||
// Sort by rank
|
// Sort by rank
|
||||||
qSort(suitable_elements_);
|
std::sort(suitable_elements_.begin(), suitable_elements_.end());
|
||||||
const SuitableElement &best = suitable_elements_.last();
|
const SuitableElement &best = suitable_elements_.last();
|
||||||
|
|
||||||
LogLine(QString("Using '%1' (rank %2)").arg(best.name_).arg(best.rank_));
|
LogLine(QString("Using '%1' (rank %2)").arg(best.name_).arg(best.rank_));
|
||||||
|
|||||||
Reference in New Issue
Block a user