Sayonara Player
MetaData.h
1 /* MetaData.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 /*
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 "Helper/MetaData/LibraryItem.h"
32 #include "Helper/Set.h"
33 
34 #include <QMetaType>
35 #include <QStringList>
36 
37 
42 enum class RadioMode : quint8
43 {
44  Off = 0,
45  Station,
46  Soundcloud
47 };
48 
49 class Genre;
50 
55 class MetaData :
56  public LibraryItem
57 {
58 public:
59  qint32 id;
60  qint32 artist_id;
61  qint32 album_id;
62 
63 public:
64  QString title;
65  QString artist;
66  QString album;
67 
68  // if radio station: name of radio station
69  SP::Set<Genre> genres;
70 
71  quint16 track_num;
72  quint16 year;
73  quint32 bitrate;
74  quint64 length_ms;
75  quint64 filesize;
76 
77  bool played;
78  bool is_extern;
79  bool pl_playing;
80  bool is_disabled;
81 
82  quint8 rating;
83  quint8 discnumber;
84  quint8 n_discs;
85 
86 private:
87  RadioMode _radio_mode;
88  QString _album_artist;
89  QString _filepath;
90  qint32 _album_artist_id;
91 
92 
93 public:
94  MetaData ();
95  MetaData (const MetaData& );
96  MetaData ( MetaData&& );
97 
98  explicit MetaData (const QString& path);
99  ~MetaData();
100 
101  QUrl url() const;
102  QString filepath() const;
103  QString set_filepath(QString filepath);
104 
105  qint32 album_artist_id() const;
106  QString album_artist() const;
107  bool has_album_artist() const;
108 
109  void set_album_artist(const QString& album_artist, qint32 id=-1);
110  void set_album_artist_id(qint32 id);
111 
112  RadioMode radio_mode() const;
113 
114  MetaData& operator=(const MetaData& md);
115  bool operator==(const MetaData& md) const;
116  bool operator!=(const MetaData& md) const;
117  bool is_equal(const MetaData& md) const;
118  bool is_equal_deep(const MetaData& md) const;
119 
120  bool has_genre(const Genre& genre) const;
121  bool remove_genre(const Genre& genre);
122  bool add_genre(const Genre& genre);
123  void set_genres(const QStringList& genres);
124  QString genres_to_string() const;
125  QStringList genres_to_list() const;
126 
127  QString to_string() const;
128 
129  static QVariant toVariant(const MetaData& md);
130  static bool fromVariant(const QVariant& v, MetaData& md);
131 };
132 
133 Q_DECLARE_METATYPE(MetaData)
134 
135 
136 #endif /* METADATA_H_ */
The LibraryItem class.
Definition: LibraryItem.h:56
RadioMode
The RadioMode enum.
Definition: MetaData.h:42
The MetaData class.
Definition: MetaData.h:55
Definition: Genre.h:29