File indexing completed on 2024-05-19 04:49:28

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Maximilian Kossick <maximilian.kossick@googlemail.com>            *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #include "core/meta/support/MetaKeys.h"
0018 
0019 #include "core/meta/Meta.h"
0020 
0021 Meta::AlbumKey::AlbumKey()
0022 {
0023 }
0024 
0025 Meta::AlbumKey::AlbumKey( const QString &name, const QString &artistName )
0026 {
0027     m_albumName = name;
0028     m_artistName = artistName;
0029 }
0030 
0031 Meta::AlbumKey::AlbumKey( const Meta::AlbumPtr &album )
0032 {
0033     m_albumName = album->name();
0034     if( album->hasAlbumArtist() && album->albumArtist() )
0035         m_artistName = album->albumArtist()->name();
0036 }
0037 
0038 Meta::AlbumKey&
0039 Meta::AlbumKey::operator=( const Meta::AlbumKey &o )
0040 {
0041     m_albumName = o.m_albumName;
0042     m_artistName = o.m_artistName;
0043     return *this;
0044 }
0045 
0046 bool
0047 Meta::AlbumKey::operator<( const Meta::AlbumKey &other ) const
0048 {
0049     // sort first by artist name, then by album name
0050     if( m_artistName == other.m_artistName )
0051         return m_albumName < other.m_albumName;
0052     return m_artistName < other.m_artistName;
0053 }
0054 
0055 Meta::TrackKey::TrackKey()
0056     : m_discNumber( 0 )
0057     , m_trackNumber( 0 )
0058 {
0059 }
0060 
0061 Meta::TrackKey::TrackKey( const Meta::TrackPtr &track )
0062 {
0063     m_trackName = track->name();
0064     m_discNumber = track->discNumber();
0065     m_trackNumber = track->trackNumber();
0066     if( track->artist() )
0067         m_artistName = track->artist()->name();
0068 
0069     if( track->album() )
0070         m_albumName = track->album()->name();
0071 }
0072 
0073 Meta::TrackKey& Meta::TrackKey::operator=( const Meta::TrackKey &o )
0074 {
0075     m_discNumber = o.m_discNumber;
0076     m_trackNumber = o.m_trackNumber;
0077     m_trackName = o.m_trackName;
0078     m_albumName = o.m_albumName;
0079     m_artistName = o.m_artistName;
0080     return *this;
0081 }
0082