mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 00:24:47 -07:00
parent
bac6beeb50
commit
122926c6cd
4 changed files with 64 additions and 33 deletions
|
|
@ -58,6 +58,8 @@ AbstractTabDeckEditor::AbstractTabDeckEditor(TabSupervisor *_tabSupervisor) : Ta
|
|||
{
|
||||
setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks);
|
||||
|
||||
historyManager = new DeckListHistoryManager(this);
|
||||
|
||||
databaseDisplayDockWidget = new DeckEditorDatabaseDisplayWidget(this);
|
||||
deckDockWidget = new DeckEditorDeckDockWidget(this);
|
||||
cardInfoDockWidget = new DeckEditorCardInfoDockWidget(this);
|
||||
|
|
@ -70,6 +72,10 @@ AbstractTabDeckEditor::AbstractTabDeckEditor(TabSupervisor *_tabSupervisor) : Ta
|
|||
// Connect deck signals to this tab
|
||||
connect(deckDockWidget, &DeckEditorDeckDockWidget::deckChanged, this, &AbstractTabDeckEditor::onDeckChanged);
|
||||
connect(deckDockWidget, &DeckEditorDeckDockWidget::deckModified, this, &AbstractTabDeckEditor::onDeckModified);
|
||||
connect(deckDockWidget, &DeckEditorDeckDockWidget::requestDeckHistorySave, this,
|
||||
&AbstractTabDeckEditor::onDeckHistorySaveRequested);
|
||||
connect(deckDockWidget, &DeckEditorDeckDockWidget::requestDeckHistoryClear, this,
|
||||
&AbstractTabDeckEditor::onDeckHistoryClearRequested);
|
||||
connect(deckDockWidget, &DeckEditorDeckDockWidget::cardChanged, this, &AbstractTabDeckEditor::updateCard);
|
||||
connect(this, &AbstractTabDeckEditor::decrementCard, deckDockWidget, &DeckEditorDeckDockWidget::actDecrementCard);
|
||||
|
||||
|
|
@ -107,6 +113,7 @@ void AbstractTabDeckEditor::updateCard(const ExactCard &card)
|
|||
/** @brief Placeholder: called when the deck changes. */
|
||||
void AbstractTabDeckEditor::onDeckChanged()
|
||||
{
|
||||
historyManager->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -118,6 +125,22 @@ void AbstractTabDeckEditor::onDeckModified()
|
|||
deckMenu->setSaveStatus(!isBlankNewDeck());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Marks the tab as modified and updates the save menu status.
|
||||
*/
|
||||
void AbstractTabDeckEditor::onDeckHistorySaveRequested(const QString &modificationReason)
|
||||
{
|
||||
historyManager->save(deckDockWidget->getDeckList()->createMemento(modificationReason));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Marks the tab as modified and updates the save menu status.
|
||||
*/
|
||||
void AbstractTabDeckEditor::onDeckHistoryClearRequested()
|
||||
{
|
||||
historyManager->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Helper for adding a card to a deck zone.
|
||||
* @param card Card to add.
|
||||
|
|
@ -131,7 +154,9 @@ void AbstractTabDeckEditor::addCardHelper(const ExactCard &card, QString zoneNam
|
|||
if (card.getInfo().getIsToken())
|
||||
zoneName = DECK_ZONE_TOKENS;
|
||||
|
||||
emit cardAboutToBeAdded(card, zoneName);
|
||||
onDeckHistorySaveRequested(QString(tr("Added (%1): %2 (%3) %4"))
|
||||
.arg(zoneName, card.getName(), card.getPrinting().getSet()->getCorrectedShortName(),
|
||||
card.getPrinting().getProperty("num")));
|
||||
|
||||
QModelIndex newCardIndex = deckDockWidget->deckModel->addCard(card, zoneName);
|
||||
deckDockWidget->deckView->clearSelection();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
#include "../interface/widgets/visual_deck_storage/deck_preview/deck_preview_deck_tags_display_widget.h"
|
||||
#include "tab.h"
|
||||
|
||||
#include <libcockatrice/deck_list/deck_list_history_manager.h>
|
||||
|
||||
class CardDatabaseModel;
|
||||
class CardDatabaseDisplayModel;
|
||||
|
||||
|
|
@ -132,6 +134,13 @@ public:
|
|||
return deckDockWidget;
|
||||
}
|
||||
|
||||
DeckListHistoryManager *getHistoryManager() const
|
||||
{
|
||||
return historyManager;
|
||||
}
|
||||
|
||||
DeckListHistoryManager *historyManager;
|
||||
|
||||
// UI Elements
|
||||
DeckEditorMenu *deckMenu; ///< Menu for deck operations
|
||||
DeckEditorDatabaseDisplayWidget *databaseDisplayDockWidget; ///< Database dock
|
||||
|
|
@ -147,6 +156,14 @@ public slots:
|
|||
/** @brief Called when the deck is modified. */
|
||||
virtual void onDeckModified();
|
||||
|
||||
/** @brief Called when a widget is about to modify the state of the DeckList.
|
||||
* @param modificationReason The reason for the state modification
|
||||
*/
|
||||
virtual void onDeckHistorySaveRequested(const QString &modificationReason);
|
||||
|
||||
/** @brief Called when a widget would like to clear the history. */
|
||||
virtual void onDeckHistoryClearRequested();
|
||||
|
||||
/** @brief Updates the card info panel.
|
||||
* @param card The card to display.
|
||||
*/
|
||||
|
|
@ -180,7 +197,6 @@ public slots:
|
|||
virtual void dockTopLevelChanged(bool topLevel) = 0;
|
||||
|
||||
signals:
|
||||
void cardAboutToBeAdded(const ExactCard &addedCard, const QString &zoneName);
|
||||
/** @brief Emitted when a deck should be opened in a new editor tab. */
|
||||
void openDeckEditor(DeckLoader *deckLoader);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue