TTKMusicPlayer  4.1.3.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicabstractqueryrequest.h
Go to the documentation of this file.
1 #ifndef MUSICABSTRACTQUERYREQUEST_H
2 #define MUSICABSTRACTQUERYREQUEST_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Music Player project
6  * Copyright (C) 2015 - 2025 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 "musicpagequeryrequest.h"
23 
28 {
29  QString m_songName;
30  QString m_artistName;
31  QString m_albumName;
32  QString m_duration;
33  QString m_type;
34 
36  : m_songName(TTK_DEFAULT_STR),
37  m_artistName(TTK_DEFAULT_STR),
38  m_albumName(TTK_DEFAULT_STR),
39  m_duration(TTK_DEFAULT_STR),
40  m_type(TTK_DEFAULT_STR)
41  {
42 
43  }
44 
46  : m_songName(info.m_songName),
47  m_artistName(info.m_artistName),
48  m_albumName(info.m_albumName),
49  m_duration(info.m_duration)
50  {
51 
52  }
53 
54  MusicResultInfoItem(const TTK::MusicSongInformation &info, const QString &type)
55  : MusicResultInfoItem(info)
56  {
57  m_type = type;
58  }
59 };
60 
65 {
66  QString m_id;
67  QString m_name;
68  QString m_title;
69  QString m_nickName;
70  QString m_coverUrl;
71  QString m_count;
72  QString m_description;
73  QString m_time;
74  QString m_category;
75 
77  : m_id(TTK_DEFAULT_STR),
78  m_name(TTK_DEFAULT_STR),
79  m_title(TTK_DEFAULT_STR),
80  m_nickName(TTK_DEFAULT_STR),
81  m_coverUrl(TTK_DEFAULT_STR),
82  m_count(TTK_DEFAULT_STR),
83  m_description(TTK_DEFAULT_STR),
84  m_time(TTK_DEFAULT_STR),
85  m_category(TTK_DEFAULT_STR)
86  {
87 
88  }
89 
90  inline bool isEmpty() const
91  {
92  return m_name == TTK_DEFAULT_STR || m_nickName == TTK_DEFAULT_STR || m_coverUrl == TTK_DEFAULT_STR || m_description == TTK_DEFAULT_STR || m_category == TTK_DEFAULT_STR;
93  }
94 };
96 
97 
98 static constexpr const char *QUERY_WY_INTERFACE = "WangYi";
99 static constexpr const char *QUERY_KW_INTERFACE = "KuWo";
100 static constexpr const char *QUERY_KG_INTERFACE = "KuGou";
101 
102 
107 {
108  Q_OBJECT
110 public:
111  enum class QueryServer
112  {
113  WY,
114  KW,
115  KG
116  };
117 
118  enum class QueryType
119  {
120  Music,
121  Movie,
122  Lrc,
123  Other
124  };
125 
126  enum class QueryMode
127  {
128  Normal,
129  Meta
130  };
131 
135  explicit MusicAbstractQueryRequest(QObject *parent = nullptr);
136 
141  virtual void startToSearch(const QString &value) = 0;
145  virtual void startToSearchByID(const QString &value);
149  virtual void startToQueryResult(TTK::MusicSongInformation *info, int bitrate);
150 
154  inline void setQueryMode(QueryMode mode) { m_queryMode = mode; }
158  inline QueryMode queryMode() const { return m_queryMode; }
162  inline void setQueryType(QueryType type) { m_queryType = type; }
166  inline QueryType queryType() const { return m_queryType; }
170  inline QString queryServer() const { return m_queryServer; }
174  inline QString queryValue() const { return m_queryValue; }
178  inline void setItems(const TTK::MusicSongInformationList &items) { m_items = items; }
182  inline const TTK::MusicSongInformationList& items() const { return m_items; }
186  inline bool isEmpty() const { return m_items.isEmpty(); }
187 
188 Q_SIGNALS:
192  void clearItems();
196  void createResultItem(const MusicResultInfoItem &songItem);
197 
198 public Q_SLOTS:
202  virtual void downLoadFinished() override;
203 
204 protected:
208  QString serverToString() const;
212  bool fetchUrlPathSize(TTK::MusicSongProperty *prop, const QString &duration) const;
216  bool fetchUrlPathSize(TTK::MusicSongPropertyList *props, const QString &duration) const;
217 
218  QString m_queryValue;
219  QString m_queryServer;
222  TTK::MusicSongInformationList m_items;
223 
224 };
225 
226 #endif // MUSICABSTRACTQUERYREQUEST_H
MusicResultInfoItem(const TTK::MusicSongInformation &info)
#define TTK_MODULE_EXPORT
The class of the search result data item.
#define TTK_DEFAULT_STR
Definition: ttkglobal.h:203
The class of the music song property.
Definition: musicobject.h:225
static constexpr const char * QUERY_KG_INTERFACE
The class of the abstract download page query request.
virtual void downLoadFinished()
TTK::MusicSongInformationList m_items
static constexpr const char * QUERY_WY_INTERFACE
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:168
static constexpr const char * QUERY_KW_INTERFACE
MusicResultInfoItem(const TTK::MusicSongInformation &info, const QString &type)
The class of the search result info item.
void setItems(const TTK::MusicSongInformationList &items)
const char int mode
Definition: ioapi.h:135
TTK_DECLARE_LIST(MusicResultDataItem)
The class of the abstract query download data from net.
const TTK::MusicSongInformationList & items() const
The class of the music song information.
Definition: musicobject.h:283