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.
* Fix selection when clicking on a folder in search mode.
* Fix defaul value for manga/comic mode in folders.
* Add an edit for filtering series results returned by Comic Vine.
## 9.8.2
### YACReaderLibrary

View File

@ -39,6 +39,13 @@ ComicVineDialog::ComicVineDialog(QWidget *parent)
doConnections();
}
void ComicVineDialog::closeEvent(QCloseEvent *event)
{
QDialog::closeEvent(event);
clearState();
}
void ComicVineDialog::doLayout()
{
setStyleSheet(""
@ -117,6 +124,8 @@ void ComicVineDialog::doConnections()
void ComicVineDialog::goNext()
{
clearState();
//
if (content->currentWidget() == seriesQuestionWidget) {
if (seriesQuestionWidget->getYes()) {
@ -167,6 +176,8 @@ void ComicVineDialog::goNext()
void ComicVineDialog::goBack()
{
clearState();
switch (status) {
case SelectingSeries:
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));
}
void ComicVineDialog::clearState()
{
selectVolumeWidget->clearFilter();
}
void ComicVineDialog::showLoading(const QString &message)
{
content->setCurrentIndex(0);

View File

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

View File

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

View File

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