Sayonara Player
MetaDataInfo.h
1 /* MetaDataInfo.h */
2 
3 /* Copyright (C) 2011-2016 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 
23 #ifndef METADATAINFO_H
24 #define METADATAINFO_H
25 
26 
27 #include "Helper/Set.h"
28 #include "Helper/Settings/SayonaraClass.h"
29 #include "Components/CoverLookup/CoverLocation.h"
30 
31 #include <QMap>
32 
33 class MetaDataList;
34 class LibraryDatabase;
35 
40 enum class InfoStrings : quint8
41 {
42  nTracks=0, // set by MetaDataInfo
43  nAlbums, // set by ArtistInfo, AlbumInfo
44  nArtists, // set by ArtistInfo, AlbumInfo
45  Filesize, // set by MetaDataInfo
46  PlayingTime, // set by MetaDataInfo
47  Year, // set by MetaDataInfo
48  Sampler, // set by AlbumInfo
49  Bitrate, // set by MetaDataInfo
50  Genre // set by MetaDataInfo
51 };
52 
53 
54 
59 class MetaDataInfo : public QObject, protected SayonaraClass
60 {
61  Q_OBJECT
62 
63 private:
64  void set_cover_location(const MetaDataList& lst);
65  void set_subheader(quint16 tracknum);
66  void set_header(const MetaDataList& lst);
67 
68  QString get_info_string(InfoStrings idx) const;
69 
70 protected:
71 
72  QString _header;
73  QString _subheader;
75  QMap<QString, QString> _additional_info;
76  QStringList _paths;
77  CoverLocation _cover_location;
78 
79  SP::Set<QString> _albums;
80  SP::Set<QString> _artists;
81  SP::Set<AlbumID> _album_ids;
82  SP::Set<ArtistID> _artist_ids;
83 
84  LibraryDatabase* _db;
85 
86 
87  QString calc_tracknum_str( quint16 tracknum );
88  QString calc_artist_str();
89  QString calc_album_str();
90 
91  virtual void set_cover_location();
92  virtual void set_subheader();
93  virtual void set_header();
94 
95  void insert_playing_time(quint64 ms);
96  void insert_genre(const QStringList& lst);
97  void insert_filesize(quint64 filesize);
98 
99  template<typename T>
100  void insert_interval(InfoStrings key, T min, T max){
101  QString str;
102 
103  if(min == max){
104  str = QString::number(min);
105  }
106 
107  else {
108  str = QString::number(min) + " - " + QString::number(max);
109  }
110 
111  if(key == InfoStrings::Bitrate){
112  str += " kBit/s";
113  }
114 
115  _info.insert(key, str);
116  }
117 
118  template<typename T>
119  void insert_number(InfoStrings key, T number){
120  QString str = QString::number(number);
121  _info.insert(key, str);
122  }
123 
124 public:
125 
126  MetaDataInfo(const MetaDataList& v_md);
127 
128  virtual ~MetaDataInfo();
129 
130  QString get_header() const;
131  QString get_subheader() const;
132  QMap<InfoStrings, QString> get_info() const;
133  QString get_info_as_string() const;
134  virtual QString get_additional_info_as_string() const;
135  QStringList get_paths() const;
136  QString get_paths_as_string() const;
137  CoverLocation get_cover_location() const;
138 
139  virtual QString get_cover_artist() const;
140  virtual QString get_cover_album() const;
141 };
142 
143 
144 #endif // METADATAINFO_H
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:31
Definition: MetaDataList.h:46
The CoverLocation class.
Definition: CoverLocation.h:37
The MetaDataInfo class.
Definition: MetaDataInfo.h:59
Definition: LibraryDatabase.h:35
InfoStrings
The InfoStrings enum.
Definition: MetaDataInfo.h:40