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 {
37  using StringMap=QMap<QString, QString>;
38 
43  class Location
44  {
45  PIMPL(Location)
46 
47 
48  private:
49  void set_valid(bool b);
50  void set_identifier(const QString& identifier);
51  void set_cover_path(const QString& cover_path);
52 
53 
54  public:
55  enum CoverSourceType
56  {
57  Invalid=0,
58  SayonaraCoverDir,
59  LocalPath,
60  AudioFile
61  };
62 
63  Location();
64  ~Location();
65  Location(const Location& cl);
66  Location& operator=(const Location& cl);
67 
73  bool valid() const;
74 
80  static bool is_invalid(const QString& cover_path);
81 
82  // CoverSourceType get_cover_source_type() const;
83 
89  QString cover_path() const;
90 
96  QString identifer() const;
97 
102  const QStringList& search_urls() const;
103 
104  QString search_url(int idx) const;
105 
110  bool has_search_urls() const;
111 
112 
118  QString search_term() const;
119 
124  void set_search_term(const QString& search_term);
125 
126  void set_search_term(const QString& search_term,
127  const QString& cover_fetcher_identifier);
128 
129  void set_search_urls(const QStringList& urls);
130 
131  void enable_freetext_search(bool b);
132  bool is_freetext_search_enabled() const;
133 
138  QString to_string() const;
139 
140  QString hash() const;
141  void set_hash(const QString& str);
142 
143 
144  bool has_audio_file_source() const;
145  QString audio_file_source() const;
146  QString audio_file_target() const;
147  bool set_audio_file_source(const QString& audio_file_source, const QString& cover_path);
148 
149 
150  QString local_path_hint() const;
151  void set_local_path_hint(const QString& base_path);
152 
153  QString preferred_path() const;
154 
155 
162  static Location cover_location(const QString& album_name, const QString& artist_name);
163 
171  static Location cover_location(const QString& album_name, const QStringList& artists);
172 
173 
180  static Location cover_location(const Album& album);
181 
182 
188  static Location cover_location(const QString& artist);
189 
190 
197  static Location cover_location(const Artist& artist);
198 
199 
209  static Location cover_location(const MetaData& md);
210 
211 
218  static Location cover_location(const QUrl& url, const QString& target_path);
219 
220 
225  static Location invalid_location();
226 
227 
232  static QString get_cover_directory(const QString& append_path);
233  };
234 }
235 
236 Q_DECLARE_METATYPE(Cover::Location)
237 
238 #endif // COVERLOCATION_H
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:43
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.
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.
QString to_string() const
to_string
const QStringList & search_urls() const
Retrieve the urls where a new cover can be searched.
The Album class.
Definition: Album.h:38
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.