mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 00:12:15 -07:00
implement filter logic
This commit is contained in:
parent
caae0c8e10
commit
6ef8537d5d
3 changed files with 21 additions and 1 deletions
|
|
@ -148,7 +148,16 @@ void ZoneViewZone::updateCardIds(CardAction action)
|
||||||
// Because of boundingRect(), this function must not be called before the zone was added to a scene.
|
// Because of boundingRect(), this function must not be called before the zone was added to a scene.
|
||||||
void ZoneViewZone::reorganizeCards()
|
void ZoneViewZone::reorganizeCards()
|
||||||
{
|
{
|
||||||
CardList cardsToDisplay(cards);
|
// filter cards
|
||||||
|
CardList cardsToDisplay = CardList(cards.getContentsKnown());
|
||||||
|
for (auto card : cards) {
|
||||||
|
if (filterString.check(card->getInfo())) {
|
||||||
|
card->show();
|
||||||
|
cardsToDisplay.append(card);
|
||||||
|
} else {
|
||||||
|
card->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// sort cards
|
// sort cards
|
||||||
QList<CardList::SortOption> sortOptions;
|
QList<CardList::SortOption> sortOptions;
|
||||||
|
|
@ -263,6 +272,12 @@ ZoneViewZone::GridSize ZoneViewZone::positionCardsForDisplay(CardList &cards, Ca
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZoneViewZone::setFilterString(const QString &_filterString)
|
||||||
|
{
|
||||||
|
filterString = FilterString(_filterString);
|
||||||
|
reorganizeCards();
|
||||||
|
}
|
||||||
|
|
||||||
void ZoneViewZone::setGroupBy(CardList::SortOption _groupBy)
|
void ZoneViewZone::setGroupBy(CardList::SortOption _groupBy)
|
||||||
{
|
{
|
||||||
groupBy = _groupBy;
|
groupBy = _groupBy;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef ZONEVIEWERZONE_H
|
#ifndef ZONEVIEWERZONE_H
|
||||||
#define ZONEVIEWERZONE_H
|
#define ZONEVIEWERZONE_H
|
||||||
|
|
||||||
|
#include "../filters/filter_string.h"
|
||||||
#include "select_zone.h"
|
#include "select_zone.h"
|
||||||
|
|
||||||
#include <QGraphicsLayoutItem>
|
#include <QGraphicsLayoutItem>
|
||||||
|
|
@ -35,6 +36,7 @@ private:
|
||||||
int minRows, numberCards;
|
int minRows, numberCards;
|
||||||
CardZone *origZone;
|
CardZone *origZone;
|
||||||
bool revealZone, writeableRevealZone;
|
bool revealZone, writeableRevealZone;
|
||||||
|
FilterString filterString = FilterString("");
|
||||||
CardList::SortOption groupBy, sortBy;
|
CardList::SortOption groupBy, sortBy;
|
||||||
bool pileView;
|
bool pileView;
|
||||||
bool isReversed;
|
bool isReversed;
|
||||||
|
|
@ -96,6 +98,7 @@ public:
|
||||||
}
|
}
|
||||||
public slots:
|
public slots:
|
||||||
void close();
|
void close();
|
||||||
|
void setFilterString(const QString &_filterString);
|
||||||
void setGroupBy(CardList::SortOption _groupBy);
|
void setGroupBy(CardList::SortOption _groupBy);
|
||||||
void setSortBy(CardList::SortOption _sortBy);
|
void setSortBy(CardList::SortOption _sortBy);
|
||||||
void setPileView(int _pileView);
|
void setPileView(int _pileView);
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,8 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
|
||||||
if (CardList::NoSort == static_cast<CardList::SortOption>(groupBySelector.currentData().toInt())) {
|
if (CardList::NoSort == static_cast<CardList::SortOption>(groupBySelector.currentData().toInt())) {
|
||||||
pileViewCheckBox.setEnabled(false);
|
pileViewCheckBox.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(&searchEdit, &QLineEdit::textChanged, zone, &ZoneViewZone::setFilterString);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLayout(vbox);
|
setLayout(vbox);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue