Edit tag dialog: merged duplicate code

This commit is contained in:
Alexander Bikadorov 2016-02-09 21:56:22 +01:00
parent ff86ecddc5
commit 9d413ad01d
2 changed files with 12 additions and 10 deletions

View File

@ -428,11 +428,7 @@ void EditTagDialog::SelectionChanged() {
if (sel.isEmpty()) return;
// Set the editable fields
ignore_edits_ = true;
for (const FieldData& field : fields_) {
InitFieldValue(field, sel);
}
ignore_edits_ = false;
UpdateUI(sel);
// If we're editing multiple songs then we have to disable certain tabs
const bool multiple = sel.count() > 1;
@ -446,6 +442,14 @@ void EditTagDialog::SelectionChanged() {
}
}
void EditTagDialog::UpdateUI(const QModelIndexList& sel){
ignore_edits_ = true;
for (const FieldData& field : fields_) {
InitFieldValue(field, sel);
}
ignore_edits_ = false;
}
static void SetText(QLabel* label, int value, const QString& suffix,
const QString& def = QString()) {
label->setText(value <= 0 ? def : (QString::number(value) + " " + suffix));
@ -857,10 +861,6 @@ void EditTagDialog::FetchTagSongChosen(const Song& original_song,
// Yes! Additionally update UI
const QModelIndexList sel =
ui_->song_list->selectionModel()->selectedIndexes();
ignore_edits_ = true;
for (const FieldData& field : fields_) {
InitFieldValue(field, sel);
}
ignore_edits_ = false;
UpdateUI(sel);
}
}

View File

@ -133,6 +133,8 @@ signals:
void UpdateSummaryTab(const Song& song);
void UpdateStatisticsTab(const Song& song);
void UpdateUI(const QModelIndexList& sel);
bool SetLoading(const QString& message);
void SetSongListVisibility(bool visible);