mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-15 15:02:16 -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()
|
void VisualDeckStorageTagFilterWidget::refreshTags()
|
||||||
{
|
{
|
||||||
QStringList allTags = gatherAllTags();
|
QSet<QString> allTags = gatherAllTags();
|
||||||
removeTagsNotInList(allTags);
|
removeTagsNotInList(allTags);
|
||||||
addTagsIfNotPresent(allTags);
|
addTagsIfNotPresent(allTags);
|
||||||
sortTags();
|
sortTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualDeckStorageTagFilterWidget::removeTagsNotInList(const QStringList &tags)
|
void VisualDeckStorageTagFilterWidget::removeTagsNotInList(const QSet<QString> &tags)
|
||||||
{
|
{
|
||||||
// Iterate through all DeckPreviewTagDisplayWidgets
|
// Iterate through all DeckPreviewTagDisplayWidgets
|
||||||
for (DeckPreviewTagDisplayWidget *tagWidget : findChildren<DeckPreviewTagDisplayWidget *>()) {
|
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) {
|
for (const QString &tag : tags) {
|
||||||
addTagIfNotPresent(tag);
|
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 *>();
|
QList<DeckPreviewWidget *> deckWidgets = parent->findChildren<DeckPreviewWidget *>();
|
||||||
|
|
||||||
for (DeckPreviewWidget *widget : deckWidgets) {
|
for (DeckPreviewWidget *widget : deckWidgets) {
|
||||||
if (widget->checkVisibility()) {
|
if (widget->checkVisibility()) {
|
||||||
allTags << widget->deckLoader->getTags();
|
for (const QString &tag : widget->deckLoader->getTags()) {
|
||||||
|
allTags.insert(tag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return allTags;
|
return allTags;
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ class VisualDeckStorageTagFilterWidget : public QWidget
|
||||||
|
|
||||||
VisualDeckStorageWidget *parent;
|
VisualDeckStorageWidget *parent;
|
||||||
|
|
||||||
QStringList gatherAllTags() const;
|
QSet<QString> gatherAllTags() const;
|
||||||
void removeTagsNotInList(const QStringList &tags);
|
void removeTagsNotInList(const QSet<QString> &tags);
|
||||||
void addTagsIfNotPresent(const QStringList &tags);
|
void addTagsIfNotPresent(const QSet<QString> &tags);
|
||||||
void addTagIfNotPresent(const QString &tag);
|
void addTagIfNotPresent(const QString &tag);
|
||||||
void sortTags();
|
void sortTags();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue