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/Pimpl.h"
25 #include "Utils/Settings/SayonaraClass.h"
26 #include "Components/Covers/CoverLocation.h"
27 
28 #include <QObject>
29 #include <QMap>
30 #include <QList>
31 
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
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  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 QStringList& lst);
80  void insert_filesize(uint64_t filesize);
81  void insert_filetype(const QStringList& filetypes);
82 
83  void insert_interval_info_field(InfoStrings key, int min, int max);
84  void insert_numeric_info_field(InfoStrings key, int number);
85 
86 
87  public:
88  explicit MetaDataInfo(const MetaDataList& v_md);
89  virtual ~MetaDataInfo();
90 
91  virtual QString header() const;
92  virtual QString subheader() const;
93  virtual QString infostring() const;
94  virtual QList<StringPair> infostring_map() const;
95  virtual QString additional_infostring() const;
96 
97  virtual Cover::Location cover_location() const;
98 
99  const Util::Set<QString>& albums() const;
100  const Util::Set<QString>& artists() const;
101  const Util::Set<QString>& album_artists() const;
102 
103  const Util::Set<AlbumId>& album_ids() const;
104  const Util::Set<ArtistId>& artist_ids() const;
105  const Util::Set<ArtistId>& album_artist_ids() const;
106 
107  QStringList paths() const;
108  QString pathsstring() const;
109 
110 
111  private:
112  void calc_cover_location(const MetaDataList& lst);
113  void calc_subheader(quint16 tracknum);
114  void calc_header(const MetaDataList& lst);
115 
116  QString get_info_string(InfoStrings idx) const;
117 };
118 
119 #endif // METADATAINFO_H
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:29
InfoStrings
The InfoStrings enum.
Definition: MetaDataInfo.h:38
The MetaDataList class.
Definition: MetaDataList.h:37
The CoverLocation class.
Definition: CoverLocation.h:37
The MetaDataInfo class.
Definition: MetaDataInfo.h:57
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