From 9a39af6da0956729d206469a19beb90726a3d84f Mon Sep 17 00:00:00 2001 From: BruebachL <44814898+BruebachL@users.noreply.github.com> Date: Sat, 8 Nov 2025 21:23:10 +0100 Subject: [PATCH] Doxygen tab_deck_editor_visual_tab_widget (#6289) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 29 seconds Took 3 minutes Co-authored-by: Lukas Brübach --- .../tab_deck_editor_visual_tab_widget.cpp | 66 ++++++++++-- .../tab_deck_editor_visual_tab_widget.h | 100 +++++++++++++++--- 2 files changed, 145 insertions(+), 21 deletions(-) diff --git a/cockatrice/src/interface/widgets/tabs/visual_deck_editor/tab_deck_editor_visual_tab_widget.cpp b/cockatrice/src/interface/widgets/tabs/visual_deck_editor/tab_deck_editor_visual_tab_widget.cpp index f42b1ff70..08728dac0 100644 --- a/cockatrice/src/interface/widgets/tabs/visual_deck_editor/tab_deck_editor_visual_tab_widget.cpp +++ b/cockatrice/src/interface/widgets/tabs/visual_deck_editor/tab_deck_editor_visual_tab_widget.cpp @@ -3,6 +3,17 @@ #include "../../interface/widgets/visual_database_display/visual_database_display_widget.h" #include "../abstract_tab_deck_editor.h" +/** + * @brief Constructs the TabDeckEditorVisualTabWidget. + * @param parent The parent QWidget. + * @param _deckEditor Pointer to the associated deck editor. + * @param _deckModel Pointer to the deck list model. + * @param _cardDatabaseModel Pointer to the card database model. + * @param _cardDatabaseDisplayModel Pointer to the card database display model. + * + * Initializes all sub-widgets (visual deck view, database display, deck analytics, + * sample hand) and sets up the tab layout and signal connections. + */ TabDeckEditorVisualTabWidget::TabDeckEditorVisualTabWidget(QWidget *parent, AbstractTabDeckEditor *_deckEditor, DeckListModel *_deckModel, @@ -14,7 +25,6 @@ TabDeckEditorVisualTabWidget::TabDeckEditorVisualTabWidget(QWidget *parent, this->setTabsClosable(true); // Enable tab closing connect(this, &QTabWidget::tabCloseRequested, this, &TabDeckEditorVisualTabWidget::handleTabClose); - // Set up the layout and add tab widget layout = new QVBoxLayout(this); setLayout(layout); @@ -46,16 +56,30 @@ TabDeckEditorVisualTabWidget::TabDeckEditorVisualTabWidget(QWidget *parent, this->addNewTab(sampleHandWidget, tr("Sample Hand")); } +/** + * @brief Emits the cardChanged signal when a card is activated in the visual deck view. + * @param activeCard The card that was activated. + */ void TabDeckEditorVisualTabWidget::onCardChanged(const ExactCard &activeCard) { emit cardChanged(activeCard); } +/** + * @brief Emits the cardChangedDatabaseDisplay signal when a card is hovered in the database display. + * @param activeCard The card that was hovered. + */ void TabDeckEditorVisualTabWidget::onCardChangedDatabaseDisplay(const ExactCard &activeCard) { emit cardChangedDatabaseDisplay(activeCard); } +/** + * @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 zoneName The zone of the deck where the card is located. + */ void TabDeckEditorVisualTabWidget::onCardClickedDeckEditor(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance, QString zoneName) @@ -63,51 +87,77 @@ void TabDeckEditorVisualTabWidget::onCardClickedDeckEditor(QMouseEvent *event, emit cardClicked(event, instance, 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. + */ void TabDeckEditorVisualTabWidget::onCardClickedDatabaseDisplay(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance) { emit cardClickedDatabaseDisplay(event, instance); } +/** + * @brief Adds a new tab with the given widget and title. + * @param widget The widget to add. + * @param title The title of the tab. + */ void TabDeckEditorVisualTabWidget::addNewTab(QWidget *widget, const QString &title) { - // Add new tab to the tab widget this->addTab(widget, title); } +/** + * @brief Removes the currently selected tab. + */ void TabDeckEditorVisualTabWidget::removeCurrentTab() { - // Remove the currently selected tab int currentIndex = this->currentIndex(); if (currentIndex != -1) { this->removeTab(currentIndex); } } +/** + * @brief Sets the title of a tab at a given index. + * @param index The index of the tab. + * @param title The new title. + */ void TabDeckEditorVisualTabWidget::setTabTitle(int index, const QString &title) { - // Set the title of the tab at the given index if (index >= 0 && index < this->count()) { this->setTabText(index, title); } } +/** + * @brief Returns the currently selected tab widget. + * @return Pointer to the current tab widget. + */ QWidget *TabDeckEditorVisualTabWidget::getCurrentTab() const { - // Return the currently selected tab widget return this->currentWidget(); } +/** + * @brief Returns the number of tabs in the tab widget. + * @return Number of tabs. + */ int TabDeckEditorVisualTabWidget::getTabCount() const { - // Return the number of tabs return this->count(); } +/** + * @brief Handles the closing of a tab. + * @param index The index of the tab to close. + * + * Removes the tab and deletes the widget to free memory. + */ void TabDeckEditorVisualTabWidget::handleTabClose(int index) { - // Handle closing of the tab at the given index QWidget *tab = this->widget(index); this->removeTab(index); - delete tab; // Delete the tab's widget to free memory + delete tab; } diff --git a/cockatrice/src/interface/widgets/tabs/visual_deck_editor/tab_deck_editor_visual_tab_widget.h b/cockatrice/src/interface/widgets/tabs/visual_deck_editor/tab_deck_editor_visual_tab_widget.h index 36027f819..b84e9bf33 100644 --- a/cockatrice/src/interface/widgets/tabs/visual_deck_editor/tab_deck_editor_visual_tab_widget.h +++ b/cockatrice/src/interface/widgets/tabs/visual_deck_editor/tab_deck_editor_visual_tab_widget.h @@ -12,34 +12,104 @@ #include #include +/** + * @class TabDeckEditorVisualTabWidget + * @ingroup DeckEditorWidgets + * @brief Tab container for the visual deck editor. + * + * **Description:** + * TabDeckEditorVisualTabWidget is a QTabWidget container for visual deck editing sub-tabs. It organizes the visual + * deck, database display, deck analytics, and sample hand preview into separate tabs. + * + * **Purpose:** + * - Provides a tabbed interface for multiple visual components of the deck editor. + * - Handles forwarding of card events (hover, click, selection) to TabDeckEditorVisual. + * - Manages dynamic tab addition, removal, and title updates. + * + * **Contained Sub-Tabs and Widgets:** + * - VisualDeckEditorWidget — Visual deck interface with card interactions. + * - VisualDatabaseDisplayWidget — Displays card database visually and supports interactions. + * - DeckAnalyticsWidget — Shows deck statistics and metrics. + * - VisualDeckEditorSampleHandWidget — Simulates and displays sample hands. + * + * **Key Methods:** + * - addNewTab(QWidget *widget, const QString &title) — Adds a new tab to the container. + * - removeCurrentTab() — Removes the currently selected tab. + * - setTabTitle(int index, const QString &title) — Sets the title of a specific tab. + * - getCurrentTab() const — Returns the currently active tab widget. + * - getTabCount() const — Returns the number of tabs. + * - handleTabClose(int index) — Handles tab close requests and deletes the widget. + * - onCardChanged(const ExactCard &activeCard) — Emits card change signal from visual deck. + * - onCardChangedDatabaseDisplay(const ExactCard &activeCard) — Emits card change signal from database display. + * - onCardClickedDeckEditor(QMouseEvent *event, ...) — Emits click events from deck editor visual tab. + * - onCardClickedDatabaseDisplay(QMouseEvent *event, ...) — Emits click events from database display tab. + */ class TabDeckEditorVisualTabWidget : public QTabWidget { Q_OBJECT public: + /** + * @brief Construct the tab widget with required models. + * @param parent Parent widget. + * @param _deckEditor Pointer to the deck editor instance. + * @param _deckModel Deck list model. + * @param _cardDatabaseModel Card database model. + * @param _cardDatabaseDisplayModel Database display model. + */ explicit TabDeckEditorVisualTabWidget(QWidget *parent, AbstractTabDeckEditor *_deckEditor, DeckListModel *_deckModel, CardDatabaseModel *_cardDatabaseModel, CardDatabaseDisplayModel *_cardDatabaseDisplayModel); - // Utility functions + /// Add a new tab with a widget and title. void addNewTab(QWidget *widget, const QString &title); + + /// Remove the currently active tab. void removeCurrentTab(); + + /// Set the title of a specific tab. void setTabTitle(int index, const QString &title); + + /// Get the currently active tab widget. QWidget *getCurrentTab() const; + + /// Get the total number of tabs. int getTabCount() const; - VisualDeckEditorWidget *visualDeckView; - DeckAnalyticsWidget *deckAnalytics; - VisualDatabaseDisplayWidget *visualDatabaseDisplay; - PrintingSelector *printingSelector; - VisualDeckEditorSampleHandWidget *sampleHandWidget; + VisualDeckEditorWidget *visualDeckView; ///< Visual deck editor widget. + DeckAnalyticsWidget *deckAnalytics; ///< Deck analytics widget. + VisualDatabaseDisplayWidget *visualDatabaseDisplay; ///< Database display widget. + PrintingSelector *printingSelector; ///< Printing selector widget. + VisualDeckEditorSampleHandWidget *sampleHandWidget; ///< Sample hand simulation widget. public slots: + /** + * @brief Emitted when the active card changes in the deck view. + * @param activeCard New active card. + */ void onCardChanged(const ExactCard &activeCard); + + /** + * @brief Emitted when the active card changes in the database display. + * @param activeCard New active card. + */ void onCardChangedDatabaseDisplay(const ExactCard &activeCard); + + /** + * @brief Emitted when a card is clicked in the deck view. + * @param event Mouse event. + * @param instance Widget representing the clicked card. + * @param zoneName Deck zone of the card. + */ void onCardClickedDeckEditor(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance, QString zoneName); + + /** + * @brief Emitted when a card is clicked in the database display. + * @param event Mouse event. + * @param instance Widget representing the clicked card. + */ void onCardClickedDatabaseDisplay(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance); signals: @@ -49,14 +119,18 @@ signals: void cardClickedDatabaseDisplay(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance); private: - QVBoxLayout *layout; // Layout for the tab widget and other controls - AbstractTabDeckEditor *deckEditor; - DeckListModel *deckModel; - CardDatabaseModel *cardDatabaseModel; - CardDatabaseDisplayModel *cardDatabaseDisplayModel; + QVBoxLayout *layout; ///< Layout for tabs and controls. + AbstractTabDeckEditor *deckEditor; ///< Reference to the deck editor. + DeckListModel *deckModel; ///< Deck list model. + CardDatabaseModel *cardDatabaseModel; ///< Card database model. + CardDatabaseDisplayModel *cardDatabaseDisplayModel; ///< Card database display model. private slots: - void handleTabClose(int index); // Slot for closing a tab + /** + * @brief Handle closing of a tab at a given index. + * @param index Index of the tab to close. + */ + void handleTabClose(int index); }; -#endif // TAB_DECK_EDITOR_VISUAL_TAB_WIDGET_H +#endif // TAB_DECK_EDITOR_VISUAL_TAB_WIDGET_H \ No newline at end of file