mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 12:23:58 -07:00
[TabDeckEditor] Refactor: pass ExactCard in signal instead of widget (#6962)
* [TabDeckEditor] Refactor: pass ExactCard in signal instead of widget * address comments
This commit is contained in:
parent
f52dc6dda8
commit
e0cbb7f06c
16 changed files with 41 additions and 69 deletions
|
|
@ -74,7 +74,7 @@ void TabDeckEditorVisual::createCentralFrame()
|
|||
connect(tabContainer, &TabDeckEditorVisualTabWidget::cardClicked, this,
|
||||
&TabDeckEditorVisual::processMainboardCardClick);
|
||||
connect(tabContainer, &TabDeckEditorVisualTabWidget::cardClickedDatabaseDisplay, this,
|
||||
&TabDeckEditorVisual::processCardClickDatabaseDisplay);
|
||||
&TabDeckEditorVisual::processDatabaseCardClick);
|
||||
|
||||
centralFrame->addWidget(tabContainer);
|
||||
setCentralWidget(centralWidget);
|
||||
|
|
@ -143,12 +143,10 @@ void TabDeckEditorVisual::changeModelIndexToCard(const ExactCard &activeCard)
|
|||
}
|
||||
}
|
||||
|
||||
void TabDeckEditorVisual::processMainboardCardClick(QMouseEvent *event,
|
||||
CardInfoPictureWithTextOverlayWidget *instance,
|
||||
void TabDeckEditorVisual::processMainboardCardClick(const QMouseEvent *event,
|
||||
const ExactCard &card,
|
||||
const QString &zoneName)
|
||||
{
|
||||
auto card = instance->getCard();
|
||||
|
||||
// Get the model index for the card
|
||||
QModelIndex idx = deckStateManager->getModel()->findCard(card.getName(), zoneName);
|
||||
if (!idx.isValid()) {
|
||||
|
|
@ -211,17 +209,16 @@ void TabDeckEditorVisual::processMainboardCardClick(QMouseEvent *event,
|
|||
}
|
||||
|
||||
/** @brief Handles clicks on cards in the database display. */
|
||||
void TabDeckEditorVisual::processCardClickDatabaseDisplay(QMouseEvent *event,
|
||||
CardInfoPictureWithTextOverlayWidget *instance)
|
||||
void TabDeckEditorVisual::processDatabaseCardClick(const QMouseEvent *event, const ExactCard &card)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
|
||||
addCard(instance->getCard(), DECK_ZONE_SIDE);
|
||||
addCard(card, DECK_ZONE_SIDE);
|
||||
} else {
|
||||
addCard(instance->getCard(), DECK_ZONE_MAIN);
|
||||
addCard(card, DECK_ZONE_MAIN);
|
||||
}
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
decrementCard(instance->getCard(), DECK_ZONE_MAIN);
|
||||
decrementCard(card, DECK_ZONE_MAIN);
|
||||
} else if (event->button() == Qt::MiddleButton) {
|
||||
deckDockWidget->actRemoveCard();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
* - changeModelIndexAndCardInfo(const ExactCard &card) — Updates deck model selection and card info.
|
||||
* - changeModelIndexToCard(const ExactCard &card) — Selects the card in the deck view.
|
||||
* - processMainboardCardClick(QMouseEvent *event, ...) — Handles clicks on mainboard cards.
|
||||
* - processCardClickDatabaseDisplay(QMouseEvent *event, ...) — Handles clicks on database cards.
|
||||
* - processDatabaseCardClick(QMouseEvent *event, ...) — Handles clicks on database cards.
|
||||
* - actSaveDeckAs() — Overrides save action with temporary UI adjustments.
|
||||
* - showPrintingSelector() — Opens the printing selector dock for the current card.
|
||||
* - freeDocksSize() — Frees constraints on dock widget sizes.
|
||||
|
|
@ -152,19 +152,17 @@ public slots:
|
|||
/**
|
||||
* @brief Handle card clicks in the mainboard visual deck.
|
||||
* @param event Mouse event triggering the action.
|
||||
* @param instance Widget representing the clicked card.
|
||||
* @param card The clicked card.
|
||||
* @param zoneName Deck zone of the card.
|
||||
*/
|
||||
void processMainboardCardClick(QMouseEvent *event,
|
||||
CardInfoPictureWithTextOverlayWidget *instance,
|
||||
const QString &zoneName);
|
||||
void processMainboardCardClick(const QMouseEvent *event, const ExactCard &card, const QString &zoneName);
|
||||
|
||||
/**
|
||||
* @brief Handle card clicks in the database visual display.
|
||||
* @param event Mouse event triggering the action.
|
||||
* @param instance Widget representing the clicked card.
|
||||
* @param card The clicked card.
|
||||
*/
|
||||
void processCardClickDatabaseDisplay(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance);
|
||||
void processDatabaseCardClick(const QMouseEvent *event, const ExactCard &card);
|
||||
|
||||
/**
|
||||
* @brief Save the deck under a new name.
|
||||
|
|
|
|||
|
|
@ -82,25 +82,24 @@ void TabDeckEditorVisualTabWidget::onCardChangedDatabaseDisplay(const ExactCard
|
|||
/**
|
||||
* @brief Emits the cardClicked signal when a card is clicked in the visual deck view.
|
||||
* @param event The mouse event.
|
||||
* @param instance The widget instance of the clicked card.
|
||||
* @param card The clicked card.
|
||||
* @param zoneName The zone of the deck where the card is located.
|
||||
*/
|
||||
void TabDeckEditorVisualTabWidget::onCardClickedDeckEditor(QMouseEvent *event,
|
||||
CardInfoPictureWithTextOverlayWidget *instance,
|
||||
QString zoneName)
|
||||
const ExactCard &card,
|
||||
const QString &zoneName)
|
||||
{
|
||||
emit cardClicked(event, instance, zoneName);
|
||||
emit cardClicked(event, card, zoneName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Emits the cardClickedDatabaseDisplay signal when a card is clicked in the database display.
|
||||
* @param event The mouse event.
|
||||
* @param instance The widget instance of the clicked card.
|
||||
* @param card The clicked card.
|
||||
*/
|
||||
void TabDeckEditorVisualTabWidget::onCardClickedDatabaseDisplay(QMouseEvent *event,
|
||||
CardInfoPictureWithTextOverlayWidget *instance)
|
||||
void TabDeckEditorVisualTabWidget::onCardClickedDatabaseDisplay(QMouseEvent *event, const ExactCard &card)
|
||||
{
|
||||
emit cardClickedDatabaseDisplay(event, instance);
|
||||
emit cardClickedDatabaseDisplay(event, card);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -101,23 +101,23 @@ public slots:
|
|||
/**
|
||||
* @brief Emitted when a card is clicked in the deck view.
|
||||
* @param event Mouse event.
|
||||
* @param instance Widget representing the clicked card.
|
||||
* @param card The clicked card.
|
||||
* @param zoneName Deck zone of the card.
|
||||
*/
|
||||
void onCardClickedDeckEditor(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance, QString zoneName);
|
||||
void onCardClickedDeckEditor(QMouseEvent *event, const ExactCard &card, const QString &zoneName);
|
||||
|
||||
/**
|
||||
* @brief Emitted when a card is clicked in the database display.
|
||||
* @param event Mouse event.
|
||||
* @param instance Widget representing the clicked card.
|
||||
* @param card The clicked card.
|
||||
*/
|
||||
void onCardClickedDatabaseDisplay(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance);
|
||||
void onCardClickedDatabaseDisplay(QMouseEvent *event, const ExactCard &card);
|
||||
|
||||
signals:
|
||||
void cardChanged(const ExactCard &activeCard);
|
||||
void cardChangedDatabaseDisplay(const ExactCard &activeCard);
|
||||
void cardClicked(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance, QString zoneName);
|
||||
void cardClickedDatabaseDisplay(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance);
|
||||
void cardClicked(QMouseEvent *event, const ExactCard &card, const QString &zoneName);
|
||||
void cardClickedDatabaseDisplay(QMouseEvent *event, const ExactCard &card);
|
||||
|
||||
private:
|
||||
QVBoxLayout *layout; ///< Layout for tabs and controls.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue