TTKMusicPlayer  4.3.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 - 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 "musicresultinfo.h"
23 #include "musicpagequeryrequest.h"
24 
25 static constexpr const char *QUERY_WY_INTERFACE = "WangYi";
26 static constexpr const char *QUERY_KW_INTERFACE = "KuWo";
27 static constexpr const char *QUERY_KG_INTERFACE = "KuGou";
28 
29 
34 {
35  Q_OBJECT
36 public:
37  enum class QueryServer
38  {
39  WY,
40  KW,
41  KG,
42  OT
43  };
44 
45  enum class QueryType
46  {
47  Music,
48  Movie,
49  Lrc,
50  Other
51  };
52 
53  enum class QueryMode
54  {
55  Normal,
56  Meta
57  };
58 
62  explicit MusicAbstractQueryRequest(QObject *parent = nullptr);
63 
68  virtual void startToSearch(const QString &value) = 0;
72  virtual void startToSearchByID(const QString &value);
76  virtual void startToQueryResult(TTK::MusicSongInformation *info, int bitrate);
77 
81  inline void setQueryMode(QueryMode mode) noexcept { m_queryMode = mode; }
85  inline QueryMode queryMode() const noexcept { return m_queryMode; }
89  inline void setQueryType(QueryType type) noexcept { m_queryType = type; }
93  inline QueryType queryType() const noexcept { return m_queryType; }
97  inline QString queryServer() const noexcept { return m_queryServer; }
101  inline QString queryValue() const noexcept { return m_queryValue; }
105  inline void setItems(const TTK::MusicSongInformationList &items) noexcept { m_items = items; }
109  inline const TTK::MusicSongInformationList& items() const noexcept { return m_items; }
113  inline bool isEmpty() const noexcept { return m_items.isEmpty(); }
114 
115 Q_SIGNALS:
119  void clearItems();
123  void createResultItem(const MusicResultInfoItem &result);
124 
125 public Q_SLOTS:
129  virtual void downloadFinished() override;
130 
131 protected:
135  QString serverToString() const;
139  bool fetchUrlPathSize(TTK::MusicSongProperty *prop, const QString &duration) const;
143  bool fetchUrlPathSize(TTK::MusicSongPropertyList *props, const QString &duration) const;
144 
145  QString m_queryValue;
146  QString m_queryServer;
149  TTK::MusicSongInformationList m_items;
150 
151 };
152 
153 #endif // MUSICABSTRACTQUERYREQUEST_H
const TTK::MusicSongInformationList & items() const noexcept
#define TTK_MODULE_EXPORT
void setQueryMode(QueryMode mode) noexcept
The class of the music song property.
Definition: musicobject.h:242
static constexpr const char * QUERY_KG_INTERFACE
The class of the abstract download page query request.
QString queryValue() const noexcept
TTK::MusicSongInformationList m_items
static constexpr const char * QUERY_WY_INTERFACE
QueryMode queryMode() const noexcept
static constexpr const char * QUERY_KW_INTERFACE
void setItems(const TTK::MusicSongInformationList &items) noexcept
The class of the search result info item.
virtual void downloadFinished()
void setQueryType(QueryType type) noexcept
const char int mode
Definition: ioapi.h:135
The class of the abstract query data from net.
#define const
Definition: zconf.h:233
QueryType queryType() const noexcept
The class of the music song information.
Definition: musicobject.h:300
QString queryServer() const noexcept