TTKMusicPlayer  3.7.0.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 - 2024 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_nickName;
69  QString m_coverUrl;
70  QString m_count;
71  QString m_description;
72  QString m_updateTime;
73  QString m_category;
74 
76  : m_id(TTK_DEFAULT_STR),
77  m_name(TTK_DEFAULT_STR),
78  m_nickName(TTK_DEFAULT_STR),
79  m_coverUrl(TTK_DEFAULT_STR),
80  m_count(TTK_DEFAULT_STR),
81  m_description(TTK_DEFAULT_STR),
82  m_updateTime(TTK_DEFAULT_STR),
83  m_category(TTK_DEFAULT_STR)
84  {
85 
86  }
87 
88  inline bool isEmpty() const
89  {
90  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;
91  }
92 };
94 
95 
96 static constexpr const char *QUERY_WY_INTERFACE = "WangYi";
97 static constexpr const char *QUERY_KW_INTERFACE = "KuWo";
98 static constexpr const char *QUERY_KG_INTERFACE = "KuGou";
99 
100 
105 {
106  Q_OBJECT
108 public:
109  enum class QueryServer
110  {
111  WY,
112  KW,
113  KG
114  };
115 
116  enum class QueryType
117  {
118  Music,
119  Movie,
120  Lrc,
121  Other
122  };
123 
124  enum class QueryMode
125  {
126  Normal,
127  Meta,
128  MetaItem
129  };
130 
134  explicit MusicAbstractQueryRequest(QObject *parent = nullptr);
135 
140  virtual void startToSearch(const QString &value) = 0;
144  virtual void startToSearchByID(const QString &value);
148  virtual void startToQueryResult(TTK::MusicSongInformation *info, int bitrate);
149 
153  inline void setQueryMode(QueryMode mode) { m_queryMode = mode; }
157  inline QueryMode queryMode() const { return m_queryMode; }
161  inline void setQueryType(QueryType type) { m_queryType = type; }
165  inline QueryType queryType() const { return m_queryType; }
169  inline QString queryServer() const { return m_queryServer; }
173  inline QString queryValue() const { return m_queryValue; }
177  inline void setItems(const TTK::MusicSongInformationList &items) { m_items = items; }
181  inline const TTK::MusicSongInformationList& items() const { return m_items; }
185  inline bool isEmpty() const { return m_items.isEmpty(); }
186 
187 Q_SIGNALS:
191  void clearItems();
195  void createResultItem(const MusicResultInfoItem &songItem);
196 
197 public Q_SLOTS:
201  virtual void downLoadFinished() override;
202 
203 protected:
207  QString serverToString() const;
211  bool findUrlPathSize(TTK::MusicSongProperty *prop, const QString &duration) const;
215  bool findUrlPathSize(TTK::MusicSongPropertyList *props, const QString &duration) const;
216 
217  QString m_queryValue;
218  QString m_queryServer;
221  TTK::MusicSongInformationList m_items;
222 
223 };
224 
225 #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:200
The class of the music song property.
Definition: musicobject.h:223
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:152
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:281