mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 17:44:01 -07:00
Doxygen, reorder fields in constructor, readability.
This commit is contained in:
parent
0cc9447cf7
commit
a08f65adf5
2 changed files with 282 additions and 107 deletions
|
|
@ -55,13 +55,11 @@ TabArchidekt::TabArchidekt(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor)
|
||||||
orderByCombo = new QComboBox(navigationContainer);
|
orderByCombo = new QComboBox(navigationContainer);
|
||||||
orderByCombo->addItems({"name", "updatedAt", "createdAt", "viewCount", "size", "edhBracket"});
|
orderByCombo->addItems({"name", "updatedAt", "createdAt", "viewCount", "size", "edhBracket"});
|
||||||
orderByCombo->setCurrentText("updatedAt"); // Pre-select updatedAt
|
orderByCombo->setCurrentText("updatedAt"); // Pre-select updatedAt
|
||||||
navigationLayout->addWidget(orderByCombo);
|
|
||||||
|
|
||||||
// Asc/Desc toggle
|
// Asc/Desc toggle
|
||||||
orderDirButton = new QPushButton(tr("Desc."), navigationContainer);
|
orderDirButton = new QPushButton(tr("Desc."), navigationContainer);
|
||||||
orderDirButton->setCheckable(true); // checked = DESC, unchecked = ASC
|
orderDirButton->setCheckable(true); // checked = DESC, unchecked = ASC
|
||||||
orderDirButton->setChecked(true);
|
orderDirButton->setChecked(true);
|
||||||
navigationLayout->addWidget(orderDirButton);
|
|
||||||
|
|
||||||
connect(orderByCombo, &QComboBox::currentTextChanged, this, [this]() { doSearch(); });
|
connect(orderByCombo, &QComboBox::currentTextChanged, this, [this]() { doSearch(); });
|
||||||
connect(orderDirButton, &QPushButton::clicked, this, [this](bool checked) {
|
connect(orderDirButton, &QPushButton::clicked, this, [this](bool checked) {
|
||||||
|
|
@ -88,10 +86,7 @@ TabArchidekt::TabArchidekt(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
navigationLayout->addLayout(colorLayout);
|
|
||||||
|
|
||||||
logicalAndCheck = new QCheckBox("Require ALL colors", navigationContainer);
|
logicalAndCheck = new QCheckBox("Require ALL colors", navigationContainer);
|
||||||
navigationLayout->addWidget(logicalAndCheck);
|
|
||||||
|
|
||||||
// Formats
|
// Formats
|
||||||
|
|
||||||
|
|
@ -110,20 +105,15 @@ TabArchidekt::TabArchidekt(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor)
|
||||||
formatSettingsWidget->addSettingsWidget(formatCheckBox);
|
formatSettingsWidget->addSettingsWidget(formatCheckBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigationLayout->addWidget(formatSettingsWidget);
|
|
||||||
navigationLayout->addWidget(formatLabel);
|
|
||||||
|
|
||||||
// EDH Bracket
|
// EDH Bracket
|
||||||
edhBracketCombo = new QComboBox(navigationContainer);
|
edhBracketCombo = new QComboBox(navigationContainer);
|
||||||
edhBracketCombo->addItem(tr("Any Bracket"));
|
edhBracketCombo->addItem(tr("Any Bracket"));
|
||||||
edhBracketCombo->addItems({"1", "2", "3", "4", "5"});
|
edhBracketCombo->addItems({"1", "2", "3", "4", "5"});
|
||||||
navigationLayout->addWidget(edhBracketCombo);
|
|
||||||
|
|
||||||
connect(edhBracketCombo, &QComboBox::currentTextChanged, this, [this]() { doSearch(); });
|
connect(edhBracketCombo, &QComboBox::currentTextChanged, this, [this]() { doSearch(); });
|
||||||
|
|
||||||
// Search for Card Packages instead of Decks
|
// Search for Card Packages instead of Decks
|
||||||
packagesCheck = new QCheckBox("Packages", navigationContainer);
|
packagesCheck = new QCheckBox("Packages", navigationContainer);
|
||||||
navigationLayout->addWidget(packagesCheck);
|
|
||||||
|
|
||||||
connect(packagesCheck, &QCheckBox::clicked, this, [this]() {
|
connect(packagesCheck, &QCheckBox::clicked, this, [this]() {
|
||||||
bool disable = packagesCheck->isChecked();
|
bool disable = packagesCheck->isChecked();
|
||||||
|
|
@ -139,25 +129,18 @@ TabArchidekt::TabArchidekt(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor)
|
||||||
// Deck Name
|
// Deck Name
|
||||||
nameField = new QLineEdit(navigationContainer);
|
nameField = new QLineEdit(navigationContainer);
|
||||||
nameField->setPlaceholderText(tr("Deck name contains..."));
|
nameField->setPlaceholderText(tr("Deck name contains..."));
|
||||||
navigationLayout->addWidget(nameField);
|
|
||||||
|
|
||||||
// Owner Name
|
// Owner Name
|
||||||
|
|
||||||
ownerField = new QLineEdit(navigationContainer);
|
ownerField = new QLineEdit(navigationContainer);
|
||||||
ownerField->setPlaceholderText(tr("Owner name contains..."));
|
ownerField->setPlaceholderText(tr("Owner name contains..."));
|
||||||
navigationLayout->addWidget(ownerField);
|
|
||||||
|
|
||||||
// Contained cards
|
// Contained cards
|
||||||
|
|
||||||
cardsField = new QLineEdit(navigationContainer);
|
cardsField = new QLineEdit(navigationContainer);
|
||||||
cardsField->setPlaceholderText("Cards (comma separated)");
|
cardsField->setPlaceholderText("Cards (comma separated)");
|
||||||
navigationLayout->addWidget(cardsField);
|
|
||||||
|
|
||||||
// Commanders
|
// Commanders
|
||||||
|
|
||||||
commandersField = new QLineEdit(navigationContainer);
|
commandersField = new QLineEdit(navigationContainer);
|
||||||
commandersField->setPlaceholderText("Commanders (comma separated)");
|
commandersField->setPlaceholderText("Commanders (comma separated)");
|
||||||
navigationLayout->addWidget(commandersField);
|
|
||||||
|
|
||||||
// DB supplemented card search
|
// DB supplemented card search
|
||||||
auto cardDatabaseModel = new CardDatabaseModel(CardDatabaseManager::getInstance(), false, this);
|
auto cardDatabaseModel = new CardDatabaseModel(CardDatabaseManager::getInstance(), false, this);
|
||||||
|
|
@ -201,14 +184,12 @@ TabArchidekt::TabArchidekt(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor)
|
||||||
// Tag Name
|
// Tag Name
|
||||||
deckTagNameField = new QLineEdit(navigationContainer);
|
deckTagNameField = new QLineEdit(navigationContainer);
|
||||||
deckTagNameField->setPlaceholderText("Deck tag");
|
deckTagNameField->setPlaceholderText("Deck tag");
|
||||||
navigationLayout->addWidget(deckTagNameField);
|
|
||||||
|
|
||||||
connect(deckTagNameField, &QLineEdit::textChanged, this, [this]() { doSearch(); });
|
connect(deckTagNameField, &QLineEdit::textChanged, this, [this]() { doSearch(); });
|
||||||
|
|
||||||
// Search button
|
// Search button
|
||||||
searchPushButton = new QPushButton(navigationContainer);
|
searchPushButton = new QPushButton(navigationContainer);
|
||||||
searchPushButton->setText("Search");
|
searchPushButton->setText("Search");
|
||||||
navigationLayout->addWidget(searchPushButton);
|
|
||||||
|
|
||||||
connect(searchPushButton, &QPushButton::clicked, this, [this]() { doSearch(); });
|
connect(searchPushButton, &QPushButton::clicked, this, [this]() { doSearch(); });
|
||||||
|
|
||||||
|
|
@ -216,23 +197,18 @@ TabArchidekt::TabArchidekt(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor)
|
||||||
settingsButton = new SettingsButtonWidget(this);
|
settingsButton = new SettingsButtonWidget(this);
|
||||||
cardSizeSlider = new CardSizeWidget(this);
|
cardSizeSlider = new CardSizeWidget(this);
|
||||||
settingsButton->addSettingsWidget(cardSizeSlider);
|
settingsButton->addSettingsWidget(cardSizeSlider);
|
||||||
navigationLayout->addWidget(settingsButton);
|
|
||||||
|
|
||||||
// Page size
|
// Min deck size
|
||||||
|
minDeckSizeLabel = new QLabel(navigationContainer);
|
||||||
|
|
||||||
pageSizeLabel = new QLabel(navigationContainer);
|
minDeckSizeSpin = new QSpinBox(navigationContainer);
|
||||||
navigationLayout->addWidget(pageSizeLabel);
|
minDeckSizeSpin->setRange(1, 200);
|
||||||
|
minDeckSizeSpin->setValue(50);
|
||||||
pageSizeSpin = new QSpinBox(navigationContainer);
|
|
||||||
pageSizeSpin->setRange(1, 200);
|
|
||||||
pageSizeSpin->setValue(50);
|
|
||||||
navigationLayout->addWidget(pageSizeSpin);
|
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
pageSpin = new QSpinBox(navigationContainer);
|
pageSpin = new QSpinBox(navigationContainer);
|
||||||
pageSpin->setRange(1, 9999);
|
pageSpin->setRange(1, 9999);
|
||||||
pageSpin->setValue(1);
|
pageSpin->setValue(1);
|
||||||
navigationLayout->addWidget(pageSpin);
|
|
||||||
|
|
||||||
connect(pageSpin, &QSpinBox::valueChanged, this, [this]() { doSearch(); });
|
connect(pageSpin, &QSpinBox::valueChanged, this, [this]() { doSearch(); });
|
||||||
|
|
||||||
|
|
@ -242,6 +218,54 @@ TabArchidekt::TabArchidekt(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor)
|
||||||
currentPageLayout->setContentsMargins(0, 0, 0, 0);
|
currentPageLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
currentPageDisplay->setLayout(currentPageLayout);
|
currentPageDisplay->setLayout(currentPageLayout);
|
||||||
|
|
||||||
|
// Layout composition
|
||||||
|
|
||||||
|
// Sort section
|
||||||
|
navigationLayout->addWidget(orderByCombo);
|
||||||
|
navigationLayout->addWidget(orderDirButton);
|
||||||
|
|
||||||
|
// Colors section
|
||||||
|
navigationLayout->addLayout(colorLayout);
|
||||||
|
navigationLayout->addWidget(logicalAndCheck);
|
||||||
|
|
||||||
|
// Formats section
|
||||||
|
navigationLayout->addWidget(formatSettingsWidget);
|
||||||
|
navigationLayout->addWidget(formatLabel);
|
||||||
|
|
||||||
|
// EDH Bracket
|
||||||
|
navigationLayout->addWidget(edhBracketCombo);
|
||||||
|
|
||||||
|
// Packages toggle
|
||||||
|
navigationLayout->addWidget(packagesCheck);
|
||||||
|
|
||||||
|
// Deck name
|
||||||
|
navigationLayout->addWidget(nameField);
|
||||||
|
|
||||||
|
// Owner name
|
||||||
|
navigationLayout->addWidget(ownerField);
|
||||||
|
|
||||||
|
// Contained cards
|
||||||
|
navigationLayout->addWidget(cardsField);
|
||||||
|
|
||||||
|
// Commanders
|
||||||
|
navigationLayout->addWidget(commandersField);
|
||||||
|
|
||||||
|
// Deck tag
|
||||||
|
navigationLayout->addWidget(deckTagNameField);
|
||||||
|
|
||||||
|
// Search button
|
||||||
|
navigationLayout->addWidget(searchPushButton);
|
||||||
|
|
||||||
|
// Card size settings
|
||||||
|
navigationLayout->addWidget(settingsButton);
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
navigationLayout->addWidget(minDeckSizeLabel);
|
||||||
|
navigationLayout->addWidget(minDeckSizeSpin);
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
navigationLayout->addWidget(pageSpin);
|
||||||
|
|
||||||
mainLayout->addWidget(navigationContainer);
|
mainLayout->addWidget(navigationContainer);
|
||||||
mainLayout->addWidget(currentPageDisplay);
|
mainLayout->addWidget(currentPageDisplay);
|
||||||
|
|
||||||
|
|
@ -260,16 +284,21 @@ void TabArchidekt::retranslateUi()
|
||||||
{
|
{
|
||||||
searchPushButton->setText(tr("Search"));
|
searchPushButton->setText(tr("Search"));
|
||||||
formatLabel->setText(tr("Formats"));
|
formatLabel->setText(tr("Formats"));
|
||||||
pageSizeLabel->setText(tr("Min. # of Cards:"));
|
minDeckSizeLabel->setText(tr("Min. # of Cards:"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TabArchidekt::buildSearchUrl()
|
QString TabArchidekt::buildSearchUrl()
|
||||||
{
|
{
|
||||||
QUrlQuery query;
|
QUrlQuery query;
|
||||||
|
|
||||||
// Name
|
// orderBy (field + direction)
|
||||||
if (!nameField->text().isEmpty()) {
|
{
|
||||||
query.addQueryItem("name", nameField->text());
|
QString field = orderByCombo->currentText();
|
||||||
|
if (!field.isEmpty()) {
|
||||||
|
bool desc = orderDirButton->isChecked();
|
||||||
|
QString final = desc ? "-" + field : field;
|
||||||
|
query.addQueryItem("orderBy", final);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
|
|
@ -277,7 +306,6 @@ QString TabArchidekt::buildSearchUrl()
|
||||||
for (QChar c : activeColors) {
|
for (QChar c : activeColors) {
|
||||||
selectedColors.append(c);
|
selectedColors.append(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selectedColors.isEmpty()) {
|
if (!selectedColors.isEmpty()) {
|
||||||
query.addQueryItem("colors", selectedColors.join(","));
|
query.addQueryItem("colors", selectedColors.join(","));
|
||||||
}
|
}
|
||||||
|
|
@ -287,6 +315,38 @@ QString TabArchidekt::buildSearchUrl()
|
||||||
query.addQueryItem("logicalAnd", "true");
|
query.addQueryItem("logicalAnd", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Formats
|
||||||
|
if (!packagesCheck->isChecked()) {
|
||||||
|
QStringList formatIds;
|
||||||
|
for (int i = 0; i < formatChecks.size(); ++i)
|
||||||
|
if (formatChecks[i]->isChecked()) {
|
||||||
|
formatIds << QString::number(i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formatIds.isEmpty()) {
|
||||||
|
query.addQueryItem("deckFormat", formatIds.join(","));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// edhBracket
|
||||||
|
if (!packagesCheck->isChecked()) {
|
||||||
|
if (!edhBracketCombo->currentText().isEmpty()) {
|
||||||
|
if (edhBracketCombo->currentText() != tr("Any Bracket")) {
|
||||||
|
query.addQueryItem("edhBracket", edhBracketCombo->currentText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search for card packages instead of decks
|
||||||
|
if (packagesCheck->isChecked()) {
|
||||||
|
query.addQueryItem("packages", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name
|
||||||
|
if (!nameField->text().isEmpty()) {
|
||||||
|
query.addQueryItem("name", nameField->text());
|
||||||
|
}
|
||||||
|
|
||||||
// owner
|
// owner
|
||||||
if (!ownerField->text().isEmpty()) {
|
if (!ownerField->text().isEmpty()) {
|
||||||
query.addQueryItem("ownerUsername", ownerField->text());
|
query.addQueryItem("ownerUsername", ownerField->text());
|
||||||
|
|
@ -304,33 +364,6 @@ QString TabArchidekt::buildSearchUrl()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Formats
|
|
||||||
if (!packagesCheck->isChecked()) {
|
|
||||||
QStringList formatIds;
|
|
||||||
for (int i = 0; i < formatChecks.size(); ++i)
|
|
||||||
if (formatChecks[i]->isChecked()) {
|
|
||||||
formatIds << QString::number(i + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!formatIds.isEmpty()) {
|
|
||||||
query.addQueryItem("deckFormat", formatIds.join(","));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search for card packages instead of decks
|
|
||||||
if (packagesCheck->isChecked()) {
|
|
||||||
query.addQueryItem("packages", "true");
|
|
||||||
}
|
|
||||||
|
|
||||||
// edhBracket
|
|
||||||
if (!packagesCheck->isChecked()) {
|
|
||||||
if (!edhBracketCombo->currentText().isEmpty()) {
|
|
||||||
if (edhBracketCombo->currentText() != tr("Any Bracket")) {
|
|
||||||
query.addQueryItem("edhBracket", edhBracketCombo->currentText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// deckTagName
|
// deckTagName
|
||||||
if (!packagesCheck->isChecked()) {
|
if (!packagesCheck->isChecked()) {
|
||||||
if (!deckTagNameField->text().isEmpty()) {
|
if (!deckTagNameField->text().isEmpty()) {
|
||||||
|
|
@ -338,24 +371,14 @@ QString TabArchidekt::buildSearchUrl()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// orderBy (field + direction)
|
|
||||||
{
|
|
||||||
QString field = orderByCombo->currentText();
|
|
||||||
if (!field.isEmpty()) {
|
|
||||||
bool desc = orderDirButton->isChecked();
|
|
||||||
QString final = desc ? "-" + field : field;
|
|
||||||
query.addQueryItem("orderBy", final);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// page number
|
// page number
|
||||||
if (pageSpin->value() <= 1) {
|
if (pageSpin->value() <= 1) {
|
||||||
query.addQueryItem("page", QString::number(pageSpin->value()));
|
query.addQueryItem("page", QString::number(pageSpin->value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// page size
|
// Min deck size
|
||||||
if (pageSizeSpin->value() != 50) {
|
if (minDeckSizeSpin->value() != 50) {
|
||||||
query.addQueryItem("pageSize", QString::number(pageSizeSpin->value()));
|
query.addQueryItem("size", QString::number(minDeckSizeSpin->value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// build final URL
|
// build final URL
|
||||||
|
|
|
||||||
|
|
@ -14,79 +14,231 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <libcockatrice/card/database/card_database.h>
|
#include <libcockatrice/card/database/card_database.h>
|
||||||
|
|
||||||
|
/** Base API link for Archidekt deck search */
|
||||||
inline QString archidektApiLink = "https://archidekt.com/api/decks/v3/?name=";
|
inline QString archidektApiLink = "https://archidekt.com/api/decks/v3/?name=";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Tab for browsing, searching, and filtering Archidekt decks.
|
||||||
|
*
|
||||||
|
* This class provides a comprehensive interface for querying decks from the Archidekt API.
|
||||||
|
* Users can filter decks by name, owner, included cards, commanders, deck tags, colors, EDH bracket,
|
||||||
|
* and formats. It also provides sorting and pagination, as well as a card size adjustment widget.
|
||||||
|
*/
|
||||||
class TabArchidekt : public Tab
|
class TabArchidekt : public Tab
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new TabArchidekt object
|
||||||
|
* @param _tabSupervisor Parent tab supervisor responsible for tab management and callbacks
|
||||||
|
*
|
||||||
|
* Initializes the network manager, creates all UI components, sets up layouts,
|
||||||
|
* connects signals and slots, and triggers an initial fetch of top decks.
|
||||||
|
*/
|
||||||
explicit TabArchidekt(TabSupervisor *_tabSupervisor);
|
explicit TabArchidekt(TabSupervisor *_tabSupervisor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Update all UI text to reflect the current language or translation
|
||||||
|
*
|
||||||
|
* This function re-applies translations to all labels, buttons, and placeholders.
|
||||||
|
* It should be called after a language change.
|
||||||
|
*/
|
||||||
void retranslateUi() override;
|
void retranslateUi() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct the search URL from all current filters
|
||||||
|
* @return QString Fully constructed URL including all query parameters
|
||||||
|
*
|
||||||
|
* The search URL is dynamically built using the state of all filter widgets.
|
||||||
|
* Parameters included:
|
||||||
|
* - Deck name
|
||||||
|
* - Owner
|
||||||
|
* - Included cards
|
||||||
|
* - Commander cards
|
||||||
|
* - Deck tag
|
||||||
|
* - Colors and logical AND requirement
|
||||||
|
* - Formats
|
||||||
|
* - EDH bracket
|
||||||
|
* - Packages toggle
|
||||||
|
* - Sorting field and direction
|
||||||
|
* - Pagination (page and page size)
|
||||||
|
*/
|
||||||
QString buildSearchUrl();
|
QString buildSearchUrl();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Trigger a search using the current filters
|
||||||
|
*
|
||||||
|
* Sends a network request to the Archidekt API using the URL generated by buildSearchUrl().
|
||||||
|
* Updates the current page display with results asynchronously.
|
||||||
|
*/
|
||||||
void doSearch();
|
void doSearch();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Retrieve the tab display text
|
||||||
|
* @return QString Human-readable title for the tab
|
||||||
|
*
|
||||||
|
* If a card is pre-selected (cardToQuery), its name is appended to the tab title.
|
||||||
|
*/
|
||||||
QString getTabText() const override
|
QString getTabText() const override
|
||||||
{
|
{
|
||||||
auto cardName = cardToQuery.isNull() ? QString() : cardToQuery->getName();
|
auto cardName = cardToQuery.isNull() ? QString() : cardToQuery->getName();
|
||||||
return tr("Archidekt: ") + cardName;
|
return tr("Archidekt: ") + cardName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the card size slider widget
|
||||||
|
* @return CardSizeWidget* Pointer to the card size adjustment slider
|
||||||
|
*
|
||||||
|
* Allows external code to read or manipulate the current card size or hook up the sliders signals.
|
||||||
|
*/
|
||||||
CardSizeWidget *getCardSizeSlider()
|
CardSizeWidget *getCardSizeSlider()
|
||||||
{
|
{
|
||||||
return cardSizeSlider;
|
return cardSizeSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @brief Network manager for handling API requests */
|
||||||
QNetworkAccessManager *networkManager;
|
QNetworkAccessManager *networkManager;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
/**
|
||||||
|
* @brief Process a network reply containing JSON data
|
||||||
|
* @param reply QNetworkReply object with the API response
|
||||||
|
*
|
||||||
|
* Determines whether the response corresponds to a top decks query or a single deck,
|
||||||
|
* and dispatches it to the appropriate handler.
|
||||||
|
*/
|
||||||
void processApiJson(QNetworkReply *reply);
|
void processApiJson(QNetworkReply *reply);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Handle a JSON response containing multiple decks
|
||||||
|
* @param reply QJsonObject containing top deck listings
|
||||||
|
*
|
||||||
|
* Clears the previous page display and creates a new display widget for the results.
|
||||||
|
*/
|
||||||
void processTopDecksResponse(QJsonObject reply);
|
void processTopDecksResponse(QJsonObject reply);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Handle a JSON response for a single deck
|
||||||
|
* @param reply QJsonObject containing deck data
|
||||||
|
*
|
||||||
|
* Clears the previous page display and creates a new display widget for the deck details.
|
||||||
|
*/
|
||||||
void processDeckResponse(QJsonObject reply);
|
void processDeckResponse(QJsonObject reply);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Pretty-print a QJsonValue for debugging
|
||||||
|
* @param value The JSON value to print
|
||||||
|
* @param indentLevel The indentation depth (number of levels)
|
||||||
|
*/
|
||||||
void prettyPrintJson(const QJsonValue &value, int indentLevel);
|
void prettyPrintJson(const QJsonValue &value, int indentLevel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Navigate to a specified page URL
|
||||||
|
* @param url The URL to request
|
||||||
|
*
|
||||||
|
* Typically called when a navigation button is clicked in a deck listing.
|
||||||
|
*/
|
||||||
void actNavigatePage(QString url);
|
void actNavigatePage(QString url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetch top decks from the Archidekt API
|
||||||
|
*
|
||||||
|
* Called on initialization to populate the initial page display.
|
||||||
|
*/
|
||||||
void getTopDecks();
|
void getTopDecks();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *container;
|
// ---------------------------------------------------------------------
|
||||||
QWidget *navigationContainer;
|
// Layout Containers
|
||||||
QWidget *currentPageDisplay;
|
// ---------------------------------------------------------------------
|
||||||
QVBoxLayout *mainLayout;
|
|
||||||
QHBoxLayout *navigationLayout;
|
|
||||||
QVBoxLayout *currentPageLayout;
|
|
||||||
// QLineEdit *searchBar;
|
|
||||||
QPushButton *searchPushButton;
|
|
||||||
|
|
||||||
// Required / basic fields
|
QWidget *container; ///< Root container for the entire tab
|
||||||
QLineEdit *nameField; // Deck name substring
|
QVBoxLayout *mainLayout; ///< Outer vertical layout containing navigation and page display
|
||||||
QLineEdit *ownerField; // Owner substring
|
QWidget *navigationContainer; ///< Container for all navigation/filter controls
|
||||||
|
QHBoxLayout *navigationLayout; ///< Layout for horizontal arrangement of filter widgets
|
||||||
|
QWidget *currentPageDisplay; ///< Widget containing the currently displayed deck(s)
|
||||||
|
QVBoxLayout *currentPageLayout; ///< Layout for deck display widgets
|
||||||
|
|
||||||
// Colors
|
// ---------------------------------------------------------------------
|
||||||
QSet<QChar> activeColors;
|
// Sorting Controls
|
||||||
QCheckBox *logicalAndCheck; // Require ALL colors instead of ANY
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
// Formats
|
QComboBox *orderByCombo; ///< Dropdown for selecting the sort field
|
||||||
QLabel *formatLabel;
|
QPushButton *orderDirButton; ///< Toggle button for ascending/descending sort
|
||||||
SettingsButtonWidget *formatSettingsWidget;
|
|
||||||
QVector<QCheckBox *> formatChecks; // Format checkboxes (13 total)
|
|
||||||
|
|
||||||
QComboBox *edhBracketCombo;
|
// ---------------------------------------------------------------------
|
||||||
QLineEdit *deckTagNameField;
|
// Color Filters
|
||||||
QComboBox *orderByCombo;
|
// ---------------------------------------------------------------------
|
||||||
QPushButton *orderDirButton;
|
|
||||||
QCheckBox *packagesCheck;
|
|
||||||
QSpinBox *pageSpin;
|
|
||||||
|
|
||||||
// Page size
|
QSet<QChar> activeColors; ///< Set of currently active mana colors
|
||||||
QLabel *pageSizeLabel;
|
QCheckBox *logicalAndCheck; ///< Require ALL selected colors instead of ANY
|
||||||
QSpinBox *pageSizeSpin;
|
|
||||||
|
|
||||||
// Cards and Commanders
|
// ---------------------------------------------------------------------
|
||||||
QLineEdit *cardsField; // comma-separated quoted card names
|
// Format Filters
|
||||||
QLineEdit *commandersField; // comma-separated quoted commander names
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
SettingsButtonWidget *settingsButton;
|
QLabel *formatLabel; ///< Label displaying "Formats"
|
||||||
CardSizeWidget *cardSizeSlider;
|
SettingsButtonWidget *formatSettingsWidget; ///< Collapsible widget containing format checkboxes
|
||||||
CardInfoPtr cardToQuery;
|
QVector<QCheckBox *> formatChecks; ///< Individual checkboxes for each format
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// EDH Bracket / Package Toggle
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
QComboBox *edhBracketCombo; ///< Dropdown for EDH bracket selection
|
||||||
|
QCheckBox *packagesCheck; ///< Toggle for searching card packages instead of full decks
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// Basic Search Fields
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
QLineEdit *nameField; ///< Input for deck name filter
|
||||||
|
QLineEdit *ownerField; ///< Input for owner name filter
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// Card Filters
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
QLineEdit *cardsField; ///< Input for cards included in the deck (comma-separated)
|
||||||
|
QLineEdit *commandersField; ///< Input for commander cards (comma-separated)
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// Deck Tag
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
QLineEdit *deckTagNameField; ///< Input for deck tag filtering
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// Search Trigger
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
QPushButton *searchPushButton; ///< Button to trigger the search manually
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// UI Settings (Card Size)
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
SettingsButtonWidget *settingsButton; ///< Container for additional UI settings
|
||||||
|
CardSizeWidget *cardSizeSlider; ///< Slider to adjust card size in results
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// Minimum Cards in Deck
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
QLabel *minDeckSizeLabel; ///< Label for minimum number of cards per deck
|
||||||
|
QSpinBox *minDeckSizeSpin; ///< Spinner to select minimum deck size
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// Pagination
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
QSpinBox *pageSpin; ///< Spinner to select the page number for results
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// Optional Context
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
CardInfoPtr cardToQuery; ///< Optional pre-selected card for initial filtering
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCKATRICE_TAB_ARCHIDEKT_H
|
#endif // COCKATRICE_TAB_ARCHIDEKT_H
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue