diff --git a/YACReaderLibrary/comic_vine/comic_vine.pri b/YACReaderLibrary/comic_vine/comic_vine.pri index cd929ab4..156d4de3 100644 --- a/YACReaderLibrary/comic_vine/comic_vine.pri +++ b/YACReaderLibrary/comic_vine/comic_vine.pri @@ -12,7 +12,11 @@ HEADERS += \ comic_vine/model/volumes_model.h \ comic_vine/model/comics_model.h \ comic_vine/model/json_model.h \ - comic_vine/model/response_parser.h + comic_vine/model/response_parser.h \ + comic_vine/scrapper_tableview.h \ + comic_vine/sort_volume_comics.h \ + comic_vine/model/local_comic_list_model.h \ + comic_vine/model/volume_comics_model.h SOURCES += \ comic_vine/comic_vine_dialog.cpp \ @@ -27,4 +31,8 @@ SOURCES += \ comic_vine/model/volumes_model.cpp \ comic_vine/model/comics_model.cpp \ comic_vine/model/json_model.cpp \ - comic_vine/model/response_parser.cpp + comic_vine/model/response_parser.cpp \ + comic_vine/scrapper_tableview.cpp \ + comic_vine/sort_volume_comics.cpp \ + comic_vine/model/local_comic_list_model.cpp \ + comic_vine/model/volume_comics_model.cpp diff --git a/YACReaderLibrary/comic_vine/comic_vine_client.cpp b/YACReaderLibrary/comic_vine/comic_vine_client.cpp index e564db48..d83a09ff 100644 --- a/YACReaderLibrary/comic_vine/comic_vine_client.cpp +++ b/YACReaderLibrary/comic_vine/comic_vine_client.cpp @@ -17,9 +17,9 @@ static const QString CV_SEARCH = CV_WEB_ADDRESS + "/search/?api_key=" + CV_API_K 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,description"; -//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 info for comics in a volume id %1 +static const QString CV_COMICS_INFO = CV_WEB_ADDRESS + "/issues/?api_key=" + CV_API_KEY + + "&format=json&field_list=name,issue_number,id,image&filter=volume:%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 + @@ -64,6 +64,13 @@ void ComicVineClient::proccessSeriesDetailData(const QByteArray &data) emit finished(); } +void ComicVineClient::processVolumeComicsInfo(const QByteArray &data) +{ + QString json(data); + emit volumeComicsInfo(json); + emit finished(); +} + void ComicVineClient::queryTimeOut() { @@ -89,9 +96,13 @@ void ComicVineClient::getSeriesCover(const QString & url) } //CV_COMIC_IDS -void ComicVineClient::getComicIds(const QString & id, int page) +void ComicVineClient::getVolumeComicsInfo(const QString & idVolume) { - + HttpWorker * search = new HttpWorker(CV_COMICS_INFO.arg(idVolume)); + connect(search,SIGNAL(dataReady(const QByteArray &)),this,SLOT(processVolumeComicsInfo(const QByteArray &))); + connect(search,SIGNAL(timeout()),this,SLOT(queryTimeOut())); //TODO + connect(search,SIGNAL(finished()),search,SLOT(deleteLater())); + search->get(); } //CV_COMIC_ID diff --git a/YACReaderLibrary/comic_vine/comic_vine_client.h b/YACReaderLibrary/comic_vine/comic_vine_client.h index d2a62c22..7ab8898f 100644 --- a/YACReaderLibrary/comic_vine/comic_vine_client.h +++ b/YACReaderLibrary/comic_vine/comic_vine_client.h @@ -15,19 +15,23 @@ signals: void searchResult(QString); void seriesDetail(QString);//JSON void seriesCover(const QByteArray &); + void volumeComicsInfo(QString); + void finished(); public slots: void search(const QString & query, int page = 0); void getSeriesDetail(const QString & id); void getSeriesCover(const QString & url); + void getVolumeComicsInfo(const QString & idVolume); - 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 proccessSeriesDetailData(const QByteArray & data); + void processVolumeComicsInfo(const QByteArray & data); + void queryTimeOut(); }; diff --git a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp index 7cb1b6ae..3ea37523 100644 --- a/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp +++ b/YACReaderLibrary/comic_vine/comic_vine_dialog.cpp @@ -17,6 +17,7 @@ #include "search_volume.h" #include "select_comic.h" #include "select_volume.h" +#include "sort_volume_comics.h" #include "response_parser.h" @@ -82,6 +83,7 @@ void ComicVineDialog::doStackedWidgets() content->addWidget(searchVolumeWidget = new SearchVolume); content->addWidget(selectVolumeWidget = new SelectVolume); content->addWidget(selectComicWidget = new SelectComic); + content->addWidget(sortVolumeComicsWidget = new SortVolumeComics); } void ComicVineDialog::doConnections() @@ -114,7 +116,7 @@ void ComicVineDialog::goNext() else { ComicDB comic = comics[currentIndex]; - QString title = comic.getTitleOrPath(); + QString title = comic.getTitleOrFileName(); titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex+1).arg(comics.length()).arg(title)); showLoading(); @@ -123,8 +125,13 @@ void ComicVineDialog::goNext() mode = SingleComicInList; } } - else if (content->currentWidget() == searchSingleComicWidget) { + else if (content->currentWidget() == selectVolumeWidget) { + showLoading(); + ComicVineClient * comicVineClient = new ComicVineClient; + connect(comicVineClient,SIGNAL(volumeComicsInfo(QString)),this,SLOT(showSortVolumeComics(QString))); + connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater())); + comicVineClient->getVolumeComicsInfo(selectVolumeWidget->getSelectedVolumeId()); } } @@ -142,7 +149,7 @@ void ComicVineDialog::show() if(comics.length() == 1) { ComicDB singleComic = comics[0]; - QString title = singleComic.getTitleOrPath(); + QString title = singleComic.getTitleOrFileName(); titleHeader->setSubTitle(title); showLoading(); @@ -240,6 +247,12 @@ void ComicVineDialog::showSearchVolume() void ComicVineDialog::showSelectVolume(const QString & json) { content->setCurrentWidget(selectVolumeWidget); + + backButton->setVisible(true); + nextButton->setVisible(true); + searchButton->setHidden(true); + closeButton->setVisible(true); + selectVolumeWidget->load(json); } @@ -249,6 +262,12 @@ void ComicVineDialog::showSelectComic(const QString &json) selectComicWidget->load(json); } +void ComicVineDialog::showSortVolumeComics(const QString &json) +{ + content->setCurrentWidget(sortVolumeComicsWidget); + sortVolumeComicsWidget->setData(comics, json); +} + void ComicVineDialog::showLoading() { content->setCurrentIndex(0); diff --git a/YACReaderLibrary/comic_vine/comic_vine_dialog.h b/YACReaderLibrary/comic_vine/comic_vine_dialog.h index f300456d..220c46b3 100644 --- a/YACReaderLibrary/comic_vine/comic_vine_dialog.h +++ b/YACReaderLibrary/comic_vine/comic_vine_dialog.h @@ -17,6 +17,7 @@ class SearchSingleComic; class SearchVolume; class SelectComic; class SelectVolume; +class SortVolumeComics; //---------------------------------------- @@ -46,6 +47,7 @@ protected slots: void launchSearchComic(); void showSelectVolume(const QString & json); void showSelectComic(const QString & json); + void showSortVolumeComics(const QString & json); private: enum ScrapperMode @@ -94,6 +96,7 @@ private: SearchVolume * searchVolumeWidget; SelectVolume * selectVolumeWidget; SelectComic * selectComicWidget; + SortVolumeComics * sortVolumeComicsWidget; }; #endif // COMIC_VINE_DIALOG_H diff --git a/YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp b/YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp new file mode 100644 index 00000000..c76767f7 --- /dev/null +++ b/YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp @@ -0,0 +1,82 @@ +#include "local_comic_list_model.h" + +LocalComicListModel::LocalComicListModel(QObject *parent) : + QAbstractItemModel(parent) +{ +} + +void LocalComicListModel::load(QList &comics) +{ + _data = comics; +} + + +QModelIndex LocalComicListModel::parent(const QModelIndex &index) const +{ + Q_UNUSED(index) + return QModelIndex(); //no parent +} + +int LocalComicListModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + return _data.count(); +} + +int LocalComicListModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + if(_data.isEmpty()) + return 0; + else + return 1;//_data.at(0)->count(); +} + +QVariant LocalComicListModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + if (role == Qt::DecorationRole) + { + return QVariant(); + } + if (role == Qt::TextAlignmentRole) + { + //TODO + } + + if(role != Qt::DisplayRole) + return QVariant(); + + int row = index.row(); + int column = index.column(); + return _data[row].getFileName(); +} + +Qt::ItemFlags LocalComicListModel::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return 0; + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +QVariant LocalComicListModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + { + return QVariant(QString(tr("file name"))); + } + + return QVariant(); +} + +QModelIndex LocalComicListModel::index(int row, int column, const QModelIndex &parent) const +{ + if (!hasIndex(row, column, parent)) + return QModelIndex(); + + return createIndex(row, column); +} + diff --git a/YACReaderLibrary/comic_vine/model/local_comic_list_model.h b/YACReaderLibrary/comic_vine/model/local_comic_list_model.h new file mode 100644 index 00000000..3b37b521 --- /dev/null +++ b/YACReaderLibrary/comic_vine/model/local_comic_list_model.h @@ -0,0 +1,34 @@ +#ifndef LOCAL_COMIC_LIST_MODEL_H +#define LOCAL_COMIC_LIST_MODEL_H + +#include + +#include "comic_db.h" + +class LocalComicListModel : public QAbstractItemModel +{ + Q_OBJECT +public: + explicit LocalComicListModel(QObject *parent = 0); + + void load(QList & comics); + + //QAbstractItemModel methods + QModelIndex parent(const QModelIndex &index) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + Qt::ItemFlags flags(const QModelIndex &index) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + +signals: + +public slots: + +private: + QList _data; +}; + +#endif // LOCAL_COMIC_LIST_MODEL_H diff --git a/YACReaderLibrary/comic_vine/model/volume_comics_model.cpp b/YACReaderLibrary/comic_vine/model/volume_comics_model.cpp new file mode 100644 index 00000000..ece45042 --- /dev/null +++ b/YACReaderLibrary/comic_vine/model/volume_comics_model.cpp @@ -0,0 +1,11 @@ +#include "volume_comics_model.h" + +VolumeComicsModel::VolumeComicsModel(QObject * parent) : + JSONModel(parent) +{ +} + +void VolumeComicsModel::load(const QString & json) +{ + +} diff --git a/YACReaderLibrary/comic_vine/model/volume_comics_model.h b/YACReaderLibrary/comic_vine/model/volume_comics_model.h new file mode 100644 index 00000000..e8eb84c1 --- /dev/null +++ b/YACReaderLibrary/comic_vine/model/volume_comics_model.h @@ -0,0 +1,18 @@ +#ifndef VOLUME_COMICS_MODEL_H +#define VOLUME_COMICS_MODEL_H + +#include "json_model.h" + +class VolumeComicsModel : public JSONModel +{ + Q_OBJECT +public: + explicit VolumeComicsModel(QObject *parent = 0); + void load(const QString & json); +signals: + +public slots: + +}; + +#endif // VOLUME_COMICS_MODEL_H diff --git a/YACReaderLibrary/comic_vine/model/volumes_model.cpp b/YACReaderLibrary/comic_vine/model/volumes_model.cpp index 90309041..8c76de87 100644 --- a/YACReaderLibrary/comic_vine/model/volumes_model.cpp +++ b/YACReaderLibrary/comic_vine/model/volumes_model.cpp @@ -139,3 +139,8 @@ QModelIndex VolumesModel::index(int row, int column, const QModelIndex &parent) return createIndex(row, column, _data[row]); } +QString VolumesModel::getVolumeId(const QModelIndex &index) const +{ + return _data.at(index.row())->at(ID); +} + diff --git a/YACReaderLibrary/comic_vine/model/volumes_model.h b/YACReaderLibrary/comic_vine/model/volumes_model.h index 98fa3e70..44136577 100644 --- a/YACReaderLibrary/comic_vine/model/volumes_model.h +++ b/YACReaderLibrary/comic_vine/model/volumes_model.h @@ -22,6 +22,8 @@ public: int role = Qt::DisplayRole) const; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + QString getVolumeId(const QModelIndex & index) const; + signals: public slots: diff --git a/YACReaderLibrary/comic_vine/scrapper_tableview.cpp b/YACReaderLibrary/comic_vine/scrapper_tableview.cpp new file mode 100644 index 00000000..ec47358d --- /dev/null +++ b/YACReaderLibrary/comic_vine/scrapper_tableview.cpp @@ -0,0 +1,59 @@ +#include "scrapper_tableview.h" + +#include + +ScrapperTableView::ScrapperTableView(QWidget *parent) : + QTableView(parent) +{ + QString tableStylesheet = "QTableView {color:white; border:0px;alternate-background-color: #2E2E2E;background-color: #2B2B2B; outline: 0px;}" + "QTableView::item {outline: 0px; border: 0px; color:#FFFFFF;}" + "QTableView::item:selected {outline: 0px; background-color: #555555; }" + "QHeaderView::section:horizontal {background-color:#292929; border-bottom:1px solid #1F1F1F; border-right:1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #292929, stop: 1 #1F1F1F); border-left:none; border-top:none; padding:4px; color:#ebebeb;}" + "QHeaderView::section:vertical {border-bottom: 1px solid #DFDFDF;border-top: 1px solid #FEFEFE;}" + "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; }"; + + setStyleSheet(tableStylesheet); + + setShowGrid(false); +#if QT_VERSION >= 0x050000 + verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); +#else + verticalHeader()->setResizeMode(QHeaderView::Fixed); +#endif + + //comicView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); + horizontalHeader()->setStretchLastSection(true); +#if QT_VERSION >= 0x050000 + horizontalHeader()->setSectionsClickable(false); +#else + horizontalHeader()->setClickable(false); +#endif + //comicView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); + verticalHeader()->setDefaultSectionSize(24); +#if QT_VERSION >= 0x050000 + verticalHeader()->setSectionsClickable(false); //TODO comportamiento anómalo +#else + verticalHeader()->setClickable(false); //TODO comportamiento anómalo +#endif + + setCornerButtonEnabled(false); + + setSelectionBehavior(QAbstractItemView::SelectRows); + setSelectionMode(QAbstractItemView::ExtendedSelection); + + setAlternatingRowColors(true); + + verticalHeader()->hide(); + + setSelectionMode(QAbstractItemView::SingleSelection); +} diff --git a/YACReaderLibrary/comic_vine/scrapper_tableview.h b/YACReaderLibrary/comic_vine/scrapper_tableview.h new file mode 100644 index 00000000..9369b178 --- /dev/null +++ b/YACReaderLibrary/comic_vine/scrapper_tableview.h @@ -0,0 +1,18 @@ +#ifndef SCRAPPER_TABLEVIEW_H +#define SCRAPPER_TABLEVIEW_H + +#include + +class ScrapperTableView : public QTableView +{ + Q_OBJECT +public: + explicit ScrapperTableView(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // SCRAPPER_TABLEVIEW_H diff --git a/YACReaderLibrary/comic_vine/select_volume.cpp b/YACReaderLibrary/comic_vine/select_volume.cpp index 5e5f8ea2..79ebc82f 100644 --- a/YACReaderLibrary/comic_vine/select_volume.cpp +++ b/YACReaderLibrary/comic_vine/select_volume.cpp @@ -1,14 +1,15 @@ #include "select_volume.h" #include -#include #include #include -#include #include #include #include #include +#include + +#include "scrapper_tableview.h" #include @@ -19,22 +20,6 @@ SelectVolume::SelectVolume(QWidget *parent) :QWidget(parent),model(0) { QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}"; - QString tableStylesheet = "QTableView {color:white; border:0px;alternate-background-color: #2E2E2E;background-color: #2B2B2B; outline: 0px;}" - "QTableView::item {outline: 0px; border: 0px; color:#FFFFFF;}" - "QTableView::item:selected {outline: 0px; background-color: #555555; }" - "QHeaderView::section:horizontal {background-color:#292929; border-bottom:1px solid #1F1F1F; border-right:1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #292929, stop: 1 #1F1F1F); border-left:none; border-top:none; padding:4px; color:#ebebeb;}" - "QHeaderView::section:vertical {border-bottom: 1px solid #DFDFDF;border-top: 1px solid #FEFEFE;}" - "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; }"; QLabel * label = new QLabel(tr("Please, select the right series for your comic.")); label->setStyleSheet(labelStylesheet); @@ -80,42 +65,7 @@ SelectVolume::SelectVolume(QWidget *parent) //iScroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); //iScroll->show(); - tableVolumes = new QTableView(); - tableVolumes->setStyleSheet(tableStylesheet); - - tableVolumes->setShowGrid(false); -#if QT_VERSION >= 0x050000 - tableVolumes->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); -#else - tableVolumes->verticalHeader()->setResizeMode(QHeaderView::Fixed); -#endif - - //comicView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); - tableVolumes->horizontalHeader()->setStretchLastSection(true); -#if QT_VERSION >= 0x050000 - tableVolumes->horizontalHeader()->setSectionsClickable(false); -#else - tableVolumes->horizontalHeader()->setClickable(false); -#endif - //comicView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); - tableVolumes->verticalHeader()->setDefaultSectionSize(24); -#if QT_VERSION >= 0x050000 - tableVolumes->verticalHeader()->setSectionsClickable(false); //TODO comportamiento anómalo -#else - tableVolumes->verticalHeader()->setClickable(false); //TODO comportamiento anómalo -#endif - - tableVolumes->setCornerButtonEnabled(false); - - tableVolumes->setSelectionBehavior(QAbstractItemView::SelectRows); - tableVolumes->setSelectionMode(QAbstractItemView::ExtendedSelection); - - tableVolumes->setAlternatingRowColors(true); - - tableVolumes->verticalHeader()->hide(); - - tableVolumes->setSelectionMode(QAbstractItemView::SingleSelection); - + tableVolumes = new ScrapperTableView(); //connections connect(tableVolumes,SIGNAL(clicked(QModelIndex)),this,SLOT(loadVolumeInfo(QModelIndex))); @@ -221,7 +171,9 @@ void SelectVolume::setDescription(const QString & jsonDetail) else { detailLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft); - detailLabel->setText(sc.property("results").property("description").toString().replace("setText(valid?descriptionValues.toString().replace("adjustSize(); } } @@ -231,3 +183,8 @@ void SelectVolume::openLink(const QString & link) QDesktopServices::openUrl(QUrl("http://www.comicvine.com"+link)); } +QString SelectVolume::getSelectedVolumeId() +{ + return model->getVolumeId(tableVolumes->currentIndex()); +} + diff --git a/YACReaderLibrary/comic_vine/select_volume.h b/YACReaderLibrary/comic_vine/select_volume.h index 42c74876..6ecb9b65 100644 --- a/YACReaderLibrary/comic_vine/select_volume.h +++ b/YACReaderLibrary/comic_vine/select_volume.h @@ -4,10 +4,11 @@ #include class QLabel; -class QTableView; class VolumesModel; class QModelIndex; +class ScrapperTableView; + class SelectVolume : public QWidget { Q_OBJECT @@ -20,10 +21,11 @@ public slots: void setCover(const QByteArray &); void setDescription(const QString & jsonDetail); void openLink(const QString & link); + QString getSelectedVolumeId(); private: QLabel * cover; QLabel * detailLabel; - QTableView * tableVolumes; + ScrapperTableView * tableVolumes; VolumesModel * model; }; diff --git a/YACReaderLibrary/comic_vine/sort_volume_comics.cpp b/YACReaderLibrary/comic_vine/sort_volume_comics.cpp new file mode 100644 index 00000000..68b87b07 --- /dev/null +++ b/YACReaderLibrary/comic_vine/sort_volume_comics.cpp @@ -0,0 +1,62 @@ +#include "sort_volume_comics.h" + +#include +#include +#include +#include + +#include "scrapper_tableview.h" +#include "local_comic_list_model.h" + +SortVolumeComics::SortVolumeComics(QWidget *parent) : + QWidget(parent) +{ + QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}"; + + QLabel * label = new QLabel(tr("Please, sort the list of comics info on the right until it matches your comics.")); + label->setStyleSheet(labelStylesheet); + + QLabel * sortLabel = new QLabel(tr("sort comic info to match your comic files")); + moveUpButton = new QPushButton; + moveDownButton = new QPushButton; + + QVBoxLayout * l = new QVBoxLayout; + QHBoxLayout * content = new QHBoxLayout; + QHBoxLayout * sortButtonsLayout = new QHBoxLayout; + + tableFiles = new ScrapperTableView(); + tableVolumeComics = new ScrapperTableView(); + + tableFiles->setFixedSize(407,341); + tableVolumeComics->setFixedSize(407,341); + content->addWidget(tableFiles,0,Qt::AlignLeft|Qt::AlignTop); + content->addWidget(tableVolumeComics,0,Qt::AlignRight|Qt::AlignTop); + //content->addWidget(tableVolumes,0,Qt::AlignRight|Qt::AlignTop); + + connect(tableVolumeComics->verticalScrollBar(), SIGNAL(valueChanged(int)), tableFiles->verticalScrollBar(), SLOT(setValue(int))); + + sortButtonsLayout->addStretch(); + sortButtonsLayout->addWidget(sortLabel); + sortButtonsLayout->addWidget(moveUpButton); + sortButtonsLayout->addWidget(moveDownButton); + + l->addSpacing(15); + l->addWidget(label); + l->addSpacing(5); + l->addLayout(content); + l->addLayout(sortButtonsLayout); + l->addStretch(); + + l->setContentsMargins(0,0,0,0); + setLayout(l); + setContentsMargins(0,0,0,0); +} + +void SortVolumeComics::setData(QList & comics, const QString &json) +{ + //set up models + localComicsModel = new LocalComicListModel; + localComicsModel->load(comics); + + tableFiles->setModel(localComicsModel); +} diff --git a/YACReaderLibrary/comic_vine/sort_volume_comics.h b/YACReaderLibrary/comic_vine/sort_volume_comics.h new file mode 100644 index 00000000..1534d6a2 --- /dev/null +++ b/YACReaderLibrary/comic_vine/sort_volume_comics.h @@ -0,0 +1,36 @@ +#ifndef SORT_VOLUME_COMICS_H +#define SORT_VOLUME_COMICS_H + +#include + +#include "comic_db.h" + +class ScrapperTableView; +class QPushButton; +class LocalComicListModel; +class VolumeComicsModel; + +class SortVolumeComics : public QWidget +{ + Q_OBJECT +public: + explicit SortVolumeComics(QWidget *parent = 0); + +signals: + +public slots: + void setData(QList & comics, const QString & json); + +private: + ScrapperTableView * tableFiles; + ScrapperTableView * tableVolumeComics; + + LocalComicListModel * localComicsModel; + VolumeComicsModel * volumeComicsModel; + + QPushButton * moveUpButton; + QPushButton * moveDownButton; + +}; + +#endif // SORT_VOLUME_COMICS_H diff --git a/common/comic_db.cpp b/common/comic_db.cpp index 06093f05..809b75d0 100644 --- a/common/comic_db.cpp +++ b/common/comic_db.cpp @@ -108,7 +108,12 @@ QString ComicDB::toTXT() return txt; } -QString ComicDB::getTitleOrPath() +QString ComicDB::getFileName() const +{ + return QFileInfo(path).fileName(); +} + +QString ComicDB::getTitleOrFileName() const { if(info.title && info.title->isEmpty()) return *(info.title); @@ -116,7 +121,7 @@ QString ComicDB::getTitleOrPath() return QFileInfo(path).fileName(); } -QString ComicDB::getParentFolderName() +QString ComicDB::getParentFolderName() const { QStringList paths = path.split('/'); if(paths.length()<2) diff --git a/common/comic_db.h b/common/comic_db.h index ffabc8e7..93c29b9e 100644 --- a/common/comic_db.h +++ b/common/comic_db.h @@ -132,11 +132,14 @@ public: bool hasCover() {return _hasCover;}; + //return comic file name + QString getFileName() const; + //returns comic title if it isn't null or empty, in other case returns fileName - QString getTitleOrPath(); + QString getTitleOrFileName() const; //returns parent folder name - QString getParentFolderName(); + QString getParentFolderName() const; QString toTXT();