organise: Add a tag override mechanism to OrganiseFormat
Add a method to set override tag values when formatting a song name. The use case for this is transcoding where the extension will change.
This commit is contained in:
parent
22cfade4a4
commit
2e921c6584
|
@ -179,9 +179,9 @@ QString OrganiseFormat::ParseBlock(QString block, const Song& song,
|
|||
QString OrganiseFormat::TagValue(const QString& tag, const Song& song) const {
|
||||
QString value;
|
||||
|
||||
// TODO(sobkas): What about nice switch statement?
|
||||
|
||||
if (tag == "title")
|
||||
if (tag_overrides_.contains(tag))
|
||||
value = tag_overrides_.value(tag);
|
||||
else if (tag == "title")
|
||||
value = song.title();
|
||||
else if (tag == "album")
|
||||
value = song.album();
|
||||
|
|
|
@ -48,6 +48,11 @@ class OrganiseFormat {
|
|||
void set_replace_spaces(bool v) { replace_spaces_ = v; }
|
||||
void set_replace_the(bool v) { replace_the_ = v; }
|
||||
|
||||
void add_tag_override(const QString& tag, const QString& v) {
|
||||
tag_overrides_[tag] = v;
|
||||
}
|
||||
void reset_tag_overrides() { tag_overrides_.clear(); }
|
||||
|
||||
bool IsValid() const;
|
||||
QString GetFilenameForSong(const Song& song) const;
|
||||
|
||||
|
@ -77,6 +82,8 @@ class OrganiseFormat {
|
|||
bool* any_empty = nullptr) const;
|
||||
QString TagValue(const QString& tag, const Song& song) const;
|
||||
|
||||
QMap<QString, QString> tag_overrides_;
|
||||
|
||||
QString format_;
|
||||
bool replace_non_ascii_;
|
||||
bool replace_spaces_;
|
||||
|
|
Loading…
Reference in New Issue