TTKMusicPlayer  4.2.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicsourceupdaterequest.cpp
Go to the documentation of this file.
3 
4 #include "qsync/qsyncutils.h"
5 
6 static constexpr const char *QUERY_VERSION_URL = "version";
7 
9  : QObject(parent)
10 {
11 
12 }
13 
15 {
17  connect(d, SIGNAL(downLoadRawDataChanged(QByteArray)), SLOT(downLoadFinished(QByteArray)));
19 }
20 
22 {
23  return m_rawData["version"].toString();
24 }
25 
27 {
28  return m_rawData["data"].toString();
29 }
30 
32 {
33  const QString &v = version();
34  if(v.isEmpty())
35  {
36  return true;
37  }
38  else
39  {
40  return TTK_VERSION_STR == v;
41  }
42 }
43 
44 void MusicSourceUpdateRequest::downLoadFinished(const QByteArray &bytes)
45 {
46  if(bytes.isEmpty())
47  {
48  TTK_ERROR_STREAM("Input byte data is empty");
49  }
50  else
51  {
52  QJsonParseError ok;
53  const QJsonDocument &json = QJsonDocument::fromJson(bytes, &ok);
55  {
56  return;
57  }
58 
59  m_rawData = json.toVariant().toMap();
60  Q_EMIT downLoadDataChanged({});
61  }
62 }
static constexpr const char * QUERY_VERSION_URL
QVariant toVariant() const
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=0)
QString description() const noexcept
void downLoadFinished(const QByteArray &bytes)
ParseError error
The class of the data source download request.
void downLoadDataChanged(const QString &bytes)
#define TTK_VERSION_STR
Definition: ttkversion.h:175
void startToRequest(const QString &url)
bool isLastedVersion() const noexcept
#define const
Definition: zconf.h:233
#define TTK_ERROR_STREAM(msg)
Definition: ttklogger.h:76
QString version() const noexcept
MusicSourceUpdateRequest(QObject *parent=nullptr)
static QString makeDataBucketUrl()
Definition: qsyncutils.cpp:89