mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 02:53:56 -07:00
[VDD] Saner and more performant color filtering, allow deleting specific filter from filterTree (#5863)
* Saner and more performant color filtering. * Update visual_database_display_color_filter_widget.cpp --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de> Co-authored-by: Zach H <zahalpern+github@gmail.com>
This commit is contained in:
parent
795149e776
commit
acd9a163f0
8 changed files with 198 additions and 130 deletions
|
|
@ -531,6 +531,31 @@ void FilterTree::removeFiltersByAttr(CardFilter::Attr filterType)
|
|||
}
|
||||
}
|
||||
|
||||
void FilterTree::removeFilter(const CardFilter *toRemove)
|
||||
{
|
||||
for (int i = childNodes.size() - 1; i >= 0; --i) {
|
||||
auto *logicMap = dynamic_cast<LogicMap *>(childNodes.at(i));
|
||||
if (!logicMap || logicMap->attr != toRemove->attr())
|
||||
continue;
|
||||
|
||||
FilterItemList *typeList = logicMap->typeList(toRemove->type());
|
||||
if (!typeList)
|
||||
continue;
|
||||
|
||||
int termIdx = typeList->termIndex(toRemove->term());
|
||||
if (termIdx != -1) {
|
||||
typeList->deleteAt(termIdx);
|
||||
emit typeList->nodeChanged();
|
||||
if (typeList->childCount() == 0) {
|
||||
int logicIndex = logicMap->childIndex(typeList);
|
||||
if (logicIndex != -1) {
|
||||
logicMap->deleteAt(logicIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FilterTree::clear()
|
||||
{
|
||||
while (childCount() > 0) {
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@ public:
|
|||
|
||||
bool acceptsCard(CardInfoPtr info) const;
|
||||
void removeFiltersByAttr(CardFilter::Attr filterType);
|
||||
void removeFilter(const CardFilter *toRemove);
|
||||
void clear();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,13 @@ void FilterTreeModel::addFilter(const CardFilter *f)
|
|||
emit layoutChanged();
|
||||
}
|
||||
|
||||
void FilterTreeModel::removeFilter(const CardFilter *f)
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
fTree->removeFilter(f);
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
void FilterTreeModel::clearFiltersOfType(CardFilter::Attr filterType)
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ private:
|
|||
|
||||
public slots:
|
||||
void addFilter(const CardFilter *f);
|
||||
void removeFilter(const CardFilter *f);
|
||||
void clearFiltersOfType(CardFilter::Attr filterType);
|
||||
QList<const CardFilter *> getFiltersOfType(CardFilter::Attr filterType) const;
|
||||
QList<const CardFilter *> allFilters() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue