From 8d8322948dd999320419795aa4bc718d1da4dc53 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 11 May 2016 22:37:40 +0200 Subject: [PATCH] Add convenience methods for ID3 tag conversion --- mediafileinfo.cpp | 42 +++++++++++++++++++++++++++++++++++++++++- mediafileinfo.h | 2 ++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/mediafileinfo.cpp b/mediafileinfo.cpp index 4bcc438..ed1cd20 100644 --- a/mediafileinfo.cpp +++ b/mediafileinfo.cpp @@ -1250,7 +1250,7 @@ void MediaFileInfo::clearParsingResults() } /*! - * \brief Merges the assigned ID3v2 tags. + * \brief Merges the assigned ID3v2 tags into a single ID3v2 tag. * * Some files I've got contain multiple successive ID3v2 tags. If the tags of * such an file is parsed by this class, these tags will be kept seperate. @@ -1280,6 +1280,46 @@ void MediaFileInfo::mergeId3v2Tags() } } +/*! + * \brief Converts an existing ID3v1 tag into an ID3v2 tag. + * + * Effectively merges all ID3 tags into a single ID3v2 tag. + * + * Does nothing if there are currently no ID3 tags assigned and the file format + * isn't known to support ID3 tags. + * + * This method does nothing the tags of the current file haven't been parsed using + * the parseTags() method. + */ +bool MediaFileInfo::id3v1ToId3v2() +{ + if(!areTagsSupported() || !m_container) { + return createAppropriateTags(false, TagUsage::Never, TagUsage::Always, true, true, 3); + } else { + return false; + } +} + +/*! + * \brief Converts the existing ID3v2 tags into an ID3v1 tag. + * + * Effectively merges all ID3 tags into a single ID3v1 tag. + * + * Does nothing if there are currently no ID3 tags assigned and the file format + * isn't known to support ID3 tags. + * + * This method does nothing the tags of the current file haven't been parsed using + * the parseTags() method. + */ +bool MediaFileInfo::id3v2ToId3v1() +{ + if(!areTagsSupported() || !m_container) { + return createAppropriateTags(false, TagUsage::Always, TagUsage::Never, true, true, 3); + } else { + return false; + } +} + /*! * \brief Stores all tags assigned to the current file in the specified vector. * diff --git a/mediafileinfo.h b/mediafileinfo.h index a5c0c59..9c29e44 100644 --- a/mediafileinfo.h +++ b/mediafileinfo.h @@ -133,6 +133,8 @@ public: void removeTag(Tag *tag); void removeAllTags(); void mergeId3v2Tags(); + bool id3v1ToId3v2(); + bool id3v2ToId3v1(); // methods to get/wipe notifications bool haveRelatedObjectsNotifications() const;