mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 03:28:49 -07:00
[DeckLoader] Refactor to make some methods static (#6336)
* Make forEachCard const * Make some DeckLoader methods static * Update usages * Update method param documentation in deck_loader.cpp --------- Co-authored-by: BruebachL <44814898+BruebachL@users.noreply.github.com>
This commit is contained in:
parent
a8ee0d7648
commit
16392c28c5
10 changed files with 80 additions and 65 deletions
|
|
@ -82,9 +82,9 @@ bool AbstractDlgDeckTextEdit::loadIntoDeck(DeckLoader *deckLoader) const
|
|||
|
||||
if (deckLoader->getDeckList()->loadFromStream_Plain(stream, true)) {
|
||||
if (loadSetNameAndNumberCheckBox->isChecked()) {
|
||||
deckLoader->resolveSetNameAndNumberToProviderID();
|
||||
DeckLoader::resolveSetNameAndNumberToProviderID(deckLoader->getDeckList());
|
||||
} else {
|
||||
deckLoader->clearSetNamesAndNumbers();
|
||||
DeckLoader::clearSetNamesAndNumbers(deckLoader->getDeckList());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -154,17 +154,17 @@ DlgEditDeckInClipboard::DlgEditDeckInClipboard(const DeckLoader &deckList, bool
|
|||
* @param addComments Whether to add annotations
|
||||
* @return A QString
|
||||
*/
|
||||
static QString deckListToString(const DeckLoader *deckList, bool addComments)
|
||||
static QString deckListToString(const DeckList *deckList, bool addComments)
|
||||
{
|
||||
QString buffer;
|
||||
QTextStream stream(&buffer);
|
||||
deckList->saveToStream_Plain(stream, addComments);
|
||||
DeckLoader::saveToStream_Plain(stream, deckList, addComments);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void DlgEditDeckInClipboard::actRefresh()
|
||||
{
|
||||
setText(deckListToString(deckLoader, annotated));
|
||||
setText(deckListToString(deckLoader->getDeckList(), annotated));
|
||||
}
|
||||
|
||||
void DlgEditDeckInClipboard::actOK()
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ void DlgLoadDeckFromWebsite::accept()
|
|||
DeckLoader *loader = new DeckLoader(this);
|
||||
QTextStream stream(&deckText);
|
||||
loader->getDeckList()->loadFromStream_Plain(stream, false);
|
||||
loader->resolveSetNameAndNumberToProviderID();
|
||||
DeckLoader::resolveSetNameAndNumberToProviderID(loader->getDeckList());
|
||||
deck = loader;
|
||||
|
||||
QDialog::accept();
|
||||
|
|
|
|||
|
|
@ -162,14 +162,14 @@ void DlgSelectSetForCards::actOK()
|
|||
|
||||
void DlgSelectSetForCards::actClear()
|
||||
{
|
||||
qobject_cast<DeckLoader *>(model->getDeckList())->clearSetNamesAndNumbers();
|
||||
DeckLoader::clearSetNamesAndNumbers(model->getDeckList());
|
||||
accept();
|
||||
}
|
||||
|
||||
void DlgSelectSetForCards::actSetAllToPreferred()
|
||||
{
|
||||
qobject_cast<DeckLoader *>(model->getDeckList())->clearSetNamesAndNumbers();
|
||||
qobject_cast<DeckLoader *>(model->getDeckList())->setProviderIdToPreferredPrinting();
|
||||
DeckLoader::clearSetNamesAndNumbers(model->getDeckList());
|
||||
DeckLoader::setProviderIdToPreferredPrinting(model->getDeckList());
|
||||
accept();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -510,32 +510,33 @@ void AbstractTabDeckEditor::actEditDeckInClipboardRaw()
|
|||
/** @brief Saves deck to clipboard with set info and annotation. */
|
||||
void AbstractTabDeckEditor::actSaveDeckToClipboard()
|
||||
{
|
||||
getDeckLoader()->saveToClipboard(true, true);
|
||||
DeckLoader::saveToClipboard(getDeckList(), true, true);
|
||||
}
|
||||
|
||||
/** @brief Saves deck to clipboard with annotation, without set info. */
|
||||
void AbstractTabDeckEditor::actSaveDeckToClipboardNoSetInfo()
|
||||
{
|
||||
getDeckLoader()->saveToClipboard(true, false);
|
||||
DeckLoader::saveToClipboard(getDeckList(), true, false);
|
||||
}
|
||||
|
||||
/** @brief Saves deck to clipboard without annotations, with set info. */
|
||||
void AbstractTabDeckEditor::actSaveDeckToClipboardRaw()
|
||||
{
|
||||
getDeckLoader()->saveToClipboard(false, true);
|
||||
DeckLoader::saveToClipboard(getDeckList(), false, true);
|
||||
}
|
||||
|
||||
/** @brief Saves deck to clipboard without annotations or set info. */
|
||||
void AbstractTabDeckEditor::actSaveDeckToClipboardRawNoSetInfo()
|
||||
{
|
||||
getDeckLoader()->saveToClipboard(false, false);
|
||||
DeckLoader::saveToClipboard(getDeckList(), false, false);
|
||||
}
|
||||
|
||||
/** @brief Prints the deck using a QPrintPreviewDialog. */
|
||||
void AbstractTabDeckEditor::actPrintDeck()
|
||||
{
|
||||
auto *dlg = new QPrintPreviewDialog(this);
|
||||
connect(dlg, &QPrintPreviewDialog::paintRequested, deckDockWidget->getDeckLoader(), &DeckLoader::printDeckList);
|
||||
connect(dlg, &QPrintPreviewDialog::paintRequested, this,
|
||||
[this](QPrinter *printer) { DeckLoader::printDeckList(printer, getDeckList()); });
|
||||
dlg->exec();
|
||||
}
|
||||
|
||||
|
|
@ -569,7 +570,7 @@ void AbstractTabDeckEditor::actLoadDeckFromWebsite()
|
|||
void AbstractTabDeckEditor::exportToDecklistWebsite(DeckLoader::DecklistWebsite website)
|
||||
{
|
||||
if (DeckLoader *const deck = getDeckLoader()) {
|
||||
QString decklistUrlString = deck->exportDeckToDecklist(website);
|
||||
QString decklistUrlString = deck->exportDeckToDecklist(getDeckList(), website);
|
||||
// Check to make sure the string isn't empty.
|
||||
if (decklistUrlString.isEmpty()) {
|
||||
// Show an error if the deck is empty, and return.
|
||||
|
|
|
|||
|
|
@ -326,13 +326,13 @@ QMenu *DeckPreviewWidget::createRightClickMenu()
|
|||
auto saveToClipboardMenu = menu->addMenu(tr("Save Deck to Clipboard"));
|
||||
|
||||
connect(saveToClipboardMenu->addAction(tr("Annotated")), &QAction::triggered, this,
|
||||
[this] { deckLoader->saveToClipboard(true, true); });
|
||||
[this] { DeckLoader::saveToClipboard(deckLoader->getDeckList(), true, true); });
|
||||
connect(saveToClipboardMenu->addAction(tr("Annotated (No set info)")), &QAction::triggered, this,
|
||||
[this] { deckLoader->saveToClipboard(true, false); });
|
||||
[this] { DeckLoader::saveToClipboard(deckLoader->getDeckList(), true, false); });
|
||||
connect(saveToClipboardMenu->addAction(tr("Not Annotated")), &QAction::triggered, this,
|
||||
[this] { deckLoader->saveToClipboard(false, true); });
|
||||
[this] { DeckLoader::saveToClipboard(deckLoader->getDeckList(), false, true); });
|
||||
connect(saveToClipboardMenu->addAction(tr("Not Annotated (No set info)")), &QAction::triggered, this,
|
||||
[this] { deckLoader->saveToClipboard(false, false); });
|
||||
[this] { DeckLoader::saveToClipboard(deckLoader->getDeckList(), false, false); });
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue