mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 20:33:58 -07:00
[Feature] TabArchidekt and Archidekt API integration (#6348)
* TabArchidekt and Archidekt API integration. Took 37 seconds Took 4 minutes Took 40 seconds Took 4 minutes * Lint. * Lont. * Search bar, fancier display, resolve providerId * Delegate click to base. * Be explicit for pedantic compilers. * Liiint. * Leave them default I guess * Leave them default I guess * Small fixes. * New utility display widgets. * New style for deck listing. * Lint. * Lont. * Scale things. * Delegate paint to base. * Use default Archidekt preview image for decks without featured. * Consistent sizes. * Increase font size, qt version guard. * More version guards. * Clean up filter layout, use mana symbols. * Set content margins. * Refresh on filter change. * Lint. * Better elision. * Query actual new endpoints, new query parameters. * Doxygen, reorder fields in constructor, readability. * Update page size doc to min size. * Update initial min deck size value. * Add label to page selection. * Okay, so, people upload a lot of 1 card decks frequently. * Whoops. * Add a selection combobox for sorting logic. * Debounce and limit searches. * Include. * Lint. * Don't imply that Archidekt supports multiple cards/commander names. * Let's not lambda it and slot it instead. * Overload. * Add button to home tab. Took 8 minutes * Adjust to selection model change. Took 5 minutes * Cleanup auto-generated comments. Took 8 minutes * Remember card sizes. Took 1 minute * Initialize with correct size. Took 3 minutes * Use correct placeholders. Took 2 minutes * Style lint. Took 16 minutes * Parse double-faced cards correctly. * Parse double-faced cards correctly. * Allow TabArchidekt to use VDE group/sort/display buttons * Lint. * Indicate that things are clickable. * Min treshold for nicer display. * Lint. * We have good labels at home. * We do a little linting. * Qt version guards. * Qt5 is the devil. * Update comments. * Lint comments. * More doxys. * One more doxy. * Lint. * Update. * Small fixes. Took 7 minutes Took 13 seconds --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
de13c22552
commit
eab4d435f8
43 changed files with 3285 additions and 141 deletions
|
|
@ -0,0 +1,29 @@
|
|||
#include "archidekt_deck_listing_api_response.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
|
||||
void ArchidektDeckListingApiResponse::fromJson(const QJsonObject &json)
|
||||
{
|
||||
count = json.value("count").toInt();
|
||||
next = QUrl(json.value("next").toString());
|
||||
|
||||
QJsonArray containerJson = json.value("results").toArray();
|
||||
|
||||
for (const QJsonValue &deckListingValue : containerJson) {
|
||||
ArchidektApiResponseDeckListingContainer listingResult;
|
||||
listingResult.fromJson(deckListingValue.toObject());
|
||||
results.append(listingResult);
|
||||
}
|
||||
}
|
||||
|
||||
void ArchidektDeckListingApiResponse::debugPrint() const
|
||||
{
|
||||
qDebug() << "Count:" << count;
|
||||
qDebug() << "Next:" << next;
|
||||
|
||||
qDebug() << "Results:";
|
||||
for (const auto &deckListing : results) {
|
||||
deckListing.debugPrint();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef COCKATRICE_ARCHIDEKT_DECK_LISTING_API_RESPONSE_H
|
||||
#define COCKATRICE_ARCHIDEKT_DECK_LISTING_API_RESPONSE_H
|
||||
|
||||
#include "deck_listings/archidekt_api_response_deck_listing_container.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
class ArchidektDeckListingApiResponse
|
||||
{
|
||||
|
||||
public:
|
||||
int count;
|
||||
QUrl next;
|
||||
QVector<ArchidektApiResponseDeckListingContainer> results;
|
||||
|
||||
void fromJson(const QJsonObject &json);
|
||||
void debugPrint() const;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_DECK_LISTING_API_RESPONSE_H
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
#include "archidekt_api_response_card.h"
|
||||
|
||||
void ArchidektApiResponseCard::fromJson(const QJsonObject &json)
|
||||
{
|
||||
id = json.value("id").toInt();
|
||||
artist = json.value("artist").toString();
|
||||
tcgProductId = json.value("tcgProductId").toInt();
|
||||
ckFoilId = json.value("ckFoilId").toInt();
|
||||
ckNormalId = json.value("ckNormalId").toInt();
|
||||
cmEd = json.value("cmEd").toString();
|
||||
scgSku = json.value("scgSku").toString();
|
||||
scgFoilSku = json.value("scgFoilSku").toString();
|
||||
collectorNumber = json.value("collectorNumber").toString();
|
||||
multiverseId = json.value("multiverseId").toInt();
|
||||
mtgoFoilId = json.value("mtgoFoilId").toInt();
|
||||
mtgoNormalId = json.value("mtgoNormalId").toInt();
|
||||
uid = json.value("uid").toString();
|
||||
displayName = json.value("displayName").toString();
|
||||
releasedAt = json.value("releasedAt").toString();
|
||||
|
||||
edition.fromJson(json.value("edition").toObject());
|
||||
|
||||
flavor = json.value("flavor").toString();
|
||||
// TODO but not really important
|
||||
// games = {""};
|
||||
// options = {""};
|
||||
scryfallImageHash = json.value("scryfallImageHash").toString();
|
||||
oracleCard = json.value("oracleCard").toObject();
|
||||
owned = json.value("owned").toInt();
|
||||
pinnedStatus = json.value("pinnedStatus").toInt();
|
||||
rarity = json.value("rarity").toString();
|
||||
// TODO but not really important
|
||||
// globalCategories = {""};
|
||||
}
|
||||
|
||||
void ArchidektApiResponseCard::debugPrint() const
|
||||
{
|
||||
qDebug() << "Id:" << id;
|
||||
qDebug() << "id:" << artist;
|
||||
qDebug() << "artist:" << tcgProductId;
|
||||
qDebug() << "tcgProductId:" << ckFoilId;
|
||||
qDebug() << "ckFoilId:" << ckNormalId;
|
||||
qDebug() << "ckNormalId:" << cmEd;
|
||||
qDebug() << "cmEd:" << scgSku;
|
||||
qDebug() << "scgSku:" << scgFoilSku;
|
||||
qDebug() << "scgFoilSku:" << collectorNumber;
|
||||
qDebug() << "collectorNumber:" << multiverseId;
|
||||
qDebug() << "multiverseId:" << mtgoFoilId;
|
||||
qDebug() << "mtgoFoilId:" << mtgoNormalId;
|
||||
qDebug() << "mtgoNormalId:" << uid;
|
||||
qDebug() << "uid:" << displayName;
|
||||
qDebug() << "displayName:" << releasedAt;
|
||||
qDebug() << "releasedAt:" << flavor;
|
||||
qDebug() << "flavor:" << games;
|
||||
qDebug() << "games:" << options;
|
||||
qDebug() << "options:" << scryfallImageHash;
|
||||
qDebug() << "scryfallImageHash:" << owned;
|
||||
qDebug() << "owned:" << pinnedStatus;
|
||||
qDebug() << "pinnedStatus:" << rarity;
|
||||
qDebug() << "rarity:" << globalCategories;
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
#ifndef COCKATRICE_ARCHIDEKT_API_RESPONSE_CARD_H
|
||||
#define COCKATRICE_ARCHIDEKT_API_RESPONSE_CARD_H
|
||||
|
||||
#include "archidekt_api_response_edition.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
class ArchidektApiResponseCard
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
ArchidektApiResponseCard() = default;
|
||||
|
||||
// Parse deck-related data from JSON
|
||||
void fromJson(const QJsonObject &json);
|
||||
|
||||
// Debug method for logging
|
||||
void debugPrint() const;
|
||||
|
||||
QJsonObject getOracleCard() const
|
||||
{
|
||||
return oracleCard;
|
||||
};
|
||||
|
||||
QString getCollectorNumber() const
|
||||
{
|
||||
return collectorNumber;
|
||||
}
|
||||
|
||||
ArchidektApiResponseEdition getEdition() const
|
||||
{
|
||||
return edition;
|
||||
}
|
||||
|
||||
private:
|
||||
int id;
|
||||
QString artist;
|
||||
int tcgProductId;
|
||||
int ckFoilId;
|
||||
int ckNormalId;
|
||||
QString cmEd;
|
||||
QString scgSku;
|
||||
QString scgFoilSku;
|
||||
QString collectorNumber;
|
||||
int multiverseId;
|
||||
int mtgoFoilId;
|
||||
int mtgoNormalId;
|
||||
QString uid;
|
||||
QString displayName;
|
||||
QString releasedAt;
|
||||
ArchidektApiResponseEdition edition;
|
||||
QString flavor;
|
||||
QStringList games;
|
||||
QStringList options;
|
||||
QString scryfallImageHash;
|
||||
QJsonObject oracleCard;
|
||||
int owned;
|
||||
int pinnedStatus;
|
||||
// ArchidektApiResponsePrices prices;
|
||||
QString rarity;
|
||||
QStringList globalCategories;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_ARCHIDEKT_API_RESPONSE_CARD_H
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#include "archidekt_api_response_card_entry.h"
|
||||
|
||||
void ArchidektApiResponseCardEntry::fromJson(const QJsonObject &json)
|
||||
{
|
||||
id = json.value("id").toInt();
|
||||
|
||||
auto categoriesJson = json.value("categories").toArray();
|
||||
|
||||
for (auto category : categoriesJson) {
|
||||
categories.append(category.toString());
|
||||
}
|
||||
|
||||
companion = json.value("companion").toBool();
|
||||
flippedDefault = json.value("flippedDefault").toBool();
|
||||
label = json.value("label").toString();
|
||||
modifier = json.value("modifier").toString();
|
||||
quantity = json.value("quantity").toInt();
|
||||
customCmc = json.value("customCmc").toInt();
|
||||
// removedCategories = {""};
|
||||
createdAt = json.value("createdAt").toString();
|
||||
updatedAt = json.value("updatedAt").toString();
|
||||
deletedAt = json.value("deletedAt").toString();
|
||||
notes = json.value("notes").toString();
|
||||
card.fromJson(json.value("card").toObject());
|
||||
}
|
||||
|
||||
void ArchidektApiResponseCardEntry::debugPrint() const
|
||||
{
|
||||
qDebug() << "Id:" << id;
|
||||
qDebug() << "Categories:" << categories;
|
||||
qDebug() << "Companion:" << companion;
|
||||
qDebug() << "FlippedDefault:" << flippedDefault;
|
||||
qDebug() << "Label:" << label;
|
||||
qDebug() << "Modifier:" << modifier;
|
||||
qDebug() << "Quantity:" << quantity;
|
||||
qDebug() << "CustomCmc:" << customCmc;
|
||||
qDebug() << "RemovedCategories:" << removedCategories;
|
||||
qDebug() << "CreatedAt:" << createdAt;
|
||||
qDebug() << "UpdatedAt:" << updatedAt;
|
||||
qDebug() << "DeletedAt:" << deletedAt;
|
||||
qDebug() << "Notes:" << notes;
|
||||
card.debugPrint();
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef COCKATRICE_ARCHIDEKT_API_RESPONSE_CARD_ENTRY_H
|
||||
#define COCKATRICE_ARCHIDEKT_API_RESPONSE_CARD_ENTRY_H
|
||||
|
||||
#include "archidekt_api_response_card.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
class ArchidektApiResponseCardEntry
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
ArchidektApiResponseCardEntry() = default;
|
||||
|
||||
// Parse deck-related data from JSON
|
||||
void fromJson(const QJsonObject &json);
|
||||
|
||||
// Debug method for logging
|
||||
void debugPrint() const;
|
||||
|
||||
ArchidektApiResponseCard getCard() const
|
||||
{
|
||||
return card;
|
||||
};
|
||||
|
||||
QStringList getCategories() const
|
||||
{
|
||||
return categories;
|
||||
}
|
||||
|
||||
int getQuantity() const
|
||||
{
|
||||
return quantity;
|
||||
}
|
||||
|
||||
private:
|
||||
int id;
|
||||
QStringList categories;
|
||||
bool companion;
|
||||
bool flippedDefault;
|
||||
QString label;
|
||||
QString modifier;
|
||||
int quantity;
|
||||
int customCmc;
|
||||
QStringList removedCategories;
|
||||
QString createdAt;
|
||||
QString updatedAt;
|
||||
QString deletedAt;
|
||||
QString notes;
|
||||
ArchidektApiResponseCard card;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_ARCHIDEKT_API_RESPONSE_CARD_ENTRY_H
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#include "archidekt_api_response_edition.h"
|
||||
|
||||
void ArchidektApiResponseEdition::fromJson(const QJsonObject &json)
|
||||
{
|
||||
editionCode = json.value("editioncode").toString();
|
||||
editionName = json.value("editionname").toString();
|
||||
editionDate = json.value("editiondate").toString();
|
||||
editionType = json.value("editiontype").toString();
|
||||
mtgoCode = json.value("mtgocode").toString();
|
||||
}
|
||||
|
||||
void ArchidektApiResponseEdition::debugPrint() const
|
||||
{
|
||||
qDebug() << "Edition Code: " << editionCode;
|
||||
qDebug() << "Edition Name: " << editionName;
|
||||
qDebug() << "Edition Date: " << editionDate;
|
||||
qDebug() << "Edition Type: " << editionType;
|
||||
qDebug() << "Mtgo Code: " << mtgoCode;
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef COCKATRICE_ARCHIDEKT_API_RESPONSE_EDITION_H
|
||||
#define COCKATRICE_ARCHIDEKT_API_RESPONSE_EDITION_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
class ArchidektApiResponseEdition
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
ArchidektApiResponseEdition() = default;
|
||||
|
||||
// Parse deck-related data from JSON
|
||||
void fromJson(const QJsonObject &json);
|
||||
|
||||
// Debug method for logging
|
||||
void debugPrint() const;
|
||||
|
||||
[[nodiscard]] QString getEditionCode() const
|
||||
{
|
||||
return editionCode;
|
||||
}
|
||||
[[nodiscard]] QString getEditionName() const
|
||||
{
|
||||
return editionName;
|
||||
}
|
||||
[[nodiscard]] QString getEditionDate() const
|
||||
{
|
||||
return editionDate;
|
||||
}
|
||||
[[nodiscard]] QString getEditionType() const
|
||||
{
|
||||
return editionType;
|
||||
}
|
||||
[[nodiscard]] QString getMtgoCode() const
|
||||
{
|
||||
return mtgoCode;
|
||||
}
|
||||
|
||||
private:
|
||||
QString editionCode;
|
||||
QString editionName;
|
||||
QString editionDate;
|
||||
QString editionType;
|
||||
QString mtgoCode;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_ARCHIDEKT_API_RESPONSE_EDITION_H
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
#include "archidekt_api_response_deck.h"
|
||||
|
||||
#include "../card/archidekt_api_response_card_entry.h"
|
||||
|
||||
void ArchidektApiResponseDeck::fromJson(const QJsonObject &json)
|
||||
{
|
||||
id = json.value("id").toInt();
|
||||
name = json.value("name").toString();
|
||||
size = json.value("size").toInt();
|
||||
updatedAt = json.value("updatedAt").toString();
|
||||
createdAt = json.value("createdAt").toString();
|
||||
deckFormat = json.value("deckFormat").toInt();
|
||||
edhBracket = json.value("edhBracket").toInt();
|
||||
featured = json.value("featured").toString();
|
||||
customFeatured = json.value("customFeatured").toString();
|
||||
viewCount = json.value("viewCount").toInt();
|
||||
privateDeck = json.value("private").toBool();
|
||||
unlisted = json.value("unlisted").toBool();
|
||||
theoryCrafted = json.value("theoryCrafted").toBool();
|
||||
points = json.value("points").toInt();
|
||||
userInput = json.value("userInput").toInt();
|
||||
owner.fromJson(json.value("owner").toObject());
|
||||
commentRoot = json.value("commentRoot").toInt();
|
||||
editors = json.value("editors").toString();
|
||||
parentFolderId = json.value("parentFolderId").toInt();
|
||||
bookmarked = json.value("bookmarked").toBool();
|
||||
|
||||
auto categoriesJson = json.value("categories").toArray();
|
||||
for (auto category : categoriesJson) {
|
||||
ArchidektApiResponseDeckCategory categoryEntry;
|
||||
categoryEntry.fromJson(category.toObject());
|
||||
categories.append(categoryEntry);
|
||||
}
|
||||
|
||||
// deckTags = {""};
|
||||
playgroupDeckUrl = json.value("playgroupDeckUrl").toString();
|
||||
cardPackage = json.value("cardPackage").toString();
|
||||
|
||||
auto cardsObject = json.value("cards").toArray();
|
||||
|
||||
for (auto card : cardsObject) {
|
||||
ArchidektApiResponseCardEntry entry;
|
||||
entry.fromJson(card.toObject());
|
||||
cards.append(entry);
|
||||
}
|
||||
|
||||
// TODO but not really important
|
||||
// customCards = {""};
|
||||
}
|
||||
|
||||
void ArchidektApiResponseDeck::debugPrint() const
|
||||
{
|
||||
qDebug() << "Id:" << id;
|
||||
qDebug() << "Name:" << name;
|
||||
qDebug() << "Size:" << size;
|
||||
qDebug() << "UpdatedAt:" << updatedAt;
|
||||
qDebug() << "CreatedAt:" << createdAt;
|
||||
qDebug() << "DeckFormat:" << deckFormat;
|
||||
qDebug() << "EdhBracket:" << edhBracket;
|
||||
qDebug() << "Featured:" << featured;
|
||||
qDebug() << "CustomFeatured:" << customFeatured;
|
||||
qDebug() << "ViewCount:" << viewCount;
|
||||
qDebug() << "Private:" << privateDeck;
|
||||
qDebug() << "Unlisted:" << unlisted;
|
||||
qDebug() << "TheoryCrafted:" << theoryCrafted;
|
||||
qDebug() << "Points:" << points;
|
||||
qDebug() << "UserInput:" << userInput;
|
||||
owner.debugPrint();
|
||||
qDebug() << "CommentRoot:" << commentRoot;
|
||||
qDebug() << "Editors:" << editors;
|
||||
qDebug() << "ParentFolderId:" << parentFolderId;
|
||||
qDebug() << "Bookmarked:" << bookmarked;
|
||||
qDebug() << "DeckTags:" << deckTags;
|
||||
qDebug() << "PlaygroupDeckUrl:" << playgroupDeckUrl;
|
||||
qDebug() << "CardPackage:" << cardPackage;
|
||||
for (auto card : cards) {
|
||||
card.debugPrint();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
#ifndef COCKATRICE_ARCHIDEKT_API_RESPONSE_DECK_H
|
||||
#define COCKATRICE_ARCHIDEKT_API_RESPONSE_DECK_H
|
||||
|
||||
#include "../card/archidekt_api_response_card.h"
|
||||
#include "../card/archidekt_api_response_card_entry.h"
|
||||
#include "../deck_listings/archidekt_api_response_deck_owner.h"
|
||||
#include "archidekt_api_response_deck_category.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
class ArchidektApiResponseDeck
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
ArchidektApiResponseDeck() = default;
|
||||
|
||||
// Parse deck-related data from JSON
|
||||
void fromJson(const QJsonObject &json);
|
||||
|
||||
// Debug method for logging
|
||||
void debugPrint() const;
|
||||
|
||||
QVector<ArchidektApiResponseCardEntry> getCards() const
|
||||
{
|
||||
return cards;
|
||||
};
|
||||
|
||||
QVector<ArchidektApiResponseDeckCategory> getCategories() const
|
||||
{
|
||||
return categories;
|
||||
}
|
||||
|
||||
QString getDeckName() const
|
||||
{
|
||||
return name;
|
||||
};
|
||||
|
||||
private:
|
||||
int id;
|
||||
QString name;
|
||||
int size;
|
||||
QString updatedAt;
|
||||
QString createdAt;
|
||||
int deckFormat;
|
||||
int edhBracket;
|
||||
QString featured;
|
||||
QString customFeatured;
|
||||
int viewCount;
|
||||
bool privateDeck;
|
||||
bool unlisted;
|
||||
bool theoryCrafted;
|
||||
int points;
|
||||
int userInput;
|
||||
ArchidektApiResponseDeckOwner owner;
|
||||
int commentRoot;
|
||||
QString editors;
|
||||
int parentFolderId;
|
||||
bool bookmarked;
|
||||
QVector<ArchidektApiResponseDeckCategory> categories;
|
||||
QStringList deckTags;
|
||||
QString playgroupDeckUrl;
|
||||
QString cardPackage;
|
||||
QVector<ArchidektApiResponseCardEntry> cards;
|
||||
QStringList customCards;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_ARCHIDEKT_API_RESPONSE_DECK_H
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#include "archidekt_api_response_deck_category.h"
|
||||
|
||||
void ArchidektApiResponseDeckCategory::fromJson(const QJsonObject &json)
|
||||
{
|
||||
id = json.value("id").toInt();
|
||||
name = json.value("name").toString();
|
||||
isPremier = json.value("isPremier").toBool();
|
||||
includedInDeck = json.value("includedInDeck").toBool();
|
||||
includedInPrice = json.value("includedInPrice").toBool();
|
||||
}
|
||||
|
||||
void ArchidektApiResponseDeckCategory::debugPrint() const
|
||||
{
|
||||
qDebug() << "Id:" << id;
|
||||
qDebug() << "Name:" << name;
|
||||
qDebug() << "isPremier:" << isPremier;
|
||||
qDebug() << "IncludedInDeck:" << includedInDeck;
|
||||
qDebug() << "IncludedInPrice:" << includedInPrice;
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
#ifndef COCKATRICE_ARCHIDEKT_API_RESPONSE_DECK_CATEGORY_H
|
||||
#define COCKATRICE_ARCHIDEKT_API_RESPONSE_DECK_CATEGORY_H
|
||||
|
||||
#include "../card/archidekt_api_response_card.h"
|
||||
#include "../card/archidekt_api_response_card_entry.h"
|
||||
#include "../deck_listings/archidekt_api_response_deck_owner.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
class ArchidektApiResponseDeckCategory
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
ArchidektApiResponseDeckCategory() = default;
|
||||
|
||||
// Parse deck-related data from JSON
|
||||
void fromJson(const QJsonObject &json);
|
||||
|
||||
// Debug method for logging
|
||||
void debugPrint() const;
|
||||
|
||||
[[nodiscard]] int getId() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
[[nodiscard]] QString getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
[[nodiscard]] bool getIsPremier() const
|
||||
{
|
||||
return isPremier;
|
||||
}
|
||||
[[nodiscard]] bool getIncludedInDeck() const
|
||||
{
|
||||
return includedInDeck;
|
||||
}
|
||||
[[nodiscard]] bool getIncludedInPrice() const
|
||||
{
|
||||
return includedInPrice;
|
||||
}
|
||||
|
||||
private:
|
||||
int id;
|
||||
QString name;
|
||||
bool isPremier;
|
||||
bool includedInDeck;
|
||||
bool includedInPrice;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_ARCHIDEKT_API_RESPONSE_DECK_CATEGORY_H
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
#include "archidekt_api_response_deck_listing_container.h"
|
||||
|
||||
#include "archidekt_api_response_deck_owner.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
|
||||
void ArchidektApiResponseDeckListingContainer::fromJson(const QJsonObject &json)
|
||||
{
|
||||
id = json.value("id").toInt();
|
||||
name = json.value("name").toString();
|
||||
size = json.value("size").toInt();
|
||||
updatedAt = json.value("updatedAt").toString();
|
||||
createdAt = json.value("createdAt").toString();
|
||||
deckFormat = json.value("deckFormat").toInt();
|
||||
edhBracket = json.value("edhBracket").toInt();
|
||||
featured = json.value("featured").toString();
|
||||
customFeatured = json.value("customFeatured").toString();
|
||||
viewCount = json.value("viewCount").toInt();
|
||||
privateDeck = json.value("private").toBool();
|
||||
unlisted = json.value("unlisted").toBool();
|
||||
theoryCrafted = json.value("theoryCrafted").toBool();
|
||||
game = json.value("game").toString();
|
||||
hasDescription = json.value("hasDescription").toBool();
|
||||
// TODO
|
||||
// tags = {""};
|
||||
parentFolderId = json.value("parentFolderId").toInt();
|
||||
owner.fromJson(json.value("owner").toObject());
|
||||
|
||||
auto colorsJson = json.value("colors").toObject();
|
||||
|
||||
for (auto color : colorsJson.keys()) {
|
||||
colors[color] = colorsJson[color].toInt();
|
||||
}
|
||||
|
||||
cardPackage = json.value("cardPackage").toString();
|
||||
contest = json.value("contest").toString();
|
||||
}
|
||||
|
||||
void ArchidektApiResponseDeckListingContainer::debugPrint() const
|
||||
{
|
||||
qDebug() << "Id:" << id;
|
||||
qDebug() << "Name:" << name;
|
||||
qDebug() << "Size:" << size;
|
||||
qDebug() << "UpdatedAt:" << updatedAt;
|
||||
qDebug() << "CreatedAt:" << createdAt;
|
||||
qDebug() << "DeckFormat:" << deckFormat;
|
||||
qDebug() << "EdhBracket:" << edhBracket;
|
||||
qDebug() << "Featured:" << featured;
|
||||
qDebug() << "CustomFeatured:" << customFeatured;
|
||||
qDebug() << "ViewCount:" << viewCount;
|
||||
qDebug() << "Private:" << privateDeck;
|
||||
qDebug() << "Unlisted:" << unlisted;
|
||||
qDebug() << "TheoryCrafted:" << theoryCrafted;
|
||||
qDebug() << "Game:" << game;
|
||||
qDebug() << "HasDescription:" << hasDescription;
|
||||
qDebug() << "Tags:" << tags;
|
||||
qDebug() << "ParentFolderId:" << parentFolderId;
|
||||
owner.debugPrint();
|
||||
qDebug() << "Colors:" << colors;
|
||||
qDebug() << "CardPackage" << cardPackage;
|
||||
qDebug() << "Contest:" << contest;
|
||||
}
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
#ifndef COCKATRICE_ARCHIDEKT_DECK_LISTING_API_RESPONSE_CONTAINER_H
|
||||
#define COCKATRICE_ARCHIDEKT_DECK_LISTING_API_RESPONSE_CONTAINER_H
|
||||
|
||||
#include "archidekt_api_response_deck_owner.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
class ArchidektApiResponseDeckListingContainer
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
ArchidektApiResponseDeckListingContainer() = default;
|
||||
|
||||
// Parse deck-related data from JSON
|
||||
void fromJson(const QJsonObject &json);
|
||||
|
||||
// Debug method for logging
|
||||
void debugPrint() const;
|
||||
|
||||
[[nodiscard]] int getId() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
[[nodiscard]] QString getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
[[nodiscard]] int getSize() const
|
||||
{
|
||||
return size;
|
||||
}
|
||||
[[nodiscard]] QString getUpdatedAt() const
|
||||
{
|
||||
return updatedAt;
|
||||
}
|
||||
[[nodiscard]] QString getCreatedAt() const
|
||||
{
|
||||
return createdAt;
|
||||
}
|
||||
[[nodiscard]] int getDeckFormat() const
|
||||
{
|
||||
return deckFormat;
|
||||
}
|
||||
[[nodiscard]] int getEDHBracket() const
|
||||
{
|
||||
return edhBracket;
|
||||
}
|
||||
[[nodiscard]] QString getFeatured() const
|
||||
{
|
||||
return featured;
|
||||
}
|
||||
[[nodiscard]] QString getCustomFeatured() const
|
||||
{
|
||||
return customFeatured;
|
||||
}
|
||||
[[nodiscard]] int getViewCount() const
|
||||
{
|
||||
return viewCount;
|
||||
}
|
||||
[[nodiscard]] bool getPrivateDeck() const
|
||||
{
|
||||
return privateDeck;
|
||||
}
|
||||
[[nodiscard]] bool getUnlisted() const
|
||||
{
|
||||
return unlisted;
|
||||
}
|
||||
[[nodiscard]] bool getTheoryCrafted() const
|
||||
{
|
||||
return theoryCrafted;
|
||||
}
|
||||
[[nodiscard]] QString getGame() const
|
||||
{
|
||||
return game;
|
||||
}
|
||||
[[nodiscard]] bool getHasDescription() const
|
||||
{
|
||||
return hasDescription;
|
||||
}
|
||||
[[nodiscard]] QStringList getTags() const
|
||||
{
|
||||
return tags;
|
||||
}
|
||||
[[nodiscard]] int getParentFolderId() const
|
||||
{
|
||||
return parentFolderId;
|
||||
}
|
||||
[[nodiscard]] ArchidektApiResponseDeckOwner getOwner() const
|
||||
{
|
||||
return owner;
|
||||
}
|
||||
[[nodiscard]] QMap<QString, int> getColors() const
|
||||
{
|
||||
return colors;
|
||||
}
|
||||
[[nodiscard]] QString getCardPackage() const
|
||||
{
|
||||
return cardPackage;
|
||||
}
|
||||
[[nodiscard]] QString getContest() const
|
||||
{
|
||||
return contest;
|
||||
}
|
||||
|
||||
private:
|
||||
int id;
|
||||
QString name;
|
||||
int size;
|
||||
QString updatedAt;
|
||||
QString createdAt;
|
||||
int deckFormat;
|
||||
int edhBracket;
|
||||
QString featured;
|
||||
QString customFeatured;
|
||||
int viewCount;
|
||||
bool privateDeck;
|
||||
bool unlisted;
|
||||
bool theoryCrafted;
|
||||
QString game;
|
||||
bool hasDescription;
|
||||
QStringList tags;
|
||||
int parentFolderId;
|
||||
ArchidektApiResponseDeckOwner owner;
|
||||
QMap<QString, int> colors;
|
||||
QString cardPackage;
|
||||
QString contest;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_ARCHIDEKT_DECK_LISTING_API_RESPONSE_CONTAINER_H
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#include "archidekt_api_response_deck_owner.h"
|
||||
|
||||
void ArchidektApiResponseDeckOwner::fromJson(const QJsonObject &json)
|
||||
{
|
||||
id = json.value("id").toInt();
|
||||
userName = json.value("username").toString();
|
||||
avatar = QUrl(json.value("avatar").toString());
|
||||
moderator = json.value("moderator").toBool();
|
||||
pledgeLevel = json.value("pledgeLevel").toInt();
|
||||
// TODO but not really important
|
||||
// roles = {""};
|
||||
}
|
||||
|
||||
void ArchidektApiResponseDeckOwner::debugPrint() const
|
||||
{
|
||||
qDebug() << "Id:" << id;
|
||||
qDebug() << "UserName:" << userName;
|
||||
qDebug() << "Avatar:" << avatar;
|
||||
qDebug() << "Moderator:" << moderator;
|
||||
qDebug() << "PledgeLevel:" << pledgeLevel;
|
||||
qDebug() << "Roles:" << roles;
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef COCKATRICE_ARCHIDEKT_API_RESPONSE_DECK_OWNER_H
|
||||
#define COCKATRICE_ARCHIDEKT_API_RESPONSE_DECK_OWNER_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
class ArchidektApiResponseDeckOwner
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
ArchidektApiResponseDeckOwner() = default;
|
||||
|
||||
// Parse deck-related data from JSON
|
||||
void fromJson(const QJsonObject &json);
|
||||
|
||||
// Debug method for logging
|
||||
void debugPrint() const;
|
||||
|
||||
[[nodiscard]] QString getName() const
|
||||
{
|
||||
return userName;
|
||||
}
|
||||
|
||||
private:
|
||||
int id;
|
||||
QString userName;
|
||||
QUrl avatar;
|
||||
bool moderator;
|
||||
int pledgeLevel;
|
||||
QStringList roles;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_ARCHIDEKT_API_RESPONSE_DECK_OWNER_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue