mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[VDS] Address second round of review nits
This commit is contained in:
parent
8d28a393d7
commit
45fec7fc74
2 changed files with 10 additions and 10 deletions
|
|
@ -54,15 +54,12 @@ void VisualDeckStorageTagFilterWidget::refreshTags()
|
|||
}
|
||||
|
||||
// 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) {
|
||||
bool tagExists = false;
|
||||
for (DeckPreviewTagDisplayWidget *tagWidget : chips) {
|
||||
if (tagWidget->getTagName() == tag) {
|
||||
tagExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!tagExists) {
|
||||
if (!existingTags.contains(tag)) {
|
||||
auto *newTagWidget = new DeckPreviewTagDisplayWidget(this, tag);
|
||||
connect(newTagWidget, &DeckPreviewTagDisplayWidget::tagClicked, this,
|
||||
&VisualDeckStorageTagFilterWidget::filterChanged);
|
||||
|
|
@ -75,7 +72,10 @@ void VisualDeckStorageTagFilterWidget::refreshTags()
|
|||
// 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.
|
||||
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) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ signals:
|
|||
* Emitted when a chip's selection or exclusion state changes.
|
||||
*
|
||||
* 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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue