1 /* Artist.h */ 2 3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras) 4 * 5 * This file is part of sayonara player 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef SAYONARA_ARTIST_H_ 22 #define SAYONARA_ARTIST_H_ 23 24 #include "Utils/MetaData/LibraryItem.h" 25 #include "Utils/Library/Sortorder.h" 26 #include "Utils/Pimpl.h" 27 28 #include <QStringList> 29 #include <QMetaType> 30 #include <deque> 31 32 /** 33 * @brief The Artist class 34 * @ingroup MetaDataHelper 35 */ 36 class Artist : 37 public LibraryItem 38 { 39 PIMPL(Artist) 40 41 public: 42 Artist(); 43 Artist(const Artist& other); 44 Artist(Artist&& other) noexcept; 45 46 Artist& operator=(const Artist& other); 47 Artist& operator=(Artist&& other) noexcept; 48 49 ~Artist(); 50 51 QString name() const; 52 void setName(const QString& name); 53 54 static bool fromVariant(const QVariant& v, Artist& a); 55 static QVariant toVariant(const Artist& a); 56 void print() const ; 57 58 uint16_t albumcount() const; 59 void setAlbumcount(const uint16_t& value); 60 61 uint16_t songcount() const; 62 void setSongcount(const uint16_t& value); 63 64 ArtistId id() const; 65 void setId(const ArtistId& value); 66 }; 67 68 Q_DECLARE_METATYPE(Artist)69Q_DECLARE_METATYPE(Artist) 70 71 /** 72 * @brief ArtistList 73 * @ingroup MetaDataHelper 74 */ 75 class ArtistList : 76 public std::deque<Artist> 77 { 78 using Parent=std::deque<Artist>; 79 80 public: 81 using Size=Parent::size_type; 82 83 ArtistList(); 84 ~ArtistList(); 85 86 /** 87 * @brief extract the main artist out of the artist list 88 * @param artists artist list 89 * @return the name that appears more than 2/3 of all available artists 90 */ 91 static QString majorArtist(const QStringList& artists); 92 93 /** 94 * @brief extract the main artist out of the artist list 95 * @param artists artist list 96 * @return the name that appears more than 2/3 of all available artists 97 */ 98 QString majorArtist() const; 99 100 Artist first() const; 101 bool contains(ArtistId artistId) const; 102 int count() const; 103 104 ArtistList& operator <<(const Artist& artist); 105 ArtistList& appendUnique(const ArtistList& other); 106 107 void sort(Library::SortOrder so); 108 }; 109 110 #endif 111