mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-17 07:52:16 -07:00
Refactor things into more sensible folders.
This commit is contained in:
parent
ca538399f6
commit
375869f873
35 changed files with 382 additions and 218 deletions
|
|
@ -21,19 +21,20 @@ set(cockatrice_SOURCES
|
||||||
src/client/tabs/api/edhrec/tab_edhrec.cpp
|
src/client/tabs/api/edhrec/tab_edhrec.cpp
|
||||||
src/client/tabs/api/edhrec/tab_edhrec_main.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_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_navigation_widget.cpp
|
||||||
src/client/tabs/api/edhrec/display/commander/edhrec_commander_api_response_card_list_display_widget.cpp
|
src/client/tabs/api/edhrec/display/cards/edhrec_api_response_card_details_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/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_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_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/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_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/cards/edhrec_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/cards/edhrec_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/cards/edhrec_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/card_prices/edhrec_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_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/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_average_deck_api_response.cpp
|
||||||
src/client/tabs/api/edhrec/api_response/average_deck/edhrec_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 <QDebug>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
void EdhrecCommanderApiResponseArchidektLink::fromJson(const QJsonObject &json)
|
void EdhrecApiResponseArchidektLink::fromJson(const QJsonObject &json)
|
||||||
{
|
{
|
||||||
c = json.value("c").toString();
|
c = json.value("c").toString();
|
||||||
f = json.value("f").toInt(0);
|
f = json.value("f").toInt(0);
|
||||||
|
|
@ -13,7 +13,7 @@ void EdhrecCommanderApiResponseArchidektLink::fromJson(const QJsonObject &json)
|
||||||
u = json.value("u").toString();
|
u = json.value("u").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EdhrecCommanderApiResponseArchidektLink::debugPrint() const
|
void EdhrecApiResponseArchidektLink::debugPrint() const
|
||||||
{
|
{
|
||||||
qDebug() << " C:" << c;
|
qDebug() << " C:" << c;
|
||||||
qDebug() << " F:" << f;
|
qDebug() << " F:" << f;
|
||||||
|
|
@ -27,7 +27,7 @@ void EdhrecCommanderApiResponseArchidektLinks::fromJson(const QJsonArray &json)
|
||||||
for (const QJsonValue &value : json) {
|
for (const QJsonValue &value : json) {
|
||||||
if (value.isObject()) {
|
if (value.isObject()) {
|
||||||
QJsonObject entryJson = value.toObject();
|
QJsonObject entryJson = value.toObject();
|
||||||
EdhrecCommanderApiResponseArchidektLink entry;
|
EdhrecApiResponseArchidektLink entry;
|
||||||
entry.fromJson(entryJson);
|
entry.fromJson(entryJson);
|
||||||
entries.append(entry);
|
entries.append(entry);
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
// Represents a single Archidekt entry
|
// Represents a single Archidekt entry
|
||||||
class EdhrecCommanderApiResponseArchidektLink
|
class EdhrecApiResponseArchidektLink
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString c;
|
QString c;
|
||||||
|
|
@ -23,7 +23,7 @@ public:
|
||||||
class EdhrecCommanderApiResponseArchidektLinks
|
class EdhrecCommanderApiResponseArchidektLinks
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QVector<EdhrecCommanderApiResponseArchidektLink> entries;
|
QVector<EdhrecApiResponseArchidektLink> entries;
|
||||||
|
|
||||||
void fromJson(const QJsonArray &json);
|
void fromJson(const QJsonArray &json);
|
||||||
void debugPrint() const;
|
void debugPrint() const;
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef EDHREC_AVERAGE_DECK_API_RESPONSE_H
|
#ifndef EDHREC_AVERAGE_DECK_API_RESPONSE_H
|
||||||
#define 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_average_deck_statistics.h"
|
||||||
#include "../commander/edhrec_commander_api_response_card_container.h"
|
|
||||||
#include "edhrec_deck_api_response.h"
|
#include "edhrec_deck_api_response.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
@ -20,7 +20,7 @@ public:
|
||||||
QString header;
|
QString header;
|
||||||
QJsonObject panels;
|
QJsonObject panels;
|
||||||
QString description;
|
QString description;
|
||||||
EdhrecCommanderApiResponseCardContainer container;
|
EdhrecApiResponseCardContainer container;
|
||||||
EdhrecDeckApiResponse deck;
|
EdhrecDeckApiResponse deck;
|
||||||
|
|
||||||
void fromJson(const QJsonObject &json);
|
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>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#include "edhrec_commander_api_response_card_container.h"
|
#include "edhrec_api_response_card_container.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
void EdhrecCommanderApiResponseCardContainer::fromJson(const QJsonObject &json)
|
void EdhrecApiResponseCardContainer::fromJson(const QJsonObject &json)
|
||||||
{
|
{
|
||||||
// Parse breadcrumb
|
// Parse breadcrumb
|
||||||
QJsonArray breadcrumbArray = json.value("breadcrumb").toArray();
|
QJsonArray breadcrumbArray = json.value("breadcrumb").toArray();
|
||||||
|
|
@ -20,7 +20,7 @@ void EdhrecCommanderApiResponseCardContainer::fromJson(const QJsonObject &json)
|
||||||
for (const QJsonValue &cardlistValue : cardlistsArray) {
|
for (const QJsonValue &cardlistValue : cardlistsArray) {
|
||||||
QJsonObject cardlistObj = cardlistValue.toObject();
|
QJsonObject cardlistObj = cardlistValue.toObject();
|
||||||
QJsonArray cardviewsArray = cardlistObj.value("cardviews").toArray();
|
QJsonArray cardviewsArray = cardlistObj.value("cardviews").toArray();
|
||||||
EdhrecCommanderApiResponseCardList cardView;
|
EdhrecApiResponseCardList cardView;
|
||||||
cardView.fromJson(cardlistValue.toObject());
|
cardView.fromJson(cardlistValue.toObject());
|
||||||
cardlists.push_back(cardView);
|
cardlists.push_back(cardView);
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ void EdhrecCommanderApiResponseCardContainer::fromJson(const QJsonObject &json)
|
||||||
title = json.value("title").toString();
|
title = json.value("title").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EdhrecCommanderApiResponseCardContainer::debugPrint() const
|
void EdhrecApiResponseCardContainer::debugPrint() const
|
||||||
{
|
{
|
||||||
qDebug() << "Breadcrumb:";
|
qDebug() << "Breadcrumb:";
|
||||||
for (const auto &breadcrumbEntry : breadcrumb) {
|
for (const auto &breadcrumbEntry : breadcrumb) {
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef CONTAINER_ENTRY_H
|
#ifndef CONTAINER_ENTRY_H
|
||||||
#define 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 "edhrec_commander_api_response_commander_details.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
@ -10,11 +10,11 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
class EdhrecCommanderApiResponseCardContainer
|
class EdhrecApiResponseCardContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
EdhrecCommanderApiResponseCardContainer() = default;
|
EdhrecApiResponseCardContainer() = default;
|
||||||
|
|
||||||
// Parse deck-related data from JSON
|
// Parse deck-related data from JSON
|
||||||
void fromJson(const QJsonObject &json);
|
void fromJson(const QJsonObject &json);
|
||||||
|
|
@ -35,7 +35,7 @@ public:
|
||||||
{
|
{
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
const QVector<EdhrecCommanderApiResponseCardList> &getCardlists() const
|
const QVector<EdhrecApiResponseCardList> &getCardlists() const
|
||||||
{
|
{
|
||||||
return cardlists;
|
return cardlists;
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ private:
|
||||||
QString description;
|
QString description;
|
||||||
QVector<QJsonObject> breadcrumb;
|
QVector<QJsonObject> breadcrumb;
|
||||||
EdhrecCommanderApiResponseCommanderDetails card;
|
EdhrecCommanderApiResponseCommanderDetails card;
|
||||||
QVector<EdhrecCommanderApiResponseCardList> cardlists;
|
QVector<EdhrecApiResponseCardList> cardlists;
|
||||||
QString keywords;
|
QString keywords;
|
||||||
QString title;
|
QString title;
|
||||||
};
|
};
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
#include "edhrec_commander_api_response_card_details.h"
|
#include "edhrec_api_response_card_details.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
EdhrecCommanderApiResponseCardDetails::EdhrecCommanderApiResponseCardDetails()
|
EdhrecApiResponseCardDetails::EdhrecApiResponseCardDetails()
|
||||||
: synergy(0.0), inclusion(0), numDecks(0), potentialDecks(0)
|
: 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
|
// Parse the fields from the JSON object
|
||||||
name = json.value("name").toString();
|
name = json.value("name").toString();
|
||||||
|
|
@ -21,7 +21,7 @@ void EdhrecCommanderApiResponseCardDetails::fromJson(const QJsonObject &json)
|
||||||
potentialDecks = json.value("potential_decks").toInt(0);
|
potentialDecks = json.value("potential_decks").toInt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EdhrecCommanderApiResponseCardDetails::debugPrint() const
|
void EdhrecApiResponseCardDetails::debugPrint() const
|
||||||
{
|
{
|
||||||
// Print out all the fields for debugging
|
// Print out all the fields for debugging
|
||||||
qDebug() << "Name:" << name;
|
qDebug() << "Name:" << name;
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class EdhrecCommanderApiResponseCardDetails
|
class EdhrecApiResponseCardDetails
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString name;
|
QString name;
|
||||||
|
|
@ -17,7 +17,7 @@ public:
|
||||||
int numDecks;
|
int numDecks;
|
||||||
int potentialDecks;
|
int potentialDecks;
|
||||||
|
|
||||||
EdhrecCommanderApiResponseCardDetails();
|
EdhrecApiResponseCardDetails();
|
||||||
|
|
||||||
// Method to populate the object from a JSON object
|
// Method to populate the object from a JSON object
|
||||||
void fromJson(const QJsonObject &json);
|
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>
|
#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
|
// Parse the header from the JSON object
|
||||||
header = json.value("header").toString();
|
header = json.value("header").toString();
|
||||||
|
|
@ -15,19 +15,19 @@ void EdhrecCommanderApiResponseCardList::fromJson(const QJsonObject &json)
|
||||||
QJsonArray cardviewsArray = json.value("cardviews").toArray();
|
QJsonArray cardviewsArray = json.value("cardviews").toArray();
|
||||||
for (const QJsonValue &value : cardviewsArray) {
|
for (const QJsonValue &value : cardviewsArray) {
|
||||||
QJsonObject cardviewObj = value.toObject();
|
QJsonObject cardviewObj = value.toObject();
|
||||||
EdhrecCommanderApiResponseCardDetails cardView;
|
EdhrecApiResponseCardDetails cardView;
|
||||||
cardView.fromJson(cardviewObj);
|
cardView.fromJson(cardviewObj);
|
||||||
cardViews.append(cardView);
|
cardViews.append(cardView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EdhrecCommanderApiResponseCardList::debugPrint() const
|
void EdhrecApiResponseCardList::debugPrint() const
|
||||||
{
|
{
|
||||||
// Print out the header
|
// Print out the header
|
||||||
qDebug() << "Header:" << header;
|
qDebug() << "Header:" << header;
|
||||||
|
|
||||||
// Print out all the CardView objects
|
// Print out all the CardView objects
|
||||||
for (const EdhrecCommanderApiResponseCardDetails &cardView : cardViews) {
|
for (const EdhrecApiResponseCardDetails &cardView : cardViews) {
|
||||||
cardView.debugPrint();
|
cardView.debugPrint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
#ifndef CARD_LIST_H
|
#ifndef CARD_LIST_H
|
||||||
#define 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 <QJsonArray>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class EdhrecCommanderApiResponseCardList
|
class EdhrecApiResponseCardList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString header;
|
QString header;
|
||||||
QList<EdhrecCommanderApiResponseCardDetails> cardViews;
|
QList<EdhrecApiResponseCardDetails> cardViews;
|
||||||
|
|
||||||
// Default constructor
|
// Default constructor
|
||||||
EdhrecCommanderApiResponseCardList();
|
EdhrecApiResponseCardList();
|
||||||
|
|
||||||
// Method to populate the object from a JSON object
|
// Method to populate the object from a JSON object
|
||||||
void fromJson(const QJsonObject &json);
|
void fromJson(const QJsonObject &json);
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_H
|
#ifndef EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_H
|
||||||
#define 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 <QJsonArray>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef DECKDATA_H
|
#ifndef DECKDATA_H
|
||||||
#define 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_average_deck_statistics.h"
|
||||||
#include "edhrec_commander_api_response_card_container.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
@ -19,7 +19,7 @@ public:
|
||||||
QString header;
|
QString header;
|
||||||
QJsonObject panels;
|
QJsonObject panels;
|
||||||
QString description;
|
QString description;
|
||||||
EdhrecCommanderApiResponseCardContainer container;
|
EdhrecApiResponseCardContainer container;
|
||||||
|
|
||||||
void fromJson(const QJsonObject &json);
|
void fromJson(const QJsonObject &json);
|
||||||
void debugPrint() const;
|
void debugPrint() const;
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
#ifndef EDHREC_TOP_CARDS_API_RESPONSE_H
|
#ifndef EDHREC_TOP_CARDS_API_RESPONSE_H
|
||||||
#define 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 <QDebug>
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
// Represents the main structure of the JSON
|
|
||||||
class EdhrecTopCardsApiResponse
|
class EdhrecTopCardsApiResponse
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString header;
|
QString header;
|
||||||
QString description;
|
QString description;
|
||||||
EdhrecCommanderApiResponseCardContainer container;
|
EdhrecApiResponseCardContainer container;
|
||||||
|
|
||||||
void fromJson(const QJsonObject &json);
|
void fromJson(const QJsonObject &json);
|
||||||
void debugPrint() const;
|
void debugPrint() const;
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
#ifndef EDHREC_TOP_COMMANDERS_API_RESPONSE_H
|
#ifndef EDHREC_TOP_COMMANDERS_API_RESPONSE_H
|
||||||
#define 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 <QDebug>
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
// Represents the main structure of the JSON
|
|
||||||
class EdhrecTopCommandersApiResponse
|
class EdhrecTopCommandersApiResponse
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString header;
|
QString header;
|
||||||
QString description;
|
QString description;
|
||||||
EdhrecCommanderApiResponseCardContainer container;
|
EdhrecApiResponseCardContainer container;
|
||||||
|
|
||||||
void fromJson(const QJsonObject &json);
|
void fromJson(const QJsonObject &json);
|
||||||
void debugPrint() const;
|
void debugPrint() const;
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
#ifndef EDHREC_TOP_TAGS_API_RESPONSE_H
|
#ifndef EDHREC_TOP_TAGS_API_RESPONSE_H
|
||||||
#define 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 <QDebug>
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
// Represents the main structure of the JSON
|
|
||||||
class EdhrecTopTagsApiResponse
|
class EdhrecTopTagsApiResponse
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString header;
|
QString header;
|
||||||
QString description;
|
QString description;
|
||||||
EdhrecCommanderApiResponseCardContainer container;
|
EdhrecApiResponseCardContainer container;
|
||||||
|
|
||||||
void fromJson(const QJsonObject &json);
|
void fromJson(const QJsonObject &json);
|
||||||
void debugPrint() const;
|
void debugPrint() const;
|
||||||
|
|
|
||||||
|
|
@ -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 "../../../../../../game/cards/card_database_manager.h"
|
||||||
#include "../../tab_edhrec_main.h"
|
#include "../../tab_edhrec_main.h"
|
||||||
|
|
||||||
EdhrecCommanderApiResponseCardDetailsDisplayWidget::EdhrecCommanderApiResponseCardDetailsDisplayWidget(
|
EdhrecApiResponseCardDetailsDisplayWidget::EdhrecApiResponseCardDetailsDisplayWidget(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
const EdhrecCommanderApiResponseCardDetails &_toDisplay)
|
const EdhrecApiResponseCardDetails &_toDisplay)
|
||||||
: QWidget(parent), toDisplay(_toDisplay)
|
: QWidget(parent), toDisplay(_toDisplay)
|
||||||
{
|
{
|
||||||
layout = new QVBoxLayout(this);
|
layout = new QVBoxLayout(this);
|
||||||
|
|
@ -55,13 +55,13 @@ EdhrecCommanderApiResponseCardDetailsDisplayWidget::EdhrecCommanderApiResponseCa
|
||||||
|
|
||||||
if (parentTab) {
|
if (parentTab) {
|
||||||
connect(cardPictureWidget, &CardInfoPictureWidget::cardClicked, this,
|
connect(cardPictureWidget, &CardInfoPictureWidget::cardClicked, this,
|
||||||
&EdhrecCommanderApiResponseCardDetailsDisplayWidget::actRequestPageNavigation);
|
&EdhrecApiResponseCardDetailsDisplayWidget::actRequestPageNavigation);
|
||||||
connect(this, &EdhrecCommanderApiResponseCardDetailsDisplayWidget::requestUrl, parentTab,
|
connect(this, &EdhrecApiResponseCardDetailsDisplayWidget::requestUrl, parentTab,
|
||||||
&TabEdhRecMain::actNavigatePage);
|
&TabEdhRecMain::actNavigatePage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EdhrecCommanderApiResponseCardDetailsDisplayWidget::actRequestPageNavigation()
|
void EdhrecApiResponseCardDetailsDisplayWidget::actRequestPageNavigation()
|
||||||
{
|
{
|
||||||
emit requestUrl(toDisplay.url);
|
emit requestUrl(toDisplay.url);
|
||||||
}
|
}
|
||||||
|
|
@ -2,26 +2,24 @@
|
||||||
#define EDHREC_COMMANDER_API_RESPONSE_CARD_DETAILS_DISPLAY_WIDGET_H
|
#define EDHREC_COMMANDER_API_RESPONSE_CARD_DETAILS_DISPLAY_WIDGET_H
|
||||||
|
|
||||||
#include "../../../../../ui/widgets/cards/card_info_picture_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 <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class EdhrecCommanderApiResponseCardDetailsDisplayWidget : public QWidget
|
class EdhrecApiResponseCardDetailsDisplayWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit EdhrecCommanderApiResponseCardDetailsDisplayWidget(
|
explicit EdhrecApiResponseCardDetailsDisplayWidget(QWidget *parent, const EdhrecApiResponseCardDetails &_toDisplay);
|
||||||
QWidget *parent,
|
|
||||||
const EdhrecCommanderApiResponseCardDetails &_toDisplay);
|
|
||||||
public slots:
|
public slots:
|
||||||
void actRequestPageNavigation();
|
void actRequestPageNavigation();
|
||||||
signals:
|
signals:
|
||||||
void requestUrl(QString url);
|
void requestUrl(QString url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EdhrecCommanderApiResponseCardDetails toDisplay;
|
EdhrecApiResponseCardDetails toDisplay;
|
||||||
QVBoxLayout *layout;
|
QVBoxLayout *layout;
|
||||||
CardInfoPictureWidget *cardPictureWidget;
|
CardInfoPictureWidget *cardPictureWidget;
|
||||||
QLabel *label;
|
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/display/banner_widget.h"
|
||||||
#include "../../../../../ui/widgets/general/layout_containers/flow_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 <QResizeEvent>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class EdhrecCommanderApiResponseCardListDisplayWidget : public QWidget
|
class EdhrecApiResponseCardListDisplayWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit EdhrecCommanderApiResponseCardListDisplayWidget(QWidget *parent,
|
explicit EdhrecApiResponseCardListDisplayWidget(QWidget *parent, EdhrecApiResponseCardList toDisplay);
|
||||||
EdhrecCommanderApiResponseCardList toDisplay);
|
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
[[nodiscard]] QString getBannerText() const
|
[[nodiscard]] QString getBannerText() const
|
||||||
{
|
{
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
#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"
|
||||||
|
|
||||||
|
EdhrecCommanderResponseCommanderDetailsDisplayWidget::EdhrecCommanderResponseCommanderDetailsDisplayWidget(
|
||||||
|
QWidget *parent,
|
||||||
|
const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails,
|
||||||
|
QUrl 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);
|
||||||
|
|
||||||
|
navigationWidget = new EdhrecCommanderApiResponseNavigationWidget(this, commanderDetails, baseUrl);
|
||||||
|
|
||||||
|
layout->addWidget(commanderPicture);
|
||||||
|
layout->addWidget(label);
|
||||||
|
layout->addWidget(salt);
|
||||||
|
layout->addWidget(navigationWidget);
|
||||||
|
|
||||||
|
retranslateUi();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EdhrecCommanderResponseCommanderDetailsDisplayWidget::retranslateUi()
|
||||||
|
{
|
||||||
|
label->setText(commanderDetails.getLabel());
|
||||||
|
salt->setText(tr("Salt: ") + QString::number(commanderDetails.getSalt()));
|
||||||
|
}
|
||||||
|
|
@ -2,36 +2,31 @@
|
||||||
#define EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_DISPLAY_WIDGET_H
|
#define EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_DISPLAY_WIDGET_H
|
||||||
|
|
||||||
#include "../../../../../ui/widgets/cards/card_info_picture_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 "edhrec_commander_api_response_navigation_widget.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
class EdhrecCommanderApiResponseNavigationWidget;
|
||||||
class EdhrecCommanderResponseCommanderDetailsDisplayWidget : public QWidget
|
class EdhrecCommanderResponseCommanderDetailsDisplayWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit EdhrecCommanderResponseCommanderDetailsDisplayWidget(
|
explicit EdhrecCommanderResponseCommanderDetailsDisplayWidget(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails);
|
const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails,
|
||||||
|
QUrl baseUrl);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
||||||
public slots:
|
|
||||||
void actRequestComboNavigation();
|
|
||||||
void actRequestAverageDeckNavigation();
|
|
||||||
signals:
|
|
||||||
void requestUrl(QString url);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel *label;
|
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
|
||||||
QLabel *salt;
|
|
||||||
QPushButton *comboPushButton;
|
|
||||||
QPushButton *averageDeckPushButton;
|
|
||||||
QVBoxLayout *layout;
|
QVBoxLayout *layout;
|
||||||
CardInfoPictureWidget *commanderPicture;
|
CardInfoPictureWidget *commanderPicture;
|
||||||
EdhrecCommanderApiResponseCommanderDetails commanderDetails;
|
QLabel *label;
|
||||||
|
QLabel *salt;
|
||||||
|
EdhrecCommanderApiResponseNavigationWidget *navigationWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_DISPLAY_WIDGET_H
|
#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 "../../../../../ui/widgets/cards/card_info_picture_widget.h"
|
||||||
#include "../../api_response/commander/edhrec_commander_api_response.h"
|
#include "../../api_response/commander/edhrec_commander_api_response.h"
|
||||||
#include "edhrec_commander_api_response_card_list_display_widget.h"
|
#include "../cards/edhrec_api_response_card_list_display_widget.h"
|
||||||
#include "edhrec_commander_api_response_commander_details_display_widget.h"
|
#include "edhrec_api_response_commander_details_display_widget.h"
|
||||||
|
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
|
|
@ -12,7 +12,8 @@
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
|
|
||||||
EdhrecCommanderApiResponseDisplayWidget::EdhrecCommanderApiResponseDisplayWidget(QWidget *parent,
|
EdhrecCommanderApiResponseDisplayWidget::EdhrecCommanderApiResponseDisplayWidget(QWidget *parent,
|
||||||
EdhrecCommanderApiResponse response)
|
EdhrecCommanderApiResponse response,
|
||||||
|
QUrl baseUrl)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
layout = new QHBoxLayout(this);
|
layout = new QHBoxLayout(this);
|
||||||
|
|
@ -31,15 +32,15 @@ EdhrecCommanderApiResponseDisplayWidget::EdhrecCommanderApiResponseDisplayWidget
|
||||||
QStringList widgetNames;
|
QStringList widgetNames;
|
||||||
|
|
||||||
// Add commander details
|
// Add commander details
|
||||||
auto commanderPicture =
|
auto commanderPicture = new EdhrecCommanderResponseCommanderDetailsDisplayWidget(
|
||||||
new EdhrecCommanderResponseCommanderDetailsDisplayWidget(this, response.container.getCommanderDetails());
|
this, response.container.getCommanderDetails(), baseUrl);
|
||||||
cardDisplayLayout->addWidget(commanderPicture);
|
cardDisplayLayout->addWidget(commanderPicture);
|
||||||
widgetNames.append("Commander Details");
|
widgetNames.append("Commander Details");
|
||||||
|
|
||||||
// Add card list widgets
|
// Add card list widgets
|
||||||
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();
|
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();
|
||||||
for (const EdhrecCommanderApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
for (const EdhrecApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
||||||
auto cardListDisplayWidget = new EdhrecCommanderApiResponseCardListDisplayWidget(this, card_list);
|
auto cardListDisplayWidget = new EdhrecApiResponseCardListDisplayWidget(this, card_list);
|
||||||
cardDisplayLayout->addWidget(cardListDisplayWidget);
|
cardDisplayLayout->addWidget(cardListDisplayWidget);
|
||||||
widgetNames.append(cardListDisplayWidget->getBannerText());
|
widgetNames.append(cardListDisplayWidget->getBannerText());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,9 @@ class EdhrecCommanderApiResponseDisplayWidget : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EdhrecCommanderApiResponseDisplayWidget(QWidget *parent, EdhrecCommanderApiResponse response);
|
explicit EdhrecCommanderApiResponseDisplayWidget(QWidget *parent,
|
||||||
|
EdhrecCommanderApiResponse response,
|
||||||
|
QUrl baseUrl);
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,158 @@
|
||||||
|
#include "edhrec_commander_api_response_navigation_widget.h"
|
||||||
|
|
||||||
|
#include "../../tab_edhrec_main.h"
|
||||||
|
|
||||||
|
EdhrecCommanderApiResponseNavigationWidget::EdhrecCommanderApiResponseNavigationWidget(
|
||||||
|
QWidget *parent,
|
||||||
|
const EdhrecCommanderApiResponseCommanderDetails &_commanderDetails,
|
||||||
|
QUrl baseUrl)
|
||||||
|
: QWidget(parent), commanderDetails(_commanderDetails)
|
||||||
|
{
|
||||||
|
qInfo() << commanderDetails.getUrl();
|
||||||
|
layout = new QGridLayout(this);
|
||||||
|
setLayout(layout);
|
||||||
|
|
||||||
|
gameChangerLabel = new QLabel(this);
|
||||||
|
budgetLabel = new QLabel(this);
|
||||||
|
|
||||||
|
commanderDetails.debugPrint();
|
||||||
|
|
||||||
|
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() ? "Any" : option.at(0).toUpper() + option.mid(1);
|
||||||
|
QPushButton *btn = new QPushButton(label, this);
|
||||||
|
gameChangerButtons[option] = btn;
|
||||||
|
layout->addWidget(btn, 2, i);
|
||||||
|
connect(btn, &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.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
// Example input: /commanders/kaalia-of-the-vast/core/budget
|
||||||
|
QStringList parts = url.split('/', Qt::SkipEmptyParts);
|
||||||
|
|
||||||
|
// Make sure there's at least a base + commander name
|
||||||
|
if (parts.size() < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Extract extra segments, if any
|
||||||
|
QString gameChangerOpt, budgetOpt;
|
||||||
|
|
||||||
|
if (parts.size() >= 3)
|
||||||
|
gameChangerOpt = parts[2]; // this would be "core", "upgraded", etc.
|
||||||
|
if (parts.size() >= 4)
|
||||||
|
budgetOpt = parts[3]; // "budget" or "expensive"
|
||||||
|
|
||||||
|
// Defensive: only accept known values
|
||||||
|
if (!gameChangerButtons.contains(gameChangerOpt))
|
||||||
|
gameChangerOpt = "";
|
||||||
|
if (!budgetButtons.contains(budgetOpt))
|
||||||
|
budgetOpt = "";
|
||||||
|
|
||||||
|
// Apply internal state
|
||||||
|
selectedGameChanger = gameChangerOpt;
|
||||||
|
selectedBudget = budgetOpt;
|
||||||
|
|
||||||
|
// Apply visual state
|
||||||
|
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;" : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EdhrecCommanderApiResponseNavigationWidget::actRequestCommanderNavigation()
|
||||||
|
{
|
||||||
|
QString url = "/commanders/" + commanderDetails.getSanitized();
|
||||||
|
if (!selectedGameChanger.isEmpty())
|
||||||
|
url += "/" + selectedGameChanger;
|
||||||
|
if (!selectedBudget.isEmpty())
|
||||||
|
url += "/" + selectedBudget;
|
||||||
|
emit requestUrl(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EdhrecCommanderApiResponseNavigationWidget::actRequestComboNavigation()
|
||||||
|
{
|
||||||
|
QString url = "/combos/" + commanderDetails.getSanitized();
|
||||||
|
if (!selectedGameChanger.isEmpty())
|
||||||
|
url += "/" + selectedGameChanger;
|
||||||
|
if (!selectedBudget.isEmpty())
|
||||||
|
url += "/" + selectedBudget;
|
||||||
|
emit requestUrl(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EdhrecCommanderApiResponseNavigationWidget::actRequestAverageDeckNavigation()
|
||||||
|
{
|
||||||
|
QString url = "/average-decks/" + commanderDetails.getSanitized();
|
||||||
|
if (!selectedGameChanger.isEmpty())
|
||||||
|
url += "/" + selectedGameChanger;
|
||||||
|
if (!selectedBudget.isEmpty())
|
||||||
|
url += "/" + selectedBudget;
|
||||||
|
emit requestUrl(url);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
#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,
|
||||||
|
QUrl 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 buildComboUrl() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EDHREC_COMMANDER_API_RESPONSE_NAVIGATION_WIDGET_H
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "edhrec_top_cards_api_response_display_widget.h"
|
#include "edhrec_top_cards_api_response_display_widget.h"
|
||||||
|
|
||||||
#include "../../api_response/top_cards/edhrec_top_cards_api_response.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,
|
EdhrecTopCardsApiResponseDisplayWidget::EdhrecTopCardsApiResponseDisplayWidget(QWidget *parent,
|
||||||
EdhrecTopCardsApiResponse response)
|
EdhrecTopCardsApiResponse response)
|
||||||
|
|
@ -14,8 +14,8 @@ EdhrecTopCardsApiResponseDisplayWidget::EdhrecTopCardsApiResponseDisplayWidget(Q
|
||||||
|
|
||||||
// Add card list widgets
|
// Add card list widgets
|
||||||
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();
|
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();
|
||||||
for (const EdhrecCommanderApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
for (const EdhrecApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
||||||
auto cardListDisplayWidget = new EdhrecCommanderApiResponseCardListDisplayWidget(this, card_list);
|
auto cardListDisplayWidget = new EdhrecApiResponseCardListDisplayWidget(this, card_list);
|
||||||
cardDisplayLayout->addWidget(cardListDisplayWidget);
|
cardDisplayLayout->addWidget(cardListDisplayWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "edhrec_top_commanders_api_response_display_widget.h"
|
#include "edhrec_top_commanders_api_response_display_widget.h"
|
||||||
|
|
||||||
#include "../../api_response/top_commanders/edhrec_top_commanders_api_response.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(
|
EdhrecTopCommandersApiResponseDisplayWidget::EdhrecTopCommandersApiResponseDisplayWidget(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
|
|
@ -15,8 +15,8 @@ EdhrecTopCommandersApiResponseDisplayWidget::EdhrecTopCommandersApiResponseDispl
|
||||||
|
|
||||||
// Add card list widgets
|
// Add card list widgets
|
||||||
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();
|
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();
|
||||||
for (const EdhrecCommanderApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
for (const EdhrecApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
||||||
auto cardListDisplayWidget = new EdhrecCommanderApiResponseCardListDisplayWidget(this, card_list);
|
auto cardListDisplayWidget = new EdhrecApiResponseCardListDisplayWidget(this, card_list);
|
||||||
cardDisplayLayout->addWidget(cardListDisplayWidget);
|
cardDisplayLayout->addWidget(cardListDisplayWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "edhrec_top_tags_api_response_display_widget.h"
|
#include "edhrec_top_tags_api_response_display_widget.h"
|
||||||
|
|
||||||
#include "../../api_response/top_tags/edhrec_top_tags_api_response.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,
|
EdhrecTopTagsApiResponseDisplayWidget::EdhrecTopTagsApiResponseDisplayWidget(QWidget *parent,
|
||||||
EdhrecTopTagsApiResponse response)
|
EdhrecTopTagsApiResponse response)
|
||||||
|
|
@ -14,8 +14,8 @@ EdhrecTopTagsApiResponseDisplayWidget::EdhrecTopTagsApiResponseDisplayWidget(QWi
|
||||||
|
|
||||||
// Add card list widgets
|
// Add card list widgets
|
||||||
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();
|
auto edhrec_commander_api_response_card_lists = response.container.getCardlists();
|
||||||
for (const EdhrecCommanderApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
for (const EdhrecApiResponseCardList &card_list : edhrec_commander_api_response_card_lists) {
|
||||||
auto cardListDisplayWidget = new EdhrecCommanderApiResponseCardListDisplayWidget(this, card_list);
|
auto cardListDisplayWidget = new EdhrecApiResponseCardListDisplayWidget(this, card_list);
|
||||||
cardDisplayLayout->addWidget(cardListDisplayWidget);
|
cardDisplayLayout->addWidget(cardListDisplayWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ void TabEdhRec::processApiJson(QNetworkReply *reply)
|
||||||
EdhrecCommanderApiResponse deckData;
|
EdhrecCommanderApiResponse deckData;
|
||||||
deckData.fromJson(jsonObj);
|
deckData.fromJson(jsonObj);
|
||||||
|
|
||||||
displayWidget = new EdhrecCommanderApiResponseDisplayWidget(this, deckData);
|
displayWidget = new EdhrecCommanderApiResponseDisplayWidget(this, deckData, reply->url());
|
||||||
// flowWidget->addWidget(displayWidget);
|
// flowWidget->addWidget(displayWidget);
|
||||||
setCentralWidget(displayWidget);
|
setCentralWidget(displayWidget);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,7 @@ void TabEdhRecMain::processCommanderResponse(QJsonObject reply)
|
||||||
currentPageLayout = new QVBoxLayout(currentPageDisplay);
|
currentPageLayout = new QVBoxLayout(currentPageDisplay);
|
||||||
currentPageDisplay->setLayout(currentPageLayout);
|
currentPageDisplay->setLayout(currentPageLayout);
|
||||||
|
|
||||||
auto display = new EdhrecCommanderApiResponseDisplayWidget(currentPageDisplay, deckData);
|
auto display = new EdhrecCommanderApiResponseDisplayWidget(currentPageDisplay, deckData, QUrl(""));
|
||||||
currentPageLayout->addWidget(display);
|
currentPageLayout->addWidget(display);
|
||||||
|
|
||||||
mainLayout->addWidget(currentPageDisplay);
|
mainLayout->addWidget(currentPageDisplay);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue