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