Add search filter to card view window (#5791)

* refactor out search syntax help window

* add search bar to ZoneViewWidget

* implement filter logic
This commit is contained in:
RickyRister 2025-04-11 20:00:46 -07:00 committed by GitHub
parent ad06814ac7
commit 3b758962e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 116 additions and 40 deletions

View file

@ -1,7 +1,9 @@
#include "view_zone_widget.h"
#include "../../client/ui/pixel_map_generator.h"
#include "../../settings/cache_settings.h"
#include "../cards/card_item.h"
#include "../filters/syntax_help.h"
#include "../game_scene.h"
#include "../player/player.h"
#include "pb/command_shuffle.pb.h"
@ -41,9 +43,24 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
setFlag(ItemIgnoresTransformations);
QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);
vbox->setSpacing(2);
// If the number is < 0, then it means that we can give the option to make the area sorted
if (numberCards < 0) {
// search edit
searchEdit.setFocusPolicy(Qt::ClickFocus);
searchEdit.setPlaceholderText(tr("Search by card name (or search expressions)"));
searchEdit.setClearButtonEnabled(true);
searchEdit.addAction(loadColorAdjustedPixmap("theme:icons/search"), QLineEdit::LeadingPosition);
auto help = searchEdit.addAction(QPixmap("theme:icons/info"), QLineEdit::TrailingPosition);
connect(help, &QAction::triggered, this, [this] { createSearchSyntaxHelpWindow(&searchEdit); });
QGraphicsProxyWidget *searchEditProxy = new QGraphicsProxyWidget;
searchEditProxy->setWidget(&searchEdit);
searchEditProxy->setZValue(2000000007);
vbox->addItem(searchEditProxy);
// top row
QGraphicsLinearLayout *hTopRow = new QGraphicsLinearLayout(Qt::Horizontal);
@ -128,6 +145,8 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
if (CardList::NoSort == static_cast<CardList::SortOption>(groupBySelector.currentData().toInt())) {
pileViewCheckBox.setEnabled(false);
}
connect(&searchEdit, &QLineEdit::textChanged, zone, &ZoneViewZone::setFilterString);
}
setLayout(vbox);