smf/smfservermodule/util/qjson/src/serializerrunnable.cpp
changeset 7 be09cf1f39dd
equal deleted inserted replaced
6:c39a6cfd1fb9 7:be09cf1f39dd
       
     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 Library General Public
       
    10  * License as published by the Free Software Foundation; either
       
    11  * version 2 of the License, or (at your option) any later version.
       
    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  * Library General Public License for more details.
       
    17  *
       
    18  * You should have received a copy of the GNU Library 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 
       
    32 class SerializerRunnable::Private
       
    33 {
       
    34 public:
       
    35   QVariant json;
       
    36 };
       
    37 
       
    38 SerializerRunnable::SerializerRunnable(QObject* parent)
       
    39     : QObject(parent),
       
    40       QRunnable(),
       
    41       d(new Private)
       
    42 {
       
    43   qRegisterMetaType<QVariant>("QVariant");
       
    44 }
       
    45 
       
    46 SerializerRunnable::~SerializerRunnable()
       
    47 {
       
    48   delete d;
       
    49 }
       
    50 
       
    51 void SerializerRunnable::setJsonObject( const QVariant& json )
       
    52 {
       
    53   d->json = json;
       
    54 }
       
    55 
       
    56 void SerializerRunnable::run()
       
    57 {
       
    58   Serializer serializer;
       
    59   emit parsingFinished( Serializer().serialize( d->json ), true, QString() );
       
    60 }