mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Refactor Tab EDHRec into folders, add navigation for budget and GC, add card prices (#5845)
* Refactor things into more sensible folders. * Add navigation widget for budget and game changers. * Lint. * Add a card price display widget. * Qt version check. * Lint some thangs. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
ca538399f6
commit
653362567b
38 changed files with 529 additions and 232 deletions
|
|
@ -21,19 +21,21 @@ set(cockatrice_SOURCES
|
|||
src/client/tabs/api/edhrec/tab_edhrec.cpp
|
||||
src/client/tabs/api/edhrec/tab_edhrec_main.cpp
|
||||
src/client/tabs/api/edhrec/display/commander/edhrec_commander_api_response_display_widget.cpp
|
||||
src/client/tabs/api/edhrec/display/commander/edhrec_commander_api_response_card_details_display_widget.cpp
|
||||
src/client/tabs/api/edhrec/display/commander/edhrec_commander_api_response_card_list_display_widget.cpp
|
||||
src/client/tabs/api/edhrec/display/commander/edhrec_commander_api_response_commander_details_display_widget.cpp
|
||||
src/client/tabs/api/edhrec/display/commander/edhrec_commander_api_response_navigation_widget.cpp
|
||||
src/client/tabs/api/edhrec/display/card_prices/edhrec_api_response_card_prices_display_widget.cpp
|
||||
src/client/tabs/api/edhrec/display/cards/edhrec_api_response_card_details_display_widget.cpp
|
||||
src/client/tabs/api/edhrec/display/cards/edhrec_api_response_card_list_display_widget.cpp
|
||||
src/client/tabs/api/edhrec/display/commander/edhrec_api_response_commander_details_display_widget.cpp
|
||||
src/client/tabs/api/edhrec/display/top_cards/edhrec_top_cards_api_response_display_widget.cpp
|
||||
src/client/tabs/api/edhrec/display/top_commander/edhrec_top_commanders_api_response_display_widget.cpp
|
||||
src/client/tabs/api/edhrec/display/top_tags/edhrec_top_tags_api_response_display_widget.cpp
|
||||
src/client/tabs/api/edhrec/api_response/commander/edhrec_commander_api_response_archidekt_links.cpp
|
||||
src/client/tabs/api/edhrec/api_response/archidekt_links/edhrec_api_response_archidekt_links.cpp
|
||||
src/client/tabs/api/edhrec/api_response/commander/edhrec_commander_api_response_average_deck_statistics.cpp
|
||||
src/client/tabs/api/edhrec/api_response/commander/edhrec_commander_api_response_card_details.cpp
|
||||
src/client/tabs/api/edhrec/api_response/commander/edhrec_commander_api_response_card_list.cpp
|
||||
src/client/tabs/api/edhrec/api_response/commander/edhrec_commander_api_response_card_container.cpp
|
||||
src/client/tabs/api/edhrec/api_response/commander/edhrec_commander_api_response_card_prices.cpp
|
||||
src/client/tabs/api/edhrec/api_response/commander/edhrec_commander_api_response_commander_details.cpp
|
||||
src/client/tabs/api/edhrec/api_response/cards/edhrec_api_response_card_details.cpp
|
||||
src/client/tabs/api/edhrec/api_response/cards/edhrec_api_response_card_list.cpp
|
||||
src/client/tabs/api/edhrec/api_response/cards/edhrec_api_response_card_container.cpp
|
||||
src/client/tabs/api/edhrec/api_response/card_prices/edhrec_api_response_card_prices.cpp
|
||||
src/client/tabs/api/edhrec/api_response/cards/edhrec_commander_api_response_commander_details.cpp
|
||||
src/client/tabs/api/edhrec/api_response/commander/edhrec_commander_api_response.cpp
|
||||
src/client/tabs/api/edhrec/api_response/average_deck/edhrec_average_deck_api_response.cpp
|
||||
src/client/tabs/api/edhrec/api_response/average_deck/edhrec_deck_api_response.cpp
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
#include "edhrec_commander_api_response_archidekt_links.h"
|
||||
#include "edhrec_api_response_archidekt_links.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
void EdhrecCommanderApiResponseArchidektLink::fromJson(const QJsonObject &json)
|
||||
void EdhrecApiResponseArchidektLink::fromJson(const QJsonObject &json)
|
||||
{
|
||||
c = json.value("c").toString();
|
||||
f = json.value("f").toInt(0);
|
||||
|
|
@ -13,7 +13,7 @@ void EdhrecCommanderApiResponseArchidektLink::fromJson(const QJsonObject &json)
|
|||
u = json.value("u").toString();
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseArchidektLink::debugPrint() const
|
||||
void EdhrecApiResponseArchidektLink::debugPrint() const
|
||||
{
|
||||
qDebug() << " C:" << c;
|
||||
qDebug() << " F:" << f;
|
||||
|
|
@ -27,7 +27,7 @@ void EdhrecCommanderApiResponseArchidektLinks::fromJson(const QJsonArray &json)
|
|||
for (const QJsonValue &value : json) {
|
||||
if (value.isObject()) {
|
||||
QJsonObject entryJson = value.toObject();
|
||||
EdhrecCommanderApiResponseArchidektLink entry;
|
||||
EdhrecApiResponseArchidektLink entry;
|
||||
entry.fromJson(entryJson);
|
||||
entries.append(entry);
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
#include <QVector>
|
||||
|
||||
// Represents a single Archidekt entry
|
||||
class EdhrecCommanderApiResponseArchidektLink
|
||||
class EdhrecApiResponseArchidektLink
|
||||
{
|
||||
public:
|
||||
QString c;
|
||||
|
|
@ -23,7 +23,7 @@ public:
|
|||
class EdhrecCommanderApiResponseArchidektLinks
|
||||
{
|
||||
public:
|
||||
QVector<EdhrecCommanderApiResponseArchidektLink> entries;
|
||||
QVector<EdhrecApiResponseArchidektLink> entries;
|
||||
|
||||
void fromJson(const QJsonArray &json);
|
||||
void debugPrint() const;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef EDHREC_AVERAGE_DECK_API_RESPONSE_H
|
||||
#define EDHREC_AVERAGE_DECK_API_RESPONSE_H
|
||||
|
||||
#include "../commander/edhrec_commander_api_response_archidekt_links.h"
|
||||
#include "../archidekt_links/edhrec_api_response_archidekt_links.h"
|
||||
#include "../cards/edhrec_api_response_card_container.h"
|
||||
#include "../commander/edhrec_commander_api_response_average_deck_statistics.h"
|
||||
#include "../commander/edhrec_commander_api_response_card_container.h"
|
||||
#include "edhrec_deck_api_response.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
|
@ -20,7 +20,7 @@ public:
|
|||
QString header;
|
||||
QJsonObject panels;
|
||||
QString description;
|
||||
EdhrecCommanderApiResponseCardContainer container;
|
||||
EdhrecApiResponseCardContainer container;
|
||||
EdhrecDeckApiResponse deck;
|
||||
|
||||
void fromJson(const QJsonObject &json);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "edhrec_commander_api_response_card_prices.h"
|
||||
#include "edhrec_api_response_card_prices.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
|
@ -18,14 +18,14 @@ void CardPrices::fromJson(const QJsonObject &json)
|
|||
|
||||
void CardPrices::debugPrint() const
|
||||
{
|
||||
qDebug() << "Card Prices:";
|
||||
qDebug() << "Cardhoarder:" << cardhoarder;
|
||||
qDebug() << "Cardkingdom:" << cardkingdom;
|
||||
qDebug() << "Cardmarket:" << cardmarket;
|
||||
qDebug() << "Face2Face:" << face2face;
|
||||
qDebug() << "Manapool:" << manapool;
|
||||
qDebug() << "Mtgstocks:" << mtgstocks;
|
||||
qDebug() << "SCG:" << scg;
|
||||
qDebug() << "TCGL:" << tcgl;
|
||||
qDebug() << "Tcgplayer:" << tcgplayer;
|
||||
qInfo() << "Card Prices:";
|
||||
qInfo() << "Cardhoarder:" << cardhoarder;
|
||||
qInfo() << "Cardkingdom:" << cardkingdom;
|
||||
qInfo() << "Cardmarket:" << cardmarket;
|
||||
qInfo() << "Face2Face:" << face2face;
|
||||
qInfo() << "Manapool:" << manapool;
|
||||
qInfo() << "Mtgstocks:" << mtgstocks;
|
||||
qInfo() << "SCG:" << scg;
|
||||
qInfo() << "TCGL:" << tcgl;
|
||||
qInfo() << "Tcgplayer:" << tcgplayer;
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
#include "edhrec_commander_api_response_card_container.h"
|
||||
#include "edhrec_api_response_card_container.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
|
||||
void EdhrecCommanderApiResponseCardContainer::fromJson(const QJsonObject &json)
|
||||
void EdhrecApiResponseCardContainer::fromJson(const QJsonObject &json)
|
||||
{
|
||||
// Parse breadcrumb
|
||||
QJsonArray breadcrumbArray = json.value("breadcrumb").toArray();
|
||||
|
|
@ -20,7 +20,7 @@ void EdhrecCommanderApiResponseCardContainer::fromJson(const QJsonObject &json)
|
|||
for (const QJsonValue &cardlistValue : cardlistsArray) {
|
||||
QJsonObject cardlistObj = cardlistValue.toObject();
|
||||
QJsonArray cardviewsArray = cardlistObj.value("cardviews").toArray();
|
||||
EdhrecCommanderApiResponseCardList cardView;
|
||||
EdhrecApiResponseCardList cardView;
|
||||
cardView.fromJson(cardlistValue.toObject());
|
||||
cardlists.push_back(cardView);
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ void EdhrecCommanderApiResponseCardContainer::fromJson(const QJsonObject &json)
|
|||
title = json.value("title").toString();
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseCardContainer::debugPrint() const
|
||||
void EdhrecApiResponseCardContainer::debugPrint() const
|
||||
{
|
||||
qDebug() << "Breadcrumb:";
|
||||
for (const auto &breadcrumbEntry : breadcrumb) {
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef CONTAINER_ENTRY_H
|
||||
#define CONTAINER_ENTRY_H
|
||||
|
||||
#include "edhrec_commander_api_response_card_list.h"
|
||||
#include "edhrec_api_response_card_list.h"
|
||||
#include "edhrec_commander_api_response_commander_details.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
|
@ -10,11 +10,11 @@
|
|||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
class EdhrecCommanderApiResponseCardContainer
|
||||
class EdhrecApiResponseCardContainer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
EdhrecCommanderApiResponseCardContainer() = default;
|
||||
EdhrecApiResponseCardContainer() = default;
|
||||
|
||||
// Parse deck-related data from JSON
|
||||
void fromJson(const QJsonObject &json);
|
||||
|
|
@ -35,7 +35,7 @@ public:
|
|||
{
|
||||
return card;
|
||||
}
|
||||
const QVector<EdhrecCommanderApiResponseCardList> &getCardlists() const
|
||||
const QVector<EdhrecApiResponseCardList> &getCardlists() const
|
||||
{
|
||||
return cardlists;
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ private:
|
|||
QString description;
|
||||
QVector<QJsonObject> breadcrumb;
|
||||
EdhrecCommanderApiResponseCommanderDetails card;
|
||||
QVector<EdhrecCommanderApiResponseCardList> cardlists;
|
||||
QVector<EdhrecApiResponseCardList> cardlists;
|
||||
QString keywords;
|
||||
QString title;
|
||||
};
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
#include "edhrec_commander_api_response_card_details.h"
|
||||
#include "edhrec_api_response_card_details.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
EdhrecCommanderApiResponseCardDetails::EdhrecCommanderApiResponseCardDetails()
|
||||
EdhrecApiResponseCardDetails::EdhrecApiResponseCardDetails()
|
||||
: synergy(0.0), inclusion(0), numDecks(0), potentialDecks(0)
|
||||
{
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseCardDetails::fromJson(const QJsonObject &json)
|
||||
void EdhrecApiResponseCardDetails::fromJson(const QJsonObject &json)
|
||||
{
|
||||
// Parse the fields from the JSON object
|
||||
name = json.value("name").toString();
|
||||
|
|
@ -21,7 +21,7 @@ void EdhrecCommanderApiResponseCardDetails::fromJson(const QJsonObject &json)
|
|||
potentialDecks = json.value("potential_decks").toInt(0);
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseCardDetails::debugPrint() const
|
||||
void EdhrecApiResponseCardDetails::debugPrint() const
|
||||
{
|
||||
// Print out all the fields for debugging
|
||||
qDebug() << "Name:" << name;
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
|
||||
class EdhrecCommanderApiResponseCardDetails
|
||||
class EdhrecApiResponseCardDetails
|
||||
{
|
||||
public:
|
||||
QString name;
|
||||
|
|
@ -17,7 +17,7 @@ public:
|
|||
int numDecks;
|
||||
int potentialDecks;
|
||||
|
||||
EdhrecCommanderApiResponseCardDetails();
|
||||
EdhrecApiResponseCardDetails();
|
||||
|
||||
// Method to populate the object from a JSON object
|
||||
void fromJson(const QJsonObject &json);
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
#include "edhrec_commander_api_response_card_list.h"
|
||||
#include "edhrec_api_response_card_list.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
EdhrecCommanderApiResponseCardList::EdhrecCommanderApiResponseCardList()
|
||||
EdhrecApiResponseCardList::EdhrecApiResponseCardList()
|
||||
{
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseCardList::fromJson(const QJsonObject &json)
|
||||
void EdhrecApiResponseCardList::fromJson(const QJsonObject &json)
|
||||
{
|
||||
// Parse the header from the JSON object
|
||||
header = json.value("header").toString();
|
||||
|
|
@ -15,19 +15,19 @@ void EdhrecCommanderApiResponseCardList::fromJson(const QJsonObject &json)
|
|||
QJsonArray cardviewsArray = json.value("cardviews").toArray();
|
||||
for (const QJsonValue &value : cardviewsArray) {
|
||||
QJsonObject cardviewObj = value.toObject();
|
||||
EdhrecCommanderApiResponseCardDetails cardView;
|
||||
EdhrecApiResponseCardDetails cardView;
|
||||
cardView.fromJson(cardviewObj);
|
||||
cardViews.append(cardView);
|
||||
}
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseCardList::debugPrint() const
|
||||
void EdhrecApiResponseCardList::debugPrint() const
|
||||
{
|
||||
// Print out the header
|
||||
qDebug() << "Header:" << header;
|
||||
|
||||
// Print out all the CardView objects
|
||||
for (const EdhrecCommanderApiResponseCardDetails &cardView : cardViews) {
|
||||
for (const EdhrecApiResponseCardDetails &cardView : cardViews) {
|
||||
cardView.debugPrint();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,21 @@
|
|||
#ifndef CARD_LIST_H
|
||||
#define CARD_LIST_H
|
||||
|
||||
#include "edhrec_commander_api_response_card_details.h"
|
||||
#include "edhrec_api_response_card_details.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
class EdhrecCommanderApiResponseCardList
|
||||
class EdhrecApiResponseCardList
|
||||
{
|
||||
public:
|
||||
QString header;
|
||||
QList<EdhrecCommanderApiResponseCardDetails> cardViews;
|
||||
QList<EdhrecApiResponseCardDetails> cardViews;
|
||||
|
||||
// Default constructor
|
||||
EdhrecCommanderApiResponseCardList();
|
||||
EdhrecApiResponseCardList();
|
||||
|
||||
// Method to populate the object from a JSON object
|
||||
void fromJson(const QJsonObject &json);
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_H
|
||||
#define EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_H
|
||||
|
||||
#include "edhrec_commander_api_response_card_prices.h"
|
||||
#include "../card_prices/edhrec_api_response_card_prices.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef DECKDATA_H
|
||||
#define DECKDATA_H
|
||||
|
||||
#include "edhrec_commander_api_response_archidekt_links.h"
|
||||
#include "../archidekt_links//edhrec_api_response_archidekt_links.h"
|
||||
#include "../cards/edhrec_api_response_card_container.h"
|
||||
#include "edhrec_commander_api_response_average_deck_statistics.h"
|
||||
#include "edhrec_commander_api_response_card_container.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonObject>
|
||||
|
|
@ -19,7 +19,7 @@ public:
|
|||
QString header;
|
||||
QJsonObject panels;
|
||||
QString description;
|
||||
EdhrecCommanderApiResponseCardContainer container;
|
||||
EdhrecApiResponseCardContainer container;
|
||||
|
||||
void fromJson(const QJsonObject &json);
|
||||
void debugPrint() const;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,17 @@
|
|||
#ifndef EDHREC_TOP_CARDS_API_RESPONSE_H
|
||||
#define EDHREC_TOP_CARDS_API_RESPONSE_H
|
||||
|
||||
#include "../commander/edhrec_commander_api_response_card_container.h"
|
||||
#include "../cards/edhrec_api_response_card_container.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
|
||||
// Represents the main structure of the JSON
|
||||
class EdhrecTopCardsApiResponse
|
||||
{
|
||||
public:
|
||||
QString header;
|
||||
QString description;
|
||||
EdhrecCommanderApiResponseCardContainer container;
|
||||
EdhrecApiResponseCardContainer container;
|
||||
|
||||
void fromJson(const QJsonObject &json);
|
||||
void debugPrint() const;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,17 @@
|
|||
#ifndef EDHREC_TOP_COMMANDERS_API_RESPONSE_H
|
||||
#define EDHREC_TOP_COMMANDERS_API_RESPONSE_H
|
||||
|
||||
#include "../commander/edhrec_commander_api_response_card_container.h"
|
||||
#include "../cards/edhrec_api_response_card_container.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
|
||||
// Represents the main structure of the JSON
|
||||
class EdhrecTopCommandersApiResponse
|
||||
{
|
||||
public:
|
||||
QString header;
|
||||
QString description;
|
||||
EdhrecCommanderApiResponseCardContainer container;
|
||||
EdhrecApiResponseCardContainer container;
|
||||
|
||||
void fromJson(const QJsonObject &json);
|
||||
void debugPrint() const;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,17 @@
|
|||
#ifndef EDHREC_TOP_TAGS_API_RESPONSE_H
|
||||
#define EDHREC_TOP_TAGS_API_RESPONSE_H
|
||||
|
||||
#include "../commander/edhrec_commander_api_response_card_container.h"
|
||||
#include "../cards/edhrec_api_response_card_container.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
|
||||
// Represents the main structure of the JSON
|
||||
class EdhrecTopTagsApiResponse
|
||||
{
|
||||
public:
|
||||
QString header;
|
||||
QString description;
|
||||
EdhrecCommanderApiResponseCardContainer container;
|
||||
EdhrecApiResponseCardContainer container;
|
||||
|
||||
void fromJson(const QJsonObject &json);
|
||||
void debugPrint() const;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
#include "edhrec_api_response_card_prices_display_widget.h"
|
||||
|
||||
EdhrecApiResponseCardPricesDisplayWidget::EdhrecApiResponseCardPricesDisplayWidget(QWidget *parent,
|
||||
const CardPrices &_cardPrices)
|
||||
: QWidget(parent), cardPrices(_cardPrices)
|
||||
{
|
||||
layout = new QGridLayout(this);
|
||||
setLayout(layout);
|
||||
|
||||
cardHoarderLabel = new QLabel(this);
|
||||
cardHoarderPrice = new QLabel(QString::number(cardPrices.getCardhoarder().value("price").toDouble()), this);
|
||||
cardKingdomLabel = new QLabel(this);
|
||||
cardKingdomPrice = new QLabel(QString::number(cardPrices.getCardkingdom().value("price").toDouble()), this);
|
||||
cardMarketLabel = new QLabel(this);
|
||||
cardMarketPrice = new QLabel(QString::number(cardPrices.getCardmarket().value("price").toDouble()), this);
|
||||
face2faceLabel = new QLabel(this);
|
||||
face2facePrice = new QLabel(QString::number(cardPrices.getFace2face().value("price").toDouble()), this);
|
||||
manaPoolLabel = new QLabel(this);
|
||||
manaPoolPrice = new QLabel(QString::number(cardPrices.getManapool().value("price").toDouble()), this);
|
||||
mtgStocksLabel = new QLabel(this);
|
||||
mtgStocksPrice = new QLabel(QString::number(cardPrices.getMtgstocks().value("price").toDouble()), this);
|
||||
scgLabel = new QLabel(this);
|
||||
scgPrice = new QLabel(QString::number(cardPrices.getScg().value("price").toDouble()), this);
|
||||
tcglLabel = new QLabel(this);
|
||||
tcglPrice = new QLabel(QString::number(cardPrices.getTcgl().value("price").toDouble()), this);
|
||||
tcgplayerLabel = new QLabel(this);
|
||||
tcgplayerPrice = new QLabel(QString::number(cardPrices.getTcgplayer().value("price").toDouble()), this);
|
||||
|
||||
layout->addWidget(cardHoarderLabel, 0, 0);
|
||||
layout->addWidget(cardHoarderPrice, 0, 1);
|
||||
layout->addWidget(cardKingdomLabel, 0, 2);
|
||||
layout->addWidget(cardKingdomPrice, 0, 3);
|
||||
|
||||
layout->addWidget(cardMarketLabel, 1, 0);
|
||||
layout->addWidget(cardMarketPrice, 1, 1);
|
||||
layout->addWidget(face2faceLabel, 1, 2);
|
||||
layout->addWidget(face2facePrice, 1, 3);
|
||||
|
||||
layout->addWidget(manaPoolLabel, 2, 0);
|
||||
layout->addWidget(manaPoolPrice, 2, 1);
|
||||
layout->addWidget(mtgStocksLabel, 2, 2);
|
||||
layout->addWidget(mtgStocksPrice, 2, 3);
|
||||
|
||||
layout->addWidget(scgLabel, 3, 0);
|
||||
layout->addWidget(scgPrice, 3, 1);
|
||||
layout->addWidget(tcglLabel, 3, 2);
|
||||
layout->addWidget(tcglPrice, 3, 3);
|
||||
|
||||
layout->addWidget(tcgplayerLabel, 4, 0);
|
||||
layout->addWidget(tcgplayerPrice, 4, 1);
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
void EdhrecApiResponseCardPricesDisplayWidget::retranslateUi()
|
||||
{
|
||||
cardHoarderLabel->setText(tr("Card Hoarder"));
|
||||
cardKingdomLabel->setText(tr("Card Kingdom"));
|
||||
cardMarketLabel->setText(tr("Card Market"));
|
||||
face2faceLabel->setText(tr("Face 2-Face"));
|
||||
manaPoolLabel->setText(tr("Mana Pool"));
|
||||
mtgStocksLabel->setText(tr("MTG Stocks"));
|
||||
scgLabel->setText(tr("Scg"));
|
||||
tcglLabel->setText(tr("Tcgl"));
|
||||
tcgplayerLabel->setText(tr("Tcgplayer"));
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef EDHREC_API_RESPONSE_CARD_PRICES_DISPLAY_WIDGET_H
|
||||
#define EDHREC_API_RESPONSE_CARD_PRICES_DISPLAY_WIDGET_H
|
||||
|
||||
#include "../../api_response/card_prices/edhrec_api_response_card_prices.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
|
||||
class EdhrecApiResponseCardPricesDisplayWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EdhrecApiResponseCardPricesDisplayWidget(QWidget *parent, const CardPrices &cardPrices);
|
||||
|
||||
public slots:
|
||||
void retranslateUi();
|
||||
|
||||
private:
|
||||
CardPrices cardPrices;
|
||||
QGridLayout *layout;
|
||||
QLabel *cardHoarderLabel;
|
||||
QLabel *cardHoarderPrice;
|
||||
QLabel *cardKingdomLabel;
|
||||
QLabel *cardKingdomPrice;
|
||||
QLabel *cardMarketLabel;
|
||||
QLabel *cardMarketPrice;
|
||||
QLabel *face2faceLabel;
|
||||
QLabel *face2facePrice;
|
||||
QLabel *manaPoolLabel;
|
||||
QLabel *manaPoolPrice;
|
||||
QLabel *mtgStocksLabel;
|
||||
QLabel *mtgStocksPrice;
|
||||
QLabel *scgLabel;
|
||||
QLabel *scgPrice;
|
||||
QLabel *tcglLabel;
|
||||
QLabel *tcglPrice;
|
||||
QLabel *tcgplayerLabel;
|
||||
QLabel *tcgplayerPrice;
|
||||
};
|
||||
|
||||
#endif // EDHREC_API_RESPONSE_CARD_PRICES_DISPLAY_WIDGET_H
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
#include "edhrec_commander_api_response_card_details_display_widget.h"
|
||||
#include "edhrec_api_response_card_details_display_widget.h"
|
||||
|
||||
#include "../../../../../../game/cards/card_database_manager.h"
|
||||
#include "../../tab_edhrec_main.h"
|
||||
|
||||
EdhrecCommanderApiResponseCardDetailsDisplayWidget::EdhrecCommanderApiResponseCardDetailsDisplayWidget(
|
||||
EdhrecApiResponseCardDetailsDisplayWidget::EdhrecApiResponseCardDetailsDisplayWidget(
|
||||
QWidget *parent,
|
||||
const EdhrecCommanderApiResponseCardDetails &_toDisplay)
|
||||
const EdhrecApiResponseCardDetails &_toDisplay)
|
||||
: QWidget(parent), toDisplay(_toDisplay)
|
||||
{
|
||||
layout = new QVBoxLayout(this);
|
||||
|
|
@ -55,13 +55,13 @@ EdhrecCommanderApiResponseCardDetailsDisplayWidget::EdhrecCommanderApiResponseCa
|
|||
|
||||
if (parentTab) {
|
||||
connect(cardPictureWidget, &CardInfoPictureWidget::cardClicked, this,
|
||||
&EdhrecCommanderApiResponseCardDetailsDisplayWidget::actRequestPageNavigation);
|
||||
connect(this, &EdhrecCommanderApiResponseCardDetailsDisplayWidget::requestUrl, parentTab,
|
||||
&EdhrecApiResponseCardDetailsDisplayWidget::actRequestPageNavigation);
|
||||
connect(this, &EdhrecApiResponseCardDetailsDisplayWidget::requestUrl, parentTab,
|
||||
&TabEdhRecMain::actNavigatePage);
|
||||
}
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseCardDetailsDisplayWidget::actRequestPageNavigation()
|
||||
void EdhrecApiResponseCardDetailsDisplayWidget::actRequestPageNavigation()
|
||||
{
|
||||
emit requestUrl(toDisplay.url);
|
||||
}
|
||||
|
|
@ -2,26 +2,24 @@
|
|||
#define EDHREC_COMMANDER_API_RESPONSE_CARD_DETAILS_DISPLAY_WIDGET_H
|
||||
|
||||
#include "../../../../../ui/widgets/cards/card_info_picture_widget.h"
|
||||
#include "../../api_response/commander/edhrec_commander_api_response_card_details.h"
|
||||
#include "../../api_response/cards/edhrec_api_response_card_details.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
|
||||
class EdhrecCommanderApiResponseCardDetailsDisplayWidget : public QWidget
|
||||
class EdhrecApiResponseCardDetailsDisplayWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EdhrecCommanderApiResponseCardDetailsDisplayWidget(
|
||||
QWidget *parent,
|
||||
const EdhrecCommanderApiResponseCardDetails &_toDisplay);
|
||||
explicit EdhrecApiResponseCardDetailsDisplayWidget(QWidget *parent, const EdhrecApiResponseCardDetails &_toDisplay);
|
||||
public slots:
|
||||
void actRequestPageNavigation();
|
||||
signals:
|
||||
void requestUrl(QString url);
|
||||
|
||||
private:
|
||||
EdhrecCommanderApiResponseCardDetails toDisplay;
|
||||
EdhrecApiResponseCardDetails toDisplay;
|
||||
QVBoxLayout *layout;
|
||||
CardInfoPictureWidget *cardPictureWidget;
|
||||
QLabel *label;
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#include "edhrec_api_response_card_list_display_widget.h"
|
||||
|
||||
#include "../../../../../ui/widgets/general/display/banner_widget.h"
|
||||
#include "edhrec_api_response_card_details_display_widget.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
EdhrecApiResponseCardListDisplayWidget::EdhrecApiResponseCardListDisplayWidget(QWidget *parent,
|
||||
EdhrecApiResponseCardList toDisplay)
|
||||
: QWidget(parent)
|
||||
{
|
||||
layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
|
||||
header = new BannerWidget(this, toDisplay.header);
|
||||
|
||||
flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAlwaysOff);
|
||||
header->setBuddy(flowWidget);
|
||||
|
||||
foreach (EdhrecApiResponseCardDetails card_detail, toDisplay.cardViews) {
|
||||
auto widget = new EdhrecApiResponseCardDetailsDisplayWidget(flowWidget, card_detail);
|
||||
flowWidget->addWidget(widget);
|
||||
}
|
||||
|
||||
layout->addWidget(header);
|
||||
layout->addWidget(flowWidget);
|
||||
}
|
||||
|
||||
void EdhrecApiResponseCardListDisplayWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
qDebug() << event->size();
|
||||
}
|
||||
|
|
@ -3,18 +3,17 @@
|
|||
|
||||
#include "../../../../../ui/widgets/general/display/banner_widget.h"
|
||||
#include "../../../../../ui/widgets/general/layout_containers/flow_widget.h"
|
||||
#include "../../api_response/commander/edhrec_commander_api_response_card_list.h"
|
||||
#include "../../api_response/cards/edhrec_api_response_card_list.h"
|
||||
|
||||
#include <QResizeEvent>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
class EdhrecCommanderApiResponseCardListDisplayWidget : public QWidget
|
||||
class EdhrecApiResponseCardListDisplayWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EdhrecCommanderApiResponseCardListDisplayWidget(QWidget *parent,
|
||||
EdhrecCommanderApiResponseCardList toDisplay);
|
||||
explicit EdhrecApiResponseCardListDisplayWidget(QWidget *parent, EdhrecApiResponseCardList toDisplay);
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
[[nodiscard]] QString getBannerText() const
|
||||
{
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#include "edhrec_api_response_commander_details_display_widget.h"
|
||||
|
||||
#include "../../../../../../game/cards/card_database_manager.h"
|
||||
#include "../../../../../ui/widgets/cards/card_info_picture_widget.h"
|
||||
#include "../card_prices/edhrec_api_response_card_prices_display_widget.h"
|
||||
|
||||
EdhrecCommanderResponseCommanderDetailsDisplayWidget::EdhrecCommanderResponseCommanderDetailsDisplayWidget(
|
||||
QWidget *parent,
|
||||
const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails,
|
||||
QString baseUrl)
|
||||
: QWidget(parent), commanderDetails(_commanderDetails)
|
||||
{
|
||||
layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
|
||||
commanderPicture = new CardInfoPictureWidget(this);
|
||||
commanderPicture->setCard(CardDatabaseManager::getInstance()->getCard(commanderDetails.getName()));
|
||||
|
||||
commanderDetails.debugPrint();
|
||||
|
||||
label = new QLabel(this);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
salt = new QLabel(this);
|
||||
salt->setAlignment(Qt::AlignCenter);
|
||||
|
||||
cardPricesDisplayWidget = new EdhrecApiResponseCardPricesDisplayWidget(this, commanderDetails.getPrices());
|
||||
|
||||
navigationWidget = new EdhrecCommanderApiResponseNavigationWidget(this, commanderDetails, baseUrl);
|
||||
|
||||
layout->addWidget(commanderPicture);
|
||||
layout->addWidget(label);
|
||||
layout->addWidget(salt);
|
||||
layout->addWidget(cardPricesDisplayWidget);
|
||||
layout->addWidget(navigationWidget);
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
void EdhrecCommanderResponseCommanderDetailsDisplayWidget::retranslateUi()
|
||||
{
|
||||
label->setText(commanderDetails.getLabel());
|
||||
salt->setText(tr("Salt: ") + QString::number(commanderDetails.getSalt()));
|
||||
}
|
||||
|
|
@ -2,36 +2,33 @@
|
|||
#define EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_DISPLAY_WIDGET_H
|
||||
|
||||
#include "../../../../../ui/widgets/cards/card_info_picture_widget.h"
|
||||
#include "../../api_response/commander/edhrec_commander_api_response_commander_details.h"
|
||||
#include "../../api_response/cards/edhrec_commander_api_response_commander_details.h"
|
||||
#include "../card_prices/edhrec_api_response_card_prices_display_widget.h"
|
||||
#include "edhrec_commander_api_response_navigation_widget.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
class EdhrecCommanderApiResponseNavigationWidget;
|
||||
class EdhrecCommanderResponseCommanderDetailsDisplayWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EdhrecCommanderResponseCommanderDetailsDisplayWidget(
|
||||
QWidget *parent,
|
||||
const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails);
|
||||
const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails,
|
||||
QString baseUrl);
|
||||
void retranslateUi();
|
||||
|
||||
public slots:
|
||||
void actRequestComboNavigation();
|
||||
void actRequestAverageDeckNavigation();
|
||||
signals:
|
||||
void requestUrl(QString url);
|
||||
|
||||
private:
|
||||
QLabel *label;
|
||||
QLabel *salt;
|
||||
QPushButton *comboPushButton;
|
||||
QPushButton *averageDeckPushButton;
|
||||
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
|
||||
QVBoxLayout *layout;
|
||||
CardInfoPictureWidget *commanderPicture;
|
||||
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
|
||||
QLabel *label;
|
||||
QLabel *salt;
|
||||
EdhrecApiResponseCardPricesDisplayWidget *cardPricesDisplayWidget;
|
||||
EdhrecCommanderApiResponseNavigationWidget *navigationWidget;
|
||||
};
|
||||
|
||||
#endif // EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_DISPLAY_WIDGET_H
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
#include "edhrec_commander_api_response_card_list_display_widget.h"
|
||||
|
||||
#include "../../../../../ui/widgets/general/display/banner_widget.h"
|
||||
#include "edhrec_commander_api_response_card_details_display_widget.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
EdhrecCommanderApiResponseCardListDisplayWidget::EdhrecCommanderApiResponseCardListDisplayWidget(
|
||||
QWidget *parent,
|
||||
EdhrecCommanderApiResponseCardList toDisplay)
|
||||
: QWidget(parent)
|
||||
{
|
||||
layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
|
||||
header = new BannerWidget(this, toDisplay.header);
|
||||
|
||||
flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAlwaysOff);
|
||||
header->setBuddy(flowWidget);
|
||||
|
||||
foreach (EdhrecCommanderApiResponseCardDetails card_detail, toDisplay.cardViews) {
|
||||
auto widget = new EdhrecCommanderApiResponseCardDetailsDisplayWidget(flowWidget, card_detail);
|
||||
flowWidget->addWidget(widget);
|
||||
}
|
||||
|
||||
layout->addWidget(header);
|
||||
layout->addWidget(flowWidget);
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseCardListDisplayWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
qDebug() << event->size();
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
#include "edhrec_commander_api_response_commander_details_display_widget.h"
|
||||
|
||||
#include "../../../../../../game/cards/card_database_manager.h"
|
||||
#include "../../../../../ui/widgets/cards/card_info_picture_widget.h"
|
||||
#include "../../tab_edhrec_main.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
||||
EdhrecCommanderResponseCommanderDetailsDisplayWidget::EdhrecCommanderResponseCommanderDetailsDisplayWidget(
|
||||
QWidget *parent,
|
||||
const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails)
|
||||
: QWidget(parent), commanderDetails(_commanderDetails)
|
||||
{
|
||||
layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
|
||||
commanderPicture = new CardInfoPictureWidget(this);
|
||||
commanderPicture->setCard(CardDatabaseManager::getInstance()->getCard(commanderDetails.getName()));
|
||||
|
||||
commanderDetails.debugPrint();
|
||||
|
||||
label = new QLabel(this);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
salt = new QLabel(this);
|
||||
salt->setAlignment(Qt::AlignCenter);
|
||||
|
||||
comboPushButton = new QPushButton(this);
|
||||
averageDeckPushButton = new QPushButton(this);
|
||||
|
||||
layout->addWidget(commanderPicture);
|
||||
layout->addWidget(label);
|
||||
layout->addWidget(salt);
|
||||
layout->addWidget(comboPushButton);
|
||||
layout->addWidget(averageDeckPushButton);
|
||||
|
||||
QWidget *currentParent = parentWidget();
|
||||
TabEdhRecMain *parentTab = nullptr;
|
||||
|
||||
while (currentParent) {
|
||||
if ((parentTab = qobject_cast<TabEdhRecMain *>(currentParent))) {
|
||||
break;
|
||||
}
|
||||
currentParent = currentParent->parentWidget();
|
||||
}
|
||||
|
||||
if (parentTab) {
|
||||
connect(comboPushButton, &QPushButton::clicked, this,
|
||||
&EdhrecCommanderResponseCommanderDetailsDisplayWidget::actRequestComboNavigation);
|
||||
connect(averageDeckPushButton, &QPushButton::clicked, this,
|
||||
&EdhrecCommanderResponseCommanderDetailsDisplayWidget::actRequestAverageDeckNavigation);
|
||||
connect(this, &EdhrecCommanderResponseCommanderDetailsDisplayWidget::requestUrl, parentTab,
|
||||
&TabEdhRecMain::actNavigatePage);
|
||||
}
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
void EdhrecCommanderResponseCommanderDetailsDisplayWidget::retranslateUi()
|
||||
{
|
||||
label->setText(commanderDetails.getLabel());
|
||||
salt->setText(tr("Salt: ") + QString::number(commanderDetails.getSalt()));
|
||||
comboPushButton->setText(tr("Combos"));
|
||||
averageDeckPushButton->setText(tr("Average Deck"));
|
||||
}
|
||||
|
||||
void EdhrecCommanderResponseCommanderDetailsDisplayWidget::actRequestComboNavigation()
|
||||
{
|
||||
emit requestUrl("/combos/" + commanderDetails.getSanitized());
|
||||
}
|
||||
|
||||
void EdhrecCommanderResponseCommanderDetailsDisplayWidget::actRequestAverageDeckNavigation()
|
||||
{
|
||||
emit requestUrl("/average-decks/" + commanderDetails.getSanitized());
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "../../../../../ui/widgets/cards/card_info_picture_widget.h"
|
||||
#include "../../api_response/commander/edhrec_commander_api_response.h"
|
||||
#include "edhrec_commander_api_response_card_list_display_widget.h"
|
||||
#include "edhrec_commander_api_response_commander_details_display_widget.h"
|
||||
#include "../cards/edhrec_api_response_card_list_display_widget.h"
|
||||
#include "edhrec_api_response_commander_details_display_widget.h"
|
||||
|
||||
#include <QListView>
|
||||
#include <QResizeEvent>
|
||||
|
|
@ -12,7 +12,8 @@
|
|||
#include <QStringListModel>
|
||||
|
||||
EdhrecCommanderApiResponseDisplayWidget::EdhrecCommanderApiResponseDisplayWidget(QWidget *parent,
|
||||
EdhrecCommanderApiResponse response)
|
||||
EdhrecCommanderApiResponse response,
|
||||
QString baseUrl)
|
||||
: QWidget(parent)
|
||||
{
|
||||
layout = new QHBoxLayout(this);
|
||||
|
|
@ -31,15 +32,15 @@ EdhrecCommanderApiResponseDisplayWidget::EdhrecCommanderApiResponseDisplayWidget
|
|||
QStringList widgetNames;
|
||||
|
||||
// Add commander details
|
||||
auto commanderPicture =
|
||||
new EdhrecCommanderResponseCommanderDetailsDisplayWidget(this, response.container.getCommanderDetails());
|
||||
auto commanderPicture = new EdhrecCommanderResponseCommanderDetailsDisplayWidget(
|
||||
this, response.container.getCommanderDetails(), baseUrl);
|
||||
cardDisplayLayout->addWidget(commanderPicture);
|
||||
widgetNames.append("Commander Details");
|
||||
|
||||
// Add card list widgets
|
||||
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();
|
||||
for (const EdhrecCommanderApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
||||
auto cardListDisplayWidget = new EdhrecCommanderApiResponseCardListDisplayWidget(this, card_list);
|
||||
for (const EdhrecApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
||||
auto cardListDisplayWidget = new EdhrecApiResponseCardListDisplayWidget(this, card_list);
|
||||
cardDisplayLayout->addWidget(cardListDisplayWidget);
|
||||
widgetNames.append(cardListDisplayWidget->getBannerText());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ class EdhrecCommanderApiResponseDisplayWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EdhrecCommanderApiResponseDisplayWidget(QWidget *parent, EdhrecCommanderApiResponse response);
|
||||
explicit EdhrecCommanderApiResponseDisplayWidget(QWidget *parent,
|
||||
EdhrecCommanderApiResponse response,
|
||||
QString baseUrl);
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
public slots:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,174 @@
|
|||
#include "edhrec_commander_api_response_navigation_widget.h"
|
||||
|
||||
#include "../../tab_edhrec_main.h"
|
||||
|
||||
EdhrecCommanderApiResponseNavigationWidget::EdhrecCommanderApiResponseNavigationWidget(
|
||||
QWidget *parent,
|
||||
const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails,
|
||||
QString baseUrl)
|
||||
: QWidget(parent), commanderDetails(_commanderDetails)
|
||||
{
|
||||
layout = new QGridLayout(this);
|
||||
setLayout(layout);
|
||||
|
||||
gameChangerLabel = new QLabel(this);
|
||||
budgetLabel = new QLabel(this);
|
||||
|
||||
comboPushButton = new QPushButton(this);
|
||||
averageDeckPushButton = new QPushButton(this);
|
||||
|
||||
layout->addWidget(comboPushButton, 0, 0, 1, 1);
|
||||
layout->addWidget(averageDeckPushButton, 0, 1, 1, 1);
|
||||
|
||||
layout->addWidget(gameChangerLabel, 1, 0, 1, 2);
|
||||
|
||||
for (int i = 0; i < gameChangerOptions.length(); i++) {
|
||||
QString option = gameChangerOptions.at(i);
|
||||
QString label = option.isEmpty() ? "All" : option.at(0).toUpper() + option.mid(1);
|
||||
QPushButton *optionButton = new QPushButton(label, this);
|
||||
gameChangerButtons[option] = optionButton;
|
||||
layout->addWidget(optionButton, 2, i);
|
||||
connect(optionButton, &QPushButton::clicked, this, [=, this]() {
|
||||
selectedGameChanger = option;
|
||||
updateOptionButtonSelection(gameChangerButtons, option);
|
||||
actRequestCommanderNavigation();
|
||||
});
|
||||
}
|
||||
|
||||
layout->addWidget(budgetLabel, 3, 0, 1, 2);
|
||||
|
||||
for (int i = 0; i < budgetOptions.length(); i++) {
|
||||
QString option = budgetOptions.at(i);
|
||||
QString label = option.isEmpty() ? "Any" : option.at(0).toUpper() + option.mid(1);
|
||||
QPushButton *btn = new QPushButton(label, this);
|
||||
budgetButtons[option] = btn;
|
||||
layout->addWidget(btn, 4, i);
|
||||
connect(btn, &QPushButton::clicked, this, [=, this]() {
|
||||
selectedBudget = option;
|
||||
updateOptionButtonSelection(budgetButtons, option);
|
||||
actRequestCommanderNavigation();
|
||||
});
|
||||
}
|
||||
|
||||
updateOptionButtonSelection(gameChangerButtons, "");
|
||||
updateOptionButtonSelection(budgetButtons, "");
|
||||
|
||||
QWidget *currentParent = parentWidget();
|
||||
TabEdhRecMain *parentTab = nullptr;
|
||||
|
||||
while (currentParent) {
|
||||
if ((parentTab = qobject_cast<TabEdhRecMain *>(currentParent))) {
|
||||
break;
|
||||
}
|
||||
currentParent = currentParent->parentWidget();
|
||||
}
|
||||
|
||||
if (parentTab) {
|
||||
connect(comboPushButton, &QPushButton::clicked, this,
|
||||
&EdhrecCommanderApiResponseNavigationWidget::actRequestComboNavigation);
|
||||
connect(averageDeckPushButton, &QPushButton::clicked, this,
|
||||
&EdhrecCommanderApiResponseNavigationWidget::actRequestAverageDeckNavigation);
|
||||
connect(this, &EdhrecCommanderApiResponseNavigationWidget::requestUrl, parentTab,
|
||||
&TabEdhRecMain::actNavigatePage);
|
||||
}
|
||||
|
||||
retranslateUi();
|
||||
applyOptionsFromUrl(baseUrl);
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseNavigationWidget::retranslateUi()
|
||||
{
|
||||
comboPushButton->setText(tr("Combos"));
|
||||
averageDeckPushButton->setText(tr("Average Deck"));
|
||||
gameChangerLabel->setText(tr("Game Changers"));
|
||||
budgetLabel->setText(tr("Budget"));
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseNavigationWidget::applyOptionsFromUrl(const QString &url)
|
||||
{
|
||||
QString cleanedUrl = url;
|
||||
|
||||
// Remove base and file extension
|
||||
if (cleanedUrl.startsWith("https://json.edhrec.com/pages/")) {
|
||||
cleanedUrl = cleanedUrl.mid(QString("https://json.edhrec.com/pages/").length());
|
||||
}
|
||||
if (cleanedUrl.endsWith(".json")) {
|
||||
cleanedUrl.chop(5);
|
||||
}
|
||||
|
||||
// Expecting something like: "commanders/the-ur-dragon/core/expensive"
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
QStringList parts = cleanedUrl.split('/', Qt::SkipEmptyParts);
|
||||
#else
|
||||
QStringList parts = cleanedUrl.split('/', QString::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
if (parts.size() < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString commanderName = parts[1];
|
||||
QString gameChangerOpt, budgetOpt;
|
||||
|
||||
// Define valid sets
|
||||
QSet<QString> validGameChangers = {"core", "upgraded", "optimized"};
|
||||
QSet<QString> validBudgets = {"budget", "expensive"};
|
||||
|
||||
// Check remaining parts after commander
|
||||
for (int i = 2; i < parts.size(); ++i) {
|
||||
QString part = parts[i].toLower();
|
||||
if (validGameChangers.contains(part)) {
|
||||
gameChangerOpt = part;
|
||||
} else if (validBudgets.contains(part)) {
|
||||
budgetOpt = part;
|
||||
}
|
||||
}
|
||||
|
||||
// Validate and apply
|
||||
if (!gameChangerButtons.contains(gameChangerOpt)) {
|
||||
gameChangerOpt.clear();
|
||||
}
|
||||
if (!budgetButtons.contains(budgetOpt)) {
|
||||
budgetOpt.clear();
|
||||
}
|
||||
|
||||
selectedGameChanger = gameChangerOpt;
|
||||
selectedBudget = budgetOpt;
|
||||
|
||||
updateOptionButtonSelection(gameChangerButtons, selectedGameChanger);
|
||||
updateOptionButtonSelection(budgetButtons, selectedBudget);
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseNavigationWidget::updateOptionButtonSelection(QMap<QString, QPushButton *> &buttons,
|
||||
const QString &selectedKey)
|
||||
{
|
||||
for (auto it = buttons.begin(); it != buttons.end(); ++it) {
|
||||
it.value()->setStyleSheet(it.key() == selectedKey ? "background-color: lightblue; font-weight: bold;" : "");
|
||||
}
|
||||
}
|
||||
|
||||
QString EdhrecCommanderApiResponseNavigationWidget::addNavigationOptionsToUrl(QString baseUrl)
|
||||
{
|
||||
if (!selectedGameChanger.isEmpty()) {
|
||||
baseUrl += "/" + selectedGameChanger;
|
||||
}
|
||||
if (!selectedBudget.isEmpty()) {
|
||||
baseUrl += "/" + selectedBudget;
|
||||
}
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseNavigationWidget::actRequestCommanderNavigation()
|
||||
{
|
||||
emit requestUrl(addNavigationOptionsToUrl("/commanders/" + commanderDetails.getSanitized()));
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseNavigationWidget::actRequestComboNavigation()
|
||||
{
|
||||
emit requestUrl("/combos/" + commanderDetails.getSanitized());
|
||||
}
|
||||
|
||||
void EdhrecCommanderApiResponseNavigationWidget::actRequestAverageDeckNavigation()
|
||||
{
|
||||
emit requestUrl(addNavigationOptionsToUrl("/average-decks/" + commanderDetails.getSanitized()));
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
#ifndef EDHREC_COMMANDER_API_RESPONSE_NAVIGATION_WIDGET_H
|
||||
#define EDHREC_COMMANDER_API_RESPONSE_NAVIGATION_WIDGET_H
|
||||
|
||||
#include "edhrec_api_response_commander_details_display_widget.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
|
||||
class EdhrecCommanderApiResponseNavigationWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EdhrecCommanderApiResponseNavigationWidget(
|
||||
QWidget *parent,
|
||||
const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails,
|
||||
QString baseUrl);
|
||||
void retranslateUi();
|
||||
void applyOptionsFromUrl(const QString &url);
|
||||
|
||||
public slots:
|
||||
void actRequestCommanderNavigation();
|
||||
void actRequestComboNavigation();
|
||||
void actRequestAverageDeckNavigation();
|
||||
signals:
|
||||
void requestUrl(QString url);
|
||||
|
||||
private:
|
||||
QGridLayout *layout;
|
||||
|
||||
QLabel *gameChangerLabel;
|
||||
QLabel *budgetLabel;
|
||||
|
||||
QStringList gameChangerOptions = {"", "core", "upgraded", "optimized"};
|
||||
QStringList budgetOptions = {"", "budget", "expensive"};
|
||||
|
||||
QString selectedGameChanger;
|
||||
QString selectedBudget;
|
||||
|
||||
QMap<QString, QPushButton *> gameChangerButtons;
|
||||
QMap<QString, QPushButton *> budgetButtons;
|
||||
|
||||
QPushButton *comboPushButton;
|
||||
QPushButton *averageDeckPushButton;
|
||||
|
||||
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
|
||||
|
||||
void updateOptionButtonSelection(QMap<QString, QPushButton *> &buttons, const QString &selectedKey);
|
||||
QString addNavigationOptionsToUrl(QString baseUrl);
|
||||
QString buildComboUrl() const;
|
||||
};
|
||||
|
||||
#endif // EDHREC_COMMANDER_API_RESPONSE_NAVIGATION_WIDGET_H
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#include "edhrec_top_cards_api_response_display_widget.h"
|
||||
|
||||
#include "../../api_response/top_cards/edhrec_top_cards_api_response.h"
|
||||
#include "../commander/edhrec_commander_api_response_card_list_display_widget.h"
|
||||
#include "../cards/edhrec_api_response_card_list_display_widget.h"
|
||||
|
||||
EdhrecTopCardsApiResponseDisplayWidget::EdhrecTopCardsApiResponseDisplayWidget(QWidget *parent,
|
||||
EdhrecTopCardsApiResponse response)
|
||||
|
|
@ -14,8 +14,8 @@ EdhrecTopCardsApiResponseDisplayWidget::EdhrecTopCardsApiResponseDisplayWidget(Q
|
|||
|
||||
// Add card list widgets
|
||||
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();
|
||||
for (const EdhrecCommanderApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
||||
auto cardListDisplayWidget = new EdhrecCommanderApiResponseCardListDisplayWidget(this, card_list);
|
||||
for (const EdhrecApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
||||
auto cardListDisplayWidget = new EdhrecApiResponseCardListDisplayWidget(this, card_list);
|
||||
cardDisplayLayout->addWidget(cardListDisplayWidget);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "edhrec_top_commanders_api_response_display_widget.h"
|
||||
|
||||
#include "../../api_response/top_commanders/edhrec_top_commanders_api_response.h"
|
||||
#include "../commander/edhrec_commander_api_response_card_list_display_widget.h"
|
||||
#include "../cards/edhrec_api_response_card_list_display_widget.h"
|
||||
|
||||
EdhrecTopCommandersApiResponseDisplayWidget::EdhrecTopCommandersApiResponseDisplayWidget(
|
||||
QWidget *parent,
|
||||
|
|
@ -15,8 +15,8 @@ EdhrecTopCommandersApiResponseDisplayWidget::EdhrecTopCommandersApiResponseDispl
|
|||
|
||||
// Add card list widgets
|
||||
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();
|
||||
for (const EdhrecCommanderApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
||||
auto cardListDisplayWidget = new EdhrecCommanderApiResponseCardListDisplayWidget(this, card_list);
|
||||
for (const EdhrecApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
||||
auto cardListDisplayWidget = new EdhrecApiResponseCardListDisplayWidget(this, card_list);
|
||||
cardDisplayLayout->addWidget(cardListDisplayWidget);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "edhrec_top_tags_api_response_display_widget.h"
|
||||
|
||||
#include "../../api_response/top_tags/edhrec_top_tags_api_response.h"
|
||||
#include "../commander/edhrec_commander_api_response_card_list_display_widget.h"
|
||||
#include "../cards/edhrec_api_response_card_list_display_widget.h"
|
||||
|
||||
EdhrecTopTagsApiResponseDisplayWidget::EdhrecTopTagsApiResponseDisplayWidget(QWidget *parent,
|
||||
EdhrecTopTagsApiResponse response)
|
||||
|
|
@ -14,8 +14,8 @@ EdhrecTopTagsApiResponseDisplayWidget::EdhrecTopTagsApiResponseDisplayWidget(QWi
|
|||
|
||||
// Add card list widgets
|
||||
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();
|
||||
for (const EdhrecCommanderApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
||||
auto cardListDisplayWidget = new EdhrecCommanderApiResponseCardListDisplayWidget(this, card_list);
|
||||
for (const EdhrecApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
||||
auto cardListDisplayWidget = new EdhrecApiResponseCardListDisplayWidget(this, card_list);
|
||||
cardDisplayLayout->addWidget(cardListDisplayWidget);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ void TabEdhRec::processApiJson(QNetworkReply *reply)
|
|||
EdhrecCommanderApiResponse deckData;
|
||||
deckData.fromJson(jsonObj);
|
||||
|
||||
displayWidget = new EdhrecCommanderApiResponseDisplayWidget(this, deckData);
|
||||
displayWidget = new EdhrecCommanderApiResponseDisplayWidget(this, deckData, reply->url().toString());
|
||||
// flowWidget->addWidget(displayWidget);
|
||||
setCentralWidget(displayWidget);
|
||||
|
||||
|
|
|
|||
|
|
@ -215,7 +215,8 @@ void TabEdhRecMain::processApiJson(QNetworkReply *reply)
|
|||
if (responseUrl.startsWith("https://json.edhrec.com/pages/commanders/year.json")) {
|
||||
processTopCommandersResponse(jsonObj);
|
||||
} else if (responseUrl.startsWith("https://json.edhrec.com/pages/commanders/")) {
|
||||
processCommanderResponse(jsonObj);
|
||||
qInfo() << "Received top kek";
|
||||
processCommanderResponse(jsonObj, responseUrl);
|
||||
} else if (responseUrl.startsWith("https://json.edhrec.com/pages/cards/")) {
|
||||
processCommanderResponse(jsonObj);
|
||||
} else if (responseUrl.startsWith("https://json.edhrec.com/pages/tags/")) {
|
||||
|
|
@ -225,6 +226,7 @@ void TabEdhRecMain::processApiJson(QNetworkReply *reply)
|
|||
} else if (responseUrl.startsWith("https://json.edhrec.com/pages/top/year.json")) {
|
||||
processTopCardsResponse(jsonObj);
|
||||
} else if (responseUrl.startsWith("https://json.edhrec.com/pages/combos/")) {
|
||||
qInfo() << "Received combos";
|
||||
processCommanderResponse(jsonObj);
|
||||
} else if (responseUrl.startsWith("https://json.edhrec.com/pages/average-decks/")) {
|
||||
processAverageDeckResponse(jsonObj);
|
||||
|
|
@ -316,7 +318,7 @@ void TabEdhRecMain::processTopCommandersResponse(QJsonObject reply)
|
|||
mainLayout->setStretch(1, 1); // Make sure currentPageDisplay takes remaining space
|
||||
}
|
||||
|
||||
void TabEdhRecMain::processCommanderResponse(QJsonObject reply)
|
||||
void TabEdhRecMain::processCommanderResponse(QJsonObject reply, QString responseUrl)
|
||||
{
|
||||
EdhrecCommanderApiResponse deckData;
|
||||
deckData.fromJson(reply);
|
||||
|
|
@ -333,7 +335,7 @@ void TabEdhRecMain::processCommanderResponse(QJsonObject reply)
|
|||
currentPageLayout = new QVBoxLayout(currentPageDisplay);
|
||||
currentPageDisplay->setLayout(currentPageLayout);
|
||||
|
||||
auto display = new EdhrecCommanderApiResponseDisplayWidget(currentPageDisplay, deckData);
|
||||
auto display = new EdhrecCommanderApiResponseDisplayWidget(currentPageDisplay, deckData, responseUrl);
|
||||
currentPageLayout->addWidget(display);
|
||||
|
||||
mainLayout->addWidget(currentPageDisplay);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ public:
|
|||
|
||||
public slots:
|
||||
void processApiJson(QNetworkReply *reply);
|
||||
void processCommanderResponse(QJsonObject reply, QString responseUrl = "");
|
||||
void processTopCardsResponse(QJsonObject reply);
|
||||
void processTopTagsResponse(QJsonObject reply);
|
||||
void processTopCommandersResponse(QJsonObject reply);
|
||||
|
|
@ -54,8 +55,6 @@ private:
|
|||
QPushButton *searchPushButton;
|
||||
CardInfoPtr cardToQuery;
|
||||
EdhrecCommanderApiResponseDisplayWidget *displayWidget;
|
||||
|
||||
void processCommanderResponse(QJsonObject reply);
|
||||
};
|
||||
|
||||
#endif // TAB_EDHREC_MAIN_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue