Sayonara Player
MetaDataInfo.h
1 /* MetaDataInfo.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (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  CreateDate, // set by MetaDataInfo
44  ModifyDate, // set by MetaDataInfo
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  Filetype, // set by MetaDataInfo
52  Comment // set by MetaDataInfo
53 };
54 
55 
60 class MetaDataInfo :
61  public QObject
62 {
63  PIMPL(MetaDataInfo)
64 
65  protected:
66  QString mHeader;
67  QString mSubheader;
69  QList<StringPair> mAdditionalInfo;
70 
71 
72  QString calcTracknumString( TrackNum tracknum );
73  QString calcArtistString() const;
74  QString calcAlbumString();
75 
76  virtual void calcCoverLocation();
77  virtual void calcSubheader();
78  virtual void calcHeader();
79 
80  void insertPlayingTime(MilliSeconds ms);
81  void insertGenre(const Util::Set<Genre>& genres);
82  void insertFilesize(uint64_t filesize);
83  void insertFiletype(const Util::Set<QString>& filetypes);
84  void insertComment(const Util::Set<QString>& comments);
85  void insertCreatedates(uint64_t minDate, uint64_t maxDate);
86  void insertModifydates(uint64_t minDate, uint64_t maxDate);
87 
88  void insertIntervalInfoField(InfoStrings key, int min, int max);
89  void insertNumericInfoField(InfoStrings key, int number);
90 
91  public:
92  explicit MetaDataInfo(const MetaDataList& v_md);
93  virtual ~MetaDataInfo();
94 
95  virtual QString header() const;
96  virtual QString subheader() const;
97  virtual QString infostring() const;
98  virtual QList<StringPair> infostringMap() const;
99  virtual QString additionalInfostring() const;
100 
101  virtual Cover::Location coverLocation() const;
102 
103  const Util::Set<QString>& albums() const;
104  const Util::Set<QString>& artists() const;
105  const Util::Set<QString>& albumArtists() const;
106 
107  const Util::Set<AlbumId>& albumIds() const;
108  const Util::Set<ArtistId>& artistIds() const;
109  const Util::Set<ArtistId>& albumArtistIds() const;
110 
111  QStringList paths() const;
112  QString pathsString() const;
113 
114  private:
115  void calcCoverLocation(const MetaDataList& lst);
116  void calcSubheader(quint16 tracknum);
117  void calcHeader(const MetaDataList& lst);
118 
119  QString getInfoString(InfoStrings idx) const;
120 };
121 
122 #endif // METADATAINFO_H
InfoStrings
InfoStrings
The InfoStrings enum.
Definition: MetaDataInfo.h:39
MetaDataList
The MetaDataList class.
Definition: MetaDataList.h:37
Util::Set
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:37
Genre
Definition: Genre.h:31
QList
Definition: EngineUtils.h:33
QMap< InfoStrings, QString >
Cover::Location
The CoverLocation class.
Definition: CoverLocation.h:39
MetaDataInfo
The MetaDataInfo class.
Definition: MetaDataInfo.h:62