mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-23 01:55:10 -07:00
[Refactor] Pass around LoadedDeck instead of DeckLoader (#6422)
This commit is contained in:
parent
367507e054
commit
d6db21419c
44 changed files with 253 additions and 264 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public:
|
|||
// Debug method for logging
|
||||
void debugPrint() const;
|
||||
|
||||
DeckLoader *deckLoader;
|
||||
DeckList deck;
|
||||
};
|
||||
|
||||
#endif // EDHREC_DECK_API_RESPONSE_H
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue