mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
Fix deck export and mana group ordering (#7729)
This commit is contained in:
parent
2056043104
commit
ca2301bc96
8 changed files with 113 additions and 10 deletions
|
|
@ -39,6 +39,7 @@
|
|||
#include <QTextTableFormat>
|
||||
#include <QVector>
|
||||
#include <QtConcurrentRun>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/card/import/card_name_normalizer.h>
|
||||
|
|
@ -372,8 +373,12 @@ bool DeckLoader::saveToStream_Plain(QTextStream &out,
|
|||
saveToStream_DeckHeader(out, deckList);
|
||||
}
|
||||
|
||||
// loop zones
|
||||
for (auto zoneNode : deckList.getZoneNodes()) {
|
||||
// Plain deck readers expect the main deck before the sideboard. Reorder a
|
||||
// copy so native saves and the relative order of other zones stay intact.
|
||||
auto zones = deckList.getZoneNodes();
|
||||
std::stable_partition(zones.begin(), zones.end(),
|
||||
[](const auto *zone) { return zone->getName() == DECK_ZONE_MAIN; });
|
||||
for (auto zoneNode : zones) {
|
||||
saveToStream_DeckZone(out, zoneNode, addComments, addSetNameAndNumber);
|
||||
|
||||
// end of zone
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ DeckCardZoneDisplayWidget::DeckCardZoneDisplayWidget(QWidget *parent,
|
|||
updateZoneCardCount();
|
||||
|
||||
connect(deckListModel, &QAbstractItemModel::rowsInserted, this, &DeckCardZoneDisplayWidget::onCategoryAddition);
|
||||
connect(deckListModel, &QAbstractItemModel::layoutChanged, this, &DeckCardZoneDisplayWidget::displayCards);
|
||||
if (selectionModel) {
|
||||
connect(selectionModel, &QItemSelectionModel::selectionChanged, this,
|
||||
&DeckCardZoneDisplayWidget::onSelectionChanged);
|
||||
|
|
@ -174,6 +175,9 @@ void DeckCardZoneDisplayWidget::displayCards()
|
|||
|
||||
for (const QPersistentModelIndex &persistent : rows) {
|
||||
constructAppropriateWidget(persistent);
|
||||
// Reuse existing widgets when a model sort moves their persistent rows.
|
||||
// This preserves collapsed groups and card selection during live edits.
|
||||
cardGroupLayout->insertWidget(persistent.row(), indexToWidgetMap.value(persistent));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue