mirror of
https://github.com/YACReader/yacreader
synced 2025-07-25 08:25:03 -04:00
added new comic_vine folder containing all the ComicVine related clases
added QtScript dependency (json parser)
This commit is contained in:
30
YACReaderLibrary/comic_vine/comic_vine.pri
Normal file
30
YACReaderLibrary/comic_vine/comic_vine.pri
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
HEADERS += \
|
||||
comic_vine/comic_vine_dialog.h \
|
||||
comic_vine/comic_vine_client.h \
|
||||
comic_vine/scrapper_lineedit.h \
|
||||
comic_vine/title_header.h \
|
||||
comic_vine/series_question.h \
|
||||
comic_vine/search_single_comic.h \
|
||||
comic_vine/search_volume.h \
|
||||
comic_vine/select_comic.h \
|
||||
comic_vine/select_volume.h \
|
||||
comic_vine/model/volumes_model.h \
|
||||
comic_vine/model/comics_model.h \
|
||||
comic_vine/model/json_model.h \
|
||||
comic_vine/model/response_parser.h
|
||||
|
||||
SOURCES += \
|
||||
comic_vine/comic_vine_dialog.cpp \
|
||||
comic_vine/comic_vine_client.cpp \
|
||||
comic_vine/scrapper_lineedit.cpp \
|
||||
comic_vine/title_header.cpp \
|
||||
comic_vine/series_question.cpp \
|
||||
comic_vine/search_single_comic.cpp \
|
||||
comic_vine/search_volume.cpp \
|
||||
comic_vine/select_comic.cpp \
|
||||
comic_vine/select_volume.cpp \
|
||||
comic_vine/model/volumes_model.cpp \
|
||||
comic_vine/model/comics_model.cpp \
|
||||
comic_vine/model/json_model.cpp \
|
||||
comic_vine/model/response_parser.cpp
|
92
YACReaderLibrary/comic_vine/comic_vine_client.cpp
Normal file
92
YACReaderLibrary/comic_vine/comic_vine_client.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
#include "comic_vine_client.h"
|
||||
|
||||
//this is the API key used by YACReader to access Comic Vine
|
||||
//please, do not use it in your own software, get one for free at Comic Vine
|
||||
static const QString CV_API_KEY = "46680bebb358f1de690a5a365e15d325f9649f91";
|
||||
|
||||
static const QString CV_WEB_ADDRESS = "http://www.comicvine.com/api";
|
||||
|
||||
//gets any volumen containing any comic matching 'query'
|
||||
static const QString CV_SEARCH = CV_WEB_ADDRESS + "/search/?api_key=" + CV_API_KEY +
|
||||
"&format=json&limit=100&resources=volume"
|
||||
"&field_list=name,start_year,publisher,id,image,count_of_issues"
|
||||
"&query=%1&page=%2";
|
||||
//http://www.comicvine.com/api/search/?api_key=46680bebb358f1de690a5a365e15d325f9649f91&format=json&limit=100&resources=volume&field_list=name,start_year,publisher,id,image,count_of_issues&query=superman
|
||||
|
||||
//gets the detail for a volume %1
|
||||
static const QString CV_SERIES_DETAIL = CV_WEB_ADDRESS + "/volume/4050-%1/?api_key=" + CV_API_KEY +
|
||||
"&format=json&field_list=name,start_year,publisher,image,count_of_issues,id";
|
||||
|
||||
//gets ids for comics in a volume id %1
|
||||
static const QString CV_COMIC_IDS = CV_WEB_ADDRESS + "/issues/?api_key=" + CV_API_KEY +
|
||||
"&format=json&field_list=name,issue_number,id,image&filter=volume:%1&page=%1";//offset??
|
||||
|
||||
//gets id for comic number %2 in a volume id %1
|
||||
static const QString CV_COMIC_ID = CV_WEB_ADDRESS + "/issues/?api_key=" + CV_API_KEY +
|
||||
"&format=json&field_list=name,issue_number,id,image"
|
||||
"&filter=volume:%1,issue_number:%2";
|
||||
//gets comic detail
|
||||
static const QString CV_COMIC_DETAIL = CV_WEB_ADDRESS + "/issue/4000-%1/?api_key=" + CV_API_KEY + "&format=json";
|
||||
|
||||
//gets comic cover URL
|
||||
static const QString CV_COVER_URL = CV_WEB_ADDRESS + "/issue/4000-%1/?api_key=" + CV_API_KEY + "&format=json&field_list=image";
|
||||
|
||||
//gets comics matching name %1 and number %2
|
||||
//http://comicvine.com/api/issues/?api_key=46680bebb358f1de690a5a365e15d325f9649f91&limit=20&filter=name:super,issue_number:15
|
||||
|
||||
ComicVineClient::ComicVineClient(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//CV_SEARCH
|
||||
void ComicVineClient::search(const QString & query, int page)
|
||||
{
|
||||
HttpWorker * search = new HttpWorker(CV_SEARCH.arg(query).arg(page));
|
||||
connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(proccessVolumesSearchData(const QByteArray &)));
|
||||
connect(search,SIGNAL(timeout()),this,SLOT(queryTimeOut()));
|
||||
connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
|
||||
search->get();
|
||||
}
|
||||
//CV_SEARCH result
|
||||
void ComicVineClient::proccessVolumesSearchData(const QByteArray & data)
|
||||
{
|
||||
QString json(data);
|
||||
emit searchResult(json);
|
||||
}
|
||||
|
||||
void ComicVineClient::queryTimeOut()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//CV_SERIES_DETAIL
|
||||
void ComicVineClient::getSeriesDetail(const QString & id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//CV_COMIC_IDS
|
||||
void ComicVineClient::getComicIds(const QString & id, int page)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//CV_COMIC_ID
|
||||
void ComicVineClient::getComicId(const QString & id, int comicNumber)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//CV_COMIC_DETAIL
|
||||
void ComicVineClient::getComicDetail(const QString & id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//CV_COVER_DETAIL
|
||||
void ComicVineClient::getCoverURL(const QString & id)
|
||||
{
|
||||
|
||||
}
|
28
YACReaderLibrary/comic_vine/comic_vine_client.h
Normal file
28
YACReaderLibrary/comic_vine/comic_vine_client.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef COMIC_VINE_CLIENT_H
|
||||
#define COMIC_VINE_CLIENT_H
|
||||
|
||||
#include "http_worker.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class ComicVineClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ComicVineClient(QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
void searchResult(QString);
|
||||
public slots:
|
||||
void search(const QString & query, int page = 0);
|
||||
void getSeriesDetail(const QString & id);
|
||||
void getComicIds(const QString & id, int page = 0);
|
||||
void getComicId(const QString & id, int comicNumber);
|
||||
void getComicDetail(const QString & id);
|
||||
void getCoverURL(const QString & id);
|
||||
protected slots:
|
||||
void proccessVolumesSearchData(const QByteArray & data);
|
||||
void queryTimeOut();
|
||||
|
||||
};
|
||||
#endif // COMIC_VINE_CLIENT_H
|
280
YACReaderLibrary/comic_vine/comic_vine_dialog.cpp
Normal file
280
YACReaderLibrary/comic_vine/comic_vine_dialog.cpp
Normal file
@ -0,0 +1,280 @@
|
||||
#include "comic_vine_dialog.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QStackedWidget>
|
||||
#include <QRadioButton>
|
||||
#include <QMessageBox>
|
||||
#include <QTableView>
|
||||
|
||||
#include "yacreader_busy_widget.h"
|
||||
#include "comic_vine_client.h"
|
||||
#include "scrapper_lineedit.h"
|
||||
#include "title_header.h"
|
||||
#include "series_question.h"
|
||||
#include "search_single_comic.h"
|
||||
#include "search_volume.h"
|
||||
#include "select_comic.h"
|
||||
#include "select_volume.h"
|
||||
|
||||
#include "response_parser.h"
|
||||
|
||||
|
||||
ComicVineDialog::ComicVineDialog(QWidget *parent) :
|
||||
QDialog(parent),comicVineClient(new ComicVineClient)
|
||||
{
|
||||
doLayout();
|
||||
doStackedWidgets();
|
||||
doConnections();
|
||||
}
|
||||
|
||||
void ComicVineDialog::doLayout()
|
||||
{
|
||||
setStyleSheet(""
|
||||
"QDialog {background-color: #404040; }"
|
||||
"");
|
||||
|
||||
QString dialogButtonsStyleSheet = "QPushButton {border: 1px solid #242424; background: #2e2e2e; color:white; padding: 5px 26px 5px 26px; font-size:12px;font-family:Arial; font-weight:bold;}";
|
||||
|
||||
skipButton = new QPushButton(tr("skip"));
|
||||
backButton = new QPushButton(tr("back"));
|
||||
nextButton = new QPushButton(tr("next"));
|
||||
searchButton = new QPushButton(tr("search"));
|
||||
closeButton = new QPushButton(tr("close"));
|
||||
|
||||
skipButton->setStyleSheet(dialogButtonsStyleSheet);
|
||||
backButton->setStyleSheet(dialogButtonsStyleSheet);
|
||||
nextButton->setStyleSheet(dialogButtonsStyleSheet);
|
||||
searchButton->setStyleSheet(dialogButtonsStyleSheet);
|
||||
closeButton->setStyleSheet(dialogButtonsStyleSheet);
|
||||
|
||||
content = new QStackedWidget(this);
|
||||
|
||||
QVBoxLayout * mainLayout = new QVBoxLayout;
|
||||
|
||||
QHBoxLayout * buttonLayout = new QHBoxLayout;
|
||||
|
||||
buttonLayout->addStretch();
|
||||
buttonLayout->addWidget(skipButton);
|
||||
buttonLayout->addWidget(backButton);
|
||||
buttonLayout->addWidget(nextButton);
|
||||
buttonLayout->addWidget(searchButton);
|
||||
buttonLayout->addWidget(closeButton);
|
||||
buttonLayout->setContentsMargins(0,0,0,0);
|
||||
|
||||
mainLayout->addWidget(titleHeader = new TitleHeader);
|
||||
mainLayout->addWidget(content);
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addLayout(buttonLayout);
|
||||
|
||||
mainLayout->setContentsMargins(26,16,26,11);
|
||||
|
||||
setLayout(mainLayout);
|
||||
setFixedSize(672,529);
|
||||
}
|
||||
|
||||
void ComicVineDialog::doStackedWidgets()
|
||||
{
|
||||
doLoading();
|
||||
content->addWidget(seriesQuestion = new SeriesQuestion);
|
||||
content->addWidget(searchSingleComic = new SearchSingleComic);
|
||||
content->addWidget(searchVolume = new SearchVolume);
|
||||
content->addWidget(selectVolume = new SelectVolume);
|
||||
}
|
||||
|
||||
void ComicVineDialog::doConnections()
|
||||
{
|
||||
connect(closeButton,SIGNAL(clicked()),this,SLOT(close()));
|
||||
connect(nextButton,SIGNAL(clicked()),this,SLOT(goNext()));
|
||||
connect(searchButton,SIGNAL(clicked()),this,SLOT(search()));
|
||||
|
||||
connect(comicVineClient,SIGNAL(searchResult(QString)),this,SLOT(debugClientResults(QString)));
|
||||
}
|
||||
|
||||
void ComicVineDialog::goNext()
|
||||
{
|
||||
//
|
||||
if(content->currentWidget() == seriesQuestion)
|
||||
{
|
||||
if(seriesQuestion->getYes())
|
||||
{
|
||||
QString volumeSearchString = comics[0].getParentFolderName();
|
||||
|
||||
if(volumeSearchString.isEmpty())
|
||||
showSearchVolume();
|
||||
else
|
||||
{
|
||||
showLoading();
|
||||
comicVineClient->search(volumeSearchString);
|
||||
}
|
||||
|
||||
status = Volume;
|
||||
}
|
||||
else
|
||||
{
|
||||
ComicDB comic = comics[currentIndex];
|
||||
QString title = comic.getTitleOrPath();
|
||||
titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex+1).arg(comics.length()).arg(title));
|
||||
showLoading();
|
||||
|
||||
comicVineClient->search(title);
|
||||
|
||||
status = SingleComicInSeries;
|
||||
}
|
||||
}
|
||||
else if (content->currentWidget() == searchSingleComic) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ComicVineDialog::setComics(const QList<ComicDB> & comics)
|
||||
{
|
||||
this->comics = comics;
|
||||
}
|
||||
|
||||
void ComicVineDialog::show()
|
||||
{
|
||||
QDialog::show();
|
||||
|
||||
currentIndex = 0;
|
||||
|
||||
if(comics.length() == 1)
|
||||
{
|
||||
ComicDB singleComic = comics[0];
|
||||
QString title = singleComic.getTitleOrPath();
|
||||
titleHeader->setSubTitle(title);
|
||||
showLoading();
|
||||
|
||||
comicVineClient->search(title);
|
||||
|
||||
status = SingleComic;
|
||||
}else if(comics.length()>1)
|
||||
{
|
||||
titleHeader->setSubTitle(tr("%1 comics selected").arg(comics.length()));
|
||||
showSeriesQuestion();
|
||||
}
|
||||
}
|
||||
|
||||
void ComicVineDialog::doLoading()
|
||||
{
|
||||
QWidget * w = new QWidget;
|
||||
QVBoxLayout * l = new QVBoxLayout;
|
||||
|
||||
YACReaderBusyWidget * bw = new YACReaderBusyWidget;
|
||||
|
||||
l->addStretch();
|
||||
l->addWidget(bw,0,Qt::AlignHCenter);
|
||||
|
||||
l->setContentsMargins(0,0,0,0);
|
||||
w->setLayout(l);
|
||||
w->setContentsMargins(0,0,0,0);
|
||||
|
||||
content->addWidget(w);
|
||||
}
|
||||
|
||||
void ComicVineDialog::debugClientResults(const QString & string)
|
||||
{
|
||||
ResponseParser p;
|
||||
p.loadJSONResponse(string);
|
||||
|
||||
QString debug = QString("%1 \n %2").arg(p.getNumResults()).arg(string);
|
||||
|
||||
QMessageBox::information(0,"-Response-", debug);
|
||||
|
||||
switch(status)
|
||||
{
|
||||
case SingleComic:
|
||||
showSearchSingleComic();
|
||||
break;
|
||||
case Volume:
|
||||
showSearchVolume();
|
||||
break;
|
||||
case SingleComicInSeries:
|
||||
showSearchSingleComic();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ComicVineDialog::showSeriesQuestion()
|
||||
{
|
||||
content->setCurrentWidget(seriesQuestion);
|
||||
backButton->setHidden(true);
|
||||
skipButton->setHidden(true);
|
||||
nextButton->setVisible(true);
|
||||
searchButton->setHidden(true);
|
||||
closeButton->setVisible(true);
|
||||
}
|
||||
|
||||
void ComicVineDialog::showSearchSingleComic()
|
||||
{
|
||||
content->setCurrentWidget(searchSingleComic);
|
||||
backButton->setHidden(true);
|
||||
skipButton->setHidden(true);
|
||||
nextButton->setHidden(true);
|
||||
searchButton->setVisible(true);
|
||||
closeButton->setVisible(true);
|
||||
}
|
||||
|
||||
void ComicVineDialog::showSearchVolume()
|
||||
{
|
||||
content->setCurrentWidget(searchVolume);
|
||||
backButton->setHidden(true);
|
||||
nextButton->setHidden(true);
|
||||
searchButton->setVisible(true);
|
||||
closeButton->setVisible(true);
|
||||
|
||||
if (status == SingleComicInSeries)
|
||||
skipButton->setVisible(true);
|
||||
else
|
||||
skipButton->setHidden(true);
|
||||
}
|
||||
|
||||
void ComicVineDialog::showSelectVolume()
|
||||
{
|
||||
content->setCurrentWidget(selectVolume);
|
||||
}
|
||||
|
||||
void ComicVineDialog::showLoading()
|
||||
{
|
||||
content->setCurrentIndex(0);
|
||||
backButton->setHidden(true);
|
||||
skipButton->setHidden(true);
|
||||
nextButton->setHidden(true);
|
||||
searchButton->setHidden(true);
|
||||
closeButton->setVisible(true);
|
||||
}
|
||||
|
||||
void ComicVineDialog::search()
|
||||
{
|
||||
switch (status) {
|
||||
case Volume:
|
||||
launchSearchVolume();
|
||||
break;
|
||||
default:
|
||||
launchSearchComic();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ComicVineDialog::launchSearchVolume()
|
||||
{
|
||||
showLoading();
|
||||
//TODO: check if volume info is empty.
|
||||
comicVineClient->search(searchVolume->getVolumeInfo());
|
||||
}
|
||||
|
||||
void ComicVineDialog::launchSearchComic()
|
||||
{
|
||||
showLoading();
|
||||
|
||||
QString volumeInfo = searchSingleComic->getVolumeInfo();
|
||||
QString comicInfo = searchSingleComic->getComicInfo();
|
||||
int comicNumber = searchSingleComic->getComicNumber();
|
||||
|
||||
if(comicInfo.isEmpty() && comicNumber == -1)
|
||||
comicVineClient->search(volumeInfo);
|
||||
}
|
||||
|
91
YACReaderLibrary/comic_vine/comic_vine_dialog.h
Normal file
91
YACReaderLibrary/comic_vine/comic_vine_dialog.h
Normal file
@ -0,0 +1,91 @@
|
||||
#ifndef COMIC_VINE_DIALOG_H
|
||||
#define COMIC_VINE_DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "comic_db.h"
|
||||
|
||||
class QPushButton;
|
||||
class QStackedWidget;
|
||||
class QLabel;
|
||||
class QRadioButton;
|
||||
class ComicVineClient;
|
||||
class QTableView;
|
||||
class TitleHeader;
|
||||
class SeriesQuestion;
|
||||
class SearchSingleComic;
|
||||
class SearchVolume;
|
||||
class SelectComic;
|
||||
class SelectVolume;
|
||||
|
||||
|
||||
//----------------------------------------
|
||||
class ComicVineDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ComicVineDialog(QWidget *parent = 0);
|
||||
QString databasePath;
|
||||
QString basePath;
|
||||
void setComics(const QList<ComicDB> & comics);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void show();
|
||||
protected slots:
|
||||
void goNext();
|
||||
void debugClientResults(const QString & string);
|
||||
//show widget methods
|
||||
void showSeriesQuestion();
|
||||
void showSearchSingleComic();
|
||||
void showSearchVolume();
|
||||
void showLoading();
|
||||
void search();
|
||||
void launchSearchVolume();
|
||||
void launchSearchComic();
|
||||
void showSelectVolume();
|
||||
private:
|
||||
|
||||
enum ScrapperStatus
|
||||
{
|
||||
SingleComic,
|
||||
Volume,
|
||||
SingleComicInSeries,
|
||||
SelectingComic,
|
||||
SelectingSeries
|
||||
};
|
||||
|
||||
ScrapperStatus status;
|
||||
|
||||
ComicVineClient * comicVineClient;
|
||||
|
||||
int currentIndex;
|
||||
|
||||
TitleHeader * titleHeader;
|
||||
|
||||
QPushButton * skipButton;
|
||||
QPushButton * backButton;
|
||||
QPushButton * nextButton;
|
||||
QPushButton * searchButton;
|
||||
QPushButton * closeButton;
|
||||
|
||||
//stacked widgets
|
||||
QStackedWidget * content;
|
||||
|
||||
QWidget * infoNotFound;
|
||||
QWidget * singleComicBrowser;
|
||||
|
||||
void doLayout();
|
||||
void doStackedWidgets();
|
||||
void doLoading();
|
||||
void doConnections();
|
||||
|
||||
QList<ComicDB> comics;
|
||||
|
||||
SeriesQuestion * seriesQuestion;
|
||||
SearchSingleComic * searchSingleComic;
|
||||
SearchVolume * searchVolume;
|
||||
SelectVolume * selectVolume;
|
||||
};
|
||||
|
||||
#endif // COMIC_VINE_DIALOG_H
|
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
|
21
YACReaderLibrary/comic_vine/scrapper_lineedit.cpp
Normal file
21
YACReaderLibrary/comic_vine/scrapper_lineedit.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "scrapper_lineedit.h"
|
||||
#include <QLabel>
|
||||
|
||||
ScrapperLineEdit::ScrapperLineEdit(const QString & title, QWidget * widget)
|
||||
:QLineEdit(widget)
|
||||
{
|
||||
titleLabel = new QLabel(title,this);
|
||||
titleLabel->setStyleSheet("QLabel {color:white;}");
|
||||
|
||||
setStyleSheet(QString("QLineEdit {"
|
||||
"border:none; background-color: #2E2E2E; color : white; padding-left: %1; padding-bottom: 1px; margin-bottom: 0px;"
|
||||
"}").arg(titleLabel->sizeHint().width()+6));
|
||||
|
||||
setFixedHeight(22);
|
||||
}
|
||||
|
||||
void ScrapperLineEdit::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
QSize szl = titleLabel->sizeHint();
|
||||
titleLabel->move(6,(rect().bottom() + 1 - szl.height())/2);
|
||||
}
|
19
YACReaderLibrary/comic_vine/scrapper_lineedit.h
Normal file
19
YACReaderLibrary/comic_vine/scrapper_lineedit.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef SCRAPPER_LINEEDIT_H
|
||||
#define SCRAPPER_LINEEDIT_H
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class QLabel;
|
||||
|
||||
class ScrapperLineEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ScrapperLineEdit(const QString & title, QWidget * widget = 0);
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
private:
|
||||
QLabel * titleLabel;
|
||||
};
|
||||
|
||||
#endif // SCRAPPER_LINEEDIT_H
|
54
YACReaderLibrary/comic_vine/search_single_comic.cpp
Normal file
54
YACReaderLibrary/comic_vine/search_single_comic.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include "search_single_comic.h"
|
||||
|
||||
#include "scrapper_lineedit.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
SearchSingleComic::SearchSingleComic(QWidget * parent)
|
||||
:QWidget(parent)
|
||||
{
|
||||
|
||||
QLabel * label = new QLabel(tr("No results found, please provide some aditional information. At least one field is needed."));
|
||||
label->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
|
||||
|
||||
titleEdit = new ScrapperLineEdit(tr("Title:"));
|
||||
numberEdit = new ScrapperLineEdit(tr("Number:"));
|
||||
volumeEdit = new ScrapperLineEdit(tr("Series:"));
|
||||
|
||||
numberEdit->setMaximumWidth(126);
|
||||
|
||||
QVBoxLayout * l = new QVBoxLayout;
|
||||
QHBoxLayout * hl = new QHBoxLayout;
|
||||
hl->addWidget(titleEdit);
|
||||
hl->addWidget(numberEdit);
|
||||
|
||||
l->addSpacing(35);
|
||||
l->addWidget(label);
|
||||
l->addLayout(hl);
|
||||
l->addWidget(volumeEdit);
|
||||
l->addStretch();
|
||||
|
||||
l->setContentsMargins(0,0,0,0);
|
||||
setLayout(l);
|
||||
setContentsMargins(0,0,0,0);
|
||||
}
|
||||
|
||||
QString SearchSingleComic::getVolumeInfo()
|
||||
{
|
||||
return volumeEdit->text();
|
||||
}
|
||||
|
||||
QString SearchSingleComic::getComicInfo()
|
||||
{
|
||||
return titleEdit->text();
|
||||
}
|
||||
|
||||
int SearchSingleComic::getComicNumber()
|
||||
{
|
||||
QString numberText = numberEdit->text();
|
||||
if(numberText.isEmpty())
|
||||
return -1;
|
||||
return numberText.toInt();
|
||||
}
|
21
YACReaderLibrary/comic_vine/search_single_comic.h
Normal file
21
YACReaderLibrary/comic_vine/search_single_comic.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef SEARCH_SINGLE_COMIC_H
|
||||
#define SEARCH_SINGLE_COMIC_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class ScrapperLineEdit;
|
||||
|
||||
class SearchSingleComic : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SearchSingleComic(QWidget * parent = 0);
|
||||
QString getVolumeInfo();
|
||||
QString getComicInfo();
|
||||
int getComicNumber();
|
||||
private:
|
||||
ScrapperLineEdit * titleEdit;
|
||||
ScrapperLineEdit * numberEdit;
|
||||
ScrapperLineEdit * volumeEdit;
|
||||
};
|
||||
#endif // SEARCH_SINGLE_COMIC_H
|
31
YACReaderLibrary/comic_vine/search_volume.cpp
Normal file
31
YACReaderLibrary/comic_vine/search_volume.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "search_volume.h"
|
||||
|
||||
#include "scrapper_lineedit.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
SearchVolume::SearchVolume(QWidget * parent)
|
||||
:QWidget(parent)
|
||||
{
|
||||
QLabel * label = new QLabel(tr("No results found, please provide some aditional information."));
|
||||
label->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
|
||||
|
||||
volumeEdit = new ScrapperLineEdit(tr("Series:"));
|
||||
|
||||
QVBoxLayout * l = new QVBoxLayout;
|
||||
|
||||
l->addSpacing(35);
|
||||
l->addWidget(label);
|
||||
l->addWidget(volumeEdit);
|
||||
l->addStretch();
|
||||
|
||||
l->setContentsMargins(0,0,0,0);
|
||||
setLayout(l);
|
||||
setContentsMargins(0,0,0,0);
|
||||
}
|
||||
|
||||
QString SearchVolume::getVolumeInfo()
|
||||
{
|
||||
return volumeEdit->text();
|
||||
}
|
20
YACReaderLibrary/comic_vine/search_volume.h
Normal file
20
YACReaderLibrary/comic_vine/search_volume.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef SEARCH_VOLUME_H
|
||||
#define SEARCH_VOLUME_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class ScrapperLineEdit;
|
||||
|
||||
|
||||
class SearchVolume : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SearchVolume(QWidget * parent = 0);
|
||||
public slots:
|
||||
QString getVolumeInfo();
|
||||
private:
|
||||
ScrapperLineEdit * volumeEdit;
|
||||
};
|
||||
|
||||
#endif // SEARCH_VOLUME_H
|
8
YACReaderLibrary/comic_vine/select_comic.cpp
Normal file
8
YACReaderLibrary/comic_vine/select_comic.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "select_comic.h"
|
||||
|
||||
|
||||
SelectComic::SelectComic(QWidget *parent)
|
||||
:QWidget(parent)
|
||||
{}
|
||||
|
||||
SelectComic::~SelectComic() {}
|
14
YACReaderLibrary/comic_vine/select_comic.h
Normal file
14
YACReaderLibrary/comic_vine/select_comic.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef SELECT_COMIC_H
|
||||
#define SELECT_COMIC_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class SelectComic : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SelectComic(QWidget * parent = 0);
|
||||
virtual ~SelectComic();
|
||||
};
|
||||
|
||||
#endif // SELECT_COMIC_H
|
72
YACReaderLibrary/comic_vine/select_volume.cpp
Normal file
72
YACReaderLibrary/comic_vine/select_volume.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
#include "select_volume.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QTableView>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "volumes_model.h"
|
||||
|
||||
SelectVolume::SelectVolume(QWidget *parent)
|
||||
:QWidget(parent)
|
||||
{
|
||||
QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
|
||||
QString tableStylesheet = ""
|
||||
"QTableView {alternate-background-color: #333333;background-color: #2B2B2B; outline: 0px;}"// border: 1px solid #999999; border-right:none; border-bottom:none;}"
|
||||
"QTableCornerButton::section {background-color:#F5F5F5; border:none; border-bottom:1px solid #B8BDC4; border-right:1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D1D1D1, stop: 1 #B8BDC4);}"
|
||||
"QTableView::item {outline: 0px; border: 0px color:#FFFFFF;}"
|
||||
"QTableView {border-top:1px solid #B8B8B8;border-bottom:none;border-left:1px solid #B8B8B8;border-right:none;}"
|
||||
"QTableView::item:selected {outline: 0px; border-bottom: 1px solid #D4D4D4;border-top: 1px solid #D4D4D4; padding-bottom:1px; background-color: #D4D4D4; }"
|
||||
"QHeaderView::section:horizontal {background-color:#F5F5F5; border-bottom:1px solid #B8BDC4; border-right:1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D1D1D1, stop: 1 #B8BDC4); border-left:none; border-top:none; padding:4px; color:#313232;}"
|
||||
"QHeaderView::section:vertical {border-bottom: 1px solid #DFDFDF;border-top: 1px solid #FEFEFE;}"
|
||||
//"QTableView::item:hover {border-bottom: 1px solid #A3A3A3;border-top: 1px solid #A3A3A3; padding-bottom:1px; background-color: #A3A3A3; color: #FFFFFF; }"
|
||||
|
||||
//scrollbar
|
||||
|
||||
"QScrollBar:vertical { border: none; background: #404040; width: 3px; margin: 0; }"
|
||||
"QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
|
||||
"QScrollBar::add-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
|
||||
|
||||
"QScrollBar::sub-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
|
||||
"QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
|
||||
"QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
|
||||
|
||||
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }"
|
||||
"";
|
||||
|
||||
QLabel * label = new QLabel(tr("Please, select the right series for your comic."));
|
||||
label->setStyleSheet(labelStylesheet);
|
||||
|
||||
QVBoxLayout * l = new QVBoxLayout;
|
||||
QWidget * leftWidget = new QWidget;
|
||||
QVBoxLayout * left = new QVBoxLayout;
|
||||
QHBoxLayout * content = new QHBoxLayout;
|
||||
|
||||
//widgets
|
||||
cover = new QLabel();
|
||||
detailLabel = new QLabel();
|
||||
detailLabel->setStyleSheet(labelStylesheet);
|
||||
tableVolumes = new QTableView();
|
||||
tableVolumes->setStyleSheet(tableStylesheet);
|
||||
|
||||
left->addWidget(cover);
|
||||
left->addWidget(detailLabel);
|
||||
left->addStretch();
|
||||
leftWidget->setMaximumWidth(168);
|
||||
leftWidget->setLayout(left);
|
||||
|
||||
content->addWidget(leftWidget);
|
||||
content->addWidget(tableVolumes);
|
||||
|
||||
l->addSpacing(15);
|
||||
l->addWidget(label);
|
||||
l->addLayout(content);
|
||||
l->addStretch();
|
||||
|
||||
l->setContentsMargins(0,0,0,0);
|
||||
setLayout(l);
|
||||
setContentsMargins(0,0,0,0);
|
||||
}
|
||||
|
||||
|
||||
SelectVolume::~SelectVolume() {}
|
23
YACReaderLibrary/comic_vine/select_volume.h
Normal file
23
YACReaderLibrary/comic_vine/select_volume.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef SELECT_VOLUME_H
|
||||
#define SELECT_VOLUME_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QTableView;
|
||||
class VolumesModel;
|
||||
|
||||
class SelectVolume : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SelectVolume(QWidget * parent = 0);
|
||||
virtual ~SelectVolume();
|
||||
private:
|
||||
QLabel * cover;
|
||||
QLabel * detailLabel;
|
||||
QTableView * tableVolumes;
|
||||
VolumesModel * model;
|
||||
};
|
||||
|
||||
#endif // SELECT_VOLUME_H
|
41
YACReaderLibrary/comic_vine/series_question.cpp
Normal file
41
YACReaderLibrary/comic_vine/series_question.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "series_question.h"
|
||||
|
||||
#include <QRadioButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
|
||||
SeriesQuestion::SeriesQuestion(QWidget * parent)
|
||||
:QWidget(parent)
|
||||
{
|
||||
QVBoxLayout * l = new QVBoxLayout;
|
||||
|
||||
QLabel * questionLabel = new QLabel(tr("You are trying to get information for various comics at once, are they part of the same series?"));
|
||||
questionLabel->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
|
||||
yes = new QRadioButton(tr("yes"));
|
||||
no = new QRadioButton(tr("no"));
|
||||
|
||||
QString rbStyle = "QRadioButton {margin-left:27px; margin-top:5px; color:white;font-size:12px;font-family:Arial;}"
|
||||
"QRadioButton::indicator {width:11px;height:11px;}"
|
||||
"QRadioButton::indicator::unchecked {image : url(:/images/comic_vine/radioUnchecked.png);}"
|
||||
"QRadioButton::indicator::checked {image : url(:/images/comic_vine/radioChecked.png);}";
|
||||
yes->setStyleSheet(rbStyle);
|
||||
no->setStyleSheet(rbStyle);
|
||||
|
||||
yes->setChecked(true);
|
||||
|
||||
l->addSpacing(35);
|
||||
l->addWidget(questionLabel);
|
||||
l->addWidget(yes);
|
||||
l->addWidget(no);
|
||||
l->addStretch();
|
||||
|
||||
l->setContentsMargins(0,0,0,0);
|
||||
setLayout(l);
|
||||
setContentsMargins(0,0,0,0);
|
||||
}
|
||||
|
||||
bool SeriesQuestion::getYes()
|
||||
{
|
||||
return yes->isChecked();
|
||||
}
|
22
YACReaderLibrary/comic_vine/series_question.h
Normal file
22
YACReaderLibrary/comic_vine/series_question.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef SERIES_QUESTION_H
|
||||
#define SERIES_QUESTION_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QRadioButton;
|
||||
|
||||
class SeriesQuestion : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SeriesQuestion(QWidget * parent = 0);
|
||||
bool getYes();
|
||||
|
||||
private:
|
||||
QRadioButton * yes;
|
||||
QRadioButton * no;
|
||||
};
|
||||
|
||||
|
||||
#endif // SERIES_QUESTION_H
|
53
YACReaderLibrary/comic_vine/title_header.cpp
Normal file
53
YACReaderLibrary/comic_vine/title_header.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "title_header.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
TitleHeader::TitleHeader(QWidget * parent )
|
||||
:QWidget(parent)
|
||||
{
|
||||
mainTitleLabel = new QLabel();
|
||||
subTitleLabel = new QLabel();
|
||||
|
||||
mainTitleLabel->setStyleSheet("QLabel {color:white; font-size:18px;font-family:Arial;}");
|
||||
subTitleLabel->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
|
||||
|
||||
QHBoxLayout * titleLayout = new QHBoxLayout;
|
||||
QVBoxLayout * titleLabelsLayout = new QVBoxLayout;
|
||||
|
||||
titleLabelsLayout->addWidget(mainTitleLabel);
|
||||
titleLabelsLayout->addWidget(subTitleLabel);
|
||||
titleLabelsLayout->setSpacing(0);
|
||||
|
||||
titleLayout->addLayout(titleLabelsLayout);
|
||||
titleLayout->setContentsMargins(0,0,0,0);
|
||||
|
||||
setLayout(titleLayout);
|
||||
|
||||
setContentsMargins(0,0,0,0);
|
||||
|
||||
setTitle(tr("SEARCH"));
|
||||
}
|
||||
|
||||
void TitleHeader::setTitle(const QString & title)
|
||||
{
|
||||
mainTitleLabel->setText(title);
|
||||
}
|
||||
|
||||
void TitleHeader::setSubTitle(const QString & title)
|
||||
{
|
||||
subTitleLabel->setText(title);
|
||||
}
|
||||
|
||||
void TitleHeader::showButtons(bool show)
|
||||
{
|
||||
if(show)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
22
YACReaderLibrary/comic_vine/title_header.h
Normal file
22
YACReaderLibrary/comic_vine/title_header.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef TITLE_HEADER_H
|
||||
#define TITLE_HEADER_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
|
||||
class TitleHeader : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TitleHeader(QWidget * parent = 0);
|
||||
public slots:
|
||||
void setTitle(const QString & title);
|
||||
void setSubTitle(const QString & title);
|
||||
void showButtons(bool show);
|
||||
private:
|
||||
QLabel * mainTitleLabel;
|
||||
QLabel * subTitleLabel;
|
||||
};
|
||||
|
||||
#endif // TITLE_HEADER_H
|
Reference in New Issue
Block a user