Sayonara Player
CoverLocation.h
1 /* CoverLocation.h */
2 
3 /* Copyright (C) 2011-2016 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 
22 
23 #ifndef COVERLOCATION_H
24 #define COVERLOCATION_H
25 
26 #include <QString>
27 #include <QStringList>
28 #include <QMetaType>
29 #include <QUrl>
30 
31 class MetaData;
32 class Album;
33 class Artist;
39 {
40 
41 private:
42 
46  QString _search_term;
47 
51  QString _search_url;
52 
56  QString _cover_path;
57 
61  QStringList _local_paths;
62 
66  bool _valid;
67 
68 
69 public:
70  CoverLocation();
72 
73  void print() const;
74  QString toString() const;
75 
76 
77  bool valid() const;
78  QStringList local_paths() const;
79  QString local_path(int idx) const;
80  QString cover_path() const;
81  QString search_url() const;
82  QString search_term() const;
83  void set_search_term(const QString& search_term);
84 
85 
92  static CoverLocation get_cover_location(const QString& album_name, const QString& artist_name);
93 
101  static CoverLocation get_cover_location(const QString& album_name, const QStringList& artists);
102 
103 
110  static CoverLocation get_cover_location(const Album& album);
111 
112 
120  static CoverLocation get_cover_location(int album_id, quint8 db_id);
121 
122 
128  static CoverLocation get_cover_location(const QString& artist);
129 
130 
137  static CoverLocation get_cover_location(const Artist& artist);
138 
139 
149  static CoverLocation get_cover_location(const MetaData& md);
150 
151 
158  static CoverLocation get_cover_location(const QUrl& url, const QString& target_path);
159 
160 
167  static CoverLocation get_cover_location_by_searchstring(const QString& search_string, const QString& target_path);
168 
169 
175 
181  static bool isInvalidLocation(const QString& cover_path);
182 
183 
188  static QString get_cover_directory();
189 
190 };
191 
192 Q_DECLARE_METATYPE(CoverLocation)
193 #endif // COVERLOCATION_H
static CoverLocation getInvalidLocation()
returns an invalid location
static bool isInvalidLocation(const QString &cover_path)
returns if path is the same as the invalid location path
Definition: MetaData.h:49
static CoverLocation get_cover_location_by_searchstring(const QString &search_string, const QString &target_path)
fetch a cover for a specific search string
The CoverLocation class.
Definition: CoverLocation.h:38
static QString get_cover_directory()
returns the standard cover directory
The Album class.
Definition: Album.h:40
static CoverLocation get_cover_location(const QString &album_name, const QString &artist_name)
creates CoverLocation by taking the md5 sum between album_name and artist_name
The Artist class.
Definition: Artist.h:36