Clementine-audio-player-Mac.../3rdparty/taglib/mod/modtag.cpp

175 lines
4.2 KiB
C++
Raw Normal View History

2012-10-28 02:12:18 +02:00
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
2016-07-19 16:58:52 +02:00
* it under the terms of the GNU Lesser General Public License version *
2012-10-28 02:12:18 +02:00
* 2.1 as published by the Free Software Foundation. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
2016-07-19 16:58:52 +02:00
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
2012-10-28 02:12:18 +02:00
***************************************************************************/
2016-07-19 16:58:52 +02:00
2012-10-28 02:12:18 +02:00
#include "modtag.h"
#include "tstringlist.h"
#include "tpropertymap.h"
using namespace TagLib;
using namespace Mod;
class Mod::Tag::TagPrivate
{
public:
TagPrivate()
{
}
String title;
String comment;
String trackerName;
};
2018-06-06 22:47:08 +02:00
Mod::Tag::Tag() :
TagLib::Tag(),
d(new TagPrivate())
2012-10-28 02:12:18 +02:00
{
}
Mod::Tag::~Tag()
{
delete d;
}
String Mod::Tag::title() const
{
return d->title;
}
String Mod::Tag::artist() const
{
2016-07-19 16:58:52 +02:00
return String();
2012-10-28 02:12:18 +02:00
}
String Mod::Tag::album() const
{
2016-07-19 16:58:52 +02:00
return String();
2012-10-28 02:12:18 +02:00
}
String Mod::Tag::comment() const
{
return d->comment;
}
String Mod::Tag::genre() const
{
2016-07-19 16:58:52 +02:00
return String();
2012-10-28 02:12:18 +02:00
}
2016-07-19 16:58:52 +02:00
unsigned int Mod::Tag::year() const
2012-10-28 02:12:18 +02:00
{
return 0;
}
2016-07-19 16:58:52 +02:00
unsigned int Mod::Tag::track() const
2012-10-28 02:12:18 +02:00
{
return 0;
}
String Mod::Tag::trackerName() const
{
return d->trackerName;
}
void Mod::Tag::setTitle(const String &title)
{
d->title = title;
}
void Mod::Tag::setArtist(const String &)
{
}
void Mod::Tag::setAlbum(const String &)
{
}
void Mod::Tag::setComment(const String &comment)
{
d->comment = comment;
}
void Mod::Tag::setGenre(const String &)
{
}
2016-07-19 16:58:52 +02:00
void Mod::Tag::setYear(unsigned int)
2012-10-28 02:12:18 +02:00
{
}
2016-07-19 16:58:52 +02:00
void Mod::Tag::setTrack(unsigned int)
2012-10-28 02:12:18 +02:00
{
}
void Mod::Tag::setTrackerName(const String &trackerName)
{
d->trackerName = trackerName;
}
PropertyMap Mod::Tag::properties() const
{
PropertyMap properties;
properties["TITLE"] = d->title;
properties["COMMENT"] = d->comment;
2016-07-19 16:58:52 +02:00
if(!(d->trackerName.isEmpty()))
2012-10-28 02:12:18 +02:00
properties["TRACKERNAME"] = d->trackerName;
return properties;
}
PropertyMap Mod::Tag::setProperties(const PropertyMap &origProps)
{
PropertyMap properties(origProps);
properties.removeEmpty();
StringList oneValueSet;
if(properties.contains("TITLE")) {
d->title = properties["TITLE"].front();
oneValueSet.append("TITLE");
} else
2016-07-19 16:58:52 +02:00
d->title.clear();
2012-10-28 02:12:18 +02:00
if(properties.contains("COMMENT")) {
d->comment = properties["COMMENT"].front();
oneValueSet.append("COMMENT");
} else
2016-07-19 16:58:52 +02:00
d->comment.clear();
2012-10-28 02:12:18 +02:00
if(properties.contains("TRACKERNAME")) {
d->trackerName = properties["TRACKERNAME"].front();
oneValueSet.append("TRACKERNAME");
} else
2016-07-19 16:58:52 +02:00
d->trackerName.clear();
2012-10-28 02:12:18 +02:00
// for each tag that has been set above, remove the first entry in the corresponding
// value list. The others will be returned as unsupported by this format.
2015-11-24 19:36:24 +01:00
for(StringList::ConstIterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) {
2012-10-28 02:12:18 +02:00
if(properties[*it].size() == 1)
properties.erase(*it);
else
properties[*it].erase( properties[*it].begin() );
}
return properties;
}