Fix for erasing old tag values when using tag fetcher, replacement for #51311
This commit is contained in:
parent
3271c06d10
commit
bad9e4af5e
@ -99,7 +99,8 @@ EditTagDialog::EditTagDialog(Application* app, QWidget* parent)
|
|||||||
connect(widget, SIGNAL(Reset()), SLOT(ResetField()));
|
connect(widget, SIGNAL(Reset()), SLOT(ResetField()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect the edited signal
|
// Connect the changed signal (emitted when value is changed
|
||||||
|
// programmatically or non-programmatically)
|
||||||
if (qobject_cast<QLineEdit*>(widget)) {
|
if (qobject_cast<QLineEdit*>(widget)) {
|
||||||
connect(widget, SIGNAL(textChanged(QString)), SLOT(FieldValueEdited()));
|
connect(widget, SIGNAL(textChanged(QString)), SLOT(FieldValueEdited()));
|
||||||
} else if (qobject_cast<QPlainTextEdit*>(widget)) {
|
} else if (qobject_cast<QPlainTextEdit*>(widget)) {
|
||||||
@ -833,27 +834,33 @@ void EditTagDialog::FetchTagSongChosen(const Song& original_song,
|
|||||||
const QString filename = original_song.url().toLocalFile();
|
const QString filename = original_song.url().toLocalFile();
|
||||||
|
|
||||||
// Find the song with this filename
|
// Find the song with this filename
|
||||||
auto data_it =
|
int id;
|
||||||
std::find_if(data_.begin(), data_.end(), [&filename](const Data& d) {
|
for (id = 0; id < data_.count(); ++id) {
|
||||||
return d.original_.url().toLocalFile() == filename;
|
if (data_[id].original_.url().toLocalFile() == filename)
|
||||||
});
|
break;
|
||||||
if (data_it == data_.end()) {
|
|
||||||
qLog(Warning) << "Could not find song to filename: " << filename;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data_it->current_.set_title(new_metadata.title());
|
if(id == data_.count()) {
|
||||||
data_it->current_.set_artist(new_metadata.artist());
|
qLog(Warning) << "Could not find song for filename: " << filename;
|
||||||
data_it->current_.set_album(new_metadata.album());
|
return;
|
||||||
data_it->current_.set_track(new_metadata.track());
|
}
|
||||||
data_it->current_.set_year(new_metadata.year());
|
|
||||||
|
|
||||||
// Is it currently selected in the UI?
|
// Update song data
|
||||||
int row = data_it - data_.begin();
|
data_[id].current_.set_title(new_metadata.title());
|
||||||
if (ui_->song_list->item(row)->isSelected()) {
|
data_[id].current_.set_artist(new_metadata.artist());
|
||||||
// We need to update view
|
data_[id].current_.set_album(new_metadata.album());
|
||||||
for (const FieldData& field : fields_)
|
data_[id].current_.set_track(new_metadata.track());
|
||||||
InitFieldValue(field,
|
data_[id].current_.set_year(new_metadata.year());
|
||||||
ui_->song_list->selectionModel()->selectedIndexes());
|
|
||||||
|
// Is it currently being displayed in the UI?
|
||||||
|
if (ui_->song_list->currentRow() == id) {
|
||||||
|
// Yes! Additionally update UI
|
||||||
|
ignore_edits_ = true;
|
||||||
|
ui_->title->set_text(new_metadata.title());
|
||||||
|
ui_->artist->set_text(new_metadata.artist());
|
||||||
|
ui_->album->set_text(new_metadata.album());
|
||||||
|
ui_->track->setValue(new_metadata.track());
|
||||||
|
ui_->year->setValue(new_metadata.year());
|
||||||
|
ignore_edits_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user