[VDS] Use display name for generic search expression (#5976)

This commit is contained in:
RickyRister 2025-06-12 16:32:24 -07:00 committed by GitHub
parent 456da93465
commit 7495d2dc65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 7 deletions

View file

@ -4,9 +4,9 @@ The search bar recognizes a set of special commands.<br>
In this list of examples below, each entry has an explanation and can be clicked to test the query. Note that all
searches are case insensitive.
<dl>
<dt>Filename:</dt>
<dd>[red deck wins](#red deck wins) <small>(Any deck filename containing the words red, deck, and wins)</small></dd>
<dd>["red deck wins"](#%22red deck wins%22) <small>(Any deck filename containing the exact phrase "red deck wins")</small></dd>
<dt>Display Name (The deck name, or the filename if the deck name isn't set):</dt>
<dd>[red deck wins](#red deck wins) <small>(Any deck with a display name containing the words red, deck, and wins)</small></dd>
<dd>["red deck wins"](#%22red deck wins%22) <small>(Any deck with a display name containing the exact phrase "red deck wins")</small></dd>
<dt>Deck Contents (Uses [card search expressions](#cardSearchSyntaxHelp)):</dt>
<dd><a href="#[[plains]]">[[plains]]</a> <small>(Any deck that contains at least one card with "plains" in its name)</small></dd>

View file

@ -182,6 +182,15 @@ QString DeckPreviewWidget::getColorIdentity()
return colorIdentity;
}
/**
* The display name is given by the deck name, or the filename if the deck name is not set.
*/
QString DeckPreviewWidget::getDisplayName() const
{
return deckLoader->getName().isEmpty() ? QFileInfo(deckLoader->getLastFileName()).fileName()
: deckLoader->getName();
}
void DeckPreviewWidget::setFilePath(const QString &_filePath)
{
filePath = _filePath;
@ -193,8 +202,7 @@ void DeckPreviewWidget::setFilePath(const QString &_filePath)
*/
void DeckPreviewWidget::refreshBannerCardText()
{
bannerCardDisplayWidget->setOverlayText(
deckLoader->getName().isEmpty() ? QFileInfo(deckLoader->getLastFileName()).fileName() : deckLoader->getName());
bannerCardDisplayWidget->setOverlayText(getDisplayName());
refreshBannerCardToolTip();
}

View file

@ -27,6 +27,7 @@ public:
const QString &_filePath);
void retranslateUi();
QString getColorIdentity();
QString getDisplayName() const;
VisualDeckStorageWidget *visualDeckStorageWidget;
QVBoxLayout *layout;

View file

@ -131,8 +131,8 @@ static void setupParserRules()
search["GenericQuery"] = [](const peg::SemanticValues &sv) -> DeckFilter {
auto name = std::any_cast<QString>(sv[0]);
return [=](const DeckPreviewWidget *, const ExtraDeckSearchInfo &info) {
return info.fileSearchName.contains(name, Qt::CaseInsensitive);
return [=](const DeckPreviewWidget *deck, const ExtraDeckSearchInfo &) {
return deck->getDisplayName().contains(name, Qt::CaseInsensitive);
};
};
}