Sayonara Player
MetaDataInfo.h
1 /* MetaDataInfo.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 #ifndef METADATAINFO_H
22 #define METADATAINFO_H
23 
24 #include "Utils/Pimpl.h"
25 #include "Components/Covers/CoverLocation.h"
26 
27 #include <QObject>
28 #include <QMap>
29 #include <QList>
30 
31 class Genre;
32 class LibraryDatabase;
33 
38 enum class InfoStrings : uint8_t
39 {
40  nTracks=0, // set by MetaDataInfo
41  nAlbums, // set by ArtistInfo, AlbumInfo
42  nArtists, // set by ArtistInfo, AlbumInfo
43  Filesize, // set by MetaDataInfo
44  PlayingTime, // set by MetaDataInfo
45  Year, // set by MetaDataInfo
46  Sampler, // set by AlbumInfo
47  Bitrate, // set by MetaDataInfo
48  Genre, // set by MetaDataInfo
49  Filetype, // set by MetaDataInfo
50  Comment // set by MetaDataInfo
51 };
52 
53 
58 class MetaDataInfo :
59  public QObject
60 {
61  PIMPL(MetaDataInfo)
62 
63  protected:
64  QString _header;
65  QString _subheader;
67  QList<StringPair> _additional_info;
68 
69 
70  QString calc_tracknum_str( uint16_t tracknum );
71  QString calc_artist_str() const;
72  QString calc_album_str();
73 
74  virtual void calc_cover_location();
75  virtual void calc_subheader();
76  virtual void calc_header();
77 
78  void insert_playing_time(MilliSeconds ms);
79  void insert_genre(const Util::Set<Genre>& genres);
80  void insert_filesize(uint64_t filesize);
81  void insert_filetype(const Util::Set<QString>& filetypes);
82  void insert_comment(const Util::Set<QString>& comments);
83 
84  void insert_interval_info_field(InfoStrings key, int min, int max);
85  void insert_numeric_info_field(InfoStrings key, int number);
86 
87 
88  public:
89  explicit MetaDataInfo(const MetaDataList& v_md);
90  virtual ~MetaDataInfo();
91 
92  virtual QString header() const;
93  virtual QString subheader() const;
94  virtual QString infostring() const;
95  virtual QList<StringPair> infostring_map() const;
96  virtual QString additional_infostring() const;
97 
98  virtual Cover::Location cover_location() const;
99 
100  const Util::Set<QString>& albums() const;
101  const Util::Set<QString>& artists() const;
102  const Util::Set<QString>& album_artists() const;
103 
104  const Util::Set<AlbumId>& album_ids() const;
105  const Util::Set<ArtistId>& artist_ids() const;
106  const Util::Set<ArtistId>& album_artist_ids() const;
107 
108  QStringList paths() const;
109  QString pathsstring() const;
110 
111 
112  private:
113  void calc_cover_location(const MetaDataList& lst);
114  void calc_subheader(quint16 tracknum);
115  void calc_header(const MetaDataList& lst);
116 
117  QString get_info_string(InfoStrings idx) const;
118 };
119 
120 #endif // METADATAINFO_H
InfoStrings
The InfoStrings enum.
Definition: MetaDataInfo.h:38
The MetaDataList class.
Definition: MetaDataList.h:37
The CoverLocation class.
Definition: CoverLocation.h:42
The MetaDataInfo class.
Definition: MetaDataInfo.h:58
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
Definition: Genre.h:30
Definition: org_mpris_media_player2_adaptor.h:20