mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-13 01:24:46 -07:00
[DeckList] Refactor load from plaintext to take normalizer as param (#6664)
* [DeckList] Refactor load from plaintext to take normalizer as param * update usages * weaken unit test * weaken unit test more * revert unit test * move CardNameNormalizer to libcockatrice_card * update unit test * formatting
This commit is contained in:
parent
bd5cbb89d4
commit
dead993639
14 changed files with 94 additions and 52 deletions
|
|
@ -14,6 +14,7 @@
|
|||
#include <QPushButton>
|
||||
#include <QTextStream>
|
||||
#include <QVBoxLayout>
|
||||
#include <libcockatrice/card/import/card_name_normalizer.h>
|
||||
|
||||
/**
|
||||
* Creates the main layout and connects the signals that are common to all versions of this window
|
||||
|
|
@ -81,7 +82,7 @@ bool AbstractDlgDeckTextEdit::loadIntoDeck(DeckList &deckList) const
|
|||
|
||||
QTextStream stream(&buffer);
|
||||
|
||||
if (deckList.loadFromStream_Plain(stream, true)) {
|
||||
if (deckList.loadFromStream_Plain(stream, true, CardNameNormalizer())) {
|
||||
if (loadSetNameAndNumberCheckBox->isChecked()) {
|
||||
deckList.forEachCard(CardNodeFunction::ResolveProviderId());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <QJsonObject>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkReply>
|
||||
#include <libcockatrice/card/import/card_name_normalizer.h>
|
||||
#include <version_string.h>
|
||||
|
||||
DlgLoadDeckFromWebsite::DlgLoadDeckFromWebsite(QWidget *parent) : QDialog(parent)
|
||||
|
|
@ -99,7 +100,7 @@ void DlgLoadDeckFromWebsite::accept()
|
|||
// Parse the plain text deck here
|
||||
DeckList deckList;
|
||||
QTextStream stream(&deckText);
|
||||
deckList.loadFromStream_Plain(stream, false);
|
||||
deckList.loadFromStream_Plain(stream, false, CardNameNormalizer());
|
||||
deckList.forEachCard(CardNodeFunction::ResolveProviderId());
|
||||
deck = deckList;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QLoggingCategory>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "../../../../../deck_loader/card_node_function.h"
|
||||
#include "../../../../../deck_loader/deck_loader.h"
|
||||
#include "../../../../cards/card_info_picture_with_text_overlay_widget.h"
|
||||
#include "../../../../cards/card_size_widget.h"
|
||||
#include "../../../../cards/deck_card_zone_display_widget.h"
|
||||
#include "../../../../visual_deck_editor/visual_deck_display_options_widget.h"
|
||||
|
|
@ -10,7 +9,7 @@
|
|||
#include "../api_response/deck/archidekt_api_response_deck.h"
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/card/import/card_name_normalizer.h>
|
||||
|
||||
ArchidektApiResponseDeckDisplayWidget::ArchidektApiResponseDeckDisplayWidget(QWidget *parent,
|
||||
ArchidektApiResponseDeck _response,
|
||||
|
|
@ -80,7 +79,7 @@ ArchidektApiResponseDeckDisplayWidget::ArchidektApiResponseDeckDisplayWidget(QWi
|
|||
connect(model, &DeckListModel::modelReset, this, &ArchidektApiResponseDeckDisplayWidget::decklistModelReset);
|
||||
|
||||
auto decklist = QSharedPointer<DeckList>(new DeckList);
|
||||
decklist->loadFromStream_Plain(deckStream, false);
|
||||
decklist->loadFromStream_Plain(deckStream, false, CardNameNormalizer());
|
||||
model->setDeckList(decklist);
|
||||
|
||||
model->forEachCard(CardNodeFunction::ResolveProviderId());
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
#include "edhrec_deck_api_response.h"
|
||||
|
||||
#include "../../../../../../deck_loader/deck_loader.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <libcockatrice/card/import/card_name_normalizer.h>
|
||||
|
||||
void EdhrecDeckApiResponse::fromJson(const QJsonArray &json)
|
||||
{
|
||||
|
|
@ -15,7 +14,7 @@ void EdhrecDeckApiResponse::fromJson(const QJsonArray &json)
|
|||
}
|
||||
|
||||
QTextStream stream(&deckList);
|
||||
deck.loadFromStream_Plain(stream, true);
|
||||
deck.loadFromStream_Plain(stream, true, CardNameNormalizer());
|
||||
}
|
||||
|
||||
void EdhrecDeckApiResponse::debugPrint() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue