TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicsong.h
Go to the documentation of this file.
1 #ifndef MUSICSONG_H
2 #define MUSICSONG_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Music Player project
6  * Copyright (C) 2015 - 2026 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17 
18  * You should have received a copy of the GNU General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include "ttktime.h"
23 #include "musicsonghelper.h"
24 
29 {
30 public:
31  enum class Sort
32  {
33  ByFileName,
34  BySinger,
35  ByFileSize,
36  ByAddTime,
37  ByDuration,
38  ByPlayCount
39  };
40 
44  MusicSong() noexcept;
45  explicit MusicSong(const QString &path, bool track = false);
46  MusicSong(const QString &path, const QString &duration, const QString &name = {}, bool track = false);
47 
51  QString title() const noexcept;
55  QString artist() const noexcept;
56 
60  inline void setAddTimeStr(const QString &t) noexcept { m_addTimeStr = t; }
64  inline QString addTimeStr() const noexcept { return m_addTimeStr; }
68  inline void setSizeStr(const QString &s) noexcept { m_sizeStr = s; }
72  inline QString sizeStr() const noexcept { return m_sizeStr; }
73 
77  inline void setName(const QString &n) noexcept { m_name = n; }
81  inline QString name() const noexcept { return m_name; }
85  inline void setPath(const QString &p) noexcept { m_path = p; }
89  inline QString path() const noexcept { return m_path; }
93  inline void setFormat(const QString &t) noexcept { m_format = t; }
97  inline QString format() const noexcept { return m_format; }
101  inline void setDuration(const QString &t) noexcept { m_duration = t; }
105  inline QString duration() const noexcept { return m_duration; }
109  inline qint64 size() const noexcept { return m_size; }
113  inline void setPlayCount(const int c) noexcept { m_playCount = c; }
117  inline int playCount() const noexcept { return m_playCount; }
121  inline void setSort(const Sort s) noexcept { m_sort = s; }
122 
123  bool operator== (const MusicSong &other) const noexcept;
124  bool operator< (const MusicSong &other) const noexcept;
125  bool operator> (const MusicSong &other) const noexcept;
126 
127 private:
129  qint64 m_size, m_addTime;
130  QString m_sizeStr, m_addTimeStr;
132  QString m_name, m_path, m_format, m_duration;
133 
134 };
136 
137 
142 {
143  int m_type;
144  Qt::SortOrder m_order;
145 
146  MusicSongSort() noexcept
147  : m_type(-1),
148  m_order(Qt::AscendingOrder)
149  {
150 
151  }
152 };
153 
154 
156 
161 {
162  int m_id;
164  QString m_itemName;
166  MusicSongList m_songs;
168 
169  MusicSongItem() noexcept
170  : m_id(-1),
171  m_itemIndex(-1),
172  m_itemWidget(nullptr)
173  {
174 
175  }
176 
177  inline bool operator<(const MusicSongItem &other) const noexcept
178  {
179  return m_itemIndex < other.m_itemIndex;
180  }
181 };
183 
184 
188 namespace TTK
189 {
193  TTK_MODULE_EXPORT MusicSongList generateSongList(const QString &path);
194 
195 }
196 
197 #endif // MUSICSONG_H
#define TTK_MODULE_EXPORT
bool operator<(const MusicSongItem &other) const noexcept
Definition: musicsong.h:177
QString sizeStr() const noexcept
Definition: musicsong.h:72
TTK_DECLARE_LIST(MusicSong)
void setSort(const Sort s) noexcept
Definition: musicsong.h:121
QString path() const noexcept
Definition: musicsong.h:89
QString m_sizeStr
Definition: musicsong.h:130
The namespace of the string literals.
bool operator==(const TTKOptional< T > &v, const T &other)
Definition: ttkoptional.h:144
void setName(const QString &n) noexcept
Definition: musicsong.h:77
Sort m_sort
Definition: musicsong.h:128
qint64 size() const noexcept
Definition: musicsong.h:109
const char * name
Definition: http_parser.c:458
MusicSongItem() noexcept
Definition: musicsong.h:169
The namespace of the application object.
Definition: ttkcompat.h:24
QString m_path
Definition: musicsong.h:132
MusicAbstractSongsListTableWidget * m_itemWidget
Definition: musicsong.h:167
int m_playCount
Definition: musicsong.h:131
void setFormat(const QString &t) noexcept
Definition: musicsong.h:93
void setSizeStr(const QString &s) noexcept
Definition: musicsong.h:68
The class of the music song sort tag.
Definition: musicsong.h:141
QString format() const noexcept
Definition: musicsong.h:97
QString duration() const noexcept
Definition: musicsong.h:105
QString name() const noexcept
Definition: musicsong.h:81
void setDuration(const QString &t) noexcept
Definition: musicsong.h:101
QString addTimeStr() const noexcept
Definition: musicsong.h:64
The class of the music song item.
Definition: musicsong.h:160
MusicSongList m_songs
Definition: musicsong.h:166
void setPlayCount(const int c) noexcept
Definition: musicsong.h:113
QString m_itemName
Definition: musicsong.h:164
The class of the music song info.
Definition: musicsong.h:28
void setPath(const QString &p) noexcept
Definition: musicsong.h:85
Qt::SortOrder m_order
Definition: musicsong.h:144
#define const
Definition: zconf.h:233
MusicSongSort m_sort
Definition: musicsong.h:165
constexpr bool operator<(int128_t, int128_t)
Definition: int128.h:634
int playCount() const noexcept
Definition: musicsong.h:117
qint64 m_size
Definition: musicsong.h:129
The class of the songs list abstract table widget.
MusicSongSort() noexcept
Definition: musicsong.h:146
TTK_MODULE_EXPORT MusicSongList generateSongList(const QString &path)
Definition: musicsong.cpp:92