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