Sayonara Player
MetaData.h
1 /* MetaData.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 /*
22  * MetaData.h
23  *
24  * Created on: Mar 10, 2011
25  * Author: Michael Lugmair (Lucio Carreras)
26  */
27 
28 #ifndef METADATA_H_
29 #define METADATA_H_
30 
31 #include "Utils/MetaData/LibraryItem.h"
32 #include "Utils/MetaData/RadioMode.h"
33 #include "Utils/MetaData/Genre.h"
34 #include "Utils/Library/Sortorder.h"
35 #include "Utils/Pimpl.h"
36 
37 #include <QMetaType>
38 #include <QString>
39 
40 class QDateTime;
45 class MetaData :
46  public LibraryItem
47 {
48  PIMPL(MetaData)
49 
50 public:
51  MetaData();
52  explicit MetaData (const QString& path);
53  MetaData(const MetaData& other);
54  MetaData(MetaData&& other) noexcept;
55  MetaData& operator=(const MetaData& md);
56  MetaData& operator=(MetaData&& md) noexcept;
57 
58  ~MetaData();
59 
60  QString title() const;
61  void setTitle(const QString& title);
62 
63  QString artist() const;
64  void setArtist(const QString& artist);
65  ArtistId artistId() const;
66  void setArtistId(ArtistId id);
67 
68  QString album() const;
69  void setAlbum(const QString& album);
70  AlbumId albumId() const;
71  void setAlbumId(AlbumId id);
72 
73  const QString& comment() const;
74  void setComment(const QString& comment);
75 
76  QString filepath() const;
77  QString setFilepath(QString filepath, RadioMode mode=RadioMode::Undefined);
78 
79  ArtistId albumArtistId() const;
80  QString albumArtist() const;
81  bool hasAlbumArtist() const;
82 
83  void setAlbumArtist(const QString& albumArtist, ArtistId id=-1);
84  void setAlbumArtistId(ArtistId id);
85 
86  void setRadioStation(const QString& url, const QString& name=QString());
87  QString radioStation() const;
88  QString radioStationName() const;
89 
90  RadioMode radioMode() const;
91  void changeRadioMode(RadioMode mode);
92 
93  bool isValid() const;
94 
95  bool operator==(const MetaData& md) const;
96  bool operator!=(const MetaData& md) const;
97  bool isEqual(const MetaData& md) const;
98  bool isEqualDeep(const MetaData& md) const;
99 
100  const Util::Set<GenreID>& genreIds() const;
101  Util::Set<Genre> genres() const;
102  bool hasGenre(const Genre& genre) const;
103  bool removeGenre(const Genre& genre);
104  bool addGenre(const Genre& genre);
105  void setGenres(const Util::Set<Genre>& genres);
106  void setGenres(const QStringList& genres);
107 
108  void setCreatedDate(uint64_t t);
109  uint64_t createdDate() const;
110  QDateTime createdDateTime() const;
111 
112  void setModifiedDate(uint64_t t);
113  uint64_t modifiedDate() const;
114  QDateTime modifiedDateTime() const;
115 
116  QString genresToString() const;
117  QStringList genresToList() const;
118 
119  QString toString() const;
120 
121  static QVariant toVariant(const MetaData& md);
122  static bool fromVariant(const QVariant& v, MetaData& md);
123 
124  Disc discnumber() const;
125  void setDiscnumber(const Disc& value);
126 
127  Disc discCount() const;
128  void setDiscCount(const Disc& value);
129 
130  Bitrate bitrate() const;
131  void setBitrate(const Bitrate& value);
132 
133  TrackNum trackNumber() const;
134  void setTrackNumber(const uint16_t& value);
135 
136  Year year() const;
137  void setYear(const uint16_t& value);
138 
139  Filesize filesize() const;
140  void setFilesize(const Filesize& value);
141 
142  Rating rating() const;
143  void setRating(const Rating& value);
144 
145  MilliSeconds durationMs() const;
146  void setDurationMs(const MilliSeconds& value);
147 
148  bool isExtern() const;
149  void setExtern(bool value);
150 
151  bool isDisabled() const;
152  void setDisabled(bool value);
153 
154  LibraryId libraryId() const;
155  void setLibraryid(const LibraryId& value);
156 
157  TrackID id() const;
158  void setId(const TrackID& value);
159 
160 private:
161  QHash<GenreID, Genre>& genrePool() const;
162 };
163 
164 #ifndef MetaDataDeclared
165 Q_DECLARE_METATYPE(MetaData)
166  #define MetaDataDeclared
167 #endif
168 
169 #endif /* METADATA_H_ */
Util::Set
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:37
RadioMode
RadioMode
The RadioMode enum.
Definition: RadioMode.h:29
Genre
Definition: Genre.h:31
MetaData
The MetaData class.
Definition: MetaData.h:47
LibraryItem
The LibraryItem class.
Definition: LibraryItem.h:65