/* * Cantata * * Copyright (c) 2011-2012 Craig Drummond * */ /* * Copyright (c) 2008 Sander Knopper (sander AT knopper DOT tk) and * Roeland Douma (roeland AT rullzer DOT com) * * This file is part of QtMPC. * * QtMPC is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * QtMPC 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with QtMPC. If not, see . */ #include #include "song.h" #ifdef ENABLE_KDE_SUPPORT #include #else #include #endif #include Song::Song() : id(-1), time(0), track(0), pos(0), disc(0), year(0), size(0) { } Song & Song::operator=(const Song &s) { id = s.id; file = s.file; time = s.time; album = s.album; artist = s.artist; albumartist = s.albumartist; title = s.title; modifiedtitle = s.modifiedtitle; track = s.track; pos = s.pos; disc = s.disc; year = s.year; genre = s.genre; name = s.name; size = s.size; return *this; } bool Song::operator==(const Song &o) const { // When transfferring off an MPT device we will not have AlbumArtist, as libMTP does not handle this. // But, MPD does, so if the labum artist is different - then treat as a new file. // TODO: ALBUMARTIST: This check can be removed when libMTP supports album artist. return file == o.file && albumartist==o.albumartist; } bool Song::operator<(const Song &o) const { int compare=albumArtist().localeAwareCompare(o.albumArtist()); if (0!=compare) { return compare<0; } compare=album.localeAwareCompare(o.album); if (0!=compare) { return compare<0; } if (track!=o.track) { return track