Simplify some things. Use iterators instead of non-const references in
two loops.
This commit is contained in:
parent
f7185101ce
commit
666faa5b37
@ -99,7 +99,7 @@ RipCDDialog::RipCDDialog(QWidget* parent)
|
|||||||
qSort(presets.begin(), presets.end(), ComparePresetsByName);
|
qSort(presets.begin(), presets.end(), ComparePresetsByName);
|
||||||
for (const TranscoderPreset& preset : presets) {
|
for (const TranscoderPreset& preset : presets) {
|
||||||
ui_->format->addItem(
|
ui_->format->addItem(
|
||||||
QString("%1 (.%2)").arg(preset.name_, preset.extension_),
|
QString("%1 (.%2)").arg(preset.name_).arg(preset.extension_),
|
||||||
QVariant::fromValue(preset));
|
QVariant::fromValue(preset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,11 +220,8 @@ void RipCDDialog::SelectNone() {
|
|||||||
|
|
||||||
void RipCDDialog::InvertSelection() {
|
void RipCDDialog::InvertSelection() {
|
||||||
for (QCheckBox* checkbox : checkboxes_) {
|
for (QCheckBox* checkbox : checkboxes_) {
|
||||||
if (checkbox->isChecked()) {
|
checkbox->setCheckState(checkbox->isChecked() ? Qt::Unchecked
|
||||||
checkbox->setCheckState(Qt::Unchecked);
|
: Qt::Checked);
|
||||||
} else {
|
|
||||||
checkbox->setCheckState(Qt::Checked);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,16 +133,20 @@ void Ripper::Cancel() {
|
|||||||
|
|
||||||
void Ripper::TranscodingJobComplete(const QString& input, const QString& output,
|
void Ripper::TranscodingJobComplete(const QString& input, const QString& output,
|
||||||
bool success) {
|
bool success) {
|
||||||
(*(success ? &finished_success_ : &finished_failed_))++;
|
if (success)
|
||||||
|
finished_success_++;
|
||||||
|
else
|
||||||
|
finished_failed_++;
|
||||||
UpdateProgress();
|
UpdateProgress();
|
||||||
|
|
||||||
// The the transcoder does not overwrite files. Instead, it changes
|
// The the transcoder does not overwrite files. Instead, it changes
|
||||||
// the name of the output file. We need to update the transcoded
|
// the name of the output file. We need to update the transcoded
|
||||||
// filename for the corresponding track so that we tag the correct
|
// filename for the corresponding track so that we tag the correct
|
||||||
// file later on.
|
// file later on.
|
||||||
for (TrackInformation& track : tracks_) {
|
for (QList<TrackInformation>::iterator it = tracks_.begin();
|
||||||
if (track.temporary_filename == input) {
|
it != tracks_.end(); ++it) {
|
||||||
track.transcoded_filename = output;
|
if (it->temporary_filename == input) {
|
||||||
|
it->transcoded_filename = output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,14 +213,15 @@ void Ripper::Rip() {
|
|||||||
// Set up progress bar
|
// Set up progress bar
|
||||||
UpdateProgress();
|
UpdateProgress();
|
||||||
|
|
||||||
for (TrackInformation& track : tracks_) {
|
for (QList<TrackInformation>::iterator it = tracks_.begin();
|
||||||
|
it != tracks_.end(); ++it) {
|
||||||
QString filename =
|
QString filename =
|
||||||
QString("%1%2.wav").arg(temporary_directory_).arg(track.track_number);
|
QString("%1%2.wav").arg(temporary_directory_).arg(it->track_number);
|
||||||
QFile destination_file(filename);
|
QFile destination_file(filename);
|
||||||
destination_file.open(QIODevice::WriteOnly);
|
destination_file.open(QIODevice::WriteOnly);
|
||||||
|
|
||||||
lsn_t i_first_lsn = cdio_get_track_lsn(cdio_, track.track_number);
|
lsn_t i_first_lsn = cdio_get_track_lsn(cdio_, it->track_number);
|
||||||
lsn_t i_last_lsn = cdio_get_track_last_lsn(cdio_, track.track_number);
|
lsn_t i_last_lsn = cdio_get_track_last_lsn(cdio_, it->track_number);
|
||||||
WriteWAVHeader(&destination_file,
|
WriteWAVHeader(&destination_file,
|
||||||
(i_last_lsn - i_first_lsn + 1) * CDIO_CD_FRAMESIZE_RAW);
|
(i_last_lsn - i_first_lsn + 1) * CDIO_CD_FRAMESIZE_RAW);
|
||||||
|
|
||||||
@ -241,8 +246,9 @@ void Ripper::Rip() {
|
|||||||
finished_success_++;
|
finished_success_++;
|
||||||
UpdateProgress();
|
UpdateProgress();
|
||||||
|
|
||||||
track.temporary_filename = filename;
|
it->temporary_filename = filename;
|
||||||
transcoder_->AddJob(track.temporary_filename, track.preset, track.transcoded_filename);
|
transcoder_->AddJob(it->temporary_filename, it->preset,
|
||||||
|
it->transcoded_filename);
|
||||||
}
|
}
|
||||||
emit(RippingComplete());
|
emit(RippingComplete());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user