A DeckLoader is not a DeckList. (#6306)

* A DeckLoader is not a DeckList.

Took 2 hours 39 minutes

* Explicitly initialize base class in copy constructor?

Took 3 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2025-11-12 02:16:44 +01:00 committed by GitHub
parent 4c431e98a6
commit 8e88749078
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 163 additions and 139 deletions

View file

@ -32,6 +32,8 @@ void DeckEditorDeckDockWidget::createDeckDock()
deckModel->setObjectName("deckModel");
connect(deckModel, &DeckListModel::deckHashChanged, this, &DeckEditorDeckDockWidget::updateHash);
deckLoader = new DeckLoader(this, deckModel->getDeckList());
DeckListStyleProxy *proxy = new DeckListStyleProxy(this);
proxy->setSourceModel(deckModel);
@ -373,10 +375,9 @@ void DeckEditorDeckDockWidget::syncBannerCardComboBoxSelectionWithDeck()
void DeckEditorDeckDockWidget::setDeck(DeckLoader *_deck)
{
deckLoader = _deck;
deckModel->setDeckList(_deck);
connect(_deck, &DeckLoader::deckLoaded, deckModel, &DeckListModel::rebuildTree);
connect(_deck, &DeckLoader::deckHashChanged, deckModel, &DeckListModel::deckHashChanged);
deckModel->setDeckList(deckLoader->getDeckList());
connect(deckLoader, &DeckLoader::deckLoaded, deckModel, &DeckListModel::rebuildTree);
connect(deckLoader->getDeckList(), &DeckList::deckHashChanged, deckModel, &DeckListModel::deckHashChanged);
nameEdit->setText(deckModel->getDeckList()->getName());
commentsEdit->setText(deckModel->getDeckList()->getComments());
@ -398,6 +399,11 @@ DeckLoader *DeckEditorDeckDockWidget::getDeckLoader()
return deckLoader;
}
DeckList *DeckEditorDeckDockWidget::getDeckList()
{
return deckModel->getDeckList();
}
/**
* Resets the tab to the state for a blank new tab.
*/

View file

@ -52,6 +52,7 @@ public slots:
void updateBannerCardComboBox();
void setDeck(DeckLoader *_deck);
DeckLoader *getDeckLoader();
DeckList *getDeckList();
void actIncrement();
bool swapCard(const QModelIndex &idx);
void actDecrementCard(const ExactCard &card, QString zoneName);

View file

@ -75,12 +75,12 @@ bool AbstractDlgDeckTextEdit::loadIntoDeck(DeckLoader *deckLoader) const
QString buffer = contentsEdit->toPlainText();
if (buffer.contains("<cockatrice_deck version=\"1\">")) {
return deckLoader->loadFromString_Native(buffer);
return deckLoader->getDeckList()->loadFromString_Native(buffer);
}
QTextStream stream(&buffer);
if (deckLoader->loadFromStream_Plain(stream, true)) {
if (deckLoader->getDeckList()->loadFromStream_Plain(stream, true)) {
if (loadSetNameAndNumberCheckBox->isChecked()) {
deckLoader->resolveSetNameAndNumberToProviderID();
} else {
@ -121,8 +121,7 @@ void DlgLoadDeckFromClipboard::actRefresh()
void DlgLoadDeckFromClipboard::actOK()
{
deckList = new DeckLoader;
deckList->setParent(this);
deckList = new DeckLoader(this);
if (loadIntoDeck(deckList)) {
accept();

View file

@ -95,9 +95,9 @@ void DlgLoadDeckFromWebsite::accept()
}
// Parse the plain text deck here
DeckLoader *loader = new DeckLoader();
DeckLoader *loader = new DeckLoader(this);
QTextStream stream(&deckText);
loader->loadFromStream_Plain(stream, false);
loader->getDeckList()->loadFromStream_Plain(stream, false);
loader->resolveSetNameAndNumberToProviderID();
deck = loader;

View file

@ -19,7 +19,7 @@ HomeWidget::HomeWidget(QWidget *parent, TabSupervisor *_tabSupervisor)
layout = new QGridLayout(this);
backgroundSourceCard = new CardInfoPictureArtCropWidget(this);
backgroundSourceDeck = new DeckLoader();
backgroundSourceDeck = new DeckLoader(this);
backgroundSourceDeck->loadFromFile(SettingsCache::instance().getDeckPath() + "background.cod",
DeckLoader::CockatriceFormat, false);
@ -94,7 +94,7 @@ void HomeWidget::updateRandomCard()
newCard.getCardPtr()->getProperty("layout") != "normal");
break;
case BackgroundSources::DeckFileArt:
QList<CardRef> cardRefs = backgroundSourceDeck->getCardRefList();
QList<CardRef> cardRefs = backgroundSourceDeck->getDeckList()->getCardRefList();
ExactCard oldCard = backgroundSourceCard->getCard();
if (!cardRefs.empty()) {

View file

@ -209,7 +209,7 @@ void AbstractTabDeckEditor::openDeck(DeckLoader *deck)
void AbstractTabDeckEditor::setDeck(DeckLoader *_deck)
{
deckDockWidget->setDeck(_deck);
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query()->getCards(getDeckLoader()->getCardRefList()));
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query()->getCards(getDeckList()->getCardRefList()));
setModified(false);
aDeckDockVisible->setChecked(true);
@ -222,6 +222,12 @@ DeckLoader *AbstractTabDeckEditor::getDeckLoader() const
return deckDockWidget->getDeckLoader();
}
/** @brief Returns the currently loaded deck list. */
DeckList *AbstractTabDeckEditor::getDeckList() const
{
return deckDockWidget->getDeckList();
}
/**
* @brief Sets the modified state of the tab.
* @param _modified True if tab is modified, false otherwise.
@ -238,7 +244,7 @@ void AbstractTabDeckEditor::setModified(bool _modified)
bool AbstractTabDeckEditor::isBlankNewDeck() const
{
DeckLoader *deck = deckDockWidget->getDeckLoader();
return !modified && deck->isBlankDeck() && deck->hasNotBeenLoaded();
return !modified && deck->getDeckList()->isBlankDeck() && deck->hasNotBeenLoaded();
}
/** @brief Creates a new deck. Handles opening in new tab if needed. */
@ -354,7 +360,7 @@ void AbstractTabDeckEditor::openDeckFromFile(const QString &fileName, DeckOpenLo
{
DeckLoader::FileFormat fmt = DeckLoader::getFormatFromName(fileName);
auto *l = new DeckLoader;
auto *l = new DeckLoader(this);
if (l->loadFromFile(fileName, fmt, true)) {
if (deckOpenLocation == NEW_TAB) {
emit openDeckEditor(l);
@ -379,7 +385,7 @@ bool AbstractTabDeckEditor::actSaveDeck()
{
DeckLoader *const deck = getDeckLoader();
if (deck->getLastRemoteDeckId() != -1) {
QString deckString = deck->writeToString_Native();
QString deckString = deck->getDeckList()->writeToString_Native();
if (deckString.length() > MAX_FILE_LENGTH) {
QMessageBox::critical(this, tr("Error"), tr("Could not save remote deck"));
return false;
@ -418,7 +424,7 @@ bool AbstractTabDeckEditor::actSaveDeckAs()
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setDefaultSuffix("cod");
dialog.setNameFilters(DeckLoader::FILE_NAME_FILTERS);
dialog.selectFile(getDeckLoader()->getName().trimmed());
dialog.selectFile(getDeckList()->getName().trimmed());
if (!dialog.exec())
return false;
@ -600,14 +606,14 @@ void AbstractTabDeckEditor::actExportDeckDecklistXyz()
void AbstractTabDeckEditor::actAnalyzeDeckDeckstats()
{
auto *interface = new DeckStatsInterface(*databaseDisplayDockWidget->databaseModel->getDatabase(), this);
interface->analyzeDeck(getDeckLoader());
interface->analyzeDeck(getDeckList());
}
/** @brief Analyzes the deck using TappedOut. */
void AbstractTabDeckEditor::actAnalyzeDeckTappedout()
{
auto *interface = new TappedOutInterface(*databaseDisplayDockWidget->databaseModel->getDatabase(), this);
interface->analyzeDeck(getDeckLoader());
interface->analyzeDeck(getDeckList());
}
/** @brief Applies a new filter tree to the database display. */

View file

@ -116,9 +116,12 @@ public:
*/
void openDeck(DeckLoader *deck);
/** @brief Returns the currently active deck. */
/** @brief Returns the currently active deck loader. */
DeckLoader *getDeckLoader() const;
/** @brief Returns the currently active deck list. */
DeckList *getDeckList() const;
/** @brief Sets the modified state of the tab.
* @param _windowModified Whether the tab is modified.
*/
@ -178,7 +181,7 @@ public slots:
signals:
/** @brief Emitted when a deck should be opened in a new editor tab. */
void openDeckEditor(const DeckLoader *deckLoader);
void openDeckEditor(DeckLoader *deckLoader);
/** @brief Emitted before the tab is closed. */
void deckEditorClosing(AbstractTabDeckEditor *tab);

View file

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

View file

@ -242,7 +242,7 @@ void TabDeckStorage::actOpenLocalDeck()
continue;
QString filePath = localDirModel->filePath(curLeft);
DeckLoader deckLoader;
DeckLoader deckLoader(this);
if (!deckLoader.loadFromFile(filePath, DeckLoader::CockatriceFormat, true))
continue;
@ -308,13 +308,13 @@ void TabDeckStorage::uploadDeck(const QString &filePath, const QString &targetPa
QFile deckFile(filePath);
QFileInfo deckFileInfo(deckFile);
DeckLoader deck;
DeckLoader deck(this);
if (!deck.loadFromFile(filePath, DeckLoader::CockatriceFormat)) {
QMessageBox::critical(this, tr("Error"), tr("Invalid deck file"));
return;
}
if (deck.getName().isEmpty()) {
if (deck.getDeckList()->getName().isEmpty()) {
bool ok;
QString deckName =
getTextWithMax(this, tr("Enter deck name"), tr("This decklist does not have a name.\nPlease enter a name:"),
@ -323,12 +323,12 @@ void TabDeckStorage::uploadDeck(const QString &filePath, const QString &targetPa
return;
if (deckName.isEmpty())
deckName = tr("Unnamed deck");
deck.setName(deckName);
deck.getDeckList()->setName(deckName);
} else {
deck.setName(deck.getName().left(MAX_NAME_LENGTH));
deck.getDeckList()->setName(deck.getDeckList()->getName().left(MAX_NAME_LENGTH));
}
QString deckString = deck.writeToString_Native();
QString deckString = deck.getDeckList()->writeToString_Native();
if (deckString.length() > MAX_FILE_LENGTH) {
QMessageBox::critical(this, tr("Error"), tr("Invalid deck file"));
return;
@ -433,7 +433,7 @@ void TabDeckStorage::openRemoteDeckFinished(const Response &r, const CommandCont
const Response_DeckDownload &resp = r.GetExtension(Response_DeckDownload::ext);
const Command_DeckDownload &cmd = commandContainer.session_command(0).GetExtension(Command_DeckDownload::ext);
DeckLoader loader;
DeckLoader loader(this);
if (!loader.loadFromRemote(QString::fromStdString(resp.deck()), cmd.deck_id()))
return;
@ -493,7 +493,7 @@ void TabDeckStorage::downloadFinished(const Response &r,
const Response_DeckDownload &resp = r.GetExtension(Response_DeckDownload::ext);
QString filePath = extraData.toString();
DeckLoader deck(QString::fromStdString(resp.deck()));
DeckLoader deck(this, new DeckList(QString::fromStdString(resp.deck())));
deck.saveToFile(filePath, DeckLoader::CockatriceFormat);
}

View file

@ -87,7 +87,7 @@ public:
return tr("Deck Storage");
}
signals:
void openDeckEditor(const DeckLoader *deckLoader);
void openDeckEditor(DeckLoader *deckLoader);
};
#endif

View file

@ -754,8 +754,9 @@ void TabGame::loadDeckForLocalPlayer(Player *localPlayer, int playerId, ServerIn
{
TabbedDeckViewContainer *deckViewContainer = deckViewContainers.value(playerId);
if (playerInfo.has_deck_list()) {
DeckLoader newDeck(QString::fromStdString(playerInfo.deck_list()));
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query()->getCards(newDeck.getCardRefList()));
DeckLoader newDeck(this, new DeckList(QString::fromStdString(playerInfo.deck_list())));
CardPictureLoader::cacheCardPixmaps(
CardDatabaseManager::query()->getCards(newDeck.getDeckList()->getCardRefList()));
deckViewContainer->playerDeckView->setDeck(newDeck);
localPlayer->setDeck(newDeck);
}

View file

@ -121,7 +121,7 @@ signals:
void containerProcessingStarted(const GameEventContext &context);
void containerProcessingDone();
void openMessageDialog(const QString &userName, bool focus);
void openDeckEditor(const DeckLoader *deck);
void openDeckEditor(DeckLoader *deck);
void notIdle();
void phaseChanged(int phase);

View file

@ -843,7 +843,7 @@ void TabSupervisor::talkLeft(TabMessage *tab)
* Creates either a classic or visual deck editor tab depending on settings
* @param deckToOpen The deck to open in the tab. Creates a copy of the DeckLoader instance.
*/
void TabSupervisor::openDeckInNewTab(const DeckLoader *deckToOpen)
void TabSupervisor::openDeckInNewTab(DeckLoader *deckToOpen)
{
int type = SettingsCache::instance().getDefaultDeckEditorType();
switch (type) {
@ -865,11 +865,11 @@ void TabSupervisor::openDeckInNewTab(const DeckLoader *deckToOpen)
* Creates a new deck editor tab
* @param deckToOpen The deck to open in the tab. Creates a copy of the DeckLoader instance.
*/
TabDeckEditor *TabSupervisor::addDeckEditorTab(const DeckLoader *deckToOpen)
TabDeckEditor *TabSupervisor::addDeckEditorTab(DeckLoader *deckToOpen)
{
auto *tab = new TabDeckEditor(this);
if (deckToOpen)
tab->openDeck(new DeckLoader(*deckToOpen));
tab->openDeck(new DeckLoader(this, deckToOpen->getDeckList()));
connect(tab, &AbstractTabDeckEditor::deckEditorClosing, this, &TabSupervisor::deckEditorClosed);
connect(tab, &AbstractTabDeckEditor::openDeckEditor, this, &TabSupervisor::addDeckEditorTab);
myAddTab(tab);
@ -878,11 +878,11 @@ TabDeckEditor *TabSupervisor::addDeckEditorTab(const DeckLoader *deckToOpen)
return tab;
}
TabDeckEditorVisual *TabSupervisor::addVisualDeckEditorTab(const DeckLoader *deckToOpen)
TabDeckEditorVisual *TabSupervisor::addVisualDeckEditorTab(DeckLoader *deckToOpen)
{
auto *tab = new TabDeckEditorVisual(this);
if (deckToOpen)
tab->openDeck(new DeckLoader(*deckToOpen));
tab->openDeck(new DeckLoader(this, deckToOpen->getDeckList()));
connect(tab, &AbstractTabDeckEditor::deckEditorClosing, this, &TabSupervisor::deckEditorClosed);
connect(tab, &AbstractTabDeckEditor::openDeckEditor, this, &TabSupervisor::addVisualDeckEditorTab);
myAddTab(tab);

View file

@ -169,9 +169,9 @@ signals:
void showWindowIfHidden();
public slots:
void openDeckInNewTab(const DeckLoader *deckToOpen);
TabDeckEditor *addDeckEditorTab(const DeckLoader *deckToOpen);
TabDeckEditorVisual *addVisualDeckEditorTab(const DeckLoader *deckToOpen);
void openDeckInNewTab(DeckLoader *deckToOpen);
TabDeckEditor *addDeckEditorTab(DeckLoader *deckToOpen);
TabDeckEditorVisual *addVisualDeckEditorTab(DeckLoader *deckToOpen);
TabVisualDatabaseDisplay *addVisualDatabaseDisplayTab();
TabEdhRecMain *addEdhrecMainTab();
TabEdhRec *addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCommander = false);

View file

@ -27,7 +27,7 @@ TabDeckStorageVisual::TabDeckStorageVisual(TabSupervisor *_tabSupervisor)
void TabDeckStorageVisual::actOpenLocalDeck(const QString &filePath)
{
DeckLoader deckLoader;
DeckLoader deckLoader(this);
if (!deckLoader.loadFromFile(filePath, DeckLoader::getFormatFromName(filePath), true)) {
QMessageBox::critical(this, tr("Error"), tr("Could not open deck at %1").arg(filePath));
return;

View file

@ -39,7 +39,7 @@ public slots:
void actOpenLocalDeck(const QString &filePath);
signals:
void openDeckEditor(const DeckLoader *deckLoader);
void openDeckEditor(DeckLoader *deckLoader);
private:
VisualDeckStorageWidget *visualDeckStorageWidget;

View file

@ -91,7 +91,7 @@ void VisualDatabaseDisplayNameFilterWidget::actLoadFromClipboard()
if (!dlg.exec())
return;
QStringList cardsInClipboard = dlg.getDeckList()->getCardList();
QStringList cardsInClipboard = dlg.getDeckList()->getDeckList()->getCardList();
for (QString cardName : cardsInClipboard) {
createNameFilter(cardName);
}

View file

@ -167,10 +167,10 @@ void DeckPreviewDeckTagsDisplayWidget::openTagEditDlg()
auto *deckEditor = qobject_cast<AbstractTabDeckEditor *>(currentParent);
QStringList knownTags;
QStringList allFiles = getAllFiles(SettingsCache::instance().getDeckPath());
DeckLoader loader;
DeckLoader loader(this);
for (const QString &file : allFiles) {
loader.loadFromFile(file, DeckLoader::getFormatFromName(file), false);
QStringList tags = loader.getTags();
QStringList tags = loader.getDeckList()->getTags();
knownTags.append(tags);
knownTags.removeDuplicates();
}

View file

@ -25,8 +25,7 @@ DeckPreviewWidget::DeckPreviewWidget(QWidget *_parent,
layout = new QVBoxLayout(this);
setLayout(layout);
deckLoader = new DeckLoader();
deckLoader->setParent(this);
deckLoader = new DeckLoader(this);
connect(deckLoader, &DeckLoader::loadFinished, this, &DeckPreviewWidget::initializeUi);
/* TODO: We shouldn't update the tags on *every* deck load, since it's kinda expensive. We should instead count how
many deck loads have finished already and if we've loaded all decks and THEN load all the tags at once. */
@ -74,23 +73,23 @@ void DeckPreviewWidget::initializeUi(const bool deckLoadSuccess)
if (!deckLoadSuccess) {
return;
}
auto bannerCard = deckLoader->getBannerCard().name.isEmpty()
auto bannerCard = deckLoader->getDeckList()->getBannerCard().name.isEmpty()
? ExactCard()
: CardDatabaseManager::query()->getCard(deckLoader->getBannerCard());
: CardDatabaseManager::query()->getCard(deckLoader->getDeckList()->getBannerCard());
bannerCardDisplayWidget->setCard(bannerCard);
bannerCardDisplayWidget->setFontSize(24);
setFilePath(deckLoader->getLastFileName());
colorIdentityWidget = new ColorIdentityWidget(this, getColorIdentity());
deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckLoader);
deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckLoader->getDeckList());
bannerCardLabel = new QLabel(this);
bannerCardLabel->setObjectName("bannerCardLabel");
bannerCardComboBox = new QComboBox(this);
bannerCardComboBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
bannerCardComboBox->setObjectName("bannerCardComboBox");
bannerCardComboBox->setCurrentText(deckLoader->getBannerCard().name);
bannerCardComboBox->setCurrentText(deckLoader->getDeckList()->getBannerCard().name);
bannerCardComboBox->installEventFilter(new NoScrollFilter());
connect(bannerCardComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DeckPreviewWidget::setBannerCard);
@ -152,7 +151,7 @@ void DeckPreviewWidget::updateTagsVisibility(bool visible)
QString DeckPreviewWidget::getColorIdentity()
{
QStringList cardList = deckLoader->getCardList();
QStringList cardList = deckLoader->getDeckList()->getCardList();
if (cardList.isEmpty()) {
return {};
}
@ -186,8 +185,8 @@ QString DeckPreviewWidget::getColorIdentity()
*/
QString DeckPreviewWidget::getDisplayName() const
{
return deckLoader->getName().isEmpty() ? QFileInfo(deckLoader->getLastFileName()).fileName()
: deckLoader->getName();
return deckLoader->getDeckList()->getName().isEmpty() ? QFileInfo(deckLoader->getLastFileName()).fileName()
: deckLoader->getDeckList()->getName();
}
void DeckPreviewWidget::setFilePath(const QString &_filePath)
@ -233,7 +232,7 @@ void DeckPreviewWidget::updateBannerCardComboBox()
// Prepare the new items with deduplication
QSet<QPair<QString, QString>> bannerCardSet;
InnerDecklistNode *listRoot = deckLoader->getRoot();
InnerDecklistNode *listRoot = deckLoader->getDeckList()->getRoot();
for (auto i : *listRoot) {
auto *currentZone = dynamic_cast<InnerDecklistNode *>(i);
for (auto j : *currentZone) {
@ -273,7 +272,7 @@ void DeckPreviewWidget::updateBannerCardComboBox()
bannerCardComboBox->setCurrentIndex(restoredIndex);
} else {
// Add a placeholder "-" and set it as the current selection
int bannerIndex = bannerCardComboBox->findText(deckLoader->getBannerCard().name);
int bannerIndex = bannerCardComboBox->findText(deckLoader->getDeckList()->getBannerCard().name);
if (bannerIndex != -1) {
bannerCardComboBox->setCurrentIndex(bannerIndex);
} else {
@ -291,7 +290,7 @@ void DeckPreviewWidget::setBannerCard(int /* changedIndex */)
{
auto [name, id] = bannerCardComboBox->currentData().value<QPair<QString, QString>>();
CardRef cardRef = {name, id};
deckLoader->setBannerCard(cardRef);
deckLoader->getDeckList()->setBannerCard(cardRef);
deckLoader->saveToFile(filePath, DeckLoader::getFormatFromName(filePath));
bannerCardDisplayWidget->setCard(CardDatabaseManager::query()->getCard(cardRef));
}
@ -374,7 +373,7 @@ void DeckPreviewWidget::addSetBannerCardMenu(QMenu *menu)
void DeckPreviewWidget::actRenameDeck()
{
// read input
const QString oldName = deckLoader->getName();
const QString oldName = deckLoader->getDeckList()->getName();
bool ok;
QString newName = QInputDialog::getText(this, "Rename deck", tr("New name:"), QLineEdit::Normal, oldName, &ok);
@ -383,7 +382,7 @@ void DeckPreviewWidget::actRenameDeck()
}
// write change
deckLoader->setName(newName);
deckLoader->getDeckList()->setName(newName);
deckLoader->saveToFile(filePath, DeckLoader::getFormatFromName(filePath));
// update VDS

View file

@ -51,7 +51,7 @@ public:
signals:
void deckLoadRequested(const QString &filePath);
void openDeckEditor(const DeckLoader *deck);
void openDeckEditor(DeckLoader *deck);
public slots:
void setFilePath(const QString &filePath);

View file

@ -210,7 +210,7 @@ QStringList VisualDeckStorageFolderDisplayWidget::gatherAllTagsFromFlowWidget()
// Iterate through all DeckPreviewWidgets
for (DeckPreviewWidget *display : flowWidget->findChildren<DeckPreviewWidget *>()) {
// Get tags from each DeckPreviewWidget
QStringList tags = display->deckLoader->getTags();
QStringList tags = display->deckLoader->getDeckList()->getTags();
// Add tags to the list while avoiding duplicates
allTags.append(tags);

View file

@ -93,14 +93,14 @@ QList<DeckPreviewWidget *> VisualDeckStorageSortWidget::filterFiles(QList<DeckPr
switch (sortOrder) {
case ByName:
return widget1->deckLoader->getName() < widget2->deckLoader->getName();
return widget1->deckLoader->getDeckList()->getName() < widget2->deckLoader->getDeckList()->getName();
case Alphabetical:
return QString::localeAwareCompare(info1.fileName(), info2.fileName()) <= 0;
case ByLastModified:
return info1.lastModified() > info2.lastModified();
case ByLastLoaded: {
QDateTime time1 = QDateTime::fromString(widget1->deckLoader->getLastLoadedTimestamp());
QDateTime time2 = QDateTime::fromString(widget2->deckLoader->getLastLoadedTimestamp());
QDateTime time1 = QDateTime::fromString(widget1->deckLoader->getDeckList()->getLastLoadedTimestamp());
QDateTime time2 = QDateTime::fromString(widget2->deckLoader->getDeckList()->getLastLoadedTimestamp());
return time1 > time2;
}
}

View file

@ -59,7 +59,7 @@ void VisualDeckStorageTagFilterWidget::filterDecksBySelectedTags(const QList<Dec
}
for (DeckPreviewWidget *deckPreview : deckPreviews) {
QStringList deckTags = deckPreview->deckLoader->getTags();
QStringList deckTags = deckPreview->deckLoader->getDeckList()->getTags();
bool hasAllSelected = std::all_of(selectedTags.begin(), selectedTags.end(),
[&deckTags](const QString &tag) { return deckTags.contains(tag); });
@ -155,7 +155,7 @@ QSet<QString> VisualDeckStorageTagFilterWidget::gatherAllTags() const
for (DeckPreviewWidget *widget : deckWidgets) {
if (widget->checkVisibility()) {
for (const QString &tag : widget->deckLoader->getTags()) {
for (const QString &tag : widget->deckLoader->getDeckList()->getTags()) {
allTags.insert(tag);
}
}

View file

@ -57,7 +57,7 @@ public slots:
signals:
void bannerCardsRefreshed();
void deckLoadRequested(const QString &filePath);
void openDeckEditor(const DeckLoader *deck);
void openDeckEditor(DeckLoader *deck);
private:
QVBoxLayout *layout;