Sayonara Player
MetaDataInfo.h
1 /* MetaDataInfo.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 #ifndef METADATAINFO_H
22 #define METADATAINFO_H
23 
24 #include "Utils/Settings/SayonaraClass.h"
25 #include "Components/Covers/CoverLocation.h"
26 
27 #include <QMap>
28 #include <QObject>
29 #include "Utils/Pimpl.h"
30 
31 class QStringList;
32 class MetaDataList;
33 class LibraryDatabase;
34 
39 enum class InfoStrings : uint8_t
40 {
41  nTracks=0, // set by MetaDataInfo
42  nAlbums, // set by ArtistInfo, AlbumInfo
43  nArtists, // set by ArtistInfo, AlbumInfo
44  Filesize, // set by MetaDataInfo
45  PlayingTime, // set by MetaDataInfo
46  Year, // set by MetaDataInfo
47  Sampler, // set by AlbumInfo
48  Bitrate, // set by MetaDataInfo
49  Genre // set by MetaDataInfo
50 };
51 
52 
57 class MetaDataInfo :
58  public QObject,
59  public SayonaraClass
60 {
61  PIMPL(MetaDataInfo)
62 
63  protected:
64  QString _header;
65  QString _subheader;
67  QMap<QString, QString> _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(uint64_t ms);
79  void insert_genre(const QStringList& lst);
80  void insert_filesize(uint64_t filesize);
81 
82  void insert_interval_info_field(InfoStrings key, int min, int max);
83  void insert_numeric_info_field(InfoStrings key, int number);
84 
85 
86  public:
87  explicit MetaDataInfo(const MetaDataList& v_md);
88  virtual ~MetaDataInfo();
89 
90  virtual QString header() const;
91  virtual QString subheader() const;
92  virtual QString infostring() const;
93  virtual QString additional_infostring() const;
94 
95  virtual Cover::Location cover_location() const;
96 
97  const SP::Set<QString>& albums() const;
98  const SP::Set<QString>& artists() const;
99  const SP::Set<QString>& album_artists() const;
100 
101  const SP::Set<AlbumId>& album_ids() const;
102  const SP::Set<ArtistId>& artist_ids() const;
103  const SP::Set<ArtistId>& album_artist_ids() const;
104 
105  QString pathsstring() const;
106 
107 
108  private:
109  void calc_cover_location(const MetaDataList& lst);
110  void calc_subheader(quint16 tracknum);
111  void calc_header(const MetaDataList& lst);
112 
113  QString get_info_string(InfoStrings idx) const;
114 };
115 
116 #endif // METADATAINFO_H
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:29
InfoStrings
The InfoStrings enum.
Definition: MetaDataInfo.h:39
The MetaDataList class.
Definition: MetaDataList.h:38
The CoverLocation class.
Definition: CoverLocation.h:41
The MetaDataInfo class.
Definition: MetaDataInfo.h:57
Definition: Genre.h:27
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: AbstractPlaylist.h:36