Sayonara Player
CoverLocation.h
1 /* CoverLocation.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 COVERLOCATION_H
22 #define COVERLOCATION_H
23 
24 #include "Utils/Pimpl.h"
25 
26 #include <QMetaType>
27 #include <QString>
28 
29 class QUrl;
30 
31 namespace Cover
32 {
33  namespace Fetcher
34  {
35  class Url;
36  }
37 
38  class Location
39  {
40  PIMPL(Location)
41 
42  public:
43  Location();
44  ~Location();
45  Location(const Location& cl);
46  Location(Location&& cl) noexcept;
47 
48  Location& operator=(const Location& cl);
49  Location& operator=(Location&& cl) noexcept;
50 
51  bool isValid() const;
52 
53  QString hashPath() const;
54 
55  QString identifier() const;
56 
57  QList<Fetcher::Url> searchUrls() const;
58 
59  bool hasSearchUrls() const;
60 
61  QString searchTerm() const;
62 
63  void setSearchTerm(const QString& searchTerm,
64  const QString& coverFetcherIdentifier = QString());
65 
66  void setSearchUrls(const QList<Fetcher::Url>& urls);
67 
68  void enableFreetextSearch(bool enabled);
69 
70  QString hash() const;
71 
72  bool hasAudioFileSource() const;
73 
74  QString audioFileSource() const;
75 
76  QString audioFileTarget() const;
77 
78  QString localPathDir() const;
79 
80  QStringList localPathHints() const;
81 
82  QString localPath() const;
83 
84  QString preferredPath() const;
85 
86  QString alternativePath() const;
87 
88  static Location coverLocation(const QString& albumName, const QString& artistName);
89 
90  static Location coverLocation(const QString& albumName, const QStringList& artists);
91 
92  static Location coverLocation(const QString& artist);
93 
94  static Location coverLocation(const Artist& artist);
95 
96  static Location coverLocation(const MetaData& track);
97 
98  static Location coverLocation(const QList<QUrl>& urls, const QString& token);
99 
100  static Location coverLocation(const Album& album);
101 
102  static Location invalidLocation();
103 
104  static QString invalidPath();
105 
106  private:
107  void setValid(bool valid);
108  void setIdentifier(const QString& identifier);
109  void setLocalPathHints(const QStringList& localPaths);
110 
111  void setHash(const QString& str);
112 
113  bool setAudioFileSource(const QString& audioFileSource, const QString& symlinkPath);
114 
115  // must be here because attributes are private
116  static Location coverLocationRadio(const QString& stationName, const QString& stationUrl);
117  };
118 }
119 
120 Q_DECLARE_METATYPE(Cover::Location)
121 
122 #endif // COVERLOCATION_H
The Album class.
Definition: Album.h:41
The Artist class.
Definition: Artist.h:38
Definition: CoverLocation.h:39
The MetaData class.
Definition: MetaData.h:47
Definition: EngineUtils.h:33