mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-17 07:52:16 -07:00
implement search expressions
This commit is contained in:
parent
7e08f7df67
commit
c4f7a16712
1 changed files with 27 additions and 1 deletions
|
|
@ -12,7 +12,7 @@ QueryPartList <- ComplexQueryPart ( ws ("AND" ws)? ComplexQueryPart)* ws*
|
||||||
ComplexQueryPart <- SomewhatComplexQueryPart ws "OR" ws ComplexQueryPart / SomewhatComplexQueryPart
|
ComplexQueryPart <- SomewhatComplexQueryPart ws "OR" ws ComplexQueryPart / SomewhatComplexQueryPart
|
||||||
SomewhatComplexQueryPart <- [(] QueryPartList [)] / QueryPart
|
SomewhatComplexQueryPart <- [(] QueryPartList [)] / QueryPart
|
||||||
|
|
||||||
QueryPart <- NotQuery / DeckContentQuery / GenericQuery
|
QueryPart <- NotQuery / DeckContentQuery / DeckNameQuery / FileNameQuery / PathQuery / GenericQuery
|
||||||
|
|
||||||
NotQuery <- ('NOT' ws/'-') SomewhatComplexQueryPart
|
NotQuery <- ('NOT' ws/'-') SomewhatComplexQueryPart
|
||||||
|
|
||||||
|
|
@ -20,6 +20,10 @@ DeckContentQuery <- CardSearch NumericExpression?
|
||||||
CardSearch <- '[[' CardFilterString ']]'
|
CardSearch <- '[[' CardFilterString ']]'
|
||||||
CardFilterString <- (!']]'.)*
|
CardFilterString <- (!']]'.)*
|
||||||
|
|
||||||
|
DeckNameQuery <- ([Dd] 'eck')? [Nn] 'ame'? [:] String
|
||||||
|
FileNameQuery <- [Ff] ('ile' 'name'?)? [:] String
|
||||||
|
PathQuery <- [Pp] 'ath'? [:] String
|
||||||
|
|
||||||
GenericQuery <- String
|
GenericQuery <- String
|
||||||
|
|
||||||
NonDoubleQuoteUnlessEscaped <- '\\\"'. / !["].
|
NonDoubleQuoteUnlessEscaped <- '\\\"'. / !["].
|
||||||
|
|
@ -129,6 +133,28 @@ static void setupParserRules()
|
||||||
return QString::fromStdString(std::string(sv.sv()));
|
return QString::fromStdString(std::string(sv.sv()));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
search["DeckNameQuery"] = [](const peg::SemanticValues &sv) -> DeckFilter {
|
||||||
|
auto name = std::any_cast<QString>(sv[0]);
|
||||||
|
return [=](const DeckPreviewWidget *deck, const ExtraDeckSearchInfo &) {
|
||||||
|
return deck->deckLoader->getName().contains(name, Qt::CaseInsensitive);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
search["FileNameQuery"] = [](const peg::SemanticValues &sv) -> DeckFilter {
|
||||||
|
auto name = std::any_cast<QString>(sv[0]);
|
||||||
|
return [=](const DeckPreviewWidget *deck, const ExtraDeckSearchInfo &) {
|
||||||
|
auto filename = QFileInfo(deck->filePath).fileName();
|
||||||
|
return filename.contains(name, Qt::CaseInsensitive);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
search["PathQuery"] = [](const peg::SemanticValues &sv) -> DeckFilter {
|
||||||
|
auto name = std::any_cast<QString>(sv[0]);
|
||||||
|
return [=](const DeckPreviewWidget *, const ExtraDeckSearchInfo &info) {
|
||||||
|
return info.relativeFilePath.contains(name, Qt::CaseInsensitive);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
search["GenericQuery"] = [](const peg::SemanticValues &sv) -> DeckFilter {
|
search["GenericQuery"] = [](const peg::SemanticValues &sv) -> DeckFilter {
|
||||||
auto name = std::any_cast<QString>(sv[0]);
|
auto name = std::any_cast<QString>(sv[0]);
|
||||||
return [=](const DeckPreviewWidget *deck, const ExtraDeckSearchInfo &) {
|
return [=](const DeckPreviewWidget *deck, const ExtraDeckSearchInfo &) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue