mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-24 18:33:03 -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.
|
// 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;
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue