[VDS] Address second round of review nits

This commit is contained in:
Lukas Brübach 2026-09-20 19:14:25 +02:00 • committed by GitHub
parent 8d28a393d7
commit 45fec7fc74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 10 deletions

View file

@ -54,15 +54,12 @@ void VisualDeckStorageTagFilterWidget::refreshTags()
} }
// Add chips for tags that are not shown yet. // Add chips for tags that are not shown yet.
QSet<QString> existingTags;
for (DeckPreviewTagDisplayWidget *tagWidget : chips) {
existingTags.insert(tagWidget->getTagName());
}
for (const QString &tag : allTags) { for (const QString &tag : allTags) {
bool tagExists = false; if (!existingTags.contains(tag)) {
for (DeckPreviewTagDisplayWidget *tagWidget : chips) {
if (tagWidget->getTagName() == tag) {
tagExists = true;
break;
}
}
if (!tagExists) {
auto *newTagWidget = new DeckPreviewTagDisplayWidget(this, tag); auto *newTagWidget = new DeckPreviewTagDisplayWidget(this, tag);
connect(newTagWidget, &DeckPreviewTagDisplayWidget::tagClicked, this, connect(newTagWidget, &DeckPreviewTagDisplayWidget::tagClicked, this,
&VisualDeckStorageTagFilterWidget::filterChanged); &VisualDeckStorageTagFilterWidget::filterChanged);
@ -75,7 +72,10 @@ void VisualDeckStorageTagFilterWidget::refreshTags()
// FlowWidget inherits QLayout::removeWidget's linear scan, so rebuilding an unchanged // FlowWidget inherits QLayout::removeWidget's linear scan, so rebuilding an unchanged
// order would be quadratic plus a full relayout on every chip click and load batch. // order would be quadratic plus a full relayout on every chip click and load batch.
std::sort(chips.begin(), chips.end(), [](DeckPreviewTagDisplayWidget *a, DeckPreviewTagDisplayWidget *b) { std::sort(chips.begin(), chips.end(), [](DeckPreviewTagDisplayWidget *a, DeckPreviewTagDisplayWidget *b) {
return a->getTagName().toLower() < b->getTagName().toLower(); const QString aName = a->getTagName();
const QString bName = b->getTagName();
const int compared = aName.compare(bName, Qt::CaseInsensitive);
return compared != 0 ? compared < 0 : aName < bName;
}); });
if (chips == currentChipOrder) { if (chips == currentChipOrder) {
return; return;

View file

@ -46,7 +46,7 @@ signals:
* Emitted when a chip's selection or exclusion state changes. * Emitted when a chip's selection or exclusion state changes.
* *
* The chip only emits when its state actually changed, so this fires once per * The chip only emits when its state actually changed, so this fires once per
* effective toggle rather than on every click." * effective toggle rather than on every click.
*/ */
void filterChanged(); void filterChanged();