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

@@ -20,6 +20,8 @@
#include "config.h"
#include <algorithm>
#include <QtGlobal>
#include <QWidget>
#include <QDialog>
@@ -62,6 +64,8 @@
#undef AddJob
#endif
using std::sort;
const char *TranscodeDialog::kSettingsGroup = "Transcoder";
const int TranscodeDialog::kProgressInterval = 500;
const int TranscodeDialog::kMaxDestinationItems = 10;
@@ -89,7 +93,7 @@ TranscodeDialog::TranscodeDialog(QWidget *parent)
// Get presets
QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
qSort(presets.begin(), presets.end(), ComparePresetsByName);
std::sort(presets.begin(), presets.end(), ComparePresetsByName);
for (const TranscoderPreset &preset : presets) {
ui_->format->addItem(QString("%1 (.%2)").arg(preset.name_, preset.extension_), QVariant::fromValue(preset));
}

View File

@@ -24,6 +24,7 @@
#include <glib/gtypes.h>
#include <stdlib.h>
#include <memory>
#include <algorithm>
#include <gst/gst.h>
#include <QtGlobal>
@@ -47,10 +48,10 @@
#include "transcoder.h"
using std::shared_ptr;
using std::sort;
int Transcoder::JobFinishedEvent::sEventType = -1;
TranscoderPreset::TranscoderPreset(Song::FileType type, const QString &name, const QString &extension, const QString &codec_mimetype, const QString &muxer_mimetype)
: type_(type),
name_(name),
@@ -145,7 +146,7 @@ GstElement *Transcoder::CreateElementForMimeType(const QString &element_type, co
if (suitable_elements_.isEmpty()) return nullptr;
// Sort by rank
qSort(suitable_elements_);
std::sort(suitable_elements_.begin(), suitable_elements_.end());
const SuitableElement &best = suitable_elements_.last();
LogLine(QString("Using '%1' (rank %2)").arg(best.name_).arg(best.rank_));