Use C++11 enum class
This commit is contained in:
@@ -193,7 +193,7 @@ void Organize::ProcessSomeFiles() {
|
||||
else {
|
||||
// Figure out if we need to transcode it
|
||||
Song::FileType dest_type = CheckTranscode(song.filetype());
|
||||
if (dest_type != Song::FileType_Unknown) {
|
||||
if (dest_type != Song::FileType::Unknown) {
|
||||
// Get the preset
|
||||
TranscoderPreset preset = Transcoder::PresetForFileType(dest_type);
|
||||
qLog(Debug) << "Transcoding with" << preset.name_;
|
||||
@@ -238,7 +238,7 @@ void Organize::ProcessSomeFiles() {
|
||||
job.cover_source_ = task.song_info_.song_.art_automatic().path();
|
||||
}
|
||||
}
|
||||
else if (destination_->source() == Song::Source_Device) {
|
||||
else if (destination_->source() == Song::Source::Device) {
|
||||
job.cover_image_ = TagReaderClient::Instance()->LoadEmbeddedArtAsImageBlocking(task.song_info_.song_.url().toLocalFile());
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ void Organize::ProcessSomeFiles() {
|
||||
job.progress_ = std::bind(&Organize::SetSongProgress, this, std::placeholders::_1, !task.transcoded_filename_.isEmpty());
|
||||
|
||||
if (destination_->CopyToStorage(job)) {
|
||||
if (job.remove_original_ && (destination_->source() == Song::Source_Collection || destination_->source() == Song::Source_Device)) {
|
||||
if (job.remove_original_ && (destination_->source() == Song::Source::Collection || destination_->source() == Song::Source::Device)) {
|
||||
// Notify other aspects of system that song has been invalidated
|
||||
QString root = destination_->LocalPath();
|
||||
QFileInfo new_file = QFileInfo(root + "/" + task.song_info_.new_filename_);
|
||||
@@ -279,28 +279,28 @@ void Organize::ProcessSomeFiles() {
|
||||
#ifdef HAVE_GSTREAMER
|
||||
Song::FileType Organize::CheckTranscode(Song::FileType original_type) const {
|
||||
|
||||
if (original_type == Song::FileType_Stream) return Song::FileType_Unknown;
|
||||
if (original_type == Song::FileType::Stream) return Song::FileType::Unknown;
|
||||
|
||||
const MusicStorage::TranscodeMode mode = destination_->GetTranscodeMode();
|
||||
const Song::FileType format = destination_->GetTranscodeFormat();
|
||||
|
||||
switch (mode) {
|
||||
case MusicStorage::Transcode_Never:
|
||||
return Song::FileType_Unknown;
|
||||
case MusicStorage::TranscodeMode::Transcode_Never:
|
||||
return Song::FileType::Unknown;
|
||||
|
||||
case MusicStorage::Transcode_Always:
|
||||
if (original_type == format) return Song::FileType_Unknown;
|
||||
case MusicStorage::TranscodeMode::Transcode_Always:
|
||||
if (original_type == format) return Song::FileType::Unknown;
|
||||
return format;
|
||||
|
||||
case MusicStorage::Transcode_Unsupported:
|
||||
if (supported_filetypes_.isEmpty() || supported_filetypes_.contains(original_type)) return Song::FileType_Unknown;
|
||||
case MusicStorage::TranscodeMode::Transcode_Unsupported:
|
||||
if (supported_filetypes_.isEmpty() || supported_filetypes_.contains(original_type)) return Song::FileType::Unknown;
|
||||
|
||||
if (format != Song::FileType_Unknown) return format;
|
||||
if (format != Song::FileType::Unknown) return format;
|
||||
|
||||
// The user hasn't visited the device properties page yet to set a preferred format for the device, so we have to pick the best available one.
|
||||
return Transcoder::PickBestFormat(supported_filetypes_);
|
||||
}
|
||||
return Song::FileType_Unknown;
|
||||
return Song::FileType::Unknown;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -522,7 +522,7 @@ void OrganizeDialog::UpdatePreviews() {
|
||||
if (ok) {
|
||||
QString extension;
|
||||
#ifdef HAVE_GSTREAMER
|
||||
if (storage && storage->GetTranscodeMode() == MusicStorage::Transcode_Always) {
|
||||
if (storage && storage->GetTranscodeMode() == MusicStorage::TranscodeMode::Transcode_Always) {
|
||||
const Song::FileType format = storage->GetTranscodeFormat();
|
||||
TranscoderPreset preset = Transcoder::PresetForFileType(format);
|
||||
extension = preset.extension_;
|
||||
@@ -565,7 +565,7 @@ void OrganizeDialog::OrganizeFinished(const QStringList &files_with_errors, cons
|
||||
if (files_with_errors.isEmpty()) return;
|
||||
|
||||
error_dialog_ = std::make_unique<OrganizeErrorDialog>();
|
||||
error_dialog_->Show(OrganizeErrorDialog::Type_Copy, files_with_errors, log);
|
||||
error_dialog_->Show(OrganizeErrorDialog::OperationType::Copy, files_with_errors, log);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -50,29 +50,29 @@ OrganizeErrorDialog::~OrganizeErrorDialog() {
|
||||
delete ui_;
|
||||
}
|
||||
|
||||
void OrganizeErrorDialog::Show(OperationType type, const SongList &songs_with_errors, const QStringList &log) {
|
||||
void OrganizeErrorDialog::Show(const OperationType operation_type, const SongList &songs_with_errors, const QStringList &log) {
|
||||
|
||||
QStringList files;
|
||||
files.reserve(songs_with_errors.count());
|
||||
for (const Song &song : songs_with_errors) {
|
||||
files << song.url().toLocalFile();
|
||||
}
|
||||
Show(type, files, log);
|
||||
Show(operation_type, files, log);
|
||||
|
||||
}
|
||||
|
||||
void OrganizeErrorDialog::Show(OperationType type, const QStringList &files_with_errors, const QStringList &log) {
|
||||
void OrganizeErrorDialog::Show(const OperationType operation_type, const QStringList &files_with_errors, const QStringList &log) {
|
||||
|
||||
QStringList sorted_files = files_with_errors;
|
||||
std::stable_sort(sorted_files.begin(), sorted_files.end());
|
||||
|
||||
switch (type) {
|
||||
case Type_Copy:
|
||||
switch (operation_type) {
|
||||
case OperationType::Copy:
|
||||
setWindowTitle(tr("Error copying songs"));
|
||||
ui_->label->setText(tr("There were problems copying some songs. The following files could not be copied:"));
|
||||
break;
|
||||
|
||||
case Type_Delete:
|
||||
case OperationType::Delete:
|
||||
setWindowTitle(tr("Error deleting songs"));
|
||||
ui_->label->setText(tr("There were problems deleting some songs. The following files could not be deleted:"));
|
||||
break;
|
||||
@@ -82,4 +82,5 @@ void OrganizeErrorDialog::Show(OperationType type, const QStringList &files_with
|
||||
ui_->log->addItems(log);
|
||||
|
||||
show();
|
||||
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@ class OrganizeErrorDialog : public QDialog {
|
||||
explicit OrganizeErrorDialog(QWidget *parent = nullptr);
|
||||
~OrganizeErrorDialog() override;
|
||||
|
||||
enum OperationType {
|
||||
Type_Copy,
|
||||
Type_Delete,
|
||||
enum class OperationType {
|
||||
Copy,
|
||||
Delete
|
||||
};
|
||||
|
||||
void Show(OperationType type, const SongList &songs_with_errors, const QStringList &log = QStringList());
|
||||
void Show(OperationType type, const QStringList &files_with_errors, const QStringList &log = QStringList());
|
||||
void Show(const OperationType operation_type, const SongList &songs_with_errors, const QStringList &log = QStringList());
|
||||
void Show(const OperationType operation_type, const QStringList &files_with_errors, const QStringList &log = QStringList());
|
||||
|
||||
private:
|
||||
Ui_OrganizeErrorDialog *ui_;
|
||||
|
||||
Reference in New Issue
Block a user