combinedtag.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     copyright            : (C) 2004 by Allan Sandfeld Jensen
00003     email                : kde@carewolf.org
00004  ***************************************************************************/
00005 
00006 /***************************************************************************
00007  *   This library is free software; you can redistribute it and/or modify  *
00008  *   it  under the terms of the GNU Lesser General Public License version  *
00009  *   2.1 as published by the Free Software Foundation.                     *
00010  *                                                                         *
00011  *   This library is distributed in the hope that it will be useful, but   *
00012  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014  *   Lesser General Public License for more details.                       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the Free Software   *
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
00019  *   USA                                                                   *
00020  ***************************************************************************/
00021 
00022 #ifndef DO_NOT_DOCUMENT // Tell Doxygen not to document this header
00023 
00024 #ifndef TAGLIB_COMBINEDTAG_H
00025 #define TAGLIB_COMBINEDTAG_H
00026 
00028 // Note that this header is not installed.
00030 
00031 #include <tag.h>
00032 
00033 namespace TagLib {
00034 
00038   class CombinedTag : public TagLib::Tag
00039   {
00040   public:
00041     CombinedTag(Tag *tag1 = 0, Tag *tag2 = 0)
00042                : TagLib::Tag(),
00043                  tag1(tag1), tag2(tag2) {}
00044 
00045     virtual String title() const {
00046       if(tag1 && !tag1->title().isEmpty())
00047           return tag1->title();
00048 
00049       if(tag2)
00050           return tag2->title();
00051 
00052       return String::null;
00053     }
00054 
00055     virtual String artist() const {
00056       if(tag1 && !tag1->artist().isEmpty())
00057           return tag1->artist();
00058 
00059       if(tag2)
00060           return tag2->artist();
00061 
00062       return String::null;
00063     }
00064 
00065     virtual String album() const {
00066       if(tag1 && !tag1->album().isEmpty())
00067           return tag1->album();
00068 
00069       if(tag2)
00070           return tag2->album();
00071 
00072       return String::null;
00073     }
00074 
00075     virtual String comment() const {
00076       if(tag1 && !tag1->comment().isEmpty())
00077           return tag1->comment();
00078 
00079       if(tag2)
00080           return tag2->comment();
00081 
00082       return String::null;
00083     }
00084 
00085     virtual String genre() const {
00086       if(tag1 && !tag1->genre().isEmpty())
00087           return tag1->genre();
00088 
00089       if(tag2)
00090           return tag2->genre();
00091 
00092       return String::null;
00093     }
00094 
00095     virtual uint year() const {
00096       if(tag1 && tag1->year() > 0)
00097           return tag1->year();
00098 
00099       if(tag2)
00100           return tag2->year();
00101 
00102       return 0;
00103     }
00104 
00105     virtual uint track() const {
00106       if(tag1 && tag1->track() > 0)
00107           return tag1->track();
00108 
00109       if(tag2)
00110           return tag2->track();
00111 
00112       return 0;
00113     }
00114 
00115     virtual void setTitle(const String &s) {
00116       if(tag1)
00117           tag1->setTitle(s);
00118       if(tag2)
00119           tag2->setTitle(s);
00120     }
00121 
00122     virtual void setArtist(const String &s) {
00123       if(tag1)
00124           tag1->setArtist(s);
00125       if(tag2)
00126           tag2->setArtist(s);
00127     }
00128 
00129     virtual void setAlbum(const String &s) {
00130       if(tag1)
00131           tag1->setAlbum(s);
00132       if(tag2)
00133           tag2->setAlbum(s);
00134     }
00135 
00136     virtual void setComment(const String &s) {
00137       if(tag1)
00138           tag1->setComment(s);
00139       if(tag2)
00140           tag2->setComment(s);
00141     }
00142 
00143     virtual void setGenre(const String &s) {
00144       if(tag1)
00145           tag1->setGenre(s);
00146       if(tag2)
00147           tag2->setGenre(s);
00148     }
00149 
00150     virtual void setYear(uint i) {
00151       if(tag1)
00152           tag1->setYear(i);
00153       if(tag2)
00154           tag2->setYear(i);
00155     }
00156 
00157     virtual void setTrack(uint i) {
00158       if(tag1)
00159           tag1->setTrack(i);
00160       if(tag2)
00161           tag2->setTrack(i);
00162     }
00163 
00164   private:
00165       Tag *tag1;
00166       Tag *tag2;
00167   };
00168 }
00169 
00170 #endif
00171 #endif