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/sort_volume_comics.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 += \
|
||||
comic_vine/comic_vine_dialog.cpp \
|
||||
@ -35,4 +36,5 @@ SOURCES += \
|
||||
comic_vine/scraper_tableview.cpp \
|
||||
comic_vine/sort_volume_comics.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();
|
||||
}
|
||||
|
||||
void ComicVineClient::proccessComicDetailData(const QByteArray &data)
|
||||
{
|
||||
QString json(data);
|
||||
emit comicDetail(json);
|
||||
emit finished();
|
||||
}
|
||||
|
||||
//CV_SERIES_DETAIL
|
||||
void ComicVineClient::getSeriesDetail(const QString & id)
|
||||
{
|
||||
@ -109,7 +116,20 @@ void ComicVineClient::getComicId(const QString & id, int comicNumber)
|
||||
//CV_COMIC_DETAIL
|
||||
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
|
||||
|
@ -14,7 +14,9 @@ public:
|
||||
signals:
|
||||
void searchResult(QString);
|
||||
void seriesDetail(QString);//JSON
|
||||
void comicDetail(QString);//JSON
|
||||
void seriesCover(const QByteArray &);
|
||||
void comicCover(const QByteArray &);
|
||||
void volumeComicsInfo(QString);
|
||||
void timeOut();
|
||||
void finished();
|
||||
@ -23,14 +25,16 @@ public slots:
|
||||
void getSeriesDetail(const QString & id);
|
||||
void getSeriesCover(const QString & url);
|
||||
void getVolumeComicsInfo(const QString & idVolume);
|
||||
void getComicDetail(const QString & id);
|
||||
void getComicCover(const QString & url);
|
||||
|
||||
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 proccessSeriesDetailData(const QByteArray & data);
|
||||
void processVolumeComicsInfo(const QByteArray & data);
|
||||
void proccessComicDetailData(const QByteArray & data);
|
||||
|
||||
};
|
||||
#endif // COMIC_VINE_CLIENT_H
|
||||
|
@ -131,8 +131,13 @@ void ComicVineDialog::goNext()
|
||||
else if (content->currentWidget() == selectVolumeWidget) {
|
||||
showLoading();
|
||||
|
||||
status = GettingVolumeComics;
|
||||
|
||||
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(finished()),comicVineClient,SLOT(deleteLater()));
|
||||
comicVineClient->getVolumeComicsInfo(selectVolumeWidget->getSelectedVolumeId());
|
||||
@ -313,13 +318,22 @@ void ComicVineDialog::queryTimeOut()
|
||||
QMessageBox::warning(this,"Comic Vine error", "Time out connecting to Comic Vine");
|
||||
|
||||
switch (status) {
|
||||
case SelectingSeries:
|
||||
case AutoSearching:
|
||||
if(mode == Volume)
|
||||
showSearchVolume();
|
||||
else
|
||||
showSearchSingleComic();
|
||||
break;
|
||||
case SortingComics:
|
||||
case SearchingVolume:
|
||||
if(mode == Volume)
|
||||
showSearchVolume();
|
||||
else
|
||||
showSearchSingleComic();
|
||||
break;
|
||||
case SearchingSingleComic:
|
||||
showSearchSingleComic();
|
||||
break;
|
||||
case GettingVolumeComics:
|
||||
showSelectVolume();
|
||||
break;
|
||||
default:
|
||||
|
@ -19,7 +19,7 @@ class SelectComic;
|
||||
class SelectVolume;
|
||||
class SortVolumeComics;
|
||||
|
||||
|
||||
//TODO this should use a QStateMachine
|
||||
//----------------------------------------
|
||||
class ComicVineDialog : public QDialog
|
||||
{
|
||||
@ -68,7 +68,8 @@ private:
|
||||
SelectingSeries,
|
||||
SearchingSingleComic,
|
||||
SearchingVolume,
|
||||
SortingComics
|
||||
SortingComics,
|
||||
GettingVolumeComics
|
||||
};
|
||||
|
||||
ScraperMode mode;
|
||||
|
@ -38,9 +38,10 @@ void VolumeComicsModel::load(const QString & json)
|
||||
resultsValue = it.value();
|
||||
QString issueNumber = resultsValue.property("issue_number").toString();
|
||||
QString name = resultsValue.property("name").toString();
|
||||
QString coverURL = resultsValue.property("image").property("medium_url").toString();
|
||||
QString id = resultsValue.property("id").toString();
|
||||
QStringList l;
|
||||
l << issueNumber << name << id;
|
||||
l << issueNumber << name << coverURL << id;
|
||||
//test = name.isEmpty() && year.isEmpty() && numIssues.isEmpty() && url.isEmpty();
|
||||
if(numResults > 0)
|
||||
_data.push_back(l);
|
||||
@ -151,6 +152,11 @@ QString VolumeComicsModel::getComicId(const QModelIndex &index) const
|
||||
return _data[index.row()][ID];
|
||||
}
|
||||
|
||||
QString VolumeComicsModel::getCoverURL(const QModelIndex &index) const
|
||||
{
|
||||
return _data[index.row()][COVER_URL];
|
||||
}
|
||||
|
||||
void VolumeComicsModel::addExtraRows(int numRows)
|
||||
{
|
||||
numExtraRows = numRows;
|
||||
|
@ -22,6 +22,7 @@ signals:
|
||||
|
||||
public slots:
|
||||
QString getComicId(const QModelIndex &index) const;
|
||||
QString getCoverURL(const QModelIndex &index) const;
|
||||
void addExtraRows(int numRows);
|
||||
|
||||
private:
|
||||
@ -31,6 +32,7 @@ private:
|
||||
enum Column {
|
||||
ISSUE = 0,
|
||||
TITLE,
|
||||
COVER_URL,
|
||||
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 "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)
|
||||
: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)
|
||||
{
|
||||
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() {}
|
||||
|
||||
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>
|
||||
|
||||
class QLabel;
|
||||
class VolumeComicsModel;
|
||||
class QModelIndex;
|
||||
|
||||
class ScraperScrollLabel;
|
||||
class ScraperTableView;
|
||||
|
||||
class SelectComic : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -10,6 +17,18 @@ public:
|
||||
SelectComic(QWidget * parent = 0);
|
||||
void load(const QString & json);
|
||||
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
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "volumes_model.h"
|
||||
#include "comic_vine_client.h"
|
||||
#include "scraper_scroll_label.h"
|
||||
|
||||
SelectVolume::SelectVolume(QWidget *parent)
|
||||
:QWidget(parent),model(0)
|
||||
@ -35,42 +36,14 @@ SelectVolume::SelectVolume(QWidget *parent)
|
||||
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 QLabel();
|
||||
detailLabel->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
|
||||
detailLabel->setWordWrap(true);
|
||||
detailLabel = new ScraperScrollLabel(this);
|
||||
|
||||
detailLabel->setMinimumSize(168,12);
|
||||
|
||||
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();
|
||||
tableVolumes = new ScraperTableView(this);
|
||||
//connections
|
||||
connect(tableVolumes,SIGNAL(clicked(QModelIndex)),this,SLOT(loadVolumeInfo(QModelIndex)));
|
||||
|
||||
left->addWidget(cover);
|
||||
left->addWidget(scroll,1);
|
||||
left->addWidget(detailLabel,1);
|
||||
left->addStretch();
|
||||
leftWidget->setMaximumWidth(180);
|
||||
leftWidget->setLayout(left);
|
||||
@ -119,18 +92,12 @@ SelectVolume::~SelectVolume() {}
|
||||
|
||||
void SelectVolume::loadVolumeInfo(const QModelIndex & mi)
|
||||
{
|
||||
//QStringList * data = static_cast<QStringList *>(mi.internalPointer());
|
||||
QString coverURL = model->getCoverURL(mi);
|
||||
//QString deck = model->data(model->index(mi.row(),VolumesModel::DECK)).toString();
|
||||
QString id = model->getVolumeId(mi);
|
||||
|
||||
//cover->setText(coverURL);
|
||||
//detailLabel->setText(deck);
|
||||
QString loadingStyle = "<font color='#AAAAAA'>%1</font>";
|
||||
cover->setText(loadingStyle.arg(tr("loading cover")));
|
||||
detailLabel->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
|
||||
detailLabel->setText(loadingStyle.arg(tr("loading description")));
|
||||
detailLabel->adjustSize();
|
||||
detailLabel->setAltText(loadingStyle.arg(tr("loading description")));
|
||||
|
||||
ComicVineClient * comicVineClient = new ComicVineClient;
|
||||
connect(comicVineClient,SIGNAL(seriesCover(const QByteArray &)),this,SLOT(setCover(const QByteArray &)));
|
||||
@ -170,19 +137,13 @@ void SelectVolume::setDescription(const QString & jsonDetail)
|
||||
}
|
||||
else
|
||||
{
|
||||
detailLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft);
|
||||
|
||||
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"));
|
||||
detailLabel->adjustSize();
|
||||
}
|
||||
}
|
||||
|
||||
void SelectVolume::openLink(const QString & link)
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl("http://www.comicvine.com"+link));
|
||||
}
|
||||
|
||||
QString SelectVolume::getSelectedVolumeId()
|
||||
{
|
||||
return model->getVolumeId(tableVolumes->currentIndex());
|
||||
|
@ -7,6 +7,7 @@ class QLabel;
|
||||
class VolumesModel;
|
||||
class QModelIndex;
|
||||
|
||||
class ScraperScrollLabel;
|
||||
class ScraperTableView;
|
||||
|
||||
class SelectVolume : public QWidget
|
||||
@ -16,15 +17,16 @@ public:
|
||||
SelectVolume(QWidget * parent = 0);
|
||||
void load(const QString & json);
|
||||
virtual ~SelectVolume();
|
||||
|
||||
public slots:
|
||||
void loadVolumeInfo(const QModelIndex & mi);
|
||||
void setCover(const QByteArray &);
|
||||
void setDescription(const QString & jsonDetail);
|
||||
void openLink(const QString & link);
|
||||
QString getSelectedVolumeId();
|
||||
|
||||
private:
|
||||
QLabel * cover;
|
||||
QLabel * detailLabel;
|
||||
ScraperScrollLabel * detailLabel;
|
||||
ScraperTableView * tableVolumes;
|
||||
VolumesModel * model;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user