mirror of
https://github.com/YACReader/yacreader
synced 2025-07-26 08:55:05 -04:00
added new comic_vine folder containing all the ComicVine related clases
added QtScript dependency (json parser)
This commit is contained in:
6
YACReaderLibrary/comic_vine/model/comics_model.cpp
Normal file
6
YACReaderLibrary/comic_vine/model/comics_model.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "comics_model.h"
|
||||
|
||||
ComicsModel::ComicsModel(QObject *parent) :
|
||||
JSONModel(parent)
|
||||
{
|
||||
}
|
18
YACReaderLibrary/comic_vine/model/comics_model.h
Normal file
18
YACReaderLibrary/comic_vine/model/comics_model.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef COMICS_MODEL_H
|
||||
#define COMICS_MODEL_H
|
||||
|
||||
#include "json_model.h"
|
||||
|
||||
class ComicsModel : public JSONModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ComicsModel(QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // COMICS_MODEL_H
|
6
YACReaderLibrary/comic_vine/model/json_model.cpp
Normal file
6
YACReaderLibrary/comic_vine/model/json_model.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "json_model.h"
|
||||
|
||||
JSONModel::JSONModel(QObject *parent) :
|
||||
QAbstractItemModel(parent)
|
||||
{
|
||||
}
|
18
YACReaderLibrary/comic_vine/model/json_model.h
Normal file
18
YACReaderLibrary/comic_vine/model/json_model.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef JSON_MODEL_H
|
||||
#define JSON_MODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
class JSONModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit JSONModel(QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // JSON_MODEL_H
|
42
YACReaderLibrary/comic_vine/model/response_parser.cpp
Normal file
42
YACReaderLibrary/comic_vine/model/response_parser.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include "response_parser.h"
|
||||
|
||||
#include <QtScript>
|
||||
#include <QDebug>
|
||||
|
||||
ResponseParser::ResponseParser(QObject *parent) :
|
||||
QObject(parent),error(false),numResults(-1)
|
||||
{
|
||||
}
|
||||
|
||||
bool ResponseParser::responseError()
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
qint32 ResponseParser::getNumResults()
|
||||
{
|
||||
return numResults;
|
||||
}
|
||||
|
||||
void ResponseParser::loadJSONResponse(const QString &response)
|
||||
{
|
||||
QScriptEngine engine;
|
||||
QScriptValue sc;
|
||||
sc = engine.evaluate("(" + response + ")");
|
||||
|
||||
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK")
|
||||
{
|
||||
error = true;
|
||||
numResults = -2;
|
||||
qDebug("Error detected");
|
||||
}
|
||||
else
|
||||
{
|
||||
error = false;
|
||||
if(sc.property("number_of_total_results").isValid())
|
||||
numResults = sc.property("number_of_total_results").toString().toInt();// sc.property("number_of_total_results").toInt32();
|
||||
else
|
||||
numResults = -3;
|
||||
qDebug() << sc.property("number_of_total_results").toString();
|
||||
}
|
||||
}
|
23
YACReaderLibrary/comic_vine/model/response_parser.h
Normal file
23
YACReaderLibrary/comic_vine/model/response_parser.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef RESPONSE_PARSER_H
|
||||
#define RESPONSE_PARSER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class ResponseParser : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ResponseParser(QObject *parent = 0);
|
||||
bool responseError();
|
||||
qint32 getNumResults();
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void loadJSONResponse(const QString & response);
|
||||
|
||||
protected:
|
||||
bool error;
|
||||
qint32 numResults;
|
||||
};
|
||||
|
||||
#endif // RESPONSE_PARSER_H
|
6
YACReaderLibrary/comic_vine/model/volumes_model.cpp
Normal file
6
YACReaderLibrary/comic_vine/model/volumes_model.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "volumes_model.h"
|
||||
|
||||
VolumesModel::VolumesModel(QObject *parent) :
|
||||
JSONModel(parent)
|
||||
{
|
||||
}
|
18
YACReaderLibrary/comic_vine/model/volumes_model.h
Normal file
18
YACReaderLibrary/comic_vine/model/volumes_model.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef VOLUMES_MODEL_H
|
||||
#define VOLUMES_MODEL_H
|
||||
|
||||
#include "json_model.h"
|
||||
|
||||
class VolumesModel : public JSONModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VolumesModel(QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // VOLUMES_MODEL_H
|
Reference in New Issue
Block a user