rename class

This commit is contained in:
RickyRister 2025-07-06 23:32:05 -07:00
parent a6216c2912
commit 3c5ace00be
28 changed files with 111 additions and 108 deletions

View file

@ -24,7 +24,7 @@ AllZonesCardAmountWidget::AllZonesCardAmountWidget(QWidget *parent,
QTreeView *deckView, QTreeView *deckView,
QSlider *cardSizeSlider, QSlider *cardSizeSlider,
CardInfoPtr rootCard, CardInfoPtr rootCard,
CardInfoPerSet setInfoForCard) PrintingInfo setInfoForCard)
: QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), cardSizeSlider(cardSizeSlider), : QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), cardSizeSlider(cardSizeSlider),
rootCard(rootCard), setInfoForCard(setInfoForCard) rootCard(rootCard), setInfoForCard(setInfoForCard)
{ {

View file

@ -17,7 +17,7 @@ public:
QTreeView *deckView, QTreeView *deckView,
QSlider *cardSizeSlider, QSlider *cardSizeSlider,
CardInfoPtr rootCard, CardInfoPtr rootCard,
CardInfoPerSet setInfoForCard); PrintingInfo setInfoForCard);
int getMainboardAmount(); int getMainboardAmount();
int getSideboardAmount(); int getSideboardAmount();
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
@ -36,7 +36,7 @@ private:
QTreeView *deckView; QTreeView *deckView;
QSlider *cardSizeSlider; QSlider *cardSizeSlider;
CardInfoPtr rootCard; CardInfoPtr rootCard;
CardInfoPerSet setInfoForCard; PrintingInfo setInfoForCard;
QLabel *zoneLabelMainboard; QLabel *zoneLabelMainboard;
CardAmountWidget *buttonBoxMainboard; CardAmountWidget *buttonBoxMainboard;
QLabel *zoneLabelSideboard; QLabel *zoneLabelSideboard;

View file

@ -21,7 +21,7 @@ CardAmountWidget::CardAmountWidget(QWidget *parent,
QTreeView *deckView, QTreeView *deckView,
QSlider *cardSizeSlider, QSlider *cardSizeSlider,
CardInfoPtr &rootCard, CardInfoPtr &rootCard,
CardInfoPerSet &setInfoForCard, PrintingInfo &setInfoForCard,
const QString &zoneName) const QString &zoneName)
: QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), cardSizeSlider(cardSizeSlider), : QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), cardSizeSlider(cardSizeSlider),
rootCard(rootCard), setInfoForCard(setInfoForCard), zoneName(zoneName), hovered(false) rootCard(rootCard), setInfoForCard(setInfoForCard), zoneName(zoneName), hovered(false)

View file

@ -23,7 +23,7 @@ public:
QTreeView *deckView, QTreeView *deckView,
QSlider *cardSizeSlider, QSlider *cardSizeSlider,
CardInfoPtr &rootCard, CardInfoPtr &rootCard,
CardInfoPerSet &setInfoForCard, PrintingInfo &setInfoForCard,
const QString &zoneName); const QString &zoneName);
int countCardsInZone(const QString &deckZone); int countCardsInZone(const QString &deckZone);
@ -41,7 +41,7 @@ private:
QTreeView *deckView; QTreeView *deckView;
QSlider *cardSizeSlider; QSlider *cardSizeSlider;
CardInfoPtr rootCard; CardInfoPtr rootCard;
CardInfoPerSet setInfoForCard; PrintingInfo setInfoForCard;
QString zoneName; QString zoneName;
QHBoxLayout *layout; QHBoxLayout *layout;
DynamicFontSizePushButton *incrementButton; DynamicFontSizePushButton *incrementButton;

View file

@ -224,11 +224,11 @@ void PrintingSelector::getAllSetsForCurrentCard()
return; return;
} }
CardInfoPerSetMap cardInfoPerSets = selectedCard->getSets(); PrintingInfoPerSetMap cardInfoPerSets = selectedCard->getSets();
const QList<CardInfoPerSet> sortedSets = sortToolBar->sortSets(cardInfoPerSets); const QList<PrintingInfo> sortedSets = sortToolBar->sortSets(cardInfoPerSets);
const QList<CardInfoPerSet> filteredSets = const QList<PrintingInfo> filteredSets =
sortToolBar->filterSets(sortedSets, searchBar->getSearchText().trimmed().toLower()); sortToolBar->filterSets(sortedSets, searchBar->getSearchText().trimmed().toLower());
QList<CardInfoPerSet> setsToUse; QList<PrintingInfo> setsToUse;
if (SettingsCache::instance().getBumpSetsWithCardsInDeckToTop()) { if (SettingsCache::instance().getBumpSetsWithCardsInDeckToTop()) {
setsToUse = sortToolBar->prependPrintingsInDeck(filteredSets, selectedCard, deckModel); setsToUse = sortToolBar->prependPrintingsInDeck(filteredSets, selectedCard, deckModel);

View file

@ -33,7 +33,7 @@ PrintingSelectorCardDisplayWidget::PrintingSelectorCardDisplayWidget(QWidget *pa
QTreeView *_deckView, QTreeView *_deckView,
QSlider *_cardSizeSlider, QSlider *_cardSizeSlider,
CardInfoPtr _rootCard, CardInfoPtr _rootCard,
const CardInfoPerSet &_setInfoForCard, const PrintingInfo &_setInfoForCard,
QString &_currentZone) QString &_currentZone)
: QWidget(parent), deckEditor(_deckEditor), deckModel(_deckModel), deckView(_deckView), : QWidget(parent), deckEditor(_deckEditor), deckModel(_deckModel), deckView(_deckView),
cardSizeSlider(_cardSizeSlider), rootCard(std::move(_rootCard)), setInfoForCard(_setInfoForCard), cardSizeSlider(_cardSizeSlider), rootCard(std::move(_rootCard)), setInfoForCard(_setInfoForCard),

View file

@ -21,7 +21,7 @@ public:
QTreeView *_deckView, QTreeView *_deckView,
QSlider *_cardSizeSlider, QSlider *_cardSizeSlider,
CardInfoPtr _rootCard, CardInfoPtr _rootCard,
const CardInfoPerSet &_setInfoForCard, const PrintingInfo &_setInfoForCard,
QString &_currentZone); QString &_currentZone);
public slots: public slots:
@ -39,7 +39,7 @@ private:
QSlider *cardSizeSlider; QSlider *cardSizeSlider;
CardInfoPtr rootCard; CardInfoPtr rootCard;
CardInfoPtr setCard; CardInfoPtr setCard;
CardInfoPerSet setInfoForCard; PrintingInfo setInfoForCard;
QString currentZone; QString currentZone;
PrintingSelectorCardOverlayWidget *overlayWidget; PrintingSelectorCardOverlayWidget *overlayWidget;
}; };

View file

@ -30,7 +30,7 @@ PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget(QWidget *pa
QTreeView *_deckView, QTreeView *_deckView,
QSlider *_cardSizeSlider, QSlider *_cardSizeSlider,
CardInfoPtr _rootCard, CardInfoPtr _rootCard,
const CardInfoPerSet &_setInfoForCard) const PrintingInfo &_setInfoForCard)
: QWidget(parent), deckEditor(_deckEditor), deckModel(_deckModel), deckView(_deckView), : QWidget(parent), deckEditor(_deckEditor), deckModel(_deckModel), deckView(_deckView),
cardSizeSlider(_cardSizeSlider), rootCard(std::move(_rootCard)), setInfoForCard(_setInfoForCard) cardSizeSlider(_cardSizeSlider), rootCard(std::move(_rootCard)), setInfoForCard(_setInfoForCard)
{ {

View file

@ -20,7 +20,7 @@ public:
QTreeView *_deckView, QTreeView *_deckView,
QSlider *_cardSizeSlider, QSlider *_cardSizeSlider,
CardInfoPtr _rootCard, CardInfoPtr _rootCard,
const CardInfoPerSet &_setInfoForCard); const PrintingInfo &_setInfoForCard);
protected: protected:
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
@ -45,7 +45,7 @@ private:
QSlider *cardSizeSlider; QSlider *cardSizeSlider;
CardInfoPtr rootCard; CardInfoPtr rootCard;
CardInfoPtr setCard; CardInfoPtr setCard;
CardInfoPerSet setInfoForCard; PrintingInfo setInfoForCard;
}; };
#endif // PRINTING_SELECTOR_CARD_OVERLAY_WIDGET_H #endif // PRINTING_SELECTOR_CARD_OVERLAY_WIDGET_H

View file

@ -76,7 +76,7 @@ void PrintingSelectorCardSortingWidget::updateSortSetting()
* @param cardInfoPerSets The list of card sets to be sorted. * @param cardInfoPerSets The list of card sets to be sorted.
* @return A sorted list of card sets. * @return A sorted list of card sets.
*/ */
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::sortSets(const CardInfoPerSetMap &cardInfoPerSets) QList<PrintingInfo> PrintingSelectorCardSortingWidget::sortSets(const PrintingInfoPerSetMap &cardInfoPerSets)
{ {
QList<CardSetPtr> sortedSets; QList<CardSetPtr> sortedSets;
@ -98,7 +98,7 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::sortSets(const CardInfo
std::sort(sortedSets.begin(), sortedSets.end(), SetReleaseDateComparator()); std::sort(sortedSets.begin(), sortedSets.end(), SetReleaseDateComparator());
} }
QList<CardInfoPerSet> sortedCardInfoPerSets; QList<PrintingInfo> sortedCardInfoPerSets;
// Reconstruct sorted list of CardInfoPerSet // Reconstruct sorted list of CardInfoPerSet
for (const auto &set : sortedSets) { for (const auto &set : sortedSets) {
for (auto it = cardInfoPerSets.begin(); it != cardInfoPerSets.end(); ++it) { for (auto it = cardInfoPerSets.begin(); it != cardInfoPerSets.end(); ++it) {
@ -130,14 +130,14 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::sortSets(const CardInfo
* @param searchText The search text used to filter the card sets. * @param searchText The search text used to filter the card sets.
* @return A filtered list of card sets. * @return A filtered list of card sets.
*/ */
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::filterSets(const QList<CardInfoPerSet> &sets, QList<PrintingInfo> PrintingSelectorCardSortingWidget::filterSets(const QList<PrintingInfo> &sets,
const QString &searchText) const QString &searchText)
{ {
if (searchText.isEmpty()) { if (searchText.isEmpty()) {
return sets; return sets;
} }
QList<CardInfoPerSet> filteredSets; QList<PrintingInfo> filteredSets;
for (const auto &set : sets) { for (const auto &set : sets) {
const QString longName = set.getPtr()->getLongName().toLower(); const QString longName = set.getPtr()->getLongName().toLower();
@ -151,7 +151,7 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::filterSets(const QList<
return filteredSets; return filteredSets;
} }
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPinnedPrintings(const QList<CardInfoPerSet> &sets, QList<PrintingInfo> PrintingSelectorCardSortingWidget::prependPinnedPrintings(const QList<PrintingInfo> &sets,
const QString &cardName) const QString &cardName)
{ {
auto setsToUse = sets; auto setsToUse = sets;
@ -180,7 +180,7 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPinnedPrintings(
* @param deckModel The model representing the deck. * @param deckModel The model representing the deck.
* @return A list of card sets with the printings contained in the deck prepended. * @return A list of card sets with the printings contained in the deck prepended.
*/ */
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPrintingsInDeck(const QList<CardInfoPerSet> &sets, QList<PrintingInfo> PrintingSelectorCardSortingWidget::prependPrintingsInDeck(const QList<PrintingInfo> &sets,
const CardInfoPtr &selectedCard, const CardInfoPtr &selectedCard,
DeckListModel *deckModel) DeckListModel *deckModel)
{ {
@ -188,8 +188,8 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPrintingsInDeck(
return {}; return {};
} }
CardInfoPerSetMap cardInfoPerSets = selectedCard->getSets(); PrintingInfoPerSetMap cardInfoPerSets = selectedCard->getSets();
QList<QPair<CardInfoPerSet, int>> countList; QList<QPair<PrintingInfo, int>> countList;
// Collect sets with their counts // Collect sets with their counts
for (const auto &cardInfoPerSetList : cardInfoPerSets) { for (const auto &cardInfoPerSetList : cardInfoPerSets) {
@ -209,16 +209,16 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPrintingsInDeck(
// Sort sets by count in descending numerical order // Sort sets by count in descending numerical order
std::sort(countList.begin(), countList.end(), std::sort(countList.begin(), countList.end(),
[](const QPair<CardInfoPerSet, int> &a, const QPair<CardInfoPerSet, int> &b) { [](const QPair<PrintingInfo, int> &a, const QPair<PrintingInfo, int> &b) {
return a.second > b.second; // Ensure numerical comparison return a.second > b.second; // Ensure numerical comparison
}); });
// Create a copy of the original list to modify // Create a copy of the original list to modify
QList<CardInfoPerSet> result = sets; QList<PrintingInfo> result = sets;
// Prepend sorted sets and remove them from the original list // Prepend sorted sets and remove them from the original list
for (const auto &pair : countList) { for (const auto &pair : countList) {
auto it = std::find_if(result.begin(), result.end(), [&pair](const CardInfoPerSet &item) { auto it = std::find_if(result.begin(), result.end(), [&pair](const PrintingInfo &item) {
return item.getProperty("uuid") == pair.first.getProperty("uuid"); return item.getProperty("uuid") == pair.first.getProperty("uuid");
}); });
if (it != result.end()) { if (it != result.end()) {

View file

@ -12,10 +12,10 @@ class PrintingSelectorCardSortingWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit PrintingSelectorCardSortingWidget(PrintingSelector *parent); explicit PrintingSelectorCardSortingWidget(PrintingSelector *parent);
QList<CardInfoPerSet> sortSets(const CardInfoPerSetMap &cardInfoPerSets); QList<PrintingInfo> sortSets(const PrintingInfoPerSetMap &cardInfoPerSets);
QList<CardInfoPerSet> filterSets(const QList<CardInfoPerSet> &sets, const QString &searchText); QList<PrintingInfo> filterSets(const QList<PrintingInfo> &sets, const QString &searchText);
QList<CardInfoPerSet> prependPinnedPrintings(const QList<CardInfoPerSet> &sets, const QString &cardName); QList<PrintingInfo> prependPinnedPrintings(const QList<PrintingInfo> &sets, const QString &cardName);
QList<CardInfoPerSet> prependPrintingsInDeck(const QList<CardInfoPerSet> &sets, QList<PrintingInfo> prependPrintingsInDeck(const QList<PrintingInfo> &sets,
const CardInfoPtr &selectedCard, const CardInfoPtr &selectedCard,
DeckListModel *deckModel); DeckListModel *deckModel);

View file

@ -230,9 +230,9 @@ void VisualDatabaseDisplayWidget::populateCards()
if (CardInfoPtr info = CardDatabaseManager::getInstance()->getCard(name.toString())) { if (CardInfoPtr info = CardDatabaseManager::getInstance()->getCard(name.toString())) {
if (setFilter) { if (setFilter) {
CardInfoPerSetMap setMap = info->getSets(); PrintingInfoPerSetMap setMap = info->getSets();
if (setMap.contains(setFilter->term())) { if (setMap.contains(setFilter->term())) {
for (CardInfoPerSet cardSetInstance : setMap[setFilter->term()]) { for (PrintingInfo cardSetInstance : setMap[setFilter->term()]) {
addCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId( addCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
name.toString(), cardSetInstance.getProperty("uuid"))); name.toString(), cardSetInstance.getProperty("uuid")));
} }
@ -296,9 +296,9 @@ void VisualDatabaseDisplayWidget::loadNextPage()
QVariant name = databaseDisplayModel->data(index, Qt::DisplayRole); QVariant name = databaseDisplayModel->data(index, Qt::DisplayRole);
if (CardInfoPtr info = CardDatabaseManager::getInstance()->getCard(name.toString())) { if (CardInfoPtr info = CardDatabaseManager::getInstance()->getCard(name.toString())) {
if (setFilter) { if (setFilter) {
CardInfoPerSetMap setMap = info->getSets(); PrintingInfoPerSetMap setMap = info->getSets();
if (setMap.contains(setFilter->term())) { if (setMap.contains(setFilter->term())) {
for (CardInfoPerSet cardSetInstance : setMap[setFilter->term()]) { for (PrintingInfo cardSetInstance : setMap[setFilter->term()]) {
addCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId( addCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
name.toString(), cardSetInstance.getProperty("uuid"))); name.toString(), cardSetInstance.getProperty("uuid")));
} }

View file

@ -372,7 +372,7 @@ QModelIndex DeckListModel::addPreferredPrintingCard(const QString &cardName, con
} }
QModelIndex DeckListModel::addCard(const QString &cardName, QModelIndex DeckListModel::addCard(const QString &cardName,
const CardInfoPerSet &cardInfoSet, const PrintingInfo &cardInfoSet,
const QString &zoneName, const QString &zoneName,
bool abAddAnyway) bool abAddAnyway)
{ {

View file

@ -112,7 +112,7 @@ public:
const QString &cardNumber = "") const; const QString &cardNumber = "") const;
QModelIndex addPreferredPrintingCard(const QString &cardName, const QString &zoneName, bool abAddAnyway); QModelIndex addPreferredPrintingCard(const QString &cardName, const QString &zoneName, bool abAddAnyway);
QModelIndex addCard(const ::QString &cardName, QModelIndex addCard(const ::QString &cardName,
const CardInfoPerSet &cardInfoSet, const PrintingInfo &cardInfoSet,
const QString &zoneName, const QString &zoneName,
bool abAddAnyway = false); bool abAddAnyway = false);
int findSortedInsertRow(InnerDecklistNode *parent, CardInfoPtr cardInfo) const; int findSortedInsertRow(InnerDecklistNode *parent, CardInfoPtr cardInfo) const;

View file

@ -324,7 +324,7 @@ struct SetProviderIdToPreferred
void operator()(const InnerDecklistNode *node, DecklistCardNode *card) const void operator()(const InnerDecklistNode *node, DecklistCardNode *card) const
{ {
Q_UNUSED(node); Q_UNUSED(node);
CardInfoPerSet preferredSet = CardDatabaseManager::getInstance()->getSpecificSetForCard( PrintingInfo preferredSet = CardDatabaseManager::getInstance()->getSpecificSetForCard(
card->getName(), card->getName(),
CardDatabaseManager::getInstance()->getPreferredPrintingProviderIdForCard(card->getName())); CardDatabaseManager::getInstance()->getPreferredPrintingProviderIdForCard(card->getName()));
QString providerId = preferredSet.getProperty("uuid"); QString providerId = preferredSet.getProperty("uuid");

View file

@ -162,8 +162,8 @@ void DlgEditTokens::actAddToken()
} }
QString setName = CardSet::TOKENS_SETNAME; QString setName = CardSet::TOKENS_SETNAME;
CardInfoPerSetMap sets; PrintingInfoPerSetMap sets;
sets[setName].append(CardInfoPerSet(databaseModel->getDatabase()->getSet(setName))); sets[setName].append(PrintingInfo(databaseModel->getDatabase()->getSet(setName)));
CardInfoPtr card = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(), CardInfoPtr card = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(),
QList<CardRelation *>(), sets, false, false, -1, false); QList<CardRelation *>(), sets, false, false, -1, false);
card->setCardType("Token"); card->setCardType("Token");

View file

@ -226,7 +226,7 @@ QMap<QString, int> DlgSelectSetForCards::getSetsForCards()
if (!infoPtr) if (!infoPtr)
continue; continue;
CardInfoPerSetMap infoPerSetMap = infoPtr->getSets(); PrintingInfoPerSetMap infoPerSetMap = infoPtr->getSets();
for (auto it = infoPerSetMap.begin(); it != infoPerSetMap.end(); ++it) { for (auto it = infoPerSetMap.begin(); it != infoPerSetMap.end(); ++it) {
setCounts[it.key()]++; setCounts[it.key()]++;
} }
@ -380,7 +380,7 @@ QMap<QString, QStringList> DlgSelectSetForCards::getCardsForSets()
if (!infoPtr) if (!infoPtr)
continue; continue;
CardInfoPerSetMap infoPerSetMap = infoPtr->getSets(); PrintingInfoPerSetMap infoPerSetMap = infoPtr->getSets();
for (auto it = infoPerSetMap.begin(); it != infoPerSetMap.end(); ++it) { for (auto it = infoPerSetMap.begin(); it != infoPerSetMap.end(); ++it) {
setCards[it.key()].append(currentCard->getName()); setCards[it.key()].append(currentCard->getName());
} }

View file

@ -67,7 +67,7 @@ void AbstractCardItem::refreshCardInfo()
QVariantHash properties = QVariantHash(); QVariantHash properties = QVariantHash();
info = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(), QList<CardRelation *>(), info = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(), QList<CardRelation *>(),
CardInfoPerSetMap(), false, false, -1, false); PrintingInfoPerSetMap(), false, false, -1, false);
} }
if (info.data()) { if (info.data()) {
connect(info.data(), &CardInfo::pixmapUpdated, this, &AbstractCardItem::pixmapUpdated); connect(info.data(), &CardInfo::pixmapUpdated, this, &AbstractCardItem::pixmapUpdated);

View file

@ -74,7 +74,7 @@ void CardDatabase::addCard(CardInfoPtr card)
if (cards.contains(card->getName())) { if (cards.contains(card->getName())) {
CardInfoPtr sameCard = cards[card->getName()]; CardInfoPtr sameCard = cards[card->getName()];
for (const auto &cardInfoPerSetList : card->getSets()) { for (const auto &cardInfoPerSetList : card->getSets()) {
for (const CardInfoPerSet &set : cardInfoPerSetList) { for (const PrintingInfo &set : cardInfoPerSetList) {
sameCard->addToSet(set.getPtr(), set); sameCard->addToSet(set.getPtr(), set);
} }
} }
@ -309,20 +309,20 @@ void CardDatabase::refreshPreferredPrintings()
} }
} }
CardInfoPerSet CardDatabase::getPreferredSetForCard(const QString &cardName) const PrintingInfo CardDatabase::getPreferredSetForCard(const QString &cardName) const
{ {
CardInfoPtr cardInfo = getCard(cardName); CardInfoPtr cardInfo = getCard(cardName);
if (!cardInfo) { if (!cardInfo) {
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
CardInfoPerSetMap setMap = cardInfo->getSets(); PrintingInfoPerSetMap setMap = cardInfo->getSets();
if (setMap.empty()) { if (setMap.empty()) {
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
CardSetPtr preferredSet = nullptr; CardSetPtr preferredSet = nullptr;
CardInfoPerSet preferredCard; PrintingInfo preferredCard;
SetPriorityComparator comparator; SetPriorityComparator comparator;
for (const auto &cardInfoPerSetList : setMap) { for (const auto &cardInfoPerSetList : setMap) {
@ -339,19 +339,19 @@ CardInfoPerSet CardDatabase::getPreferredSetForCard(const QString &cardName) con
return preferredCard; return preferredCard;
} }
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
CardInfoPerSet CardDatabase::getSpecificSetForCard(const QString &cardName, const QString &providerId) const PrintingInfo CardDatabase::getSpecificSetForCard(const QString &cardName, const QString &providerId) const
{ {
CardInfoPtr cardInfo = getCard(cardName); CardInfoPtr cardInfo = getCard(cardName);
if (!cardInfo) { if (!cardInfo) {
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
CardInfoPerSetMap setMap = cardInfo->getSets(); PrintingInfoPerSetMap setMap = cardInfo->getSets();
if (setMap.empty()) { if (setMap.empty()) {
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
for (const auto &cardInfoPerSetList : setMap) { for (const auto &cardInfoPerSetList : setMap) {
@ -366,21 +366,21 @@ CardInfoPerSet CardDatabase::getSpecificSetForCard(const QString &cardName, cons
return getPreferredSetForCard(cardName); return getPreferredSetForCard(cardName);
} }
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
CardInfoPerSet CardDatabase::getSpecificSetForCard(const QString &cardName, PrintingInfo CardDatabase::getSpecificSetForCard(const QString &cardName,
const QString &setShortName, const QString &setShortName,
const QString &collectorNumber) const const QString &collectorNumber) const
{ {
CardInfoPtr cardInfo = getCard(cardName); CardInfoPtr cardInfo = getCard(cardName);
if (!cardInfo) { if (!cardInfo) {
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
CardInfoPerSetMap setMap = cardInfo->getSets(); PrintingInfoPerSetMap setMap = cardInfo->getSets();
if (setMap.empty()) { if (setMap.empty()) {
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
for (const auto &cardInfoPerSetList : setMap) { for (const auto &cardInfoPerSetList : setMap) {
@ -398,12 +398,12 @@ CardInfoPerSet CardDatabase::getSpecificSetForCard(const QString &cardName,
} }
} }
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
QString CardDatabase::getPreferredPrintingProviderIdForCard(const QString &cardName) QString CardDatabase::getPreferredPrintingProviderIdForCard(const QString &cardName)
{ {
CardInfoPerSet preferredSetCardInfo = getPreferredSetForCard(cardName); PrintingInfo preferredSetCardInfo = getPreferredSetForCard(cardName);
QString preferredPrintingProviderId = preferredSetCardInfo.getProperty(QString("uuid")); QString preferredPrintingProviderId = preferredSetCardInfo.getProperty(QString("uuid"));
if (preferredPrintingProviderId.isEmpty()) { if (preferredPrintingProviderId.isEmpty()) {
CardInfoPtr defaultCardInfo = getCard(cardName); CardInfoPtr defaultCardInfo = getCard(cardName);
@ -424,11 +424,11 @@ bool CardDatabase::isProviderIdForPreferredPrinting(const QString &cardName, con
return providerId == getPreferredPrintingProviderIdForCard(cardName); return providerId == getPreferredPrintingProviderIdForCard(cardName);
} }
CardInfoPerSet CardDatabase::getSetInfoForCard(const CardInfoPtr &_card) PrintingInfo CardDatabase::getSetInfoForCard(const CardInfoPtr &_card)
{ {
const CardInfoPerSetMap &setMap = _card->getSets(); const PrintingInfoPerSetMap &setMap = _card->getSets();
if (setMap.empty()) { if (setMap.empty()) {
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
for (const auto &cardInfoPerSetList : setMap) { for (const auto &cardInfoPerSetList : setMap) {
@ -440,7 +440,7 @@ CardInfoPerSet CardDatabase::getSetInfoForCard(const CardInfoPtr &_card)
} }
} }
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
void CardDatabase::refreshCachedReverseRelatedCards() void CardDatabase::refreshCachedReverseRelatedCards()

View file

@ -69,9 +69,9 @@ public:
[[nodiscard]] QList<CardInfoPtr> getCards(const QStringList &cardNames) const; [[nodiscard]] QList<CardInfoPtr> getCards(const QStringList &cardNames) const;
QList<CardInfoPtr> getCardsByNameAndProviderId(const QMap<QString, QString> &cardNames) const; QList<CardInfoPtr> getCardsByNameAndProviderId(const QMap<QString, QString> &cardNames) const;
[[nodiscard]] CardInfoPtr getCardByNameAndProviderId(const QString &cardName, const QString &providerId) const; [[nodiscard]] CardInfoPtr getCardByNameAndProviderId(const QString &cardName, const QString &providerId) const;
[[nodiscard]] CardInfoPerSet getPreferredSetForCard(const QString &cardName) const; [[nodiscard]] PrintingInfo getPreferredSetForCard(const QString &cardName) const;
[[nodiscard]] CardInfoPerSet getSpecificSetForCard(const QString &cardName, const QString &providerId) const; [[nodiscard]] PrintingInfo getSpecificSetForCard(const QString &cardName, const QString &providerId) const;
CardInfoPerSet PrintingInfo
getSpecificSetForCard(const QString &cardName, const QString &setShortName, const QString &collectorNumber) const; getSpecificSetForCard(const QString &cardName, const QString &setShortName, const QString &collectorNumber) const;
QString getPreferredPrintingProviderIdForCard(const QString &cardName); QString getPreferredPrintingProviderIdForCard(const QString &cardName);
[[nodiscard]] CardInfoPtr guessCard(const QString &cardName, const QString &providerId = QString()) const; [[nodiscard]] CardInfoPtr guessCard(const QString &cardName, const QString &providerId = QString()) const;
@ -84,7 +84,7 @@ public:
CardSetPtr getSet(const QString &setName); CardSetPtr getSet(const QString &setName);
bool isProviderIdForPreferredPrinting(const QString &cardName, const QString &providerId); bool isProviderIdForPreferredPrinting(const QString &cardName, const QString &providerId);
static CardInfoPerSet getSetInfoForCard(const CardInfoPtr &_card); static PrintingInfo getSetInfoForCard(const CardInfoPtr &_card);
const CardNameMap &getCardList() const const CardNameMap &getCardList() const
{ {
return cards; return cards;

View file

@ -160,7 +160,7 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
QVariantHash properties = QVariantHash(); QVariantHash properties = QVariantHash();
QString colors = QString(""); QString colors = QString("");
QList<CardRelation *> relatedCards, reverseRelatedCards; QList<CardRelation *> relatedCards, reverseRelatedCards;
auto _sets = CardInfoPerSetMap(); auto _sets = PrintingInfoPerSetMap();
int tableRow = 0; int tableRow = 0;
bool cipt = false; bool cipt = false;
bool landscapeOrientation = false; bool landscapeOrientation = false;
@ -209,7 +209,7 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
// NOTE: attributes must be read before readElementText() // NOTE: attributes must be read before readElementText()
QXmlStreamAttributes attrs = xml.attributes(); QXmlStreamAttributes attrs = xml.attributes();
QString setName = xml.readElementText(QXmlStreamReader::IncludeChildElements); QString setName = xml.readElementText(QXmlStreamReader::IncludeChildElements);
CardInfoPerSet setInfo(internalAddSet(setName)); PrintingInfo setInfo(internalAddSet(setName));
if (attrs.hasAttribute("muId")) { if (attrs.hasAttribute("muId")) {
setInfo.setProperty("muid", attrs.value("muId").toString()); setInfo.setProperty("muid", attrs.value("muId").toString());
} }
@ -343,9 +343,9 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
} }
// sets // sets
const CardInfoPerSetMap sets = info->getSets(); const PrintingInfoPerSetMap sets = info->getSets();
for (const auto &cardInfoPerSetList : sets) { for (const auto &cardInfoPerSetList : sets) {
for (const CardInfoPerSet &set : cardInfoPerSetList) { for (const PrintingInfo &set : cardInfoPerSetList) {
xml.writeStartElement("set"); xml.writeStartElement("set");
xml.writeAttribute("rarity", set.getProperty("rarity")); xml.writeAttribute("rarity", set.getProperty("rarity"));
xml.writeAttribute("muId", set.getProperty("muid")); xml.writeAttribute("muId", set.getProperty("muid"));

View file

@ -144,7 +144,7 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
QString text = QString(""); QString text = QString("");
QVariantHash properties = QVariantHash(); QVariantHash properties = QVariantHash();
QList<CardRelation *> relatedCards, reverseRelatedCards; QList<CardRelation *> relatedCards, reverseRelatedCards;
auto _sets = CardInfoPerSetMap(); auto _sets = PrintingInfoPerSetMap();
int tableRow = 0; int tableRow = 0;
bool cipt = false; bool cipt = false;
bool landscapeOrientation = false; bool landscapeOrientation = false;
@ -184,7 +184,7 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
QString setName = xml.readElementText(QXmlStreamReader::IncludeChildElements); QString setName = xml.readElementText(QXmlStreamReader::IncludeChildElements);
auto set = internalAddSet(setName); auto set = internalAddSet(setName);
if (set->getEnabled()) { if (set->getEnabled()) {
CardInfoPerSet setInfo(set); PrintingInfo setInfo(set);
for (QXmlStreamAttribute attr : attrs) { for (QXmlStreamAttribute attr : attrs) {
QString attrName = attr.name().toString(); QString attrName = attr.name().toString();
if (attrName == "picURL") if (attrName == "picURL")
@ -310,7 +310,7 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
// sets // sets
for (const auto &cardInfoPerSetList : info->getSets()) { for (const auto &cardInfoPerSetList : info->getSets()) {
for (const CardInfoPerSet &set : cardInfoPerSetList) { for (const PrintingInfo &set : cardInfoPerSetList) {
xml.writeStartElement("set"); xml.writeStartElement("set");
for (const QString &propName : set.getProperties()) { for (const QString &propName : set.getProperties()) {
xml.writeAttribute(propName, set.getProperty(propName)); xml.writeAttribute(propName, set.getProperty(propName));

View file

@ -215,7 +215,7 @@ void SetList::defaultSort()
}); });
} }
CardInfoPerSet::CardInfoPerSet(const CardSetPtr &_set) : set(_set) PrintingInfo::PrintingInfo(const CardSetPtr &_set) : set(_set)
{ {
} }
@ -225,7 +225,7 @@ CardInfo::CardInfo(const QString &_name,
QVariantHash _properties, QVariantHash _properties,
const QList<CardRelation *> &_relatedCards, const QList<CardRelation *> &_relatedCards,
const QList<CardRelation *> &_reverseRelatedCards, const QList<CardRelation *> &_reverseRelatedCards,
CardInfoPerSetMap _sets, PrintingInfoPerSetMap _sets,
bool _cipt, bool _cipt,
bool _landscapeOrientation, bool _landscapeOrientation,
int _tableRow, int _tableRow,
@ -248,7 +248,7 @@ CardInfo::~CardInfo()
CardInfoPtr CardInfo::newInstance(const QString &_name) CardInfoPtr CardInfo::newInstance(const QString &_name)
{ {
return newInstance(_name, QString(), false, QVariantHash(), QList<CardRelation *>(), QList<CardRelation *>(), return newInstance(_name, QString(), false, QVariantHash(), QList<CardRelation *>(), QList<CardRelation *>(),
CardInfoPerSetMap(), false, false, 0, false); PrintingInfoPerSetMap(), false, false, 0, false);
} }
CardInfoPtr CardInfo::newInstance(const QString &_name, CardInfoPtr CardInfo::newInstance(const QString &_name,
@ -257,7 +257,7 @@ CardInfoPtr CardInfo::newInstance(const QString &_name,
QVariantHash _properties, QVariantHash _properties,
const QList<CardRelation *> &_relatedCards, const QList<CardRelation *> &_relatedCards,
const QList<CardRelation *> &_reverseRelatedCards, const QList<CardRelation *> &_reverseRelatedCards,
CardInfoPerSetMap _sets, PrintingInfoPerSetMap _sets,
bool _cipt, bool _cipt,
bool _landscapeOrientation, bool _landscapeOrientation,
int _tableRow, int _tableRow,
@ -268,7 +268,7 @@ CardInfoPtr CardInfo::newInstance(const QString &_name,
ptr->setSmartPointer(ptr); ptr->setSmartPointer(ptr);
for (const auto &cardInfoPerSetList : _sets) { for (const auto &cardInfoPerSetList : _sets) {
for (const CardInfoPerSet &set : cardInfoPerSetList) { for (const PrintingInfo &set : cardInfoPerSetList) {
set.getPtr()->append(ptr); set.getPtr()->append(ptr);
break; break;
} }
@ -289,7 +289,7 @@ QString CardInfo::getCorrectedName() const
return result.remove(rmrx).replace(spacerx, space); return result.remove(rmrx).replace(spacerx, space);
} }
void CardInfo::addToSet(const CardSetPtr &_set, const CardInfoPerSet _info) void CardInfo::addToSet(const CardSetPtr &_set, const PrintingInfo _info)
{ {
if (!_set->contains(smartThis)) { if (!_set->contains(smartThis)) {
_set->append(smartThis); _set->append(smartThis);

View file

@ -15,14 +15,14 @@
inline Q_LOGGING_CATEGORY(CardInfoLog, "card_info"); inline Q_LOGGING_CATEGORY(CardInfoLog, "card_info");
class CardInfo; class CardInfo;
class CardInfoPerSet; class PrintingInfo;
class CardSet; class CardSet;
class CardRelation; class CardRelation;
class ICardDatabaseParser; class ICardDatabaseParser;
typedef QSharedPointer<CardInfo> CardInfoPtr; typedef QSharedPointer<CardInfo> CardInfoPtr;
typedef QSharedPointer<CardSet> CardSetPtr; typedef QSharedPointer<CardSet> CardSetPtr;
typedef QMap<QString, QList<CardInfoPerSet>> CardInfoPerSetMap; typedef QMap<QString, QList<PrintingInfo>> PrintingInfoPerSetMap;
typedef QHash<QString, CardInfoPtr> CardNameMap; typedef QHash<QString, CardInfoPtr> CardNameMap;
typedef QHash<QString, CardSetPtr> SetNameMap; typedef QHash<QString, CardSetPtr> SetNameMap;
@ -142,20 +142,23 @@ public:
void defaultSort(); void defaultSort();
}; };
class CardInfoPerSet /**
* Info relating to a specific printing for a card.
*/
class PrintingInfo
{ {
public: public:
explicit CardInfoPerSet(const CardSetPtr &_set = QSharedPointer<CardSet>(nullptr)); explicit PrintingInfo(const CardSetPtr &_set = QSharedPointer<CardSet>(nullptr));
~CardInfoPerSet() = default; ~PrintingInfo() = default;
bool operator==(const CardInfoPerSet &other) const bool operator==(const PrintingInfo &other) const
{ {
return this->set == other.set && this->properties == other.properties; return this->set == other.set && this->properties == other.properties;
} }
private: private:
CardSetPtr set; CardSetPtr set;
// per-set card properties; // per-printing card properties;
QVariantHash properties; QVariantHash properties;
public: public:
@ -201,7 +204,7 @@ private:
// the cards thare are reverse-related to me // the cards thare are reverse-related to me
QList<CardRelation *> reverseRelatedCardsToMe; QList<CardRelation *> reverseRelatedCardsToMe;
// card sets // card sets
CardInfoPerSetMap sets; PrintingInfoPerSetMap sets;
// cached set names // cached set names
QString setsNames; QString setsNames;
// positioning properties; used by UI // positioning properties; used by UI
@ -217,7 +220,7 @@ public:
QVariantHash _properties, QVariantHash _properties,
const QList<CardRelation *> &_relatedCards, const QList<CardRelation *> &_relatedCards,
const QList<CardRelation *> &_reverseRelatedCards, const QList<CardRelation *> &_reverseRelatedCards,
CardInfoPerSetMap _sets, PrintingInfoPerSetMap _sets,
bool _cipt, bool _cipt,
bool _landscapeOrientation, bool _landscapeOrientation,
int _tableRow, int _tableRow,
@ -240,7 +243,7 @@ public:
QVariantHash _properties, QVariantHash _properties,
const QList<CardRelation *> &_relatedCards, const QList<CardRelation *> &_relatedCards,
const QList<CardRelation *> &_reverseRelatedCards, const QList<CardRelation *> &_reverseRelatedCards,
CardInfoPerSetMap _sets, PrintingInfoPerSetMap _sets,
bool _cipt, bool _cipt,
bool _landscapeOrientation, bool _landscapeOrientation,
int _tableRow, int _tableRow,
@ -308,7 +311,7 @@ public:
{ {
return properties.contains(propertyName); return properties.contains(propertyName);
} }
const CardInfoPerSetMap &getSets() const const PrintingInfoPerSetMap &getSets() const
{ {
return sets; return sets;
} }
@ -398,7 +401,7 @@ public:
return getSetProperty(set, "picurl"); return getSetProperty(set, "picurl");
} }
QString getCorrectedName() const; QString getCorrectedName() const;
void addToSet(const CardSetPtr &_set, CardInfoPerSet _info = CardInfoPerSet()); void addToSet(const CardSetPtr &_set, PrintingInfo _info = PrintingInfo());
void combineLegalities(const QVariantHash &props); void combineLegalities(const QVariantHash &props);
void emitPixmapUpdated() void emitPixmapUpdated()
{ {

View file

@ -129,14 +129,14 @@ static void setupParserRules()
search["RarityQuery"] = [](const peg::SemanticValues &sv) -> Filter { search["RarityQuery"] = [](const peg::SemanticValues &sv) -> Filter {
const auto rarity = std::any_cast<QString>(sv[0]); const auto rarity = std::any_cast<QString>(sv[0]);
return [=](const CardData &x) -> bool { return [=](const CardData &x) -> bool {
QList<CardInfoPerSet> infos; QList<PrintingInfo> infos;
for (const auto &setsValue : x->getSets().values()) { for (const auto &setsValue : x->getSets().values()) {
for (const auto &cardInfoPerSet : setsValue) { for (const auto &cardInfoPerSet : setsValue) {
infos.append(cardInfoPerSet); infos.append(cardInfoPerSet);
} }
} }
auto matchesRarity = [&rarity](const CardInfoPerSet &info) { return rarity == info.getProperty("rarity"); }; auto matchesRarity = [&rarity](const PrintingInfo &info) { return rarity == info.getProperty("rarity"); };
return std::any_of(infos.begin(), infos.end(), matchesRarity); return std::any_of(infos.begin(), infos.end(), matchesRarity);
}; };
}; };

View file

@ -47,7 +47,7 @@ public:
* Enabled sets have priority over disabled sets * Enabled sets have priority over disabled sets
* Both groups follow the user-defined order * Both groups follow the user-defined order
*/ */
inline bool operator()(const CardInfoPerSet &a, const CardInfoPerSet &b) const inline bool operator()(const PrintingInfo &a, const PrintingInfo &b) const
{ {
if (a.getPtr()->getEnabled()) { if (a.getPtr()->getEnabled()) {
return !b.getPtr()->getEnabled() || a.getPtr()->getSortKey() < b.getPtr()->getSortKey(); return !b.getPtr()->getEnabled() || a.getPtr()->getSortKey() < b.getPtr()->getSortKey();

View file

@ -12,7 +12,7 @@
SplitCardPart::SplitCardPart(const QString &_name, SplitCardPart::SplitCardPart(const QString &_name,
const QString &_text, const QString &_text,
const QVariantHash &_properties, const QVariantHash &_properties,
const CardInfoPerSet &_setInfo) const PrintingInfo &_setInfo)
: name(_name), text(_text), properties(_properties), setInfo(_setInfo) : name(_name), text(_text), properties(_properties), setInfo(_setInfo)
{ {
} }
@ -129,7 +129,7 @@ CardInfoPtr OracleImporter::addCard(QString name,
bool isToken, bool isToken,
QVariantHash properties, QVariantHash properties,
const QList<CardRelation *> &relatedCards, const QList<CardRelation *> &relatedCards,
const CardInfoPerSet &setInfo) const PrintingInfo &setInfo)
{ {
// Workaround for card name weirdness // Workaround for card name weirdness
name = name.replace("Æ", "AE"); name = name.replace("Æ", "AE");
@ -200,7 +200,7 @@ CardInfoPtr OracleImporter::addCard(QString name,
// insert the card and its properties // insert the card and its properties
QList<CardRelation *> reverseRelatedCards; QList<CardRelation *> reverseRelatedCards;
CardInfoPerSetMap setsInfo; PrintingInfoPerSetMap setsInfo;
setsInfo[setInfo.getPtr()->getShortName()].append(setInfo); setsInfo[setInfo.getPtr()->getShortName()].append(setInfo);
CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards, CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards,
setsInfo, cipt, landscapeOrientation, tableRow, upsideDown); setsInfo, cipt, landscapeOrientation, tableRow, upsideDown);
@ -242,7 +242,7 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
static constexpr bool isToken = false; static constexpr bool isToken = false;
static const QList<QString> setsWithCardsWithSameNameButDifferentText = {"UST"}; static const QList<QString> setsWithCardsWithSameNameButDifferentText = {"UST"};
QVariantHash properties; QVariantHash properties;
CardInfoPerSet setInfo; PrintingInfo setInfo;
QList<CardRelation *> relatedCards; QList<CardRelation *> relatedCards;
QList<QString> allNameProps; QList<QString> allNameProps;
@ -281,7 +281,7 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
} }
// per-set properties // per-set properties
setInfo = CardInfoPerSet(currentSet); setInfo = PrintingInfo(currentSet);
QMapIterator it2(setInfoProperties); QMapIterator it2(setInfoProperties);
while (it2.hasNext()) { while (it2.hasNext()) {
it2.next(); it2.next();

View file

@ -95,7 +95,7 @@ public:
SplitCardPart(const QString &_name, SplitCardPart(const QString &_name,
const QString &_text, const QString &_text,
const QVariantHash &_properties, const QVariantHash &_properties,
const CardInfoPerSet &setInfo); const PrintingInfo &setInfo);
inline const QString &getName() const inline const QString &getName() const
{ {
return name; return name;
@ -108,7 +108,7 @@ public:
{ {
return properties; return properties;
} }
inline const CardInfoPerSet &getSetInfo() const inline const PrintingInfo &getSetInfo() const
{ {
return setInfo; return setInfo;
} }
@ -117,7 +117,7 @@ private:
QString name; QString name;
QString text; QString text;
QVariantHash properties; QVariantHash properties;
CardInfoPerSet setInfo; PrintingInfo setInfo;
}; };
class OracleImporter : public QObject class OracleImporter : public QObject
@ -143,7 +143,7 @@ private:
bool isToken, bool isToken,
QVariantHash properties, QVariantHash properties,
const QList<CardRelation *> &relatedCards, const QList<CardRelation *> &relatedCards,
const CardInfoPerSet &setInfo); const PrintingInfo &setInfo);
signals: signals:
void setIndexChanged(int cardsImported, int setIndex, const QString &setName); void setIndexChanged(int cardsImported, int setIndex, const QString &setName);
void dataReadProgress(int bytesRead, int totalBytes); void dataReadProgress(int bytesRead, int totalBytes);