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:
BruebachL 2025-04-18 05:28:04 +02:00 committed by GitHub
parent ca538399f6
commit 653362567b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 529 additions and 232 deletions

View file

@ -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);
}

View file

@ -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;

View file

@ -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);

View file

@ -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;
}

View file

@ -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) {

View file

@ -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;
};

View file

@ -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;

View file

@ -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);

View file

@ -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();
}
}

View file

@ -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);

View file

@ -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>

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;