Add an edit for filtering series results returned by Comic Vine

This commit is contained in:
Luis Ángel San Martín 2022-08-18 16:22:07 +02:00
parent 8b4b586acc
commit 7df011e181
6 changed files with 45 additions and 8 deletions

View File

@ -30,6 +30,7 @@ Version counting is based on semantic versioning (Major.Feature.Patch)
* Add system info to the help/about dialog to help reporting bugs. * Add system info to the help/about dialog to help reporting bugs.
* Fix selection when clicking on a folder in search mode. * Fix selection when clicking on a folder in search mode.
* Fix defaul value for manga/comic mode in folders. * Fix defaul value for manga/comic mode in folders.
* Add an edit for filtering series results returned by Comic Vine.
## 9.8.2 ## 9.8.2
### YACReaderLibrary ### YACReaderLibrary

View File

@ -39,6 +39,13 @@ ComicVineDialog::ComicVineDialog(QWidget *parent)
doConnections(); doConnections();
} }
void ComicVineDialog::closeEvent(QCloseEvent *event)
{
QDialog::closeEvent(event);
clearState();
}
void ComicVineDialog::doLayout() void ComicVineDialog::doLayout()
{ {
setStyleSheet("" setStyleSheet(""
@ -117,6 +124,8 @@ void ComicVineDialog::doConnections()
void ComicVineDialog::goNext() void ComicVineDialog::goNext()
{ {
clearState();
// //
if (content->currentWidget() == seriesQuestionWidget) { if (content->currentWidget() == seriesQuestionWidget) {
if (seriesQuestionWidget->getYes()) { if (seriesQuestionWidget->getYes()) {
@ -167,6 +176,8 @@ void ComicVineDialog::goNext()
void ComicVineDialog::goBack() void ComicVineDialog::goBack()
{ {
clearState();
switch (status) { switch (status) {
case SelectingSeries: case SelectingSeries:
if (mode == Volume) if (mode == Volume)
@ -722,6 +733,11 @@ void ComicVineDialog::goToNextComic()
titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex + 1).arg(comics.length()).arg(title)); titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex + 1).arg(comics.length()).arg(title));
} }
void ComicVineDialog::clearState()
{
selectVolumeWidget->clearFilter();
}
void ComicVineDialog::showLoading(const QString &message) void ComicVineDialog::showLoading(const QString &message)
{ {
content->setCurrentIndex(0); content->setCurrentIndex(0);

View File

@ -33,7 +33,7 @@ public:
QSize minimumSizeHint() const override; QSize minimumSizeHint() const override;
void getComicsInfo(QList<QPair<ComicDB, QString>> matchingInfo, int count, const QString &publisher); void getComicsInfo(QList<QPair<ComicDB, QString>> matchingInfo, int count, const QString &publisher);
void getComicInfo(const QString &comicId, int count, const QString &publisher); void getComicInfo(const QString &comicId, int count, const QString &publisher);
void closeEvent(QCloseEvent *event) override;
signals: signals:
public slots: public slots:
@ -63,6 +63,7 @@ protected slots:
void goToNextComic(); void goToNextComic();
private: private:
void clearState();
QString getCharacters(const QVariant &json_characters); QString getCharacters(const QVariant &json_characters);
QMultiMap<QString, QString> getAuthors(const QVariant &json_authors); QMultiMap<QString, QString> getAuthors(const QVariant &json_authors);
QPair<QString, QString> getFirstStoryArcIdAndName(const QVariant &json_story_arcs); QPair<QString, QString> getFirstStoryArcIdAndName(const QVariant &json_story_arcs);

View File

@ -12,8 +12,10 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QToolButton> #include <QToolButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QAction>
#include "scraper_tableview.h" #include "scraper_tableview.h"
#include "scraper_lineedit.h"
#include "volumes_model.h" #include "volumes_model.h"
#include "comic_vine_client.h" #include "comic_vine_client.h"
@ -26,6 +28,7 @@ SelectVolume::SelectVolume(QWidget *parent)
: ScraperSelector(parent), model(0) : ScraperSelector(parent), model(0)
{ {
proxyModel = new QSortFilterProxyModel; proxyModel = new QSortFilterProxyModel;
proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}"; QString labelStylesheet = "QLabel {color:white; font-size:12px;font-family:Arial;}";
@ -36,6 +39,7 @@ SelectVolume::SelectVolume(QWidget *parent)
QWidget *leftWidget = new QWidget; QWidget *leftWidget = new QWidget;
auto left = new QVBoxLayout; auto left = new QVBoxLayout;
auto content = new QGridLayout; auto content = new QGridLayout;
auto top = new QHBoxLayout;
// widgets // widgets
cover = new QLabel(); cover = new QLabel();
@ -47,12 +51,14 @@ SelectVolume::SelectVolume(QWidget *parent)
tableVolumes = new ScraperTableView(); tableVolumes = new ScraperTableView();
tableVolumes->setSortingEnabled(true); tableVolumes->setSortingEnabled(true);
#if QT_VERSION >= 0x050000
tableVolumes->horizontalHeader()->setSectionsClickable(true); tableVolumes->horizontalHeader()->setSectionsClickable(true);
#else
tableVolumes->horizontalHeader()->setClickable(true); filterEdit = new ScraperLineEdit(tr("Filter:"));
#endif filterEdit->setMaximumWidth(200);
// tableVolumes->horizontalHeader()->setSortIndicatorShown(false); filterEdit->setClearButtonEnabled(true);
connect(filterEdit, &QLineEdit::textChanged, proxyModel, &QSortFilterProxyModel::setFilterFixedString);
connect(tableVolumes->horizontalHeader(), &QHeaderView::sectionClicked, connect(tableVolumes->horizontalHeader(), &QHeaderView::sectionClicked,
[=](int index) { tableVolumes->horizontalHeader()->sortIndicatorSection() == index ? tableVolumes->sortByColumn(index, tableVolumes->horizontalHeader()->sortIndicatorOrder() == Qt::AscendingOrder ? Qt::DescendingOrder : Qt::AscendingOrder) [=](int index) { tableVolumes->horizontalHeader()->sortIndicatorSection() == index ? tableVolumes->sortByColumn(index, tableVolumes->horizontalHeader()->sortIndicatorOrder() == Qt::AscendingOrder ? Qt::DescendingOrder : Qt::AscendingOrder)
: tableVolumes->sortByColumn(index, Qt::AscendingOrder); }); : tableVolumes->sortByColumn(index, Qt::AscendingOrder); });
@ -61,6 +67,10 @@ SelectVolume::SelectVolume(QWidget *parent)
paginator->setCustomLabel(tr("volumes")); paginator->setCustomLabel(tr("volumes"));
top->addWidget(label);
top->addStretch();
top->addWidget(filterEdit);
left->addWidget(cover); left->addWidget(cover);
left->addWidget(detailLabel, 1); left->addWidget(detailLabel, 1);
leftWidget->setMaximumWidth(180); leftWidget->setMaximumWidth(180);
@ -76,7 +86,7 @@ SelectVolume::SelectVolume(QWidget *parent)
content->setRowStretch(0, 1); content->setRowStretch(0, 1);
l->addSpacing(15); l->addSpacing(15);
l->addWidget(label); l->addLayout(top);
l->addSpacing(5); l->addSpacing(5);
l->addLayout(content); l->addLayout(content);
@ -111,6 +121,11 @@ void SelectVolume::load(const QString &json, const QString &searchString)
ScraperSelector::load(json, searchString); ScraperSelector::load(json, searchString);
} }
void SelectVolume::clearFilter()
{
filterEdit->clear();
}
SelectVolume::~SelectVolume() { } SelectVolume::~SelectVolume() { }
void SelectVolume::loadVolumeInfo(const QModelIndex &omi) void SelectVolume::loadVolumeInfo(const QModelIndex &omi)

View File

@ -11,6 +11,7 @@ class QSortFilterProxyModel;
class ScraperScrollLabel; class ScraperScrollLabel;
class ScraperTableView; class ScraperTableView;
class ScraperLineEdit;
class SelectVolume : public ScraperSelector class SelectVolume : public ScraperSelector
{ {
@ -18,6 +19,7 @@ class SelectVolume : public ScraperSelector
public: public:
SelectVolume(QWidget *parent = nullptr); SelectVolume(QWidget *parent = nullptr);
void load(const QString &json, const QString &searchString) override; void load(const QString &json, const QString &searchString) override;
void clearFilter();
virtual ~SelectVolume(); virtual ~SelectVolume();
public slots: public slots:
@ -34,6 +36,7 @@ private:
ScraperTableView *tableVolumes; ScraperTableView *tableVolumes;
VolumesModel *model; VolumesModel *model;
QSortFilterProxyModel *proxyModel; QSortFilterProxyModel *proxyModel;
ScraperLineEdit *filterEdit;
}; };
#endif // SELECT_VOLUME_H #endif // SELECT_VOLUME_H

View File

@ -69,7 +69,8 @@ YACReader::WhatsNewDialog::WhatsNewDialog(QWidget *parent)
" &#8226; Use a scale effect in the comics grids on mouse over.<br/>" " &#8226; Use a scale effect in the comics grids on mouse over.<br/>"
" &#8226; Fix selection when clicking on a folder in search mode.<br/>" " &#8226; Fix selection when clicking on a folder in search mode.<br/>"
" &#8226; Add system info to the help/about dialog to help reporting bugs.<br/>" " &#8226; Add system info to the help/about dialog to help reporting bugs.<br/>"
" &#8226; Fix defaul value for manga/comic mode in folders..<br/>" " &#8226; Fix defaul value for manga/comic mode in folders.<br/>"
" &#8226; Add an edit for filtering series results returned by Comic Vine.<br/>"
"<br/>" "<br/>"
"I hope you enjoy the new update. Please, if you like YACReader consider to become a patron in <a href=\"https://www.patreon.com/yacreader\" style=\"color:#E8B800;\">Patreon</a> or donate some money using <a href=\"https://www.paypal.com/donate?business=5TAMNQCDDMVP8&item_name=Support+YACReader\" style=\"color:#E8B800;\">Pay-Pal</a> and help keeping the project alive. Remember that there is an iOS version available in the <a href=\"https://apps.apple.com/app/id635717885\" style=\"color:#E8B800;\">Apple App Store</a>."); "I hope you enjoy the new update. Please, if you like YACReader consider to become a patron in <a href=\"https://www.patreon.com/yacreader\" style=\"color:#E8B800;\">Patreon</a> or donate some money using <a href=\"https://www.paypal.com/donate?business=5TAMNQCDDMVP8&item_name=Support+YACReader\" style=\"color:#E8B800;\">Pay-Pal</a> and help keeping the project alive. Remember that there is an iOS version available in the <a href=\"https://apps.apple.com/app/id635717885\" style=\"color:#E8B800;\">Apple App Store</a>.");
QFont textLabelFont("Arial", 15, QFont::Light); QFont textLabelFont("Arial", 15, QFont::Light);