mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 22:42:14 -07:00
use QSet instead of QStringList
This commit is contained in:
parent
99fb1b4690
commit
86ed7c1188
2 changed files with 11 additions and 9 deletions
|
|
@ -64,13 +64,13 @@ void VisualDeckStorageTagFilterWidget::filterDecksBySelectedTags(const QList<Dec
|
|||
|
||||
void VisualDeckStorageTagFilterWidget::refreshTags()
|
||||
{
|
||||
QStringList allTags = gatherAllTags();
|
||||
QSet<QString> allTags = gatherAllTags();
|
||||
removeTagsNotInList(allTags);
|
||||
addTagsIfNotPresent(allTags);
|
||||
sortTags();
|
||||
}
|
||||
|
||||
void VisualDeckStorageTagFilterWidget::removeTagsNotInList(const QStringList &tags)
|
||||
void VisualDeckStorageTagFilterWidget::removeTagsNotInList(const QSet<QString> &tags)
|
||||
{
|
||||
// Iterate through all DeckPreviewTagDisplayWidgets
|
||||
for (DeckPreviewTagDisplayWidget *tagWidget : findChildren<DeckPreviewTagDisplayWidget *>()) {
|
||||
|
|
@ -83,7 +83,7 @@ void VisualDeckStorageTagFilterWidget::removeTagsNotInList(const QStringList &ta
|
|||
}
|
||||
}
|
||||
|
||||
void VisualDeckStorageTagFilterWidget::addTagsIfNotPresent(const QStringList &tags)
|
||||
void VisualDeckStorageTagFilterWidget::addTagsIfNotPresent(const QSet<QString> &tags)
|
||||
{
|
||||
for (const QString &tag : tags) {
|
||||
addTagIfNotPresent(tag);
|
||||
|
|
@ -136,14 +136,16 @@ void VisualDeckStorageTagFilterWidget::sortTags()
|
|||
}
|
||||
}
|
||||
|
||||
QStringList VisualDeckStorageTagFilterWidget::gatherAllTags() const
|
||||
QSet<QString> VisualDeckStorageTagFilterWidget::gatherAllTags() const
|
||||
{
|
||||
QStringList allTags;
|
||||
QSet<QString> allTags;
|
||||
QList<DeckPreviewWidget *> deckWidgets = parent->findChildren<DeckPreviewWidget *>();
|
||||
|
||||
for (DeckPreviewWidget *widget : deckWidgets) {
|
||||
if (widget->checkVisibility()) {
|
||||
allTags << widget->deckLoader->getTags();
|
||||
for (const QString &tag : widget->deckLoader->getTags()) {
|
||||
allTags.insert(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
return allTags;
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ class VisualDeckStorageTagFilterWidget : public QWidget
|
|||
|
||||
VisualDeckStorageWidget *parent;
|
||||
|
||||
QStringList gatherAllTags() const;
|
||||
void removeTagsNotInList(const QStringList &tags);
|
||||
void addTagsIfNotPresent(const QStringList &tags);
|
||||
QSet<QString> gatherAllTags() const;
|
||||
void removeTagsNotInList(const QSet<QString> &tags);
|
||||
void addTagsIfNotPresent(const QSet<QString> &tags);
|
||||
void addTagIfNotPresent(const QString &tag);
|
||||
void sortTags();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue