mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[DeckEditor] Apply sort criteria inside custom zones and align display order with the model
This commit is contained in:
parent
67ea3412f8
commit
6e92d53c54
2 changed files with 1 additions and 17 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue