mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Merge pull request #222 from YACReader/feature/drop_qtscript
fix: Replace QtScript with QJson*
This commit is contained in:
commit
81f9b74fa2
@ -69,7 +69,7 @@ macx {
|
||||
|
||||
#CONFIG += release
|
||||
CONFIG -= flat
|
||||
QT += sql network widgets script svg
|
||||
QT += sql network widgets svg
|
||||
!CONFIG(no_opengl) {
|
||||
QT += opengl
|
||||
}
|
||||
@ -231,8 +231,8 @@ SOURCES += comic_flow.cpp \
|
||||
}
|
||||
|
||||
macx {
|
||||
HEADERS += trayhandler.h
|
||||
OBJECTIVE_SOURCES += trayhandler.mm
|
||||
HEADERS += trayhandler.h
|
||||
OBJECTIVE_SOURCES += trayhandler.mm
|
||||
}
|
||||
|
||||
include(./server/server.pri)
|
||||
|
@ -3,7 +3,9 @@
|
||||
#include "http_worker.h"
|
||||
#include "response_parser.h"
|
||||
|
||||
#include <QtScript>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
ComicVineAllVolumeComicsRetriever::ComicVineAllVolumeComicsRetriever(const QString &volumeURLString, QObject *parent)
|
||||
: QObject(parent), volumeURLString(volumeURLString)
|
||||
|
@ -1,21 +1,22 @@
|
||||
#include "comic_vine_dialog.h"
|
||||
#include <QtWidgets>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QStackedWidget>
|
||||
#include <QRadioButton>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <QStackedWidget>
|
||||
#include <QTableView>
|
||||
#include <QVBoxLayout>
|
||||
#include <QtWidgets>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
#else
|
||||
#include <QtConcurrentRun>
|
||||
#endif
|
||||
#include <QSqlDatabase>
|
||||
#include <QtScript>
|
||||
#include "data_base_management.h"
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QSqlDatabase>
|
||||
|
||||
#include "yacreader_busy_widget.h"
|
||||
#include "comic_vine_client.h"
|
||||
@ -488,138 +489,114 @@ void ComicVineDialog::getComicInfo(const QString &comicId, int count, const QStr
|
||||
|
||||
ComicDB ComicVineDialog::parseComicInfo(ComicDB &comic, const QString &json, int count, const QString &publisher)
|
||||
{
|
||||
QScriptEngine engine;
|
||||
QScriptValue sc;
|
||||
sc = engine.evaluate("(" + json + ")");
|
||||
QJsonParseError Err;
|
||||
|
||||
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
|
||||
QVariantMap sc = QJsonDocument::fromJson(json.toUtf8(), &Err).toVariant().toMap();
|
||||
if (Err.error != QJsonParseError::NoError) {
|
||||
qDebug("Error detected");
|
||||
} else {
|
||||
int numResults = sc.property("number_of_total_results").toString().toInt(); //fix to weird behaviour using hasNext
|
||||
return comic;
|
||||
}
|
||||
|
||||
if (numResults > 0) {
|
||||
QScriptValue result = sc.property("results");
|
||||
int numResults = sc.value("number_of_total_results").toInt(); //fix to weird behaviour using hasNext
|
||||
|
||||
if (!result.property("name").isNull()) {
|
||||
QString title = result.property("name").toString();
|
||||
if (numResults > 0) {
|
||||
QVariantMap result = sc.value("results").toMap();
|
||||
comic.info.title = result.value("name");
|
||||
comic.info.number = result.value("issue_number");
|
||||
comic.info.volume = result.value("volume").toMap().value("name");
|
||||
|
||||
comic.info.title = title;
|
||||
}
|
||||
if (result.contains("person_credits") && !result.value("person_credits").isNull()) {
|
||||
QMap<QString, QString> authors = getAuthors(result.value("person_credits"));
|
||||
|
||||
if (!result.property("issue_number").isNull()) {
|
||||
QString number = result.property("issue_number").toString();
|
||||
QString writer = QStringList(authors.values("writer")).join("\n");
|
||||
QString penciller = QStringList(authors.values("penciller")).join("\n");
|
||||
QString inker = QStringList(authors.values("inker")).join("\n");
|
||||
QString colorist = QStringList(authors.values("colorist")).join("\n");
|
||||
QString letterer = QStringList(authors.values("letterer")).join("\n");
|
||||
QString coverArtist = QStringList(authors.values("cover")).join("\n");
|
||||
|
||||
comic.info.number = number;
|
||||
}
|
||||
|
||||
if (!result.property("volume").property("name").isNull()) {
|
||||
QString volume = result.property("volume").property("name").toString();
|
||||
|
||||
comic.info.volume = volume;
|
||||
}
|
||||
|
||||
if (!result.property("person_credits").isNull()) {
|
||||
QMap<QString, QString> authors = getAuthors(result.property("person_credits"));
|
||||
|
||||
QString writer = QStringList(authors.values("writer")).join("\n");
|
||||
QString penciller = QStringList(authors.values("penciller")).join("\n");
|
||||
QString inker = QStringList(authors.values("inker")).join("\n");
|
||||
QString colorist = QStringList(authors.values("colorist")).join("\n");
|
||||
QString letterer = QStringList(authors.values("letterer")).join("\n");
|
||||
QString coverArtist = QStringList(authors.values("cover")).join("\n");
|
||||
|
||||
comic.info.writer = writer;
|
||||
comic.info.penciller = penciller;
|
||||
comic.info.inker = inker;
|
||||
comic.info.colorist = colorist;
|
||||
comic.info.letterer = letterer;
|
||||
comic.info.coverArtist = coverArtist;
|
||||
}
|
||||
|
||||
if (!result.property("cover_date").isNull()) {
|
||||
QString date = result.property("cover_date").toString();
|
||||
|
||||
QStringList tempList = date.split("-");
|
||||
|
||||
if (tempList.length() == 3) {
|
||||
std::reverse(tempList.begin(), tempList.end());
|
||||
comic.info.date = tempList.join("/");
|
||||
}
|
||||
}
|
||||
|
||||
if (!result.property("description").isNull()) {
|
||||
QString synopsis = result.property("description").toString().remove(QRegExp("<[^>]*>")); //description
|
||||
comic.info.synopsis = synopsis;
|
||||
}
|
||||
|
||||
if (!result.property("character_credits").isNull()) {
|
||||
QString characters = getCharacters(result.property("character_credits"));
|
||||
|
||||
comic.info.characters = characters;
|
||||
}
|
||||
|
||||
if (!result.property("story_arc_credits").isNull()) {
|
||||
QPair<QString, QString> storyArcIdAndName = getFirstStoryArcIdAndName(result.property("story_arc_credits"));
|
||||
QString storyArcId = storyArcIdAndName.first;
|
||||
QString storyArcName = storyArcIdAndName.second;
|
||||
if (!storyArcId.isNull()) {
|
||||
|
||||
QString comicId = result.property("id").toString();
|
||||
|
||||
QPair<QString, QString> arcNumberAndArcCount = getArcNumberAndArcCount(storyArcId, comicId);
|
||||
if (!arcNumberAndArcCount.first.isNull()) {
|
||||
QString arcNumber = arcNumberAndArcCount.first;
|
||||
QString arcCount = arcNumberAndArcCount.second;
|
||||
|
||||
comic.info.storyArc = storyArcName;
|
||||
comic.info.arcNumber = arcNumber;
|
||||
comic.info.arcCount = arcCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
comic.info.count = count;
|
||||
|
||||
comic.info.publisher = publisher;
|
||||
comic.info.writer = writer;
|
||||
comic.info.penciller = penciller;
|
||||
comic.info.inker = inker;
|
||||
comic.info.colorist = colorist;
|
||||
comic.info.letterer = letterer;
|
||||
comic.info.coverArtist = coverArtist;
|
||||
}
|
||||
|
||||
if (result.contains("cover_date") && !result.value("conver_date").isNull()) {
|
||||
QString date = result.value("cover_date").toString();
|
||||
|
||||
QStringList tempList = date.split("-");
|
||||
|
||||
if (tempList.length() == 3) {
|
||||
std::reverse(tempList.begin(), tempList.end());
|
||||
comic.info.date = tempList.join("/");
|
||||
}
|
||||
}
|
||||
|
||||
if (result.contains("description") && !result.value("description").isNull()) {
|
||||
comic.info.synopsis = result.value("description").toString().remove(QRegExp("<[^>]*>")); //description
|
||||
}
|
||||
|
||||
if (result.contains("character_credits") && !result.value("character_credits").isNull()) {
|
||||
comic.info.characters = getCharacters(result.value("character_credits"));
|
||||
}
|
||||
|
||||
if (result.contains("story_arc_credits") && !result.value("story_arc_credits").isNull()) {
|
||||
QPair<QString, QString> storyArcIdAndName = getFirstStoryArcIdAndName(result.value("story_arc_credits"));
|
||||
QString storyArcId = storyArcIdAndName.first;
|
||||
QString storyArcName = storyArcIdAndName.second;
|
||||
if (!storyArcId.isNull()) {
|
||||
|
||||
QString comicId = result.value("id").toString();
|
||||
|
||||
QPair<QString, QString> arcNumberAndArcCount = getArcNumberAndArcCount(storyArcId, comicId);
|
||||
if (!arcNumberAndArcCount.first.isNull()) {
|
||||
QString arcNumber = arcNumberAndArcCount.first;
|
||||
QString arcCount = arcNumberAndArcCount.second;
|
||||
|
||||
comic.info.storyArc = storyArcName;
|
||||
comic.info.arcNumber = arcNumber;
|
||||
comic.info.arcCount = arcCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
comic.info.count = count;
|
||||
|
||||
comic.info.publisher = publisher;
|
||||
}
|
||||
|
||||
return comic;
|
||||
}
|
||||
|
||||
QString ComicVineDialog::getCharacters(const QScriptValue &json_characters)
|
||||
QString ComicVineDialog::getCharacters(const QVariant &json_characters)
|
||||
{
|
||||
QString characters;
|
||||
QStringList characters;
|
||||
|
||||
QScriptValueIterator it(json_characters);
|
||||
QScriptValue resultsValue;
|
||||
QListIterator<QVariant> it(json_characters.toList());
|
||||
QVariantMap resultsValue;
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (it.flags() & QScriptValue::SkipInEnumeration)
|
||||
continue;
|
||||
resultsValue = it.value();
|
||||
resultsValue = it.next().toMap();
|
||||
|
||||
characters += resultsValue.property("name").toString() + "\n";
|
||||
characters << resultsValue.value("name").toString();
|
||||
}
|
||||
|
||||
return characters;
|
||||
return (characters.isEmpty()) ? "" : (characters.join("\n") + "\n");
|
||||
}
|
||||
|
||||
QMap<QString, QString> ComicVineDialog::getAuthors(const QScriptValue &json_authors)
|
||||
QMap<QString, QString> ComicVineDialog::getAuthors(const QVariant &json_authors)
|
||||
{
|
||||
QMap<QString, QString> authors;
|
||||
|
||||
QScriptValueIterator it(json_authors);
|
||||
QScriptValue resultsValue;
|
||||
QListIterator<QVariant> it(json_authors.toList());
|
||||
QVariantMap resultsValue;
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (it.flags() & QScriptValue::SkipInEnumeration)
|
||||
continue;
|
||||
resultsValue = it.value();
|
||||
resultsValue = it.next().toMap();
|
||||
|
||||
QString authorName = resultsValue.property("name").toString();
|
||||
QString authorName = resultsValue.value("name").toString();
|
||||
|
||||
QStringList roles = resultsValue.property("role").toString().split(",");
|
||||
QStringList roles = resultsValue.value("role").toString().split(",");
|
||||
foreach (QString role, roles) {
|
||||
if (role.trimmed() == "writer")
|
||||
authors.insertMulti("writer", authorName);
|
||||
@ -639,20 +616,17 @@ QMap<QString, QString> ComicVineDialog::getAuthors(const QScriptValue &json_auth
|
||||
return authors;
|
||||
}
|
||||
|
||||
QPair<QString, QString> ComicVineDialog::getFirstStoryArcIdAndName(const QScriptValue &json_story_arcs)
|
||||
QPair<QString, QString> ComicVineDialog::getFirstStoryArcIdAndName(const QVariant &json_story_arcs)
|
||||
{
|
||||
QString story_arc_id = QString();
|
||||
QString story_arc_name = QString();
|
||||
|
||||
QScriptValueIterator it(json_story_arcs);
|
||||
QScriptValue resultsValue;
|
||||
QListIterator<QVariant> it(json_story_arcs.toList());
|
||||
QVariantMap resultsValue;
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (it.flags() & QScriptValue::SkipInEnumeration)
|
||||
continue;
|
||||
resultsValue = it.value();
|
||||
story_arc_id = resultsValue.property("id").toString();
|
||||
story_arc_name = resultsValue.property("name").toString();
|
||||
resultsValue = it.next().toMap();
|
||||
story_arc_id = resultsValue.value("id").toString();
|
||||
story_arc_name = resultsValue.value("name").toString();
|
||||
break;
|
||||
}
|
||||
return qMakePair(story_arc_id, story_arc_name);
|
||||
@ -668,40 +642,33 @@ QPair<QString, QString> ComicVineDialog::getArcNumberAndArcCount(const QString &
|
||||
return qMakePair(QString(), QString());
|
||||
QString json = result;
|
||||
|
||||
QScriptEngine engine;
|
||||
QScriptValue sc;
|
||||
sc = engine.evaluate("(" + json + ")");
|
||||
QJsonParseError Err;
|
||||
QVariantMap sc = QJsonDocument::fromJson(json.toUtf8(), &Err).toVariant().toMap();
|
||||
|
||||
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
|
||||
if (Err.error != QJsonParseError::NoError) {
|
||||
qDebug("Error detected");
|
||||
return qMakePair(QString(), QString());
|
||||
} else {
|
||||
int numResults = sc.property("number_of_total_results").toString().toInt(); //fix to weird behaviour using hasNext
|
||||
}
|
||||
|
||||
if (numResults > 0) {
|
||||
QScriptValue result = sc.property("results");
|
||||
int numResults = sc.value("number_of_total_results").toInt(); //fix to weird behaviour using hasNext
|
||||
|
||||
if (!result.property("issues").isNull()) {
|
||||
QScriptValue issues = result.property("issues");
|
||||
if (numResults > 0) {
|
||||
QVariantMap result = sc.value("results").toMap();
|
||||
|
||||
int arcNumber = 0;
|
||||
int arcCount = 0;
|
||||
if (result.contains("issues")) {
|
||||
QListIterator<QVariant> it(result.value("issues").toList());
|
||||
int arcNumber = 0;
|
||||
int arcCount = 0;
|
||||
|
||||
QScriptValueIterator it(issues);
|
||||
QScriptValue resultsValue;
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (it.flags() & QScriptValue::SkipInEnumeration)
|
||||
continue;
|
||||
resultsValue = it.value();
|
||||
if (comicId == resultsValue.property("id").toString()) {
|
||||
arcNumber = arcCount + 1;
|
||||
}
|
||||
arcCount++;
|
||||
QVariantMap resultsValue;
|
||||
while (it.hasNext()) {
|
||||
resultsValue = it.next().toMap();
|
||||
if (comicId == resultsValue.value("id").toString()) {
|
||||
arcNumber = arcCount + 1;
|
||||
}
|
||||
return qMakePair(QString::number(arcNumber), QString::number(arcCount));
|
||||
arcCount++;
|
||||
}
|
||||
return qMakePair(QString(), QString());
|
||||
return qMakePair(QString::number(arcNumber), QString::number(arcCount));
|
||||
}
|
||||
return qMakePair(QString(), QString());
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ class SearchVolume;
|
||||
class SelectComic;
|
||||
class SelectVolume;
|
||||
class SortVolumeComics;
|
||||
class QScriptValue;
|
||||
|
||||
//TODO this should use a QStateMachine
|
||||
//----------------------------------------
|
||||
@ -64,9 +63,9 @@ protected slots:
|
||||
void goToNextComic();
|
||||
|
||||
private:
|
||||
QString getCharacters(const QScriptValue &json_characters);
|
||||
QMap<QString, QString> getAuthors(const QScriptValue &json_authors);
|
||||
QPair<QString, QString> getFirstStoryArcIdAndName(const QScriptValue &json_story_arcs);
|
||||
QString getCharacters(const QVariant &json_characters);
|
||||
QMap<QString, QString> getAuthors(const QVariant &json_authors);
|
||||
QPair<QString, QString> getFirstStoryArcIdAndName(const QVariant &json_story_arcs);
|
||||
QPair<QString, QString> getArcNumberAndArcCount(const QString &storyArcId, const QString &comicId);
|
||||
|
||||
void toggleSkipButton();
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "response_parser.h"
|
||||
|
||||
#include <QtScript>
|
||||
#include <QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
|
||||
ResponseParser::ResponseParser(QObject *parent)
|
||||
: QObject(parent), error(false), errorTxt("None"), numResults(-1), currentPage(-1), totalPages(-1)
|
||||
@ -46,32 +46,43 @@ bool ResponseParser::isError(qint32 error)
|
||||
|
||||
void ResponseParser::loadJSONResponse(const QString &response)
|
||||
{
|
||||
QScriptEngine engine;
|
||||
QScriptValue sc;
|
||||
sc = engine.evaluate("(" + response + ")");
|
||||
QJsonParseError Err;
|
||||
QVariantMap sc = QJsonDocument::fromJson(response.toUtf8(), &Err).toVariant().toMap();
|
||||
|
||||
errorTxt = "None";
|
||||
|
||||
if (!sc.property("status_code").isValid() || isError(sc.property("status_code").toInt32())) {
|
||||
if (Err.error != QJsonParseError::NoError) {
|
||||
errorTxt = "Json syntax error";
|
||||
error = true;
|
||||
if (sc.property("error").isValid())
|
||||
errorTxt = sc.property("error").toString();
|
||||
else
|
||||
errorTxt = "Unknown error";
|
||||
} 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
|
||||
qDebug() << sc.property("oops").toString();
|
||||
return;
|
||||
}
|
||||
|
||||
int limit = sc.property("limit").toInt32();
|
||||
int offset = sc.property("offset").toInt32();
|
||||
int total = sc.property("number_of_total_results").toInt32();
|
||||
if (limit > 0) {
|
||||
totalPages = (total / limit) + (total % limit > 0 ? 1 : 0);
|
||||
currentPage = (offset / limit) + 1;
|
||||
} else
|
||||
totalPages = currentPage = 1;
|
||||
if (!sc.value("status_code").isValid() || isError(sc.value("status_code").toInt())) {
|
||||
error = true;
|
||||
if (sc.value("error").isValid()) {
|
||||
errorTxt = sc.value("error").toString();
|
||||
|
||||
} else {
|
||||
errorTxt = "Unknown error";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
error = false;
|
||||
if (sc.value("number_of_total_results").isValid()) {
|
||||
numResults = sc.value("number_of_total_results").toInt(); // sc.property("number_of_total_results").toInt32();
|
||||
|
||||
} else {
|
||||
qDebug() << sc.value("oops").toString();
|
||||
}
|
||||
|
||||
auto limit = sc.value("limit").toInt();
|
||||
auto offset = sc.value("offset").toInt();
|
||||
auto total = sc.value("number_of_total_results").toInt();
|
||||
if (limit > 0) {
|
||||
totalPages = (total / limit) + (total % limit > 0 ? 1 : 0);
|
||||
currentPage = (offset / limit) + 1;
|
||||
} else {
|
||||
totalPages = currentPage = 1;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "volume_comics_model.h"
|
||||
#include "qnaturalsorting.h"
|
||||
|
||||
#include <QtScript>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
|
||||
bool lessThan(const QList<QString> &left, const QList<QString> &right)
|
||||
{
|
||||
@ -18,33 +19,29 @@ VolumeComicsModel::VolumeComicsModel(QObject *parent)
|
||||
|
||||
void VolumeComicsModel::load(const QString &json)
|
||||
{
|
||||
QScriptEngine engine;
|
||||
QScriptValue sc;
|
||||
sc = engine.evaluate("(" + json + ")");
|
||||
QJsonParseError Err;
|
||||
QVariantMap sc = QJsonDocument::fromJson(json.toUtf8(), &Err).toVariant().toMap();
|
||||
|
||||
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
|
||||
if (Err.error != QJsonParseError::NoError) {
|
||||
qDebug("Error detected");
|
||||
} else {
|
||||
QScriptValueIterator it(sc.property("results"));
|
||||
//bool test;
|
||||
QScriptValue resultsValue;
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (it.flags() & QScriptValue::SkipInEnumeration)
|
||||
continue;
|
||||
resultsValue = it.value();
|
||||
QString issueNumber = resultsValue.property("issue_number").toString();
|
||||
QScriptValue propertyName = resultsValue.property("name");
|
||||
QString name = propertyName.isNull() ? "-" : propertyName.toString();
|
||||
QString coverURL = resultsValue.property("image").property("medium_url").toString();
|
||||
QString id = resultsValue.property("id").toString();
|
||||
QStringList l;
|
||||
l << issueNumber << name << coverURL << id;
|
||||
_data.push_back(l);
|
||||
}
|
||||
|
||||
qSort(_data.begin(), _data.end(), lessThan);
|
||||
return;
|
||||
}
|
||||
|
||||
QListIterator<QVariant> it(sc.value("results").toList());
|
||||
QVariantMap resultsValue;
|
||||
while (it.hasNext()) {
|
||||
resultsValue = it.next().toMap();
|
||||
QString issueNumber = resultsValue.value("issue_number").toString();
|
||||
QVariant propertyName = resultsValue.value("name");
|
||||
QString name = propertyName.isNull() ? "-" : propertyName.toString();
|
||||
QString coverURL = resultsValue.value("image").toMap().value("medium_url").toString();
|
||||
QString id = resultsValue.value("id").toString();
|
||||
QStringList l;
|
||||
l << issueNumber << name << coverURL << id;
|
||||
_data.push_back(l);
|
||||
}
|
||||
|
||||
qSort(_data.begin(), _data.end(), lessThan);
|
||||
}
|
||||
|
||||
/*void VolumeComicsModel::load(const QStringList &jsonList)
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "volumes_model.h"
|
||||
|
||||
#include <QtScript>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
|
||||
VolumesModel::VolumesModel(QObject *parent)
|
||||
: JSONModel(parent)
|
||||
@ -14,34 +15,33 @@ VolumesModel::~VolumesModel()
|
||||
|
||||
void VolumesModel::load(const QString &json)
|
||||
{
|
||||
QScriptEngine engine;
|
||||
QScriptValue sc;
|
||||
sc = engine.evaluate("(" + json + ")");
|
||||
QJsonParseError Err;
|
||||
QVariantMap sc = QJsonDocument::fromJson(json.toUtf8(), &Err).toVariant().toMap();
|
||||
|
||||
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
|
||||
if (Err.error != QJsonParseError::NoError) {
|
||||
qDebug("Error detected");
|
||||
} else {
|
||||
int numResults = sc.property("number_of_total_results").toString().toInt(); //fix to weird behaviour using hasNext
|
||||
QScriptValueIterator it(sc.property("results"));
|
||||
bool test;
|
||||
QScriptValue resultsValue;
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
resultsValue = it.value();
|
||||
QString numIssues = resultsValue.property("count_of_issues").toString();
|
||||
QString year = resultsValue.property("start_year").toString();
|
||||
QString name = resultsValue.property("name").toString();
|
||||
QString publisher = resultsValue.property("publisher").property("name").toString();
|
||||
QString url = resultsValue.property("image").property("medium_url").toString();
|
||||
QString deck = resultsValue.property("deck").toString();
|
||||
QString id = resultsValue.property("id").toString();
|
||||
QStringList l;
|
||||
l << name << year << numIssues << publisher << url << deck << id;
|
||||
test = name.isEmpty() && year.isEmpty() && numIssues.isEmpty() && url.isEmpty();
|
||||
if (numResults > 0 && !test)
|
||||
_data.push_back(l);
|
||||
numResults--;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int numResults = sc.value("number_of_total_results").toInt(); //fix to weird behaviour using hasNext
|
||||
QListIterator<QVariant> it(sc.value("results").toList());
|
||||
bool test;
|
||||
QVariantMap resultsValue;
|
||||
while (it.hasNext()) {
|
||||
resultsValue = it.next().toMap();
|
||||
QString numIssues = resultsValue.value("count_of_issues").toString();
|
||||
QString year = resultsValue.value("start_year").toString();
|
||||
QString name = resultsValue.value("name").toString();
|
||||
QString publisher = resultsValue.value("publisher").toMap().value("name").toString();
|
||||
QString url = resultsValue.value("image").toMap().value("medium_url").toString();
|
||||
QString deck = resultsValue.value("deck").toString();
|
||||
QString id = resultsValue.value("id").toString();
|
||||
QStringList l;
|
||||
l << name << year << numIssues << publisher << url << deck << id;
|
||||
test = name.isEmpty() && year.isEmpty() && numIssues.isEmpty() && url.isEmpty();
|
||||
if (numResults > 0 && !test)
|
||||
_data.push_back(l);
|
||||
numResults--;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QToolButton>
|
||||
#include <QtScript>
|
||||
|
||||
ScraperResultsPaginator::ScraperResultsPaginator(QWidget *parent)
|
||||
: QWidget(parent), customLabel("items")
|
||||
|
@ -5,9 +5,10 @@
|
||||
#include "scraper_tableview.h"
|
||||
#include "volume_comics_model.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QtScript>
|
||||
|
||||
SelectComic::SelectComic(QWidget *parent)
|
||||
: ScraperSelector(parent), model(0)
|
||||
@ -121,18 +122,17 @@ void SelectComic::setCover(const QByteArray &data)
|
||||
|
||||
void SelectComic::setDescription(const QString &jsonDetail)
|
||||
{
|
||||
QScriptEngine engine;
|
||||
QScriptValue sc;
|
||||
sc = engine.evaluate("(" + jsonDetail + ")");
|
||||
QJsonParseError Err;
|
||||
QVariantMap sc = QJsonDocument::fromJson(jsonDetail.toUtf8(), &Err).toVariant().toMap();
|
||||
|
||||
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
|
||||
if (Err.error != QJsonParseError::NoError) {
|
||||
qDebug("Error detected");
|
||||
} else {
|
||||
|
||||
QScriptValue descriptionValues = sc.property("results").property("description");
|
||||
bool valid = !descriptionValues.isNull() && descriptionValues.isValid();
|
||||
detailLabel->setText(valid ? descriptionValues.toString().replace("<a", "<a style = 'color:#827A68; text-decoration:none;'") : tr("description unavailable"));
|
||||
return;
|
||||
}
|
||||
|
||||
QVariant descriptionValues = sc.value("results").toMap().value("description");
|
||||
bool valid = !descriptionValues.isNull() && descriptionValues.isValid();
|
||||
detailLabel->setText(valid ? descriptionValues.toString().replace("<a", "<a style = 'color:#827A68; text-decoration:none;'") : tr("description unavailable"));
|
||||
}
|
||||
|
||||
QString SelectComic::getSelectedComicId()
|
||||
|
@ -1,20 +1,20 @@
|
||||
#include "select_volume.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QDesktopServices>
|
||||
#include <QHBoxLayout>
|
||||
#include <QScrollBar>
|
||||
#include <QHeaderView>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QLabel>
|
||||
#include <QModelIndex>
|
||||
#include <QScrollArea>
|
||||
#include <QDesktopServices>
|
||||
#include <QHeaderView>
|
||||
#include <QToolButton>
|
||||
#include <QScrollBar>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "scraper_tableview.h"
|
||||
|
||||
#include <QtScript>
|
||||
|
||||
#include "volumes_model.h"
|
||||
#include "comic_vine_client.h"
|
||||
#include "scraper_scroll_label.h"
|
||||
@ -149,18 +149,17 @@ void SelectVolume::setCover(const QByteArray &data)
|
||||
|
||||
void SelectVolume::setDescription(const QString &jsonDetail)
|
||||
{
|
||||
QScriptEngine engine;
|
||||
QScriptValue sc;
|
||||
sc = engine.evaluate("(" + jsonDetail + ")");
|
||||
QJsonParseError Err;
|
||||
QVariantMap sc = QJsonDocument::fromJson(jsonDetail.toUtf8(), &Err).toVariant().toMap();
|
||||
|
||||
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK") {
|
||||
if (Err.error != QJsonParseError::NoError) {
|
||||
qDebug("Error detected");
|
||||
} else {
|
||||
|
||||
QScriptValue descriptionValues = sc.property("results").property("description");
|
||||
bool valid = !descriptionValues.isNull() && descriptionValues.isValid();
|
||||
detailLabel->setText(valid ? descriptionValues.toString().replace("<a", "<a style = 'color:#827A68; text-decoration:none;'") : tr("description unavailable"));
|
||||
return;
|
||||
}
|
||||
|
||||
QVariant descriptionValues = sc.value("results").toMap().value("description");
|
||||
bool valid = !descriptionValues.isNull() && descriptionValues.isValid();
|
||||
detailLabel->setText(valid ? descriptionValues.toString().replace("<a", "<a style = 'color:#827A68; text-decoration:none;'") : tr("description unavailable"));
|
||||
}
|
||||
|
||||
QString SelectVolume::getSelectedVolumeId()
|
||||
|
@ -17,7 +17,7 @@ jobs:
|
||||
- script: |
|
||||
pip install aqtinstall
|
||||
mkdir C:\Qt
|
||||
python -m aqt install -O c:\Qt ${{ parameters.qt_version }} windows desktop ${{ parameters.qt_aqt_spec }} -m qtscript
|
||||
python -m aqt install -O c:\Qt ${{ parameters.qt_version }} windows desktop ${{ parameters.qt_aqt_spec }}
|
||||
dir C:\Qt\${{ parameters.qt_version }}\${{ parameters.qt_spec }}\bin
|
||||
choco install -y wget
|
||||
choco install innosetup
|
||||
|
@ -37,7 +37,7 @@ jobs:
|
||||
sudo add-apt-repository ppa:kubuntu-ppa/backports
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --allow-unauthenticated qt-default qt5-qmake \
|
||||
qtbase5-dev qtmultimedia5-dev libpoppler-qt5-dev qtscript5-dev \
|
||||
qtbase5-dev qtmultimedia5-dev libpoppler-qt5-dev \
|
||||
libqt5opengl5-dev libglu1-mesa-dev libunarr-dev qtdeclarative5-dev libqt5svg5-dev
|
||||
displayName: 'Install dependencies'
|
||||
- script: |
|
||||
|
@ -38,7 +38,6 @@ Source: Qt5Multimedia.dll; DestDir: {app}
|
||||
Source: Qt5Network.dll; DestDir: {app}
|
||||
Source: Qt5Qml.dll; DestDir: {app}
|
||||
Source: Qt5Quick.dll; DestDir: {app}
|
||||
Source: Qt5Script.dll; DestDir: {app}
|
||||
Source: Qt5Sql.dll; DestDir: {app}
|
||||
Source: Qt5Svg.dll; DestDir: {app}
|
||||
Source: Qt5Widgets.dll; DestDir: {app}
|
||||
@ -140,7 +139,7 @@ procedure InitializeWizard();
|
||||
begin
|
||||
|
||||
URLLabel := TNewStaticText.Create(WizardForm);
|
||||
URLLabel.Caption:='Make a DONATION/Haz una DONACIÓN';
|
||||
URLLabel.Caption:='Make a DONATION/Haz una DONACI<EFBFBD>N';
|
||||
URLLabel.Cursor:=crHand;
|
||||
URLLabel.OnClick:=@URLLabelOnClick;
|
||||
URLLabel.Parent:=WizardForm;
|
||||
@ -154,7 +153,7 @@ begin
|
||||
donationPage := CreateOutputMsgPage(wpWelcome,
|
||||
'Iformation', 'Please read the following information before continuing.',
|
||||
'YACReader is FREE software. If you like it, please, consider to make a DONATION'#13#13 +
|
||||
'YACReader es software libre y GRATUITO. Si te gusta, por favor, considera realizar una DONACIÓN'#13#13)
|
||||
'YACReader es software libre y GRATUITO. Si te gusta, por favor, considera realizar una DONACI<EFBFBD>N'#13#13)
|
||||
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user