[DeckEditor] Apply sort criteria inside custom zones and align display order with the model

This commit is contained in:
Lukas Brübach 2026-08-30 22:48:36 +02:00 committed by GitHub
parent 67ea3412f8
commit 6e92d53c54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 17 deletions

View file

@ -155,18 +155,6 @@ QWidget *CardGroupDisplayWidget::constructWidgetForIndex(QPersistentModelIndex i
void CardGroupDisplayWidget::updateCardDisplays()
{
// Custom zones are user-defined containers: they display their cards in the same
// order as the tree view, i.e. the model row order. Only criteria groups apply
// the visual sort criteria.
const bool isCustomZone = trackedIndex.data(DeckRoles::IsCustomZoneRole).toBool();
if (isCustomZone) {
for (int i = 0; i < deckListModel->rowCount(trackedIndex); ++i) {
addCardWidgets(QPersistentModelIndex(deckListModel->index(i, 0, trackedIndex)));
}
return;
}
DeckListSortFilterProxyModel proxy;
proxy.setSourceModel(deckListModel);
proxy.setSortCriteria(activeSortCriteria);

View file

@ -133,16 +133,12 @@ void DeckCardZoneDisplayWidget::displayCards()
}
// Iterate the direct children of the tracked zone, keeping the tree view's row
// order (criteria groups first, then custom zones in their creation order).
// order (criteria groups first, then custom zones, both in the model's sort order).
QList<QPersistentModelIndex> rows;
for (int i = 0; i < deckListModel->rowCount(trackedIndex); ++i) {
rows.append(QPersistentModelIndex(deckListModel->index(i, 0, trackedIndex)));
}
std::stable_partition(rows.begin(), rows.end(), [](const QPersistentModelIndex &row) {
return !row.data(DeckRoles::IsCustomZoneRole).toBool();
});
for (const QPersistentModelIndex &persistent : rows) {
constructAppropriateWidget(persistent);
}