[Refactor] Pass around LoadedDeck instead of DeckLoader (#6422)

This commit is contained in:
RickyRister 2025-12-20 04:39:00 -08:00 committed by GitHub
parent 367507e054
commit d6db21419c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 253 additions and 264 deletions

View file

@ -90,14 +90,14 @@ void ArchidektApiResponseDeckDisplayWidget::onGroupCriteriaChange(const QString
void ArchidektApiResponseDeckDisplayWidget::actOpenInDeckEditor()
{
auto loader = new DeckLoader(this);
loader->getDeckList()->loadFromString_Native(model->getDeckList()->writeToString_Native());
loader->getDeckList()->setName(response.getDeckName());
loader->getDeckList()->setGameFormat(
DeckList deckList(*model->getDeckList());
deckList.setName(response.getDeckName());
deckList.setGameFormat(
ArchidektFormats::formatToCockatriceName(ArchidektFormats::DeckFormat(response.getDeckFormat() - 1)));
emit openInDeckEditor(loader);
LoadedDeck loadedDeck = {deckList, {}};
emit openInDeckEditor(loadedDeck);
}
void ArchidektApiResponseDeckDisplayWidget::clearAllDisplayWidgets()

View file

@ -31,7 +31,7 @@
*
* ### Signals
* - `requestNavigation(QString url)` triggered when navigation to a deck URL is requested.
* - `openInDeckEditor(DeckLoader *loader)` emitted when the user chooses to open the deck
* - `openInDeckEditor(const LoadedDeck &deck)` emitted when the user chooses to open the deck
* in the deck editor.
*
* ### Features
@ -52,9 +52,9 @@ signals:
/**
* @brief Emitted when the deck should be opened in the deck editor.
* @param loader Initialized DeckLoader containing the deck data.
* @param deck LoadedDeck containing the deck data.
*/
void openInDeckEditor(DeckLoader *loader);
void openInDeckEditor(const LoadedDeck &deck);
public:
/**
@ -75,7 +75,7 @@ public:
void retranslateUi();
/**
* @brief Opens the deck in the deck editor via DeckLoader.
* @brief Opens the deck in the deck editor.
*/
void actOpenInDeckEditor();

View file

@ -14,10 +14,8 @@ void EdhrecDeckApiResponse::fromJson(const QJsonArray &json)
deckList += cardlistValue.toString() + "\n";
}
deckLoader = new DeckLoader(nullptr);
QTextStream stream(&deckList);
deckLoader->getDeckList()->loadFromStream_Plain(stream, true);
deck.loadFromStream_Plain(stream, true);
}
void EdhrecDeckApiResponse::debugPrint() const

View file

@ -21,7 +21,7 @@ public:
// Debug method for logging
void debugPrint() const;
DeckLoader *deckLoader;
DeckList deck;
};
#endif // EDHREC_DECK_API_RESPONSE_H

View file

@ -363,7 +363,7 @@ void TabEdhRecMain::processAverageDeckResponse(QJsonObject reply)
{
EdhrecAverageDeckApiResponse deckData;
deckData.fromJson(reply);
tabSupervisor->openDeckInNewTab(deckData.deck.deckLoader);
tabSupervisor->openDeckInNewTab({deckData.deck.deck, {}});
}
void TabEdhRecMain::prettyPrintJson(const QJsonValue &value, int indentLevel)