Sayonara Player
CoverLocation.h
1 /* CoverLocation.h */
2 
3 /* Copyright (C) 2011-2017 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 COVERLOCATION_H
22 #define COVERLOCATION_H
23 
24 #include <QMetaType>
25 #include <QMap>
26 #include "Utils/Pimpl.h"
27 
28 class QUrl;
29 class QString;
30 class QStringList;
31 class MetaData;
32 class Album;
33 class Artist;
34 
35 namespace Cover
36 {
41  class Location
42  {
43  PIMPL(Location)
44 
45  public:
46  Location();
47  ~Location();
48  Location(const Location& cl);
49  Location& operator=(const Location& cl);
50 
56  bool valid() const;
57 
63  static bool is_invalid(const QString& cover_path);
64 
65 
71  QStringList local_paths() const;
72 
77  void add_local_path(const QString& path);
78 
86  QString preferred_path() const;
87 
93  QString cover_path() const;
94 
100  QString identifer() const;
101 
106  QStringList search_urls() const;
107 
112  bool has_search_urls() const;
113 
114 
115  QMap<QString, QString> all_search_urls() const;
116 
122  QString search_term() const;
123 
128  void set_search_term(const QString& search_term);
129 
130  void set_search_term(const QString& search_term,
131  const QString& cover_fetcher_identifier);
132 
133  void set_search_urls(const QStringList& urls);
134 
139  QString to_string() const;
140 
141 
148  static Location cover_location(const QString& album_name, const QString& artist_name);
149 
157  static Location cover_location(const QString& album_name, const QStringList& artists);
158 
159 
166  static Location cover_location(const Album& album);
167 
168 
174  static Location cover_location(const QString& artist);
175 
176 
183  static Location cover_location(const Artist& artist);
184 
185 
195  static Location cover_location(const MetaData& md);
196 
197 
204  static Location cover_location(const QUrl& url, const QString& target_path);
205 
206 
211  static Location invalid_location();
212 
213 
214 
219  static QString get_cover_directory(const QString& append_path);
220  };
221 }
222 
223 Q_DECLARE_METATYPE(Cover::Location)
224 
225 #endif // COVERLOCATION_H
QString preferred_path() const
Returns the most suitable path for covers. Usually this is the first of local_paths(). If not, the cover_path() is taken. If this file does not exist either, the fallback path is returned (logo)
bool valid() const
returns if the current location is a valid or a standard constructed location
The MetaData class.
Definition: MetaData.h:48
bool has_search_urls() const
Check for existing search urls.
static Location invalid_location()
returns an invalid location
void set_search_term(const QString &search_term)
Set a new search term.
static bool is_invalid(const QString &cover_path)
returns if path is the same as the invalid location path
The CoverLocation class.
Definition: CoverLocation.h:41
static QString get_cover_directory(const QString &append_path)
returns the standard cover directory
QString identifer() const
This identifier may be used in order to check how the cover algorithm determined the locations...
QStringList local_paths() const
returns paths of images in the directory where the soundfiles are located.
static Location cover_location(const QString &album_name, const QString &artist_name)
creates CoverLocation by taking the md5 sum between album_name and artist_name
QString cover_path() const
Returns the standard cover path in the .Sayonara directory.
QStringList search_urls() const
Retrieve the urls where a new cover can be searched.
QString to_string() const
to_string
void add_local_path(const QString &path)
adds an local path to other local paths
The Album class.
Definition: Album.h:38
Definition: SomaFMStation.h:33
The Artist class.
Definition: Artist.h:35
QString search_term() const
Search term for a free search. As a human you would type that search term into your browser...