mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-11 12:54:10 -07:00
Change getDeckList to return a const ref
This commit is contained in:
parent
65c7f87d0f
commit
c80ce804fd
4 changed files with 29 additions and 34 deletions
|
|
@ -527,9 +527,9 @@ DeckLoader *DeckEditorDeckDockWidget::getDeckLoader()
|
||||||
return deckLoader;
|
return deckLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeckList *DeckEditorDeckDockWidget::getDeckList()
|
const DeckList &DeckEditorDeckDockWidget::getDeckList() const
|
||||||
{
|
{
|
||||||
return deckModel->getDeckList();
|
return *deckModel->getDeckList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public slots:
|
||||||
void syncDisplayWidgetsToModel();
|
void syncDisplayWidgetsToModel();
|
||||||
void sortDeckModelToDeckView();
|
void sortDeckModelToDeckView();
|
||||||
DeckLoader *getDeckLoader();
|
DeckLoader *getDeckLoader();
|
||||||
DeckList *getDeckList();
|
const DeckList &getDeckList() const;
|
||||||
void actIncrement();
|
void actIncrement();
|
||||||
bool swapCard(const QModelIndex &idx);
|
bool swapCard(const QModelIndex &idx);
|
||||||
void actDecrementCard(const ExactCard &card, QString zoneName);
|
void actDecrementCard(const ExactCard &card, QString zoneName);
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ void AbstractTabDeckEditor::onDeckModified()
|
||||||
*/
|
*/
|
||||||
void AbstractTabDeckEditor::onDeckHistorySaveRequested(const QString &modificationReason)
|
void AbstractTabDeckEditor::onDeckHistorySaveRequested(const QString &modificationReason)
|
||||||
{
|
{
|
||||||
historyManager->save(deckDockWidget->getDeckList()->createMemento(modificationReason));
|
historyManager->save(deckDockWidget->getDeckList().createMemento(modificationReason));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -231,7 +231,7 @@ void AbstractTabDeckEditor::openDeck(const LoadedDeck &deck)
|
||||||
void AbstractTabDeckEditor::setDeck(const LoadedDeck &_deck)
|
void AbstractTabDeckEditor::setDeck(const LoadedDeck &_deck)
|
||||||
{
|
{
|
||||||
deckDockWidget->setDeck(_deck);
|
deckDockWidget->setDeck(_deck);
|
||||||
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query()->getCards(getDeckList()->getCardRefList()));
|
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query()->getCards(getDeckList().getCardRefList()));
|
||||||
setModified(false);
|
setModified(false);
|
||||||
|
|
||||||
aDeckDockVisible->setChecked(true);
|
aDeckDockVisible->setChecked(true);
|
||||||
|
|
@ -245,7 +245,7 @@ DeckLoader *AbstractTabDeckEditor::getDeckLoader() const
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Returns the currently loaded deck list. */
|
/** @brief Returns the currently loaded deck list. */
|
||||||
DeckList *AbstractTabDeckEditor::getDeckList() const
|
const DeckList &AbstractTabDeckEditor::getDeckList() const
|
||||||
{
|
{
|
||||||
return deckDockWidget->getDeckList();
|
return deckDockWidget->getDeckList();
|
||||||
}
|
}
|
||||||
|
|
@ -446,7 +446,7 @@ bool AbstractTabDeckEditor::actSaveDeckAs()
|
||||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||||
dialog.setDefaultSuffix("cod");
|
dialog.setDefaultSuffix("cod");
|
||||||
dialog.setNameFilters(DeckLoader::FILE_NAME_FILTERS);
|
dialog.setNameFilters(DeckLoader::FILE_NAME_FILTERS);
|
||||||
dialog.selectFile(getDeckList()->getName().trimmed());
|
dialog.selectFile(getDeckList().getName().trimmed());
|
||||||
|
|
||||||
if (!dialog.exec())
|
if (!dialog.exec())
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -532,25 +532,25 @@ void AbstractTabDeckEditor::actEditDeckInClipboardRaw()
|
||||||
/** @brief Saves deck to clipboard with set info and annotation. */
|
/** @brief Saves deck to clipboard with set info and annotation. */
|
||||||
void AbstractTabDeckEditor::actSaveDeckToClipboard()
|
void AbstractTabDeckEditor::actSaveDeckToClipboard()
|
||||||
{
|
{
|
||||||
DeckLoader::saveToClipboard(*getDeckList(), true, true);
|
DeckLoader::saveToClipboard(getDeckList(), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Saves deck to clipboard with annotation, without set info. */
|
/** @brief Saves deck to clipboard with annotation, without set info. */
|
||||||
void AbstractTabDeckEditor::actSaveDeckToClipboardNoSetInfo()
|
void AbstractTabDeckEditor::actSaveDeckToClipboardNoSetInfo()
|
||||||
{
|
{
|
||||||
DeckLoader::saveToClipboard(*getDeckList(), true, false);
|
DeckLoader::saveToClipboard(getDeckList(), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Saves deck to clipboard without annotations, with set info. */
|
/** @brief Saves deck to clipboard without annotations, with set info. */
|
||||||
void AbstractTabDeckEditor::actSaveDeckToClipboardRaw()
|
void AbstractTabDeckEditor::actSaveDeckToClipboardRaw()
|
||||||
{
|
{
|
||||||
DeckLoader::saveToClipboard(*getDeckList(), false, true);
|
DeckLoader::saveToClipboard(getDeckList(), false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Saves deck to clipboard without annotations or set info. */
|
/** @brief Saves deck to clipboard without annotations or set info. */
|
||||||
void AbstractTabDeckEditor::actSaveDeckToClipboardRawNoSetInfo()
|
void AbstractTabDeckEditor::actSaveDeckToClipboardRawNoSetInfo()
|
||||||
{
|
{
|
||||||
DeckLoader::saveToClipboard(*getDeckList(), false, false);
|
DeckLoader::saveToClipboard(getDeckList(), false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Prints the deck using a QPrintPreviewDialog. */
|
/** @brief Prints the deck using a QPrintPreviewDialog. */
|
||||||
|
|
@ -558,7 +558,7 @@ void AbstractTabDeckEditor::actPrintDeck()
|
||||||
{
|
{
|
||||||
auto *dlg = new QPrintPreviewDialog(this);
|
auto *dlg = new QPrintPreviewDialog(this);
|
||||||
connect(dlg, &QPrintPreviewDialog::paintRequested, this,
|
connect(dlg, &QPrintPreviewDialog::paintRequested, this,
|
||||||
[this](QPrinter *printer) { DeckLoader::printDeckList(printer, *getDeckList()); });
|
[this](QPrinter *printer) { DeckLoader::printDeckList(printer, getDeckList()); });
|
||||||
dlg->exec();
|
dlg->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -591,26 +591,21 @@ void AbstractTabDeckEditor::actLoadDeckFromWebsite()
|
||||||
*/
|
*/
|
||||||
void AbstractTabDeckEditor::exportToDecklistWebsite(DeckLoader::DecklistWebsite website)
|
void AbstractTabDeckEditor::exportToDecklistWebsite(DeckLoader::DecklistWebsite website)
|
||||||
{
|
{
|
||||||
if (DeckList *deckList = getDeckList()) {
|
QString decklistUrlString = DeckLoader::exportDeckToDecklist(getDeckList(), website);
|
||||||
QString decklistUrlString = DeckLoader::exportDeckToDecklist(*deckList, website);
|
// Check to make sure the string isn't empty.
|
||||||
// Check to make sure the string isn't empty.
|
if (decklistUrlString.isEmpty()) {
|
||||||
if (decklistUrlString.isEmpty()) {
|
// Show an error if the deck is empty, and return.
|
||||||
// Show an error if the deck is empty, and return.
|
QMessageBox::critical(this, tr("Error"), tr("There are no cards in your deck to be exported"));
|
||||||
QMessageBox::critical(this, tr("Error"), tr("There are no cards in your deck to be exported"));
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode the string recieved from the model to make sure all characters are encoded.
|
|
||||||
// first we put it into a qurl object
|
|
||||||
QUrl decklistUrl = QUrl(decklistUrlString);
|
|
||||||
// we get the correctly encoded url.
|
|
||||||
decklistUrlString = decklistUrl.toEncoded();
|
|
||||||
// We open the url in the user's default browser
|
|
||||||
QDesktopServices::openUrl(decklistUrlString);
|
|
||||||
} else {
|
|
||||||
// if there's no deck loader object, return an error
|
|
||||||
QMessageBox::critical(this, tr("Error"), tr("No deck was selected to be exported."));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Encode the string recieved from the model to make sure all characters are encoded.
|
||||||
|
// first we put it into a qurl object
|
||||||
|
QUrl decklistUrl = QUrl(decklistUrlString);
|
||||||
|
// we get the correctly encoded url.
|
||||||
|
decklistUrlString = decklistUrl.toEncoded();
|
||||||
|
// We open the url in the user's default browser
|
||||||
|
QDesktopServices::openUrl(decklistUrlString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Exports deck to www.decklist.org. */
|
/** @brief Exports deck to www.decklist.org. */
|
||||||
|
|
@ -629,14 +624,14 @@ void AbstractTabDeckEditor::actExportDeckDecklistXyz()
|
||||||
void AbstractTabDeckEditor::actAnalyzeDeckDeckstats()
|
void AbstractTabDeckEditor::actAnalyzeDeckDeckstats()
|
||||||
{
|
{
|
||||||
auto *interface = new DeckStatsInterface(*databaseDisplayDockWidget->databaseModel->getDatabase(), this);
|
auto *interface = new DeckStatsInterface(*databaseDisplayDockWidget->databaseModel->getDatabase(), this);
|
||||||
interface->analyzeDeck(*getDeckList());
|
interface->analyzeDeck(getDeckList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Analyzes the deck using TappedOut. */
|
/** @brief Analyzes the deck using TappedOut. */
|
||||||
void AbstractTabDeckEditor::actAnalyzeDeckTappedout()
|
void AbstractTabDeckEditor::actAnalyzeDeckTappedout()
|
||||||
{
|
{
|
||||||
auto *interface = new TappedOutInterface(*databaseDisplayDockWidget->databaseModel->getDatabase(), this);
|
auto *interface = new TappedOutInterface(*databaseDisplayDockWidget->databaseModel->getDatabase(), this);
|
||||||
interface->analyzeDeck(*getDeckList());
|
interface->analyzeDeck(getDeckList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Applies a new filter tree to the database display. */
|
/** @brief Applies a new filter tree to the database display. */
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ public:
|
||||||
DeckLoader *getDeckLoader() const;
|
DeckLoader *getDeckLoader() const;
|
||||||
|
|
||||||
/** @brief Returns the currently active deck list. */
|
/** @brief Returns the currently active deck list. */
|
||||||
DeckList *getDeckList() const;
|
const DeckList &getDeckList() const;
|
||||||
|
|
||||||
/** @brief Sets the modified state of the tab.
|
/** @brief Sets the modified state of the tab.
|
||||||
* @param _windowModified Whether the tab is modified.
|
* @param _windowModified Whether the tab is modified.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue