mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
comic vine search query working
This commit is contained in:
parent
0738f1b0e8
commit
93bc691998
@ -4,13 +4,14 @@
|
|||||||
//please, do not use it in your own software, get one for free at 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_API_KEY = "46680bebb358f1de690a5a365e15d325f9649f91";
|
||||||
|
|
||||||
static const QString CV_WEB_ADDRESS = "http://comicvine.com/api";
|
static const QString CV_WEB_ADDRESS = "http://www.comicvine.com/api";
|
||||||
|
|
||||||
//gets any volumen containing any comic matching 'query'
|
//gets any volumen containing any comic matching 'query'
|
||||||
static const QString CV_SEARCH = CV_WEB_ADDRESS + "/search/?api_key=" + CV_API_KEY +
|
static const QString CV_SEARCH = CV_WEB_ADDRESS + "/search/?api_key=" + CV_API_KEY +
|
||||||
"&format=xml&limit=100&resources=volume"
|
"&format=xml&limit=100&resources=volume"
|
||||||
"&field_list=name,start_year,publisher,id,image,count_of_issues"
|
"&field_list=name,start_year,publisher,id,image,count_of_issues"
|
||||||
"&query=%1&page=%2";
|
"&query=%1&page=%2";
|
||||||
|
//http://comicvine.com/api/search/?api_key=46680bebb358f1de690a5a365e15d325f9649f91&format=xml&limit=100&resources=volume&field_list=name,start_year,publisher,id,image,count_of_issues&query=superman
|
||||||
|
|
||||||
//gets the detail for a volume %1
|
//gets the detail for a volume %1
|
||||||
static const QString CV_SERIES_DETAIL = CV_WEB_ADDRESS + "/volume/4050-%1/?api_key=" + CV_API_KEY +
|
static const QString CV_SERIES_DETAIL = CV_WEB_ADDRESS + "/volume/4050-%1/?api_key=" + CV_API_KEY +
|
||||||
@ -42,16 +43,22 @@ ComicVineClient::ComicVineClient(QObject *parent) :
|
|||||||
//CV_SEARCH
|
//CV_SEARCH
|
||||||
void ComicVineClient::search(const QString & query, int page)
|
void ComicVineClient::search(const QString & query, int page)
|
||||||
{
|
{
|
||||||
CVSearch * search = new CVSearch(CV_SEARCH.arg(query).arg(page));
|
HttpWorker * search = new HttpWorker(CV_SEARCH.arg(query).arg(page));
|
||||||
connect(search,SIGNAL(dataReady(const QByteArry &)),this,SLOT(proccessVolumesSearchData(const QByteArry &)));
|
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()));
|
connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
|
||||||
search->get();
|
search->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
//CV_SEARCH result
|
//CV_SEARCH result
|
||||||
void ComicVineClient::proccessVolumesSearchData(const QByteArray & data)
|
void ComicVineClient::proccessVolumesSearchData(const QByteArray & data)
|
||||||
{
|
{
|
||||||
QString xml(data);
|
QString xml(data);
|
||||||
|
emit searchResult(xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComicVineClient::queryTimeOut()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//CV_SERIES_DETAIL
|
//CV_SERIES_DETAIL
|
||||||
@ -83,10 +90,3 @@ void ComicVineClient::getCoverURL(const QString & id)
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//CVSearch
|
|
||||||
CVSearch::CVSearch(const QString & URL)
|
|
||||||
:HttpWorker(URL)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -12,7 +12,7 @@ public:
|
|||||||
explicit ComicVineClient(QObject *parent = 0);
|
explicit ComicVineClient(QObject *parent = 0);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void searchResult(QString);
|
||||||
public slots:
|
public slots:
|
||||||
void search(const QString & query, int page = 0);
|
void search(const QString & query, int page = 0);
|
||||||
void getSeriesDetail(const QString & id);
|
void getSeriesDetail(const QString & id);
|
||||||
@ -20,15 +20,9 @@ public slots:
|
|||||||
void getComicId(const QString & id, int comicNumber);
|
void getComicId(const QString & id, int comicNumber);
|
||||||
void getComicDetail(const QString & id);
|
void getComicDetail(const QString & id);
|
||||||
void getCoverURL(const QString & id);
|
void getCoverURL(const QString & id);
|
||||||
private slots:
|
protected slots:
|
||||||
void proccessVolumesSearchData(const QByteArray & data);
|
void proccessVolumesSearchData(const QByteArray & data);
|
||||||
|
void queryTimeOut();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CVSearch : public HttpWorker
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CVSearch(const QString & URL);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // COMIC_VINE_CLIENT_H
|
#endif // COMIC_VINE_CLIENT_H
|
||||||
|
@ -5,12 +5,13 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QFileInfo>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "yacreader_busy_widget.h"
|
#include "yacreader_busy_widget.h"
|
||||||
|
#include "comic_vine_client.h"
|
||||||
|
|
||||||
ComicVineDialog::ComicVineDialog(QWidget *parent) :
|
ComicVineDialog::ComicVineDialog(QWidget *parent) :
|
||||||
QDialog(parent)
|
QDialog(parent),comicVineClient(new ComicVineClient)
|
||||||
{
|
{
|
||||||
doLayout();
|
doLayout();
|
||||||
doStackedWidgets();
|
doStackedWidgets();
|
||||||
@ -65,6 +66,8 @@ void ComicVineDialog::doConnections()
|
|||||||
{
|
{
|
||||||
connect(closeButton,SIGNAL(pressed()),this,SLOT(close()));
|
connect(closeButton,SIGNAL(pressed()),this,SLOT(close()));
|
||||||
connect(nextButton,SIGNAL(pressed()),this,SLOT(goNext()));
|
connect(nextButton,SIGNAL(pressed()),this,SLOT(goNext()));
|
||||||
|
|
||||||
|
connect(comicVineClient,SIGNAL(searchResult(QString)),this,SLOT(debugClientResults(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComicVineDialog::goNext()
|
void ComicVineDialog::goNext()
|
||||||
@ -78,9 +81,13 @@ void ComicVineDialog::goNext()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//titleHeader->setSubtitle
|
ComicDB comic = comics[currentIndex];
|
||||||
|
QString title = comic.getTitleOrPath();
|
||||||
|
titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex+1).arg(comics.length()).arg(title));
|
||||||
content->setCurrentWidget(searchSingleComic);
|
content->setCurrentWidget(searchSingleComic);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (content->currentWidget() == searchSingleComic) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,19 +99,19 @@ void ComicVineDialog::setComics(const QList<ComicDB> & comics)
|
|||||||
|
|
||||||
void ComicVineDialog::show()
|
void ComicVineDialog::show()
|
||||||
{
|
{
|
||||||
|
currentIndex = 0;
|
||||||
|
|
||||||
if(comics.length() == 1)
|
if(comics.length() == 1)
|
||||||
{
|
{
|
||||||
ComicDB singleComic = comics[0];
|
ComicDB singleComic = comics[0];
|
||||||
|
QString title = singleComic.getTitleOrPath();
|
||||||
if(singleComic.info.title != 0)
|
titleHeader->setSubTitle(title);
|
||||||
titleHeader->setSubtitle(*singleComic.info.title);
|
|
||||||
else
|
|
||||||
titleHeader->setSubtitle(QFileInfo(singleComic.path).fileName());
|
|
||||||
|
|
||||||
content->setCurrentWidget(searchSingleComic);
|
content->setCurrentWidget(searchSingleComic);
|
||||||
|
|
||||||
|
comicVineClient->search(title);
|
||||||
}else if(comics.length()>1)
|
}else if(comics.length()>1)
|
||||||
{
|
{
|
||||||
titleHeader->setSubtitle(tr("%1 comics selected").arg(comics.length()));
|
titleHeader->setSubTitle(tr("%1 comics selected").arg(comics.length()));
|
||||||
content->setCurrentWidget(seriesQuestion);
|
content->setCurrentWidget(seriesQuestion);
|
||||||
}
|
}
|
||||||
QDialog::show();
|
QDialog::show();
|
||||||
@ -127,6 +134,11 @@ void ComicVineDialog::doLoading()
|
|||||||
content->addWidget(w);
|
content->addWidget(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComicVineDialog::debugClientResults(const QString & string)
|
||||||
|
{
|
||||||
|
QMessageBox::information(0,"-Response-", string);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------
|
//---------------------------------------
|
||||||
//TitleHeader
|
//TitleHeader
|
||||||
//---------------------------------------
|
//---------------------------------------
|
||||||
@ -161,7 +173,7 @@ void TitleHeader::setTitle(const QString & title)
|
|||||||
mainTitleLabel->setText(title);
|
mainTitleLabel->setText(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleHeader::setSubtitle(const QString & title)
|
void TitleHeader::setSubTitle(const QString & title)
|
||||||
{
|
{
|
||||||
subTitleLabel->setText(title);
|
subTitleLabel->setText(title);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ class QPushButton;
|
|||||||
class QStackedWidget;
|
class QStackedWidget;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QRadioButton;
|
class QRadioButton;
|
||||||
|
class ComicVineClient;
|
||||||
|
|
||||||
class ScrapperLineEdit : public QLineEdit
|
class ScrapperLineEdit : public QLineEdit
|
||||||
{
|
{
|
||||||
@ -30,7 +31,7 @@ public:
|
|||||||
TitleHeader(QWidget * parent = 0);
|
TitleHeader(QWidget * parent = 0);
|
||||||
public slots:
|
public slots:
|
||||||
void setTitle(const QString & title);
|
void setTitle(const QString & title);
|
||||||
void setSubtitle(const QString & title);
|
void setSubTitle(const QString & title);
|
||||||
void showButtons(bool show);
|
void showButtons(bool show);
|
||||||
private:
|
private:
|
||||||
QLabel * mainTitleLabel;
|
QLabel * mainTitleLabel;
|
||||||
@ -86,7 +87,12 @@ public slots:
|
|||||||
void show();
|
void show();
|
||||||
protected slots:
|
protected slots:
|
||||||
void goNext();
|
void goNext();
|
||||||
|
void debugClientResults(const QString & string);
|
||||||
private:
|
private:
|
||||||
|
ComicVineClient * comicVineClient;
|
||||||
|
|
||||||
|
int currentIndex;
|
||||||
|
|
||||||
TitleHeader * titleHeader;
|
TitleHeader * titleHeader;
|
||||||
QPushButton * nextButton;
|
QPushButton * nextButton;
|
||||||
QPushButton * closeButton;
|
QPushButton * closeButton;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "comic_db.h"
|
#include "comic_db.h"
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//COMIC------------------------------------------------------------------------
|
//COMIC------------------------------------------------------------------------
|
||||||
@ -106,6 +107,15 @@ QString ComicDB::toTXT()
|
|||||||
|
|
||||||
return txt;
|
return txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ComicDB::getTitleOrPath()
|
||||||
|
{
|
||||||
|
if(info.title && info.title->isEmpty())
|
||||||
|
return *(info.title);
|
||||||
|
else
|
||||||
|
return QFileInfo(path).fileName();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//COMIC_INFO-------------------------------------------------------------------
|
//COMIC_INFO-------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -132,6 +132,9 @@ public:
|
|||||||
|
|
||||||
bool hasCover() {return _hasCover;};
|
bool hasCover() {return _hasCover;};
|
||||||
|
|
||||||
|
//returns comic title if it isn't null or empty, in other case returns fileName
|
||||||
|
QString getTitleOrPath();
|
||||||
|
|
||||||
QString toTXT();
|
QString toTXT();
|
||||||
|
|
||||||
ComicInfo info;
|
ComicInfo info;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user