TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
serializerrunnable.cpp
Go to the documentation of this file.
1 #include "serializerrunnable.h"
2 
3 /* This file is part of qjson
4  *
5  * Copyright (C) 2009 Flavio Castelli <flavio@castelli.name>
6  * 2009 Frank Osterfeld <osterfeld@kde.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software Foundation.
11  *
12  *
13  * This library 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 GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING.LIB. If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #include "parserrunnable.h"
25 #include "serializer.h"
26 
27 #include <QtCore/QDebug>
28 #include <QtCore/QVariant>
29 
30 using namespace QJson;
31 
36 {
37 public:
38  QVariant json;
39 };
40 
42  : QObject(parent),
43  QRunnable()
44 {
46  qRegisterMetaType<QVariant>("QVariant");
47 }
48 
49 void SerializerRunnable::setJsonObject(const QVariant &json)
50 {
52  d->json = json;
53 }
54 
56 {
58  Serializer serializer;
59  bool ok = false;
60  const QByteArray serialized = serializer.serialize( d->json, &ok);
61  Q_EMIT parsingFinished( serialized, ok, serializer.errorMessage() );
62 }
void parsingFinished(const QByteArray &serialized, bool ok, const QString &error_msg)
This signal is emitted when the serialization process has been completed.
Convenience class for converting JSON data to QVariant objects using a dedicated thread.
Main class used to convert QVariant objects to JSON data.
Definition: serializer.h:151
void setJsonObject(const QVariant &json)
Sets the json object to serialize.
Namespace used by QJson.
Definition: parser.h:34
SerializerRunnable(QObject *parent=nullptr)
Convenience class for converting JSON data to QVariant objects using a dedicated thread private...
QString errorMessage() const
Returns the error message.
Definition: serializer.cpp:494
#define TTK_INIT_PRIVATE(Class)
Definition: ttkprivate.h:33
The class of the ttk private base.
Definition: ttkprivate.h:48
void serialize(const QVariant &variant, QIODevice *out, bool *ok)
This method generates a textual JSON representation and outputs it to the passed in I/O Device...
Definition: serializer.cpp:420
#define TTK_D(Class)
Definition: ttkprivate.h:41