[DeckList] Disable copy constructor

Took 1 hour 44 minutes

Took 1 minute

# Commit time for manual adjustment:
# Took 28 seconds


Took 33 seconds
This commit is contained in:
Lukas Brübach 2025-11-19 13:22:09 +01:00
parent 8788a7aada
commit 9260bebd1c
21 changed files with 162 additions and 105 deletions

View file

@ -29,8 +29,8 @@ public:
QString deckName = obj.value("name").toString();
QString deckDescription = obj.value("description").toString();
loader->getDeckList()->setName(deckName);
loader->getDeckList()->setComments(deckDescription);
loader->setName(deckName);
loader->setComments(deckDescription);
QString outputText;
QTextStream outStream(&outputText);
@ -47,7 +47,7 @@ public:
outStream << quantity << ' ' << cardName << " (" << setName << ") " << collectorNumber << '\n';
}
loader->getDeckList()->loadFromStream_Plain(outStream, false);
loader->loadFromStream_Plain(outStream, false);
DeckLoader::resolveSetNameAndNumberToProviderID(loader->getDeckList());
return loader;
@ -64,8 +64,8 @@ public:
QString deckName = obj.value("name").toString();
QString deckDescription = obj.value("description").toString();
loader->getDeckList()->setName(deckName);
loader->getDeckList()->setComments(deckDescription);
loader->setName(deckName);
loader->setComments(deckDescription);
QString outputText;
QTextStream outStream(&outputText);
@ -94,7 +94,7 @@ public:
outStream << quantity << ' ' << cardName << " (" << setName << ") " << collectorNumber << '\n';
}
loader->getDeckList()->loadFromStream_Plain(outStream, false);
loader->loadFromStream_Plain(outStream, false);
DeckLoader::resolveSetNameAndNumberToProviderID(loader->getDeckList());
QJsonObject commandersObj = obj.value("commanders").toObject();
@ -106,8 +106,8 @@ public:
QString collectorNumber = cardData.value("cn").toString();
QString providerId = cardData.value("scryfall_id").toString();
loader->getDeckList()->setBannerCard({commanderName, providerId});
loader->getDeckList()->addCard(commanderName, DECK_ZONE_MAIN, -1, setName, collectorNumber, providerId);
loader->setBannerCard({commanderName, providerId});
loader->addCard(commanderName, DECK_ZONE_MAIN, -1, setName, collectorNumber, providerId);
}
}

View file

@ -330,7 +330,7 @@ void DeckViewScene::setDeck(const DeckList &_deck)
if (deck)
delete deck;
deck = new DeckList(_deck);
deck = new DeckList(_deck.writeToString_Native());
rebuildTree();
applySideboardPlan(deck->getCurrentSideboardPlan());
rearrangeItems();

View file

@ -263,7 +263,8 @@ void Player::deleteCard(CardItem *card)
}
}
void Player::setDeck(const DeckLoader &_deck)
// TODO: Does a player need a DeckLoader?
void Player::setDeck(DeckLoader &_deck)
{
deck = new DeckLoader(this, _deck.getDeckList());

View file

@ -130,7 +130,7 @@ public:
return playerMenu;
}
void setDeck(const DeckLoader &_deck);
void setDeck(DeckLoader &_deck);
[[nodiscard]] DeckLoader *getDeck() const
{

View file

@ -25,21 +25,14 @@ const QStringList DeckLoader::ACCEPTED_FILE_EXTENSIONS = {"*.cod", "*.dec", "*.d
const QStringList DeckLoader::FILE_NAME_FILTERS = {
tr("Common deck formats (%1)").arg(ACCEPTED_FILE_EXTENSIONS.join(" ")), tr("All files (*.*)")};
DeckLoader::DeckLoader(QObject *parent)
: QObject(parent), deckList(new DeckList()), lastFileFormat(CockatriceFormat), lastRemoteDeckId(-1)
DeckLoader::DeckLoader(QObject *parent) : QObject(parent), lastFileFormat(CockatriceFormat), lastRemoteDeckId(-1)
{
}
DeckLoader::DeckLoader(QObject *parent, DeckList *_deckList)
: QObject(parent), deckList(_deckList), lastFileFormat(CockatriceFormat), lastRemoteDeckId(-1)
DeckLoader::DeckLoader(QObject *parent, const DeckList *_deckList)
: QObject(parent), deckList(_deckList->writeToString_Native()), lastFileFormat(CockatriceFormat),
lastRemoteDeckId(-1)
{
deckList->setParent(this);
}
void DeckLoader::setDeckList(DeckList *_deckList)
{
deckList = _deckList;
deckList->setParent(this);
}
bool DeckLoader::loadFromFile(const QString &fileName, FileFormat fmt, bool userRequest)
@ -52,15 +45,15 @@ bool DeckLoader::loadFromFile(const QString &fileName, FileFormat fmt, bool user
bool result = false;
switch (fmt) {
case PlainTextFormat:
result = deckList->loadFromFile_Plain(&file);
result = deckList.loadFromFile_Plain(&file);
break;
case CockatriceFormat: {
result = deckList->loadFromFile_Native(&file);
result = deckList.loadFromFile_Native(&file);
qCInfo(DeckLoaderLog) << "Loaded from" << fileName << "-" << result;
if (!result) {
qCInfo(DeckLoaderLog) << "Retrying as plain format";
file.seek(0);
result = deckList->loadFromFile_Plain(&file);
result = deckList.loadFromFile_Plain(&file);
fmt = PlainTextFormat;
}
break;
@ -112,13 +105,13 @@ bool DeckLoader::loadFromFileAsync(const QString &fileName, FileFormat fmt, bool
switch (fmt) {
case PlainTextFormat:
return deckList->loadFromFile_Plain(&file);
return deckList.loadFromFile_Plain(&file);
case CockatriceFormat: {
bool result = false;
result = deckList->loadFromFile_Native(&file);
result = deckList.loadFromFile_Native(&file);
if (!result) {
file.seek(0);
return deckList->loadFromFile_Plain(&file);
return deckList.loadFromFile_Plain(&file);
}
return result;
}
@ -134,7 +127,7 @@ bool DeckLoader::loadFromFileAsync(const QString &fileName, FileFormat fmt, bool
bool DeckLoader::loadFromRemote(const QString &nativeString, int remoteDeckId)
{
bool result = deckList->loadFromString_Native(nativeString);
bool result = deckList.loadFromString_Native(nativeString);
if (result) {
lastFileName = QString();
lastFileFormat = CockatriceFormat;
@ -155,16 +148,18 @@ bool DeckLoader::saveToFile(const QString &fileName, FileFormat fmt)
bool result = false;
switch (fmt) {
case PlainTextFormat:
result = deckList->saveToFile_Plain(&file);
result = deckList.saveToFile_Plain(&file);
break;
case CockatriceFormat:
result = deckList->saveToFile_Native(&file);
result = deckList.saveToFile_Native(&file);
qCInfo(DeckLoaderLog) << "Saving to " << fileName << "-" << result;
break;
}
if (result) {
lastFileName = fileName;
lastFileFormat = fmt;
qInfo() << "Deck was saved -" << result;
}
file.flush();
@ -195,11 +190,11 @@ bool DeckLoader::updateLastLoadedTimestamp(const QString &fileName, FileFormat f
// Perform file modifications
switch (fmt) {
case PlainTextFormat:
result = deckList->saveToFile_Plain(&file);
result = deckList.saveToFile_Plain(&file);
break;
case CockatriceFormat:
deckList->setLastLoadedTimestamp(QDateTime::currentDateTime().toString());
result = deckList->saveToFile_Native(&file);
deckList.setLastLoadedTimestamp(QDateTime::currentDateTime().toString());
result = deckList.saveToFile_Native(&file);
break;
}
@ -566,7 +561,7 @@ bool DeckLoader::convertToCockatriceFormat(QString fileName)
switch (getFormatFromName(fileName)) {
case PlainTextFormat:
// Save in Cockatrice's native format
result = deckList->saveToFile_Native(&file);
result = deckList.saveToFile_Native(&file);
break;
case CockatriceFormat:
qCInfo(DeckLoaderLog) << "File is already in Cockatrice format. No conversion needed.";

View file

@ -45,19 +45,17 @@ public:
};
private:
DeckList *deckList;
DeckList deckList;
QString lastFileName;
FileFormat lastFileFormat;
int lastRemoteDeckId;
public:
DeckLoader(QObject *parent);
DeckLoader(QObject *parent, DeckList *_deckList);
DeckLoader(QObject *parent, const DeckList *_deckList);
DeckLoader(const DeckLoader &) = delete;
DeckLoader &operator=(const DeckLoader &) = delete;
void setDeckList(DeckList *_deckList);
const QString &getLastFileName() const
{
return lastFileName;
@ -80,6 +78,20 @@ public:
return getLastFileName().isEmpty() && getLastRemoteDeckId() == -1;
}
void setName(const QString &_name = QString())
{
deckList.setName(_name);
}
void setComments(const QString &_comments = QString())
{
deckList.setComments(_comments);
}
void setTags(const QStringList &_tags = QStringList())
{
deckList.setTags(_tags);
}
static void clearSetNamesAndNumbers(const DeckList *deckList);
static FileFormat getFormatFromName(const QString &fileName);
@ -100,6 +112,54 @@ public:
bool addComments = true,
bool addSetNameAndNumber = true);
/// @name Serialization (XML)
///@{
bool loadFromXml(QXmlStreamReader *xml)
{
return deckList.loadFromXml(xml);
};
bool loadFromString_Native(const QString &nativeString)
{
return deckList.loadFromString_Native(nativeString);
};
QString writeToString_Native() const
{
return deckList.writeToString_Native();
};
bool loadFromFile_Native(QIODevice *device)
{
return deckList.loadFromFile_Native(device);
};
bool saveToFile_Native(QIODevice *device)
{
return deckList.saveToFile_Native(device);
};
///@}
/// @name Serialization (Plain text)
///@{
bool loadFromStream_Plain(QTextStream &stream, bool preserveMetadata)
{
return deckList.loadFromStream_Plain(stream, preserveMetadata);
};
bool loadFromFile_Plain(QIODevice *device)
{
return deckList.loadFromFile_Plain(device);
};
bool saveToStream_Plain(QTextStream &stream, bool prefixSideboardCards, bool slashTappedOutSplitCards)
{
return deckList.saveToStream_Plain(stream, prefixSideboardCards, slashTappedOutSplitCards);
};
bool saveToFile_Plain(QIODevice *device, bool prefixSideboardCards = true, bool slashTappedOutSplitCards = false)
{
return deckList.saveToFile_Plain(device, prefixSideboardCards, slashTappedOutSplitCards);
};
QString writeToString_Plain(bool prefixSideboardCards = true, bool slashTappedOutSplitCards = false)
{
return deckList.writeToString_Plain(prefixSideboardCards, slashTappedOutSplitCards);
};
///@}
/**
* @brief Prints the decklist to the provided QPrinter.
* @param printer The printer to render the decklist to.
@ -109,9 +169,24 @@ public:
bool convertToCockatriceFormat(QString fileName);
DeckList *getDeckList() const
DeckList *getDeckList()
{
return deckList;
return &deckList;
}
DecklistCardNode *addCard(const QString &cardName,
const QString &zoneName,
int position,
const QString &cardSetName = QString(),
const QString &cardSetCollectorNumber = QString(),
const QString &cardProviderId = QString())
{
return deckList.addCard(cardName, zoneName, position, cardSetName, cardSetCollectorNumber, cardProviderId);
};
void setBannerCard(const CardRef &_bannerCard = {})
{
deckList.setBannerCard(_bannerCard);
}
private:

View file

@ -109,7 +109,7 @@ void DeckEditorDeckDockWidget::createDeckDock()
&DeckEditorDeckDockWidget::setBannerCard);
bannerCardComboBox->setHidden(!SettingsCache::instance().getDeckEditorBannerCardComboBoxVisible());
deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckModel->getDeckList());
deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckLoader);
deckTagsDisplayWidget->setHidden(!SettingsCache::instance().getDeckEditorTagsWidgetVisible());
activeGroupCriteriaLabel = new QLabel(this);
@ -382,7 +382,7 @@ void DeckEditorDeckDockWidget::setDeck(DeckLoader *_deck)
deckView->expandAll();
deckView->expandAll();
deckTagsDisplayWidget->connectDeckList(deckModel->getDeckList());
deckTagsDisplayWidget->connectDeckList();
emit deckChanged();
}
@ -412,7 +412,7 @@ void DeckEditorDeckDockWidget::cleanDeck()
emit deckModified();
emit deckChanged();
updateBannerCardComboBox();
deckTagsDisplayWidget->connectDeckList(deckModel->getDeckList());
deckTagsDisplayWidget->connectDeckList();
}
void DeckEditorDeckDockWidget::recursiveExpand(const QModelIndex &index)

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->getDeckList()->loadFromString_Native(buffer);
return deckLoader->loadFromString_Native(buffer);
}
QTextStream stream(&buffer);
if (deckLoader->getDeckList()->loadFromStream_Plain(stream, true)) {
if (deckLoader->loadFromStream_Plain(stream, true)) {
if (loadSetNameAndNumberCheckBox->isChecked()) {
DeckLoader::resolveSetNameAndNumberToProviderID(deckLoader->getDeckList());
} else {
@ -133,16 +133,16 @@ void DlgLoadDeckFromClipboard::actOK()
/**
* Creates the dialog window for the "Edit deck in clipboard" action
*
* @param deckList The existing deck in the deck editor. Copies the instance
* @param _deckLoader The existing deck in the deck editor. Copies the instance
* @param _annotated Whether to add annotations to the text that is loaded from the deck
* @param parent The parent widget
*/
DlgEditDeckInClipboard::DlgEditDeckInClipboard(const DeckLoader &deckList, bool _annotated, QWidget *parent)
DlgEditDeckInClipboard::DlgEditDeckInClipboard(DeckLoader *_deckLoader, bool _annotated, QWidget *parent)
: AbstractDlgDeckTextEdit(parent), annotated(_annotated)
{
setWindowTitle(tr("Edit deck in clipboard"));
deckLoader = new DeckLoader(this, deckList.getDeckList());
deckLoader = new DeckLoader(this, _deckLoader->getDeckList());
deckLoader->setParent(this);
DlgEditDeckInClipboard::actRefresh();

View file

@ -88,7 +88,7 @@ private:
bool annotated;
public:
explicit DlgEditDeckInClipboard(const DeckLoader &deckList, bool _annotated, QWidget *parent = nullptr);
explicit DlgEditDeckInClipboard(DeckLoader *_deckLoader, bool _annotated, QWidget *parent = nullptr);
[[nodiscard]] DeckLoader *getDeckList() const override
{

View file

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

View file

@ -486,7 +486,7 @@ void AbstractTabDeckEditor::actLoadDeckFromClipboard()
*/
void AbstractTabDeckEditor::editDeckInClipboard(bool annotated)
{
DlgEditDeckInClipboard dlg(*getDeckLoader(), annotated, this);
DlgEditDeckInClipboard dlg(getDeckLoader(), annotated, this);
if (!dlg.exec())
return;

View file

@ -18,7 +18,7 @@ void EdhrecDeckApiResponse::fromJson(const QJsonArray &json)
deckLoader = new DeckLoader(nullptr);
QTextStream stream(&deckList);
deckLoader->getDeckList()->loadFromStream_Plain(stream, true);
deckLoader->loadFromStream_Plain(stream, true);
}
void EdhrecDeckApiResponse::debugPrint() const

View file

@ -242,11 +242,11 @@ void TabDeckStorage::actOpenLocalDeck()
continue;
QString filePath = localDirModel->filePath(curLeft);
DeckLoader deckLoader(this);
if (!deckLoader.loadFromFile(filePath, DeckLoader::CockatriceFormat, true))
auto deckLoader = new DeckLoader(this);
if (!deckLoader->loadFromFile(filePath, DeckLoader::CockatriceFormat, true))
continue;
emit openDeckEditor(&deckLoader);
emit openDeckEditor(deckLoader);
}
}
@ -323,9 +323,9 @@ void TabDeckStorage::uploadDeck(const QString &filePath, const QString &targetPa
return;
if (deckName.isEmpty())
deckName = tr("Unnamed deck");
deck.getDeckList()->setName(deckName);
deck.setName(deckName);
} else {
deck.getDeckList()->setName(deck.getDeckList()->getName().left(MAX_NAME_LENGTH));
deck.setName(deck.getDeckList()->getName().left(MAX_NAME_LENGTH));
}
QString deckString = deck.getDeckList()->writeToString_Native();

View file

@ -869,7 +869,7 @@ TabDeckEditor *TabSupervisor::addDeckEditorTab(DeckLoader *deckToOpen)
{
auto *tab = new TabDeckEditor(this);
if (deckToOpen)
tab->openDeck(new DeckLoader(this, deckToOpen->getDeckList()));
tab->openDeck(deckToOpen);
connect(tab, &AbstractTabDeckEditor::deckEditorClosing, this, &TabSupervisor::deckEditorClosed);
connect(tab, &AbstractTabDeckEditor::openDeckEditor, this, &TabSupervisor::addDeckEditorTab);
myAddTab(tab);
@ -882,7 +882,7 @@ TabDeckEditorVisual *TabSupervisor::addVisualDeckEditorTab(DeckLoader *deckToOpe
{
auto *tab = new TabDeckEditorVisual(this);
if (deckToOpen)
tab->openDeck(new DeckLoader(this, deckToOpen->getDeckList()));
tab->openDeck(deckToOpen);
connect(tab, &AbstractTabDeckEditor::deckEditorClosing, this, &TabSupervisor::deckEditorClosed);
connect(tab, &AbstractTabDeckEditor::openDeckEditor, this, &TabSupervisor::addVisualDeckEditorTab);
myAddTab(tab);

View file

@ -27,11 +27,11 @@ TabDeckStorageVisual::TabDeckStorageVisual(TabSupervisor *_tabSupervisor)
void TabDeckStorageVisual::actOpenLocalDeck(const QString &filePath)
{
DeckLoader deckLoader(this);
if (!deckLoader.loadFromFile(filePath, DeckLoader::getFormatFromName(filePath), true)) {
auto deckLoader = new 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;
}
emit openDeckEditor(&deckLoader);
emit openDeckEditor(deckLoader);
}

View file

@ -14,8 +14,8 @@
#include <QLabel>
#include <QMessageBox>
DeckPreviewDeckTagsDisplayWidget::DeckPreviewDeckTagsDisplayWidget(QWidget *_parent, DeckList *_deckList)
: QWidget(_parent), deckList(nullptr)
DeckPreviewDeckTagsDisplayWidget::DeckPreviewDeckTagsDisplayWidget(QWidget *_parent, DeckLoader *_deckLoader)
: QWidget(_parent), deckLoader(_deckLoader)
{
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
@ -28,21 +28,20 @@ DeckPreviewDeckTagsDisplayWidget::DeckPreviewDeckTagsDisplayWidget(QWidget *_par
flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
if (_deckList) {
connectDeckList(_deckList);
}
connectDeckList();
layout->addWidget(flowWidget);
}
void DeckPreviewDeckTagsDisplayWidget::connectDeckList(DeckList *_deckList)
void DeckPreviewDeckTagsDisplayWidget::connectDeckList()
{
if (deckList) {
disconnect(deckList, &DeckList::deckTagsChanged, this, &DeckPreviewDeckTagsDisplayWidget::refreshTags);
if (deckLoader) {
disconnect(deckLoader->getDeckList(), &DeckList::deckTagsChanged, this,
&DeckPreviewDeckTagsDisplayWidget::refreshTags);
}
deckList = _deckList;
connect(deckList, &DeckList::deckTagsChanged, this, &DeckPreviewDeckTagsDisplayWidget::refreshTags);
connect(deckLoader->getDeckList(), &DeckList::deckTagsChanged, this,
&DeckPreviewDeckTagsDisplayWidget::refreshTags);
refreshTags();
}
@ -51,7 +50,7 @@ void DeckPreviewDeckTagsDisplayWidget::refreshTags()
{
flowWidget->clearLayout();
for (const QString &tag : deckList->getTags()) {
for (const QString &tag : deckLoader->getDeckList()->getTags()) {
flowWidget->addWidget(new DeckPreviewTagDisplayWidget(this, tag));
}
@ -98,7 +97,7 @@ void DeckPreviewDeckTagsDisplayWidget::openTagEditDlg()
if (qobject_cast<DeckPreviewWidget *>(parentWidget())) {
auto *deckPreviewWidget = qobject_cast<DeckPreviewWidget *>(parentWidget());
QStringList knownTags = deckPreviewWidget->visualDeckStorageWidget->tagFilterWidget->getAllKnownTags();
QStringList activeTags = deckList->getTags();
QStringList activeTags = deckLoader->getDeckList()->getTags();
bool canAddTags = true;
@ -149,7 +148,7 @@ void DeckPreviewDeckTagsDisplayWidget::openTagEditDlg()
DeckPreviewTagDialog dialog(knownTags, activeTags);
if (dialog.exec() == QDialog::Accepted) {
QStringList updatedTags = dialog.getActiveTags();
deckList->setTags(updatedTags);
deckLoader->setTags(updatedTags);
deckPreviewWidget->deckLoader->saveToFile(deckPreviewWidget->filePath, DeckLoader::CockatriceFormat);
}
}
@ -175,12 +174,12 @@ void DeckPreviewDeckTagsDisplayWidget::openTagEditDlg()
knownTags.removeDuplicates();
}
QStringList activeTags = deckList->getTags();
QStringList activeTags = deckLoader->getDeckList()->getTags();
DeckPreviewTagDialog dialog(knownTags, activeTags);
if (dialog.exec() == QDialog::Accepted) {
QStringList updatedTags = dialog.getActiveTags();
deckList->setTags(updatedTags);
deckLoader->setTags(updatedTags);
deckEditor->setModified(true);
}
}

View file

@ -20,10 +20,10 @@ class DeckPreviewDeckTagsDisplayWidget : public QWidget
Q_OBJECT
public:
explicit DeckPreviewDeckTagsDisplayWidget(QWidget *_parent, DeckList *_deckList);
void connectDeckList(DeckList *_deckList);
explicit DeckPreviewDeckTagsDisplayWidget(QWidget *_parent, DeckLoader *_deckLoader);
void connectDeckList();
void refreshTags();
DeckList *deckList;
DeckLoader *deckLoader;
FlowWidget *flowWidget;
public slots:

View file

@ -82,7 +82,7 @@ void DeckPreviewWidget::initializeUi(const bool deckLoadSuccess)
setFilePath(deckLoader->getLastFileName());
colorIdentityWidget = new ColorIdentityWidget(this, getColorIdentity());
deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckLoader->getDeckList());
deckTagsDisplayWidget = new DeckPreviewDeckTagsDisplayWidget(this, deckLoader);
bannerCardLabel = new QLabel(this);
bannerCardLabel->setObjectName("bannerCardLabel");
@ -285,7 +285,7 @@ void DeckPreviewWidget::setBannerCard(int /* changedIndex */)
{
auto [name, id] = bannerCardComboBox->currentData().value<QPair<QString, QString>>();
CardRef cardRef = {name, id};
deckLoader->getDeckList()->setBannerCard(cardRef);
deckLoader->setBannerCard(cardRef);
deckLoader->saveToFile(filePath, DeckLoader::getFormatFromName(filePath));
bannerCardDisplayWidget->setCard(CardDatabaseManager::query()->getCard(cardRef));
}
@ -377,7 +377,7 @@ void DeckPreviewWidget::actRenameDeck()
}
// write change
deckLoader->getDeckList()->setName(newName);
deckLoader->setName(newName);
deckLoader->saveToFile(filePath, DeckLoader::getFormatFromName(filePath));
// update VDS

View file

@ -80,20 +80,6 @@ DeckList::DeckList()
root = new InnerDecklistNode;
}
// TODO: https://qt-project.org/doc/qt-4.8/qobject.html#no-copy-constructor-or-assignment-operator
DeckList::DeckList(const DeckList &other)
: QObject(), name(other.name), comments(other.comments), bannerCard(other.bannerCard),
lastLoadedTimestamp(other.lastLoadedTimestamp), tags(other.tags), cachedDeckHash(other.cachedDeckHash)
{
root = new InnerDecklistNode(other.getRoot());
QMapIterator<QString, SideboardPlan *> spIterator(other.getSideboardPlans());
while (spIterator.hasNext()) {
spIterator.next();
sideboardPlans.insert(spIterator.key(), new SideboardPlan(spIterator.key(), spIterator.value()->getMoveList()));
}
}
DeckList::DeckList(const QString &nativeString)
{
root = new InnerDecklistNode;

View file

@ -215,8 +215,9 @@ public slots:
public:
/// @brief Construct an empty deck.
explicit DeckList();
/// @brief Deep-copy constructor.
DeckList(const DeckList &other);
/// @brief Delete copy constructor.
DeckList(const DeckList &) = delete;
DeckList &operator=(const DeckList &) = delete;
/// @brief Construct from a serialized native-format string.
explicit DeckList(const QString &nativeString);
~DeckList() override;

View file

@ -533,14 +533,14 @@ void DeckListModel::cleanList()
}
/**
* @param _deck The deck. Takes ownership of the object
* @param _deck The deck.
*/
void DeckListModel::setDeckList(DeckList *_deck)
{
deckList->deleteLater();
deckList = _deck;
deckList->setParent(this);
rebuildTree();
if (deckList != _deck) {
deckList = _deck;
rebuildTree();
}
}
QList<ExactCard> DeckListModel::getCards() const