Deck loader is a gui class. (#6294)

* Deck loader is a gui class.

Took 31 minutes

Took 3 minutes

* Deck Loader is responsible for printing.

Took 8 minutes


Took 2 seconds

* Style proxy.

Took 14 minutes

Took 6 minutes

Took 1 minute

* Don't need to include QBrush anymore.

Took 3 minutes

Took 7 seconds

* Includes for printer.

Took 5 minutes

* Nuke getDeckList()

Took 9 minutes

* Adjust to rebase.

Took 35 seconds

* Lint.

Took 3 minutes

* Braces for one line return statements.

Took 13 minutes

Took 50 seconds

* Enum for model columns.

Took 9 minutes

* One more single line if.

Took 1 minute

* Another style lint on a sunday night

Took 5 minutes

* Move enum to namespace.

Took 3 minutes

* Fix a critical blocker.

Took 5 minutes

* Update docs.

Took 3 minutes

* Doxygen and namespace enums.

Took 2 minutes

Took 15 seconds

* Adjust to namespace.

Took 4 minutes

Took 1 minute

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2025-11-11 11:57:41 +01:00 committed by GitHub
parent c16267e60f
commit bfedc12fa8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 384 additions and 255 deletions

View file

@ -209,7 +209,7 @@ void AbstractTabDeckEditor::openDeck(DeckLoader *deck)
void AbstractTabDeckEditor::setDeck(DeckLoader *_deck)
{
deckDockWidget->setDeck(_deck);
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query()->getCards(getDeckList()->getCardRefList()));
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query()->getCards(getDeckLoader()->getCardRefList()));
setModified(false);
aDeckDockVisible->setChecked(true);
@ -217,9 +217,9 @@ void AbstractTabDeckEditor::setDeck(DeckLoader *_deck)
}
/** @brief Returns the currently loaded deck. */
DeckLoader *AbstractTabDeckEditor::getDeckList() const
DeckLoader *AbstractTabDeckEditor::getDeckLoader() const
{
return deckDockWidget->getDeckList();
return deckDockWidget->getDeckLoader();
}
/**
@ -237,7 +237,7 @@ void AbstractTabDeckEditor::setModified(bool _modified)
*/
bool AbstractTabDeckEditor::isBlankNewDeck() const
{
DeckLoader *deck = getDeckList();
DeckLoader *deck = deckDockWidget->getDeckLoader();
return !modified && deck->isBlankDeck() && deck->hasNotBeenLoaded();
}
@ -377,7 +377,7 @@ void AbstractTabDeckEditor::openDeckFromFile(const QString &fileName, DeckOpenLo
*/
bool AbstractTabDeckEditor::actSaveDeck()
{
DeckLoader *const deck = getDeckList();
DeckLoader *const deck = getDeckLoader();
if (deck->getLastRemoteDeckId() != -1) {
QString deckString = deck->writeToString_Native();
if (deckString.length() > MAX_FILE_LENGTH) {
@ -418,7 +418,7 @@ bool AbstractTabDeckEditor::actSaveDeckAs()
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setDefaultSuffix("cod");
dialog.setNameFilters(DeckLoader::FILE_NAME_FILTERS);
dialog.selectFile(getDeckList()->getName().trimmed());
dialog.selectFile(getDeckLoader()->getName().trimmed());
if (!dialog.exec())
return false;
@ -426,7 +426,7 @@ bool AbstractTabDeckEditor::actSaveDeckAs()
QString fileName = dialog.selectedFiles().at(0);
DeckLoader::FileFormat fmt = DeckLoader::getFormatFromName(fileName);
if (!getDeckList()->saveToFile(fileName, fmt)) {
if (!getDeckLoader()->saveToFile(fileName, fmt)) {
QMessageBox::critical(
this, tr("Error"),
tr("The deck could not be saved.\nPlease check that the directory is writable and try again."));
@ -480,7 +480,7 @@ void AbstractTabDeckEditor::actLoadDeckFromClipboard()
*/
void AbstractTabDeckEditor::editDeckInClipboard(bool annotated)
{
DlgEditDeckInClipboard dlg(*getDeckList(), annotated, this);
DlgEditDeckInClipboard dlg(*getDeckLoader(), annotated, this);
if (!dlg.exec())
return;
@ -504,32 +504,32 @@ void AbstractTabDeckEditor::actEditDeckInClipboardRaw()
/** @brief Saves deck to clipboard with set info and annotation. */
void AbstractTabDeckEditor::actSaveDeckToClipboard()
{
getDeckList()->saveToClipboard(true, true);
getDeckLoader()->saveToClipboard(true, true);
}
/** @brief Saves deck to clipboard with annotation, without set info. */
void AbstractTabDeckEditor::actSaveDeckToClipboardNoSetInfo()
{
getDeckList()->saveToClipboard(true, false);
getDeckLoader()->saveToClipboard(true, false);
}
/** @brief Saves deck to clipboard without annotations, with set info. */
void AbstractTabDeckEditor::actSaveDeckToClipboardRaw()
{
getDeckList()->saveToClipboard(false, true);
getDeckLoader()->saveToClipboard(false, true);
}
/** @brief Saves deck to clipboard without annotations or set info. */
void AbstractTabDeckEditor::actSaveDeckToClipboardRawNoSetInfo()
{
getDeckList()->saveToClipboard(false, false);
getDeckLoader()->saveToClipboard(false, false);
}
/** @brief Prints the deck using a QPrintPreviewDialog. */
void AbstractTabDeckEditor::actPrintDeck()
{
auto *dlg = new QPrintPreviewDialog(this);
connect(dlg, &QPrintPreviewDialog::paintRequested, deckDockWidget->deckModel, &DeckListModel::printDeckList);
connect(dlg, &QPrintPreviewDialog::paintRequested, deckDockWidget->getDeckLoader(), &DeckLoader::printDeckList);
dlg->exec();
}
@ -562,7 +562,7 @@ void AbstractTabDeckEditor::actLoadDeckFromWebsite()
*/
void AbstractTabDeckEditor::exportToDecklistWebsite(DeckLoader::DecklistWebsite website)
{
if (DeckLoader *const deck = getDeckList()) {
if (DeckLoader *const deck = getDeckLoader()) {
QString decklistUrlString = deck->exportDeckToDecklist(website);
// Check to make sure the string isn't empty.
if (decklistUrlString.isEmpty()) {
@ -600,14 +600,14 @@ void AbstractTabDeckEditor::actExportDeckDecklistXyz()
void AbstractTabDeckEditor::actAnalyzeDeckDeckstats()
{
auto *interface = new DeckStatsInterface(*databaseDisplayDockWidget->databaseModel->getDatabase(), this);
interface->analyzeDeck(getDeckList());
interface->analyzeDeck(getDeckLoader());
}
/** @brief Analyzes the deck using TappedOut. */
void AbstractTabDeckEditor::actAnalyzeDeckTappedout()
{
auto *interface = new TappedOutInterface(*databaseDisplayDockWidget->databaseModel->getDatabase(), this);
interface->analyzeDeck(getDeckList());
interface->analyzeDeck(getDeckLoader());
}
/** @brief Applies a new filter tree to the database display. */

View file

@ -117,7 +117,7 @@ public:
void openDeck(DeckLoader *deck);
/** @brief Returns the currently active deck. */
DeckLoader *getDeckList() const;
DeckLoader *getDeckLoader() const;
/** @brief Sets the modified state of the tab.
* @param _windowModified Whether the tab is modified.

View file

@ -1,11 +1,12 @@
#include "edhrec_deck_api_response.h"
#include "../../../../../../deck_loader/deck_loader.h"
#include <QApplication>
#include <QDebug>
#include <QJsonArray>
#include <QJsonObject>
#include <QMainWindow>
#include <libcockatrice/models/deck_list/deck_loader.h>
void EdhrecDeckApiResponse::fromJson(const QJsonArray &json)
{

View file

@ -7,12 +7,13 @@
#ifndef EDHREC_DECK_API_RESPONSE_H
#define EDHREC_DECK_API_RESPONSE_H
#include "../../../../../../deck_loader/deck_loader.h"
#include <QDebug>
#include <QJsonArray>
#include <QJsonObject>
#include <QString>
#include <QVector>
#include <libcockatrice/models/deck_list/deck_loader.h>
class EdhrecDeckApiResponse
{

View file

@ -1,6 +1,7 @@
#include "tab_deck_storage.h"
#include "../../../client/settings/cache_settings.h"
#include "../../deck_loader/deck_loader.h"
#include "../interface/widgets/server/remote/remote_decklist_tree_widget.h"
#include "../interface/widgets/utility/get_text_with_max.h"
@ -19,7 +20,6 @@
#include <QUrl>
#include <QVBoxLayout>
#include <libcockatrice/deck_list/deck_list.h>
#include <libcockatrice/models/deck_list/deck_loader.h>
#include <libcockatrice/protocol/pb/command_deck_del.pb.h>
#include <libcockatrice/protocol/pb/command_deck_del_dir.pb.h>
#include <libcockatrice/protocol/pb/command_deck_download.pb.h>

View file

@ -8,6 +8,7 @@
#ifndef TAB_SUPERVISOR_H
#define TAB_SUPERVISOR_H
#include "../../deck_loader/deck_loader.h"
#include "../interface/widgets/server/user/user_list_proxy.h"
#include "abstract_tab_deck_editor.h"
#include "api/edhrec/tab_edhrec.h"
@ -23,7 +24,6 @@
#include <QMap>
#include <QProxyStyle>
#include <QTabWidget>
#include <libcockatrice/models/deck_list/deck_loader.h>
inline Q_LOGGING_CATEGORY(TabSupervisorLog, "tab_supervisor");