mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Implemented SelectComic
This commit is contained in:
parent
3d48eeb12d
commit
25072a7135
@ -16,7 +16,8 @@ HEADERS += \
|
|||||||
comic_vine/scraper_tableview.h \
|
comic_vine/scraper_tableview.h \
|
||||||
comic_vine/sort_volume_comics.h \
|
comic_vine/sort_volume_comics.h \
|
||||||
comic_vine/model/local_comic_list_model.h \
|
comic_vine/model/local_comic_list_model.h \
|
||||||
comic_vine/model/volume_comics_model.h
|
comic_vine/model/volume_comics_model.h \
|
||||||
|
comic_vine/scraper_scroll_label.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
comic_vine/comic_vine_dialog.cpp \
|
comic_vine/comic_vine_dialog.cpp \
|
||||||
@ -35,4 +36,5 @@ SOURCES += \
|
|||||||
comic_vine/scraper_tableview.cpp \
|
comic_vine/scraper_tableview.cpp \
|
||||||
comic_vine/sort_volume_comics.cpp \
|
comic_vine/sort_volume_comics.cpp \
|
||||||
comic_vine/model/local_comic_list_model.cpp \
|
comic_vine/model/local_comic_list_model.cpp \
|
||||||
comic_vine/model/volume_comics_model.cpp
|
comic_vine/model/volume_comics_model.cpp \
|
||||||
|
comic_vine/scraper_scroll_label.cpp
|
||||||
|
@ -71,6 +71,13 @@ void ComicVineClient::processVolumeComicsInfo(const QByteArray &data)
|
|||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComicVineClient::proccessComicDetailData(const QByteArray &data)
|
||||||
|
{
|
||||||
|
QString json(data);
|
||||||
|
emit comicDetail(json);
|
||||||
|
emit finished();
|
||||||
|
}
|
||||||
|
|
||||||
//CV_SERIES_DETAIL
|
//CV_SERIES_DETAIL
|
||||||
void ComicVineClient::getSeriesDetail(const QString & id)
|
void ComicVineClient::getSeriesDetail(const QString & id)
|
||||||
{
|
{
|
||||||
@ -109,7 +116,20 @@ void ComicVineClient::getComicId(const QString & id, int comicNumber)
|
|||||||
//CV_COMIC_DETAIL
|
//CV_COMIC_DETAIL
|
||||||
void ComicVineClient::getComicDetail(const QString & id)
|
void ComicVineClient::getComicDetail(const QString & id)
|
||||||
{
|
{
|
||||||
|
HttpWorker * search = new HttpWorker(CV_COMIC_DETAIL.arg(id));
|
||||||
|
connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(proccessComicDetailData(const QByteArray &)));
|
||||||
|
connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut()));
|
||||||
|
connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
|
||||||
|
search->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComicVineClient::getComicCover(const QString &url)
|
||||||
|
{
|
||||||
|
HttpWorker * search = new HttpWorker(url);
|
||||||
|
connect(search,SIGNAL(dataReady(const QByteArray &)),this,SIGNAL(comicCover(QByteArray)));
|
||||||
|
connect(search,SIGNAL(timeout()),this,SIGNAL(timeOut())); //TODO
|
||||||
|
connect(search,SIGNAL(finished()),search,SLOT(deleteLater()));
|
||||||
|
search->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
//CV_COVER_DETAIL
|
//CV_COVER_DETAIL
|
||||||
|
@ -14,7 +14,9 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void searchResult(QString);
|
void searchResult(QString);
|
||||||
void seriesDetail(QString);//JSON
|
void seriesDetail(QString);//JSON
|
||||||
|
void comicDetail(QString);//JSON
|
||||||
void seriesCover(const QByteArray &);
|
void seriesCover(const QByteArray &);
|
||||||
|
void comicCover(const QByteArray &);
|
||||||
void volumeComicsInfo(QString);
|
void volumeComicsInfo(QString);
|
||||||
void timeOut();
|
void timeOut();
|
||||||
void finished();
|
void finished();
|
||||||
@ -23,14 +25,16 @@ public slots:
|
|||||||
void getSeriesDetail(const QString & id);
|
void getSeriesDetail(const QString & id);
|
||||||
void getSeriesCover(const QString & url);
|
void getSeriesCover(const QString & url);
|
||||||
void getVolumeComicsInfo(const QString & idVolume);
|
void getVolumeComicsInfo(const QString & idVolume);
|
||||||
|
void getComicDetail(const QString & id);
|
||||||
|
void getComicCover(const QString & url);
|
||||||
|
|
||||||
void getComicId(const QString & id, int comicNumber);
|
void getComicId(const QString & id, int comicNumber);
|
||||||
void getComicDetail(const QString & id);
|
|
||||||
void getCoverURL(const QString & id);
|
void getCoverURL(const QString & id);
|
||||||
protected slots:
|
protected slots:
|
||||||
void proccessVolumesSearchData(const QByteArray & data);
|
void proccessVolumesSearchData(const QByteArray & data);
|
||||||
void proccessSeriesDetailData(const QByteArray & data);
|
void proccessSeriesDetailData(const QByteArray & data);
|
||||||
void processVolumeComicsInfo(const QByteArray & data);
|
void processVolumeComicsInfo(const QByteArray & data);
|
||||||
|
void proccessComicDetailData(const QByteArray & data);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // COMIC_VINE_CLIENT_H
|
#endif // COMIC_VINE_CLIENT_H
|
||||||
|
@ -131,8 +131,13 @@ void ComicVineDialog::goNext()
|
|||||||
else if (content->currentWidget() == selectVolumeWidget) {
|
else if (content->currentWidget() == selectVolumeWidget) {
|
||||||
showLoading();
|
showLoading();
|
||||||
|
|
||||||
|
status = GettingVolumeComics;
|
||||||
|
|
||||||
ComicVineClient * comicVineClient = new ComicVineClient;
|
ComicVineClient * comicVineClient = new ComicVineClient;
|
||||||
connect(comicVineClient,SIGNAL(volumeComicsInfo(QString)),this,SLOT(showSortVolumeComics(QString)));
|
if(mode == Volume)
|
||||||
|
connect(comicVineClient,SIGNAL(volumeComicsInfo(QString)),this,SLOT(showSortVolumeComics(QString)));
|
||||||
|
else
|
||||||
|
connect(comicVineClient,SIGNAL(volumeComicsInfo(QString)),this,SLOT(showSelectComic(QString)));
|
||||||
connect(comicVineClient,SIGNAL(timeOut()),this,SLOT(queryTimeOut()));
|
connect(comicVineClient,SIGNAL(timeOut()),this,SLOT(queryTimeOut()));
|
||||||
connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
|
connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
|
||||||
comicVineClient->getVolumeComicsInfo(selectVolumeWidget->getSelectedVolumeId());
|
comicVineClient->getVolumeComicsInfo(selectVolumeWidget->getSelectedVolumeId());
|
||||||
@ -313,13 +318,22 @@ void ComicVineDialog::queryTimeOut()
|
|||||||
QMessageBox::warning(this,"Comic Vine error", "Time out connecting to Comic Vine");
|
QMessageBox::warning(this,"Comic Vine error", "Time out connecting to Comic Vine");
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case SelectingSeries:
|
case AutoSearching:
|
||||||
if(mode == Volume)
|
if(mode == Volume)
|
||||||
showSearchVolume();
|
showSearchVolume();
|
||||||
else
|
else
|
||||||
showSearchSingleComic();
|
showSearchSingleComic();
|
||||||
break;
|
break;
|
||||||
case SortingComics:
|
case SearchingVolume:
|
||||||
|
if(mode == Volume)
|
||||||
|
showSearchVolume();
|
||||||
|
else
|
||||||
|
showSearchSingleComic();
|
||||||
|
break;
|
||||||
|
case SearchingSingleComic:
|
||||||
|
showSearchSingleComic();
|
||||||
|
break;
|
||||||
|
case GettingVolumeComics:
|
||||||
showSelectVolume();
|
showSelectVolume();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -19,7 +19,7 @@ class SelectComic;
|
|||||||
class SelectVolume;
|
class SelectVolume;
|
||||||
class SortVolumeComics;
|
class SortVolumeComics;
|
||||||
|
|
||||||
|
//TODO this should use a QStateMachine
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
class ComicVineDialog : public QDialog
|
class ComicVineDialog : public QDialog
|
||||||
{
|
{
|
||||||
@ -68,7 +68,8 @@ private:
|
|||||||
SelectingSeries,
|
SelectingSeries,
|
||||||
SearchingSingleComic,
|
SearchingSingleComic,
|
||||||
SearchingVolume,
|
SearchingVolume,
|
||||||
SortingComics
|
SortingComics,
|
||||||
|
GettingVolumeComics
|
||||||
};
|
};
|
||||||
|
|
||||||
ScraperMode mode;
|
ScraperMode mode;
|
||||||
|
@ -38,9 +38,10 @@ void VolumeComicsModel::load(const QString & json)
|
|||||||
resultsValue = it.value();
|
resultsValue = it.value();
|
||||||
QString issueNumber = resultsValue.property("issue_number").toString();
|
QString issueNumber = resultsValue.property("issue_number").toString();
|
||||||
QString name = resultsValue.property("name").toString();
|
QString name = resultsValue.property("name").toString();
|
||||||
|
QString coverURL = resultsValue.property("image").property("medium_url").toString();
|
||||||
QString id = resultsValue.property("id").toString();
|
QString id = resultsValue.property("id").toString();
|
||||||
QStringList l;
|
QStringList l;
|
||||||
l << issueNumber << name << id;
|
l << issueNumber << name << coverURL << id;
|
||||||
//test = name.isEmpty() && year.isEmpty() && numIssues.isEmpty() && url.isEmpty();
|
//test = name.isEmpty() && year.isEmpty() && numIssues.isEmpty() && url.isEmpty();
|
||||||
if(numResults > 0)
|
if(numResults > 0)
|
||||||
_data.push_back(l);
|
_data.push_back(l);
|
||||||
@ -151,6 +152,11 @@ QString VolumeComicsModel::getComicId(const QModelIndex &index) const
|
|||||||
return _data[index.row()][ID];
|
return _data[index.row()][ID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString VolumeComicsModel::getCoverURL(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
return _data[index.row()][COVER_URL];
|
||||||
|
}
|
||||||
|
|
||||||
void VolumeComicsModel::addExtraRows(int numRows)
|
void VolumeComicsModel::addExtraRows(int numRows)
|
||||||
{
|
{
|
||||||
numExtraRows = numRows;
|
numExtraRows = numRows;
|
||||||
|
@ -22,6 +22,7 @@ signals:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QString getComicId(const QModelIndex &index) const;
|
QString getComicId(const QModelIndex &index) const;
|
||||||
|
QString getCoverURL(const QModelIndex &index) const;
|
||||||
void addExtraRows(int numRows);
|
void addExtraRows(int numRows);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -31,6 +32,7 @@ private:
|
|||||||
enum Column {
|
enum Column {
|
||||||
ISSUE = 0,
|
ISSUE = 0,
|
||||||
TITLE,
|
TITLE,
|
||||||
|
COVER_URL,
|
||||||
ID
|
ID
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
53
YACReaderLibrary/comic_vine/scraper_scroll_label.cpp
Normal file
53
YACReaderLibrary/comic_vine/scraper_scroll_label.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#include "scraper_scroll_label.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
ScraperScrollLabel::ScraperScrollLabel(QWidget *parent) :
|
||||||
|
QScrollArea(parent)
|
||||||
|
{
|
||||||
|
textLabel = new QLabel(this);
|
||||||
|
textLabel->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
|
||||||
|
|
||||||
|
textLabel->setWordWrap(true);
|
||||||
|
textLabel->setMinimumSize(168,12);
|
||||||
|
|
||||||
|
setWidget(textLabel);
|
||||||
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setStyleSheet(
|
||||||
|
"QScrollArea {background-color:#2B2B2B; border:none;}"
|
||||||
|
"QScrollBar:vertical { border: none; background: #2B2B2B; width: 3px; margin: 0; }"
|
||||||
|
"QScrollBar:horizontal { border: none; background: #2B2B2B; height: 3px; margin: 0; }"
|
||||||
|
"QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
|
||||||
|
"QScrollBar::handle:horizontal { 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::add-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 0 3px 0;}"
|
||||||
|
"QScrollBar::sub-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 0 3px 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, QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {background: none; }"
|
||||||
|
);
|
||||||
|
|
||||||
|
connect(textLabel,SIGNAL(linkActivated(QString)),this,SLOT(openLink(QString)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScraperScrollLabel::setAltText(const QString &text)
|
||||||
|
{
|
||||||
|
textLabel->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
|
||||||
|
textLabel->setText(text);
|
||||||
|
textLabel->adjustSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScraperScrollLabel::setText(const QString &text)
|
||||||
|
{
|
||||||
|
textLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||||
|
textLabel->setText(text);
|
||||||
|
textLabel->adjustSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScraperScrollLabel::openLink(const QString & link)
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl(QUrl("http://www.comicvine.com"+link));
|
||||||
|
}
|
25
YACReaderLibrary/comic_vine/scraper_scroll_label.h
Normal file
25
YACReaderLibrary/comic_vine/scraper_scroll_label.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef SCRAPER_SCROLL_LABEL_H
|
||||||
|
#define SCRAPER_SCROLL_LABEL_H
|
||||||
|
|
||||||
|
#include <QScrollArea>
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
|
class ScraperScrollLabel : public QScrollArea
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ScraperScrollLabel(QWidget *parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setText(const QString & text);
|
||||||
|
void setAltText(const QString &text);
|
||||||
|
|
||||||
|
void openLink(const QString &link);
|
||||||
|
private:
|
||||||
|
QLabel * textLabel;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SCRAPER_SCROLL_LABEL_H
|
@ -1,15 +1,140 @@
|
|||||||
#include "select_comic.h"
|
#include "select_comic.h"
|
||||||
|
|
||||||
|
#include "comic_vine_client.h"
|
||||||
|
#include "scraper_scroll_label.h"
|
||||||
|
#include "scraper_tableview.h"
|
||||||
|
#include "volume_comics_model.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLayout>
|
||||||
|
#include <QtScript>
|
||||||
|
|
||||||
SelectComic::SelectComic(QWidget *parent)
|
SelectComic::SelectComic(QWidget *parent)
|
||||||
:QWidget(parent)
|
:QWidget(parent),model(0)
|
||||||
{
|
{
|
||||||
|
QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
|
||||||
|
|
||||||
|
QLabel * label = new QLabel(tr("Please, select the right comic info."));
|
||||||
|
label->setStyleSheet(labelStylesheet);
|
||||||
|
|
||||||
|
QVBoxLayout * l = new QVBoxLayout;
|
||||||
|
QWidget * leftWidget = new QWidget;
|
||||||
|
QVBoxLayout * left = new QVBoxLayout;
|
||||||
|
QHBoxLayout * content = new QHBoxLayout;
|
||||||
|
|
||||||
|
//widgets
|
||||||
|
cover = new QLabel();
|
||||||
|
cover->setScaledContents(true);
|
||||||
|
cover->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
|
||||||
|
cover->setMinimumSize(168,168*5.0/3);
|
||||||
|
cover->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
|
||||||
|
detailLabel = new ScraperScrollLabel(this);
|
||||||
|
|
||||||
|
tableComics = new ScraperTableView(this);
|
||||||
|
//connections
|
||||||
|
connect(tableComics,SIGNAL(clicked(QModelIndex)),this,SLOT(loadComicInfo(QModelIndex)));
|
||||||
|
|
||||||
|
left->addWidget(cover);
|
||||||
|
left->addWidget(detailLabel,1);
|
||||||
|
left->addStretch();
|
||||||
|
leftWidget->setMaximumWidth(180);
|
||||||
|
leftWidget->setLayout(left);
|
||||||
|
left->setContentsMargins(0,0,0,0);
|
||||||
|
leftWidget->setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
|
content->addWidget(leftWidget);
|
||||||
|
content->addWidget(tableComics,0,Qt::AlignRight|Qt::AlignTop);
|
||||||
|
|
||||||
|
l->addSpacing(15);
|
||||||
|
l->addWidget(label);
|
||||||
|
l->addSpacing(5);
|
||||||
|
l->addLayout(content);
|
||||||
|
l->addStretch();
|
||||||
|
|
||||||
|
l->setContentsMargins(0,0,0,0);
|
||||||
|
setLayout(l);
|
||||||
|
setContentsMargins(0,0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectComic::load(const QString &json)
|
void SelectComic::load(const QString &json)
|
||||||
{
|
{
|
||||||
|
VolumeComicsModel * tempM = new VolumeComicsModel();
|
||||||
|
tempM->load(json);
|
||||||
|
tableComics->setModel(tempM);
|
||||||
|
|
||||||
|
tableComics->setFixedSize(619,341);
|
||||||
|
|
||||||
|
if(model != 0)
|
||||||
|
delete model;
|
||||||
|
|
||||||
|
model = tempM;
|
||||||
|
|
||||||
|
if(model->rowCount()>0)
|
||||||
|
{
|
||||||
|
tableComics->selectRow(0);
|
||||||
|
loadComicInfo(model->index(0,0));
|
||||||
|
}
|
||||||
|
|
||||||
|
tableComics->resizeColumnToContents(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectComic::~SelectComic() {}
|
SelectComic::~SelectComic() {}
|
||||||
|
|
||||||
|
void SelectComic::loadComicInfo(const QModelIndex &mi)
|
||||||
|
{
|
||||||
|
QString coverURL = model->getCoverURL(mi);
|
||||||
|
QString id = model->getComicId(mi);
|
||||||
|
|
||||||
|
QString loadingStyle = "<font color='#AAAAAA'>%1</font>";
|
||||||
|
cover->setText(loadingStyle.arg(tr("loading cover")));
|
||||||
|
detailLabel->setAltText(loadingStyle.arg(tr("loading description")));
|
||||||
|
|
||||||
|
ComicVineClient * comicVineClient = new ComicVineClient;
|
||||||
|
connect(comicVineClient,SIGNAL(comicCover(const QByteArray &)),this,SLOT(setCover(const QByteArray &)));
|
||||||
|
connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
|
||||||
|
comicVineClient->getComicCover(coverURL);
|
||||||
|
|
||||||
|
ComicVineClient * comicVineClient2 = new ComicVineClient;
|
||||||
|
connect(comicVineClient2,SIGNAL(comicDetail(QString)),this,SLOT(setDescription(QString)));
|
||||||
|
connect(comicVineClient2,SIGNAL(finished()),comicVineClient2,SLOT(deleteLater()));
|
||||||
|
comicVineClient2->getComicDetail(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectComic::setCover(const QByteArray & data)
|
||||||
|
{
|
||||||
|
QPixmap p;
|
||||||
|
p.loadFromData(data);
|
||||||
|
int w = p.width();
|
||||||
|
int h = p.height();
|
||||||
|
|
||||||
|
cover->setPixmap(p);
|
||||||
|
float aspectRatio = static_cast<float>(w)/h;
|
||||||
|
|
||||||
|
cover->setFixedSize(180,static_cast<int>(180/aspectRatio));
|
||||||
|
|
||||||
|
cover->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectComic::setDescription(const QString &jsonDetail)
|
||||||
|
{
|
||||||
|
QScriptEngine engine;
|
||||||
|
QScriptValue sc;
|
||||||
|
sc = engine.evaluate("(" + jsonDetail + ")");
|
||||||
|
|
||||||
|
if (!sc.property("error").isValid() && sc.property("error").toString() != "OK")
|
||||||
|
{
|
||||||
|
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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SelectComic::getSelectedComicId()
|
||||||
|
{
|
||||||
|
return model->getComicId(tableComics->currentIndex());
|
||||||
|
}
|
||||||
|
@ -3,6 +3,13 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
class VolumeComicsModel;
|
||||||
|
class QModelIndex;
|
||||||
|
|
||||||
|
class ScraperScrollLabel;
|
||||||
|
class ScraperTableView;
|
||||||
|
|
||||||
class SelectComic : public QWidget
|
class SelectComic : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -10,6 +17,18 @@ public:
|
|||||||
SelectComic(QWidget * parent = 0);
|
SelectComic(QWidget * parent = 0);
|
||||||
void load(const QString & json);
|
void load(const QString & json);
|
||||||
virtual ~SelectComic();
|
virtual ~SelectComic();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void loadComicInfo(const QModelIndex & mi);
|
||||||
|
void setCover(const QByteArray &);
|
||||||
|
void setDescription(const QString & jsonDetail);
|
||||||
|
QString getSelectedComicId();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLabel * cover;
|
||||||
|
ScraperScrollLabel * detailLabel;
|
||||||
|
ScraperTableView * tableComics;
|
||||||
|
VolumeComicsModel * model;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SELECT_COMIC_H
|
#endif // SELECT_COMIC_H
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "volumes_model.h"
|
#include "volumes_model.h"
|
||||||
#include "comic_vine_client.h"
|
#include "comic_vine_client.h"
|
||||||
|
#include "scraper_scroll_label.h"
|
||||||
|
|
||||||
SelectVolume::SelectVolume(QWidget *parent)
|
SelectVolume::SelectVolume(QWidget *parent)
|
||||||
:QWidget(parent),model(0)
|
:QWidget(parent),model(0)
|
||||||
@ -35,42 +36,14 @@ SelectVolume::SelectVolume(QWidget *parent)
|
|||||||
cover->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
|
cover->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
|
||||||
cover->setMinimumSize(168,168*5.0/3);
|
cover->setMinimumSize(168,168*5.0/3);
|
||||||
cover->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
|
cover->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
|
||||||
detailLabel = new QLabel();
|
detailLabel = new ScraperScrollLabel(this);
|
||||||
detailLabel->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
|
|
||||||
detailLabel->setWordWrap(true);
|
|
||||||
|
|
||||||
detailLabel->setMinimumSize(168,12);
|
tableVolumes = new ScraperTableView(this);
|
||||||
|
|
||||||
connect(detailLabel,SIGNAL(linkActivated(QString)),this,SLOT(openLink(QString)));
|
|
||||||
|
|
||||||
QScrollArea * scroll = new QScrollArea(this);
|
|
||||||
scroll->setWidget(detailLabel);
|
|
||||||
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
scroll->setStyleSheet(
|
|
||||||
"QScrollArea {background-color:#2B2B2B; border:none;}"
|
|
||||||
"QScrollBar:vertical { border: none; background: #2B2B2B; width: 3px; margin: 0; }"
|
|
||||||
"QScrollBar:horizontal { border: none; background: #2B2B2B; height: 3px; margin: 0; }"
|
|
||||||
"QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
|
|
||||||
"QScrollBar::handle:horizontal { 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::add-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 0 3px 0;}"
|
|
||||||
"QScrollBar::sub-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 0 3px 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, QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {background: none; }"
|
|
||||||
|
|
||||||
);
|
|
||||||
//scroll->setWidgetResizable(true);
|
|
||||||
//iScroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
|
||||||
//iScroll->show();
|
|
||||||
|
|
||||||
tableVolumes = new ScraperTableView();
|
|
||||||
//connections
|
//connections
|
||||||
connect(tableVolumes,SIGNAL(clicked(QModelIndex)),this,SLOT(loadVolumeInfo(QModelIndex)));
|
connect(tableVolumes,SIGNAL(clicked(QModelIndex)),this,SLOT(loadVolumeInfo(QModelIndex)));
|
||||||
|
|
||||||
left->addWidget(cover);
|
left->addWidget(cover);
|
||||||
left->addWidget(scroll,1);
|
left->addWidget(detailLabel,1);
|
||||||
left->addStretch();
|
left->addStretch();
|
||||||
leftWidget->setMaximumWidth(180);
|
leftWidget->setMaximumWidth(180);
|
||||||
leftWidget->setLayout(left);
|
leftWidget->setLayout(left);
|
||||||
@ -119,18 +92,12 @@ SelectVolume::~SelectVolume() {}
|
|||||||
|
|
||||||
void SelectVolume::loadVolumeInfo(const QModelIndex & mi)
|
void SelectVolume::loadVolumeInfo(const QModelIndex & mi)
|
||||||
{
|
{
|
||||||
//QStringList * data = static_cast<QStringList *>(mi.internalPointer());
|
|
||||||
QString coverURL = model->getCoverURL(mi);
|
QString coverURL = model->getCoverURL(mi);
|
||||||
//QString deck = model->data(model->index(mi.row(),VolumesModel::DECK)).toString();
|
|
||||||
QString id = model->getVolumeId(mi);
|
QString id = model->getVolumeId(mi);
|
||||||
|
|
||||||
//cover->setText(coverURL);
|
|
||||||
//detailLabel->setText(deck);
|
|
||||||
QString loadingStyle = "<font color='#AAAAAA'>%1</font>";
|
QString loadingStyle = "<font color='#AAAAAA'>%1</font>";
|
||||||
cover->setText(loadingStyle.arg(tr("loading cover")));
|
cover->setText(loadingStyle.arg(tr("loading cover")));
|
||||||
detailLabel->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
|
detailLabel->setAltText(loadingStyle.arg(tr("loading description")));
|
||||||
detailLabel->setText(loadingStyle.arg(tr("loading description")));
|
|
||||||
detailLabel->adjustSize();
|
|
||||||
|
|
||||||
ComicVineClient * comicVineClient = new ComicVineClient;
|
ComicVineClient * comicVineClient = new ComicVineClient;
|
||||||
connect(comicVineClient,SIGNAL(seriesCover(const QByteArray &)),this,SLOT(setCover(const QByteArray &)));
|
connect(comicVineClient,SIGNAL(seriesCover(const QByteArray &)),this,SLOT(setCover(const QByteArray &)));
|
||||||
@ -170,19 +137,13 @@ void SelectVolume::setDescription(const QString & jsonDetail)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
detailLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
|
||||||
QScriptValue descriptionValues = sc.property("results").property("description");
|
QScriptValue descriptionValues = sc.property("results").property("description");
|
||||||
bool valid = !descriptionValues.isNull() && descriptionValues.isValid();
|
bool valid = !descriptionValues.isNull() && descriptionValues.isValid();
|
||||||
detailLabel->setText(valid?descriptionValues.toString().replace("<a","<a style = 'color:#827A68; text-decoration:none;'"):tr("description unavailable"));
|
detailLabel->setText(valid?descriptionValues.toString().replace("<a","<a style = 'color:#827A68; text-decoration:none;'"):tr("description unavailable"));
|
||||||
detailLabel->adjustSize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectVolume::openLink(const QString & link)
|
|
||||||
{
|
|
||||||
QDesktopServices::openUrl(QUrl("http://www.comicvine.com"+link));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SelectVolume::getSelectedVolumeId()
|
QString SelectVolume::getSelectedVolumeId()
|
||||||
{
|
{
|
||||||
return model->getVolumeId(tableVolumes->currentIndex());
|
return model->getVolumeId(tableVolumes->currentIndex());
|
||||||
|
@ -7,6 +7,7 @@ class QLabel;
|
|||||||
class VolumesModel;
|
class VolumesModel;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
|
||||||
|
class ScraperScrollLabel;
|
||||||
class ScraperTableView;
|
class ScraperTableView;
|
||||||
|
|
||||||
class SelectVolume : public QWidget
|
class SelectVolume : public QWidget
|
||||||
@ -16,15 +17,16 @@ public:
|
|||||||
SelectVolume(QWidget * parent = 0);
|
SelectVolume(QWidget * parent = 0);
|
||||||
void load(const QString & json);
|
void load(const QString & json);
|
||||||
virtual ~SelectVolume();
|
virtual ~SelectVolume();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void loadVolumeInfo(const QModelIndex & mi);
|
void loadVolumeInfo(const QModelIndex & mi);
|
||||||
void setCover(const QByteArray &);
|
void setCover(const QByteArray &);
|
||||||
void setDescription(const QString & jsonDetail);
|
void setDescription(const QString & jsonDetail);
|
||||||
void openLink(const QString & link);
|
|
||||||
QString getSelectedVolumeId();
|
QString getSelectedVolumeId();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel * cover;
|
QLabel * cover;
|
||||||
QLabel * detailLabel;
|
ScraperScrollLabel * detailLabel;
|
||||||
ScraperTableView * tableVolumes;
|
ScraperTableView * tableVolumes;
|
||||||
VolumesModel * model;
|
VolumesModel * model;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user