mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-22 17:45:09 -07:00
[Client] Expose custom zone management in the deck editor (#7205)
* [Client] Expose custom zone management in the deck editor Wires the state layer into every editor surface that shows deck zones. - Deck dock: context menu on zones gains New/Rename/Delete/Change board actions, with per-zone submenus for adding cards. - Card database dock and visual database display gain an add-to-zone submenu listing custom zones per board plus a create-zone entry. - All prompt call sites pass validateNewZoneName so duplicates and reserved names are rejected inline before Ok unlocks. - Rename reuses the same dialog in name-only mode, keeping one validation contract for every zone-name entry point. - Change board marks the current board instead of offering a no-op, and the state layer refuses moves onto boards holding a same-named zone from imported decks. * [DeckEditor] Address custom-zone menu and export review feedback * [DeckLoader] Keep the sideboard marker and block ordering when exporting nested zones - saveToStream_DeckZone threads the owning board zone name down to the card writer, so cards in a custom zone under the sideboard keep their SB: prefix instead of being re-imported into the maindeck - nested sub-zones are collected during the loop and written after the parent zone's own header and cards, so they no longer read as part of the zone printed before them * [DeckEditor] Fix move-to-zone menu use-after-free and per-zone enabled state - resolve the card name/provider/collector number before createNewCustomZone rebuilds the model tree, then re-find the refreshed index via findCard and move it (mirrors the decrementCard re-find pattern) - the enabled test now compares the card's own zone (nearest custom-zone ancestor, else its board), matching moveCardToZone's lookup, so moving a card out of a custom zone back to the board root is offered and the card's own zone is disabled --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
9677fad342
commit
0d09e633e3
12 changed files with 418 additions and 17 deletions
|
|
@ -21,6 +21,7 @@
|
|||
#include <libcockatrice/card/card_info_comparator.h>
|
||||
#include <libcockatrice/card/database/card_database.h>
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/deck_list/tree/inner_deck_list_node.h>
|
||||
#include <libcockatrice/settings/cards_display_settings.h>
|
||||
#include <utility>
|
||||
|
||||
|
|
@ -89,6 +90,19 @@ VisualDatabaseDisplayWidget::VisualDatabaseDisplayWidget(QWidget *parent,
|
|||
databaseView->setItemDelegate(nullptr);
|
||||
databaseView->setVisible(false);
|
||||
|
||||
// Without a deck model there is nothing to add cards to, so the zone menu stays hidden.
|
||||
if (deckListModel) {
|
||||
databaseView->setZoneMenuProvider(
|
||||
[deckListModel]() -> QList<QPair<QString, QStringList>> {
|
||||
QList<QPair<QString, QStringList>> result;
|
||||
for (const QString &boardName : InnerDecklistNode::boardZoneNames()) {
|
||||
result.append({boardName, deckListModel->getCustomZoneNames(boardName)});
|
||||
}
|
||||
return result;
|
||||
},
|
||||
[this] { return newZoneCreator ? newZoneCreator() : QString(); });
|
||||
}
|
||||
|
||||
searchEdit->setTreeView(databaseView);
|
||||
searchEdit->installEventFilter(databaseView->getKeySignals());
|
||||
|
||||
|
|
@ -195,6 +209,11 @@ void VisualDatabaseDisplayWidget::showEvent(QShowEvent *event)
|
|||
initializeFilters();
|
||||
}
|
||||
|
||||
void VisualDatabaseDisplayWidget::setNewZoneCreator(const std::function<QString()> &creator)
|
||||
{
|
||||
newZoneCreator = creator;
|
||||
}
|
||||
|
||||
void VisualDatabaseDisplayWidget::retranslateUi()
|
||||
{
|
||||
databaseLoadIndicator->setText(tr("Loading database ..."));
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <QVBoxLayout>
|
||||
#include <QWheelEvent>
|
||||
#include <QWidget>
|
||||
#include <functional>
|
||||
#include <libcockatrice/models/database/card_database_model.h>
|
||||
#include <libcockatrice/models/deck_list/deck_list_model.h>
|
||||
#include <qscrollarea.h>
|
||||
|
|
@ -46,6 +47,12 @@ public:
|
|||
void sortCardList(const QStringList &properties, Qt::SortOrder order) const;
|
||||
void setDeckList(const DeckList &new_deck_list_model);
|
||||
|
||||
/**
|
||||
* @brief Sets the callback used to create a custom zone from the add-to-zone menu.
|
||||
* The callback returns the name of the created zone, or an empty string if creation was cancelled.
|
||||
*/
|
||||
void setNewZoneCreator(const std::function<QString()> &creator);
|
||||
|
||||
CardDatabaseDisplayModel *getDatabaseDisplayModel()
|
||||
{
|
||||
return databaseDisplayModel;
|
||||
|
|
@ -106,6 +113,7 @@ private:
|
|||
VisualDatabaseDisplayFilterToolbarWidget *filterContainer;
|
||||
CardDatabaseDisplayModel *databaseDisplayModel;
|
||||
CardDatabaseView *databaseView;
|
||||
std::function<QString()> newZoneCreator;
|
||||
QList<ExactCard> *cards;
|
||||
QVBoxLayout *mainLayout;
|
||||
QScrollArea *scrollArea;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue