Sayonara Player
MetaData.h
1 /* MetaData.h */
2 
3 /* Copyright (C) 2011-2019 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: 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 
44 class MetaData :
45  public LibraryItem
46 {
47  PIMPL(MetaData)
48 
49 public:
50  MilliSeconds duration_ms;
51  Filesize filesize;
52 
53  TrackID id;
54  ArtistId artist_id;
55  AlbumId album_id;
56 
57  Bitrate bitrate;
58  uint16_t track_num;
59  uint16_t year;
60 
61  Disc discnumber;
62  Disc n_discs;
63 
64  LibraryId library_id;
65  Rating rating;
66 
67  bool played;
68  bool is_extern;
69  bool pl_playing;
70  bool is_disabled;
71 
72 public:
73  MetaData();
74  explicit MetaData (const QString& path);
75  MetaData(const MetaData& other);
76  MetaData(MetaData&& other) noexcept;
77  MetaData& operator=(const MetaData& md);
78  MetaData& operator=(MetaData&& md) noexcept;
79 
80  ~MetaData();
81 
82  QString title() const;
83  void set_title(const QString& title);
84 
85  QString artist() const;
86  void set_artist(const QString& artist);
87 
88  QString album() const;
89  void set_album(const QString& album);
90 
91  const QString& comment() const;
92  void set_comment(const QString& comment);
93 
94  QString filepath() const;
95  QString set_filepath(QString filepath);
96 
97  ArtistId album_artist_id() const;
98  QString album_artist() const;
99  bool has_album_artist() const;
100 
101  void set_album_artist(const QString& album_artist, ArtistId id=-1);
102  void set_album_artist_id(ArtistId id);
103 
104  void set_radio_station(const QString& name);
105  QString radio_station() const;
106 
107  RadioMode radio_mode() const;
108  bool is_valid() const;
109 
110  bool operator==(const MetaData& md) const;
111  bool operator!=(const MetaData& md) const;
112  bool is_equal(const MetaData& md) const;
113  bool is_equal_deep(const MetaData& md) const;
114 
115  const Util::Set<GenreID>& genre_ids() const;
116  Util::Set<Genre> genres() const;
117  bool has_genre(const Genre& genre) const;
118  bool remove_genre(const Genre& genre);
119  bool add_genre(const Genre& genre);
120  void set_genres(const Util::Set<Genre>& genres);
121  void set_genres(const QStringList& genres);
122 
123  QString genres_to_string() const;
124  QStringList genres_to_list() const;
125 
126  QString to_string() const;
127 
128  static QVariant toVariant(const MetaData& md);
129  static bool fromVariant(const QVariant& v, MetaData& md);
130 
131 private:
132  QHash<GenreID, Genre>& genre_pool() const;
133 };
134 
135 #ifndef MetaDataDeclared
136  Q_DECLARE_METATYPE(MetaData)
137  #define MetaDataDeclared
138 #endif
139 
140 #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:35
Genre
Definition: Genre.h:30
RadioMode
RadioMode
The RadioMode enum.
Definition: RadioMode.h:30
MetaData
The MetaData class.
Definition: MetaData.h:44
LibraryItem
The LibraryItem class.
Definition: LibraryItem.h:63