Doxygen tab_deck_editor_visual_tab_widget (#6289)

Took 29 seconds


Took 3 minutes

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL
2025-11-08 21:23:10 +01:00
committed by GitHub
parent 6d75ce4b1c
commit 9a39af6da0
2 changed files with 145 additions and 21 deletions

View File

@@ -3,6 +3,17 @@
#include "../../interface/widgets/visual_database_display/visual_database_display_widget.h" #include "../../interface/widgets/visual_database_display/visual_database_display_widget.h"
#include "../abstract_tab_deck_editor.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, TabDeckEditorVisualTabWidget::TabDeckEditorVisualTabWidget(QWidget *parent,
AbstractTabDeckEditor *_deckEditor, AbstractTabDeckEditor *_deckEditor,
DeckListModel *_deckModel, DeckListModel *_deckModel,
@@ -14,7 +25,6 @@ TabDeckEditorVisualTabWidget::TabDeckEditorVisualTabWidget(QWidget *parent,
this->setTabsClosable(true); // Enable tab closing this->setTabsClosable(true); // Enable tab closing
connect(this, &QTabWidget::tabCloseRequested, this, &TabDeckEditorVisualTabWidget::handleTabClose); connect(this, &QTabWidget::tabCloseRequested, this, &TabDeckEditorVisualTabWidget::handleTabClose);
// Set up the layout and add tab widget
layout = new QVBoxLayout(this); layout = new QVBoxLayout(this);
setLayout(layout); setLayout(layout);
@@ -46,16 +56,30 @@ TabDeckEditorVisualTabWidget::TabDeckEditorVisualTabWidget(QWidget *parent,
this->addNewTab(sampleHandWidget, tr("Sample Hand")); 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) void TabDeckEditorVisualTabWidget::onCardChanged(const ExactCard &activeCard)
{ {
emit cardChanged(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) void TabDeckEditorVisualTabWidget::onCardChangedDatabaseDisplay(const ExactCard &activeCard)
{ {
emit cardChangedDatabaseDisplay(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, void TabDeckEditorVisualTabWidget::onCardClickedDeckEditor(QMouseEvent *event,
CardInfoPictureWithTextOverlayWidget *instance, CardInfoPictureWithTextOverlayWidget *instance,
QString zoneName) QString zoneName)
@@ -63,51 +87,77 @@ void TabDeckEditorVisualTabWidget::onCardClickedDeckEditor(QMouseEvent *event,
emit cardClicked(event, instance, zoneName); 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, void TabDeckEditorVisualTabWidget::onCardClickedDatabaseDisplay(QMouseEvent *event,
CardInfoPictureWithTextOverlayWidget *instance) CardInfoPictureWithTextOverlayWidget *instance)
{ {
emit cardClickedDatabaseDisplay(event, 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) void TabDeckEditorVisualTabWidget::addNewTab(QWidget *widget, const QString &title)
{ {
// Add new tab to the tab widget
this->addTab(widget, title); this->addTab(widget, title);
} }
/**
* @brief Removes the currently selected tab.
*/
void TabDeckEditorVisualTabWidget::removeCurrentTab() void TabDeckEditorVisualTabWidget::removeCurrentTab()
{ {
// Remove the currently selected tab
int currentIndex = this->currentIndex(); int currentIndex = this->currentIndex();
if (currentIndex != -1) { if (currentIndex != -1) {
this->removeTab(currentIndex); 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) void TabDeckEditorVisualTabWidget::setTabTitle(int index, const QString &title)
{ {
// Set the title of the tab at the given index
if (index >= 0 && index < this->count()) { if (index >= 0 && index < this->count()) {
this->setTabText(index, title); this->setTabText(index, title);
} }
} }
/**
* @brief Returns the currently selected tab widget.
* @return Pointer to the current tab widget.
*/
QWidget *TabDeckEditorVisualTabWidget::getCurrentTab() const QWidget *TabDeckEditorVisualTabWidget::getCurrentTab() const
{ {
// Return the currently selected tab widget
return this->currentWidget(); return this->currentWidget();
} }
/**
* @brief Returns the number of tabs in the tab widget.
* @return Number of tabs.
*/
int TabDeckEditorVisualTabWidget::getTabCount() const int TabDeckEditorVisualTabWidget::getTabCount() const
{ {
// Return the number of tabs
return this->count(); 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) void TabDeckEditorVisualTabWidget::handleTabClose(int index)
{ {
// Handle closing of the tab at the given index
QWidget *tab = this->widget(index); QWidget *tab = this->widget(index);
this->removeTab(index); this->removeTab(index);
delete tab; // Delete the tab's widget to free memory delete tab;
} }

View File

@@ -12,34 +12,104 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWidget> #include <QWidget>
/**
* @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 class TabDeckEditorVisualTabWidget : public QTabWidget
{ {
Q_OBJECT Q_OBJECT
public: 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, explicit TabDeckEditorVisualTabWidget(QWidget *parent,
AbstractTabDeckEditor *_deckEditor, AbstractTabDeckEditor *_deckEditor,
DeckListModel *_deckModel, DeckListModel *_deckModel,
CardDatabaseModel *_cardDatabaseModel, CardDatabaseModel *_cardDatabaseModel,
CardDatabaseDisplayModel *_cardDatabaseDisplayModel); CardDatabaseDisplayModel *_cardDatabaseDisplayModel);
// Utility functions /// Add a new tab with a widget and title.
void addNewTab(QWidget *widget, const QString &title); void addNewTab(QWidget *widget, const QString &title);
/// Remove the currently active tab.
void removeCurrentTab(); void removeCurrentTab();
/// Set the title of a specific tab.
void setTabTitle(int index, const QString &title); void setTabTitle(int index, const QString &title);
/// Get the currently active tab widget.
QWidget *getCurrentTab() const; QWidget *getCurrentTab() const;
/// Get the total number of tabs.
int getTabCount() const; int getTabCount() const;
VisualDeckEditorWidget *visualDeckView; VisualDeckEditorWidget *visualDeckView; ///< Visual deck editor widget.
DeckAnalyticsWidget *deckAnalytics; DeckAnalyticsWidget *deckAnalytics; ///< Deck analytics widget.
VisualDatabaseDisplayWidget *visualDatabaseDisplay; VisualDatabaseDisplayWidget *visualDatabaseDisplay; ///< Database display widget.
PrintingSelector *printingSelector; PrintingSelector *printingSelector; ///< Printing selector widget.
VisualDeckEditorSampleHandWidget *sampleHandWidget; VisualDeckEditorSampleHandWidget *sampleHandWidget; ///< Sample hand simulation widget.
public slots: public slots:
/**
* @brief Emitted when the active card changes in the deck view.
* @param activeCard New active card.
*/
void onCardChanged(const ExactCard &activeCard); 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); 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); 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); void onCardClickedDatabaseDisplay(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance);
signals: signals:
@@ -49,14 +119,18 @@ signals:
void cardClickedDatabaseDisplay(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance); void cardClickedDatabaseDisplay(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance);
private: private:
QVBoxLayout *layout; // Layout for the tab widget and other controls QVBoxLayout *layout; ///< Layout for tabs and controls.
AbstractTabDeckEditor *deckEditor; AbstractTabDeckEditor *deckEditor; ///< Reference to the deck editor.
DeckListModel *deckModel; DeckListModel *deckModel; ///< Deck list model.
CardDatabaseModel *cardDatabaseModel; CardDatabaseModel *cardDatabaseModel; ///< Card database model.
CardDatabaseDisplayModel *cardDatabaseDisplayModel; CardDatabaseDisplayModel *cardDatabaseDisplayModel; ///< Card database display model.
private slots: 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