Refactor: rename CardInfoPerSet to PrintingInfo (#6024)

* remove unnecessary consts

* removed unused

* rename class

* rename variables and methods

* rename again

* rename variables again

* rename field

* run formatter
This commit is contained in:
RickyRister 2025-07-07 20:41:19 -07:00 committed by GitHub
parent 686e90d0ed
commit a9684f67cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 288 additions and 287 deletions

View file

@ -28,9 +28,9 @@ PictureToLoad::PictureToLoad(CardInfoPtr _card)
QList<CardSetPtr> PictureToLoad::extractSetsSorted(const CardInfoPtr &card) QList<CardSetPtr> PictureToLoad::extractSetsSorted(const CardInfoPtr &card)
{ {
QList<CardSetPtr> sortedSets; QList<CardSetPtr> sortedSets;
for (const auto &cardInfoPerSetList : card->getSets()) { for (const auto &printings : card->getSets()) {
for (const auto &set : cardInfoPerSetList) { for (const auto &printing : printings) {
sortedSets << set.getPtr(); sortedSets << printing.getSet();
} }
} }
if (sortedSets.empty()) { if (sortedSets.empty()) {
@ -41,11 +41,11 @@ QList<CardSetPtr> PictureToLoad::extractSetsSorted(const CardInfoPtr &card)
// If the user hasn't disabled arts other than their personal preference... // If the user hasn't disabled arts other than their personal preference...
if (!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) { if (!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
// If the pixmapCacheKey corresponds to a specific set, we have to try to load it first. // If the pixmapCacheKey corresponds to a specific set, we have to try to load it first.
for (const auto &cardInfoPerSetList : card->getSets()) { for (const auto &printings : card->getSets()) {
for (const auto &set : cardInfoPerSetList) { for (const auto &printing : printings) {
if (QLatin1String("card_") + card->getName() + QString("_") + QString(set.getProperty("uuid")) == if (QLatin1String("card_") + card->getName() + QString("_") + QString(printing.getProperty("uuid")) ==
card->getPixmapCacheKey()) { card->getPixmapCacheKey()) {
long long setIndex = sortedSets.indexOf(set.getPtr()); long long setIndex = sortedSets.indexOf(printing.getSet());
CardSetPtr setForCardProviderID = sortedSets.takeAt(setIndex); CardSetPtr setForCardProviderID = sortedSets.takeAt(setIndex);
sortedSets.prepend(setForCardProviderID); sortedSets.prepend(setForCardProviderID);
} }

View file

@ -476,9 +476,9 @@ bool DeckEditorDeckDockWidget::swapCard(const QModelIndex &currentIndex)
const QString otherZoneName = zoneName == DECK_ZONE_MAIN ? DECK_ZONE_SIDE : DECK_ZONE_MAIN; const QString otherZoneName = zoneName == DECK_ZONE_MAIN ? DECK_ZONE_SIDE : DECK_ZONE_MAIN;
// Third argument (true) says create the card no matter what, even if not in DB // Third argument (true) says create the card no matter what, even if not in DB
QModelIndex newCardIndex = deckModel->addCard( QModelIndex newCardIndex =
cardName, CardDatabaseManager::getInstance()->getSpecificSetForCard(cardName, cardProviderID), otherZoneName, deckModel->addCard(cardName, CardDatabaseManager::getInstance()->getSpecificPrinting(cardName, cardProviderID),
true); otherZoneName, true);
recursiveExpand(newCardIndex); recursiveExpand(newCardIndex);
return true; return true;

View file

@ -16,7 +16,7 @@
* @param deckView Pointer to the QTreeView for the deck display. * @param deckView Pointer to the QTreeView for the deck display.
* @param cardSizeSlider Pointer to the QSlider used for dynamic font resizing. * @param cardSizeSlider Pointer to the QSlider used for dynamic font resizing.
* @param rootCard The root card for the widget. * @param rootCard The root card for the widget.
* @param setInfoForCard The set information for the card. * @param printingInfo The printing information for the card.
*/ */
AllZonesCardAmountWidget::AllZonesCardAmountWidget(QWidget *parent, AllZonesCardAmountWidget::AllZonesCardAmountWidget(QWidget *parent,
AbstractTabDeckEditor *deckEditor, AbstractTabDeckEditor *deckEditor,
@ -24,9 +24,9 @@ AllZonesCardAmountWidget::AllZonesCardAmountWidget(QWidget *parent,
QTreeView *deckView, QTreeView *deckView,
QSlider *cardSizeSlider, QSlider *cardSizeSlider,
CardInfoPtr rootCard, CardInfoPtr rootCard,
CardInfoPerSet setInfoForCard) PrintingInfo printingInfo)
: 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), printingInfo(printingInfo)
{ {
layout = new QVBoxLayout(this); layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignHCenter); layout->setAlignment(Qt::AlignHCenter);
@ -36,10 +36,10 @@ AllZonesCardAmountWidget::AllZonesCardAmountWidget(QWidget *parent,
zoneLabelMainboard = new ShadowBackgroundLabel(this, tr("Mainboard")); zoneLabelMainboard = new ShadowBackgroundLabel(this, tr("Mainboard"));
buttonBoxMainboard = new CardAmountWidget(this, deckEditor, deckModel, deckView, cardSizeSlider, rootCard, buttonBoxMainboard = new CardAmountWidget(this, deckEditor, deckModel, deckView, cardSizeSlider, rootCard,
setInfoForCard, DECK_ZONE_MAIN); printingInfo, DECK_ZONE_MAIN);
zoneLabelSideboard = new ShadowBackgroundLabel(this, tr("Sideboard")); zoneLabelSideboard = new ShadowBackgroundLabel(this, tr("Sideboard"));
buttonBoxSideboard = new CardAmountWidget(this, deckEditor, deckModel, deckView, cardSizeSlider, rootCard, buttonBoxSideboard = new CardAmountWidget(this, deckEditor, deckModel, deckView, cardSizeSlider, rootCard,
setInfoForCard, DECK_ZONE_SIDE); printingInfo, DECK_ZONE_SIDE);
layout->addWidget(zoneLabelMainboard, 0, Qt::AlignHCenter | Qt::AlignBottom); layout->addWidget(zoneLabelMainboard, 0, Qt::AlignHCenter | Qt::AlignBottom);
layout->addWidget(buttonBoxMainboard, 0, Qt::AlignHCenter | Qt::AlignTop); layout->addWidget(buttonBoxMainboard, 0, Qt::AlignHCenter | Qt::AlignTop);

View file

@ -17,7 +17,7 @@ public:
QTreeView *deckView, QTreeView *deckView,
QSlider *cardSizeSlider, QSlider *cardSizeSlider,
CardInfoPtr rootCard, CardInfoPtr rootCard,
CardInfoPerSet setInfoForCard); PrintingInfo printingInfo);
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 printingInfo;
QLabel *zoneLabelMainboard; QLabel *zoneLabelMainboard;
CardAmountWidget *buttonBoxMainboard; CardAmountWidget *buttonBoxMainboard;
QLabel *zoneLabelSideboard; QLabel *zoneLabelSideboard;

View file

@ -12,7 +12,7 @@
* @param deckView Pointer to the QTreeView displaying the deck. * @param deckView Pointer to the QTreeView displaying the deck.
* @param cardSizeSlider Pointer to the QSlider for adjusting font size. * @param cardSizeSlider Pointer to the QSlider for adjusting font size.
* @param rootCard The root card to manage within the widget. * @param rootCard The root card to manage within the widget.
* @param setInfoForCard Card set information for the root card. * @param printingInfo Printing info for the root card.
* @param zoneName The zone name (e.g., DECK_ZONE_MAIN or DECK_ZONE_SIDE). * @param zoneName The zone name (e.g., DECK_ZONE_MAIN or DECK_ZONE_SIDE).
*/ */
CardAmountWidget::CardAmountWidget(QWidget *parent, CardAmountWidget::CardAmountWidget(QWidget *parent,
@ -21,10 +21,10 @@ CardAmountWidget::CardAmountWidget(QWidget *parent,
QTreeView *deckView, QTreeView *deckView,
QSlider *cardSizeSlider, QSlider *cardSizeSlider,
CardInfoPtr &rootCard, CardInfoPtr &rootCard,
CardInfoPerSet &setInfoForCard, PrintingInfo &printingInfo,
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), printingInfo(printingInfo), zoneName(zoneName), hovered(false)
{ {
layout = new QHBoxLayout(this); layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
@ -142,18 +142,18 @@ void CardAmountWidget::updateCardCount()
*/ */
void CardAmountWidget::addPrinting(const QString &zone) void CardAmountWidget::addPrinting(const QString &zone)
{ {
auto newCardIndex = deckModel->addCard(rootCard->getName(), setInfoForCard, zone); auto newCardIndex = deckModel->addCard(rootCard->getName(), printingInfo, zone);
recursiveExpand(newCardIndex); recursiveExpand(newCardIndex);
QModelIndex find_card = deckModel->findCard(rootCard->getName(), zone); QModelIndex find_card = deckModel->findCard(rootCard->getName(), zone);
if (find_card.isValid() && find_card != newCardIndex) { if (find_card.isValid() && find_card != newCardIndex) {
auto amount = deckModel->data(find_card, Qt::DisplayRole); auto amount = deckModel->data(find_card, Qt::DisplayRole);
for (int i = 0; i < amount.toInt() - 1; i++) { for (int i = 0; i < amount.toInt() - 1; i++) {
deckModel->addCard(rootCard->getName(), setInfoForCard, zone); deckModel->addCard(rootCard->getName(), printingInfo, zone);
} }
deckModel->removeRow(find_card.row(), find_card.parent()); deckModel->removeRow(find_card.row(), find_card.parent());
} }
newCardIndex = deckModel->findCard(rootCard->getName(), zone, setInfoForCard.getProperty("uuid"), newCardIndex = deckModel->findCard(rootCard->getName(), zone, printingInfo.getProperty("uuid"),
setInfoForCard.getProperty("num")); printingInfo.getProperty("num"));
deckView->setCurrentIndex(newCardIndex); deckView->setCurrentIndex(newCardIndex);
deckView->setFocus(Qt::FocusReason::MouseFocusReason); deckView->setFocus(Qt::FocusReason::MouseFocusReason);
deckEditor->setModified(true); deckEditor->setModified(true);
@ -235,8 +235,8 @@ void CardAmountWidget::offsetCountAtIndex(const QModelIndex &idx, int offset)
*/ */
void CardAmountWidget::decrementCardHelper(const QString &zone) void CardAmountWidget::decrementCardHelper(const QString &zone)
{ {
QModelIndex idx = deckModel->findCard(rootCard->getName(), zone, setInfoForCard.getProperty("uuid"), QModelIndex idx = deckModel->findCard(rootCard->getName(), zone, printingInfo.getProperty("uuid"),
setInfoForCard.getProperty("num")); printingInfo.getProperty("num"));
offsetCountAtIndex(idx, -1); offsetCountAtIndex(idx, -1);
deckEditor->setModified(true); deckEditor->setModified(true);
} }
@ -249,7 +249,7 @@ void CardAmountWidget::decrementCardHelper(const QString &zone)
*/ */
int CardAmountWidget::countCardsInZone(const QString &deckZone) int CardAmountWidget::countCardsInZone(const QString &deckZone)
{ {
if (setInfoForCard.getProperty("uuid").isEmpty()) { if (printingInfo.getProperty("uuid").isEmpty()) {
return 0; // Cards without uuids/providerIds CANNOT match another card, they are undefined for us. return 0; // Cards without uuids/providerIds CANNOT match another card, they are undefined for us.
} }
@ -286,7 +286,7 @@ int CardAmountWidget::countCardsInZone(const QString &deckZone)
} }
for (int k = 0; k < currentCard->getNumber(); ++k) { for (int k = 0; k < currentCard->getNumber(); ++k) {
if (currentCard->getCardProviderId() == setInfoForCard.getProperty("uuid")) { if (currentCard->getCardProviderId() == printingInfo.getProperty("uuid")) {
count++; count++;
} }
} }

View file

@ -23,7 +23,7 @@ public:
QTreeView *deckView, QTreeView *deckView,
QSlider *cardSizeSlider, QSlider *cardSizeSlider,
CardInfoPtr &rootCard, CardInfoPtr &rootCard,
CardInfoPerSet &setInfoForCard, PrintingInfo &printingInfo,
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 printingInfo;
QString zoneName; QString zoneName;
QHBoxLayout *layout; QHBoxLayout *layout;
DynamicFontSizePushButton *incrementButton; DynamicFontSizePushButton *incrementButton;

View file

@ -224,27 +224,27 @@ void PrintingSelector::getAllSetsForCurrentCard()
return; return;
} }
CardInfoPerSetMap cardInfoPerSets = selectedCard->getSets(); SetToPrintingsMap setMap = selectedCard->getSets();
const QList<CardInfoPerSet> sortedSets = sortToolBar->sortSets(cardInfoPerSets); const QList<PrintingInfo> sortedPrintings = sortToolBar->sortSets(setMap);
const QList<CardInfoPerSet> filteredSets = const QList<PrintingInfo> filteredPrintings =
sortToolBar->filterSets(sortedSets, searchBar->getSearchText().trimmed().toLower()); sortToolBar->filterSets(sortedPrintings, searchBar->getSearchText().trimmed().toLower());
QList<CardInfoPerSet> setsToUse; QList<PrintingInfo> printingsToUse;
if (SettingsCache::instance().getBumpSetsWithCardsInDeckToTop()) { if (SettingsCache::instance().getBumpSetsWithCardsInDeckToTop()) {
setsToUse = sortToolBar->prependPrintingsInDeck(filteredSets, selectedCard, deckModel); printingsToUse = sortToolBar->prependPrintingsInDeck(filteredPrintings, selectedCard, deckModel);
} else { } else {
setsToUse = filteredSets; printingsToUse = filteredPrintings;
} }
setsToUse = sortToolBar->prependPinnedPrintings(setsToUse, selectedCard->getName()); printingsToUse = sortToolBar->prependPinnedPrintings(printingsToUse, selectedCard->getName());
// Defer widget creation // Defer widget creation
currentIndex = 0; currentIndex = 0;
connect(widgetLoadingBufferTimer, &QTimer::timeout, this, [=, this]() mutable { connect(widgetLoadingBufferTimer, &QTimer::timeout, this, [=, this]() mutable {
for (int i = 0; i < BATCH_SIZE && currentIndex < setsToUse.size(); ++i, ++currentIndex) { for (int i = 0; i < BATCH_SIZE && currentIndex < printingsToUse.size(); ++i, ++currentIndex) {
auto *cardDisplayWidget = new PrintingSelectorCardDisplayWidget(this, deckEditor, deckModel, deckView, auto *cardDisplayWidget = new PrintingSelectorCardDisplayWidget(this, deckEditor, deckModel, deckView,
cardSizeWidget->getSlider(), selectedCard, cardSizeWidget->getSlider(), selectedCard,
setsToUse[currentIndex], currentZone); printingsToUse[currentIndex], currentZone);
flowWidget->addWidget(cardDisplayWidget); flowWidget->addWidget(cardDisplayWidget);
cardDisplayWidget->clampSetNameToPicture(); cardDisplayWidget->clampSetNameToPicture();
connect(cardDisplayWidget, &PrintingSelectorCardDisplayWidget::cardPreferenceChanged, this, connect(cardDisplayWidget, &PrintingSelectorCardDisplayWidget::cardPreferenceChanged, this,
@ -252,7 +252,7 @@ void PrintingSelector::getAllSetsForCurrentCard()
} }
// Stop timer when done // Stop timer when done
if (currentIndex >= setsToUse.size()) { if (currentIndex >= printingsToUse.size()) {
widgetLoadingBufferTimer->stop(); widgetLoadingBufferTimer->stop();
} }
}); });

View file

@ -24,7 +24,7 @@
* @param _deckView The QTreeView instance displaying the deck. * @param _deckView The QTreeView instance displaying the deck.
* @param _cardSizeSlider The slider controlling the size of the displayed card. * @param _cardSizeSlider The slider controlling the size of the displayed card.
* @param _rootCard The root card object, representing the card to be displayed. * @param _rootCard The root card object, representing the card to be displayed.
* @param _setInfoForCard The set-specific information for the card being displayed. * @param _printingInfo The printing info for the card being displayed.
* @param _currentZone The current zone in which the card is located. * @param _currentZone The current zone in which the card is located.
*/ */
PrintingSelectorCardDisplayWidget::PrintingSelectorCardDisplayWidget(QWidget *parent, PrintingSelectorCardDisplayWidget::PrintingSelectorCardDisplayWidget(QWidget *parent,
@ -33,10 +33,10 @@ PrintingSelectorCardDisplayWidget::PrintingSelectorCardDisplayWidget(QWidget *pa
QTreeView *_deckView, QTreeView *_deckView,
QSlider *_cardSizeSlider, QSlider *_cardSizeSlider,
CardInfoPtr _rootCard, CardInfoPtr _rootCard,
const CardInfoPerSet &_setInfoForCard, const PrintingInfo &_printingInfo,
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)), printingInfo(_printingInfo),
currentZone(_currentZone) currentZone(_currentZone)
{ {
layout = new QVBoxLayout(this); layout = new QVBoxLayout(this);
@ -45,15 +45,15 @@ PrintingSelectorCardDisplayWidget::PrintingSelectorCardDisplayWidget(QWidget *pa
// Create the overlay widget for the card display // Create the overlay widget for the card display
overlayWidget = new PrintingSelectorCardOverlayWidget(this, deckEditor, deckModel, deckView, cardSizeSlider, overlayWidget = new PrintingSelectorCardOverlayWidget(this, deckEditor, deckModel, deckView, cardSizeSlider,
rootCard, setInfoForCard); rootCard, _printingInfo);
connect(overlayWidget, &PrintingSelectorCardOverlayWidget::cardPreferenceChanged, this, connect(overlayWidget, &PrintingSelectorCardOverlayWidget::cardPreferenceChanged, this,
[this]() { emit cardPreferenceChanged(); }); [this]() { emit cardPreferenceChanged(); });
// Create the widget to display the set name and collector's number // Create the widget to display the set name and collector's number
const QString combinedSetName = const QString combinedSetName =
QString(setInfoForCard.getPtr()->getLongName() + " (" + setInfoForCard.getPtr()->getShortName() + ")"); QString(_printingInfo.getSet()->getLongName() + " (" + _printingInfo.getSet()->getShortName() + ")");
setNameAndCollectorsNumberDisplayWidget = new SetNameAndCollectorsNumberDisplayWidget( setNameAndCollectorsNumberDisplayWidget = new SetNameAndCollectorsNumberDisplayWidget(
this, combinedSetName, setInfoForCard.getProperty("num"), cardSizeSlider); this, combinedSetName, _printingInfo.getProperty("num"), cardSizeSlider);
// Add the widgets to the layout // Add the widgets to the layout
layout->addWidget(overlayWidget, 0, Qt::AlignHCenter); layout->addWidget(overlayWidget, 0, Qt::AlignHCenter);

View file

@ -21,7 +21,7 @@ public:
QTreeView *_deckView, QTreeView *_deckView,
QSlider *_cardSizeSlider, QSlider *_cardSizeSlider,
CardInfoPtr _rootCard, CardInfoPtr _rootCard,
const CardInfoPerSet &_setInfoForCard, const PrintingInfo &_printingInfo,
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 printingInfo;
QString currentZone; QString currentZone;
PrintingSelectorCardOverlayWidget *overlayWidget; PrintingSelectorCardOverlayWidget *overlayWidget;
}; };

View file

@ -22,7 +22,7 @@
* @param _deckView The QTreeView instance displaying the deck. * @param _deckView The QTreeView instance displaying the deck.
* @param _cardSizeSlider The slider controlling the size of the card. * @param _cardSizeSlider The slider controlling the size of the card.
* @param _rootCard The root card object that contains information about the card. * @param _rootCard The root card object that contains information about the card.
* @param _setInfoForCard The set-specific information for the card being displayed. * @param _printingInfo The printing-specific information for the card being displayed.
*/ */
PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget(QWidget *parent, PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget(QWidget *parent,
AbstractTabDeckEditor *_deckEditor, AbstractTabDeckEditor *_deckEditor,
@ -30,9 +30,9 @@ PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget(QWidget *pa
QTreeView *_deckView, QTreeView *_deckView,
QSlider *_cardSizeSlider, QSlider *_cardSizeSlider,
CardInfoPtr _rootCard, CardInfoPtr _rootCard,
const CardInfoPerSet &_setInfoForCard) const PrintingInfo &_printingInfo)
: 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)), printingInfo(_printingInfo)
{ {
// Set up the main layout // Set up the main layout
auto *mainLayout = new QVBoxLayout(this); auto *mainLayout = new QVBoxLayout(this);
@ -45,13 +45,13 @@ PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget(QWidget *pa
cardInfoPicture->setMinimumSize(0, 0); cardInfoPicture->setMinimumSize(0, 0);
cardInfoPicture->setScaleFactor(cardSizeSlider->value()); cardInfoPicture->setScaleFactor(cardSizeSlider->value());
setCard = CardDatabaseManager::getInstance()->getCardByNameAndProviderId(rootCard->getName(), setCard = CardDatabaseManager::getInstance()->getCardByNameAndProviderId(rootCard->getName(),
setInfoForCard.getProperty("uuid")); _printingInfo.getProperty("uuid"));
cardInfoPicture->setCard(setCard); cardInfoPicture->setCard(setCard);
mainLayout->addWidget(cardInfoPicture); mainLayout->addWidget(cardInfoPicture);
// Add AllZonesCardAmountWidget // Add AllZonesCardAmountWidget
allZonesCardAmountWidget = allZonesCardAmountWidget =
new AllZonesCardAmountWidget(this, deckEditor, deckModel, deckView, cardSizeSlider, setCard, setInfoForCard); new AllZonesCardAmountWidget(this, deckEditor, deckModel, deckView, cardSizeSlider, setCard, _printingInfo);
allZonesCardAmountWidget->raise(); // Ensure it's on top of the picture allZonesCardAmountWidget->raise(); // Ensure it's on top of the picture
// Set initial visibility based on amounts // Set initial visibility based on amounts
@ -172,7 +172,7 @@ void PrintingSelectorCardOverlayWidget::customMenu(QPoint point)
const auto &preferredProviderId = const auto &preferredProviderId =
SettingsCache::instance().cardOverrides().getCardPreferenceOverride(rootCard->getName()); SettingsCache::instance().cardOverrides().getCardPreferenceOverride(rootCard->getName());
const auto &cardProviderId = setInfoForCard.getProperty("uuid"); const auto &cardProviderId = printingInfo.getProperty("uuid");
if (preferredProviderId.isEmpty() || preferredProviderId != cardProviderId) { if (preferredProviderId.isEmpty() || preferredProviderId != cardProviderId) {
auto *pinAction = preferenceMenu->addAction(tr("Pin Printing")); auto *pinAction = preferenceMenu->addAction(tr("Pin Printing"));

View file

@ -20,7 +20,7 @@ public:
QTreeView *_deckView, QTreeView *_deckView,
QSlider *_cardSizeSlider, QSlider *_cardSizeSlider,
CardInfoPtr _rootCard, CardInfoPtr _rootCard,
const CardInfoPerSet &_setInfoForCard); const PrintingInfo &_printingInfo);
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 printingInfo;
}; };
#endif // PRINTING_SELECTOR_CARD_OVERLAY_WIDGET_H #endif // PRINTING_SELECTOR_CARD_OVERLAY_WIDGET_H

View file

@ -73,16 +73,16 @@ void PrintingSelectorCardSortingWidget::updateSortSetting()
* - Contained in Deck * - Contained in Deck
* - Potential Cards in Deck * - Potential Cards in Deck
* *
* @param cardInfoPerSets The list of card sets to be sorted. * @param setMap The list of card sets to be sorted.
* @return A sorted list of card sets. * @return A sorted list of printings.
*/ */
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::sortSets(const CardInfoPerSetMap &cardInfoPerSets) QList<PrintingInfo> PrintingSelectorCardSortingWidget::sortSets(const SetToPrintingsMap &setMap)
{ {
QList<CardSetPtr> sortedSets; QList<CardSetPtr> sortedSets;
for (const auto &cardInfoPerSetList : cardInfoPerSets) { for (const auto &printingInfos : setMap) {
for (const auto &set : cardInfoPerSetList) { for (const auto &set : printingInfos) {
sortedSets << set.getPtr(); sortedSets << set.getSet();
break; break;
} }
} }
@ -98,14 +98,14 @@ 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> sortedPrintings;
// Reconstruct sorted list of CardInfoPerSet // Reconstruct sorted list of PrintingInfo
for (const auto &set : sortedSets) { for (const auto &set : sortedSets) {
for (auto it = cardInfoPerSets.begin(); it != cardInfoPerSets.end(); ++it) { for (auto it = setMap.begin(); it != setMap.end(); ++it) {
for (const auto &cardInfoPerSet : it.value()) { for (const auto &printingInfo : it.value()) {
if (cardInfoPerSet.getPtr() == set) { if (printingInfo.getSet() == set) {
if (!sortedCardInfoPerSets.contains(cardInfoPerSet)) { if (!sortedPrintings.contains(printingInfo)) {
sortedCardInfoPerSets << cardInfoPerSet; sortedPrintings << printingInfo;
} }
} }
} }
@ -113,10 +113,10 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::sortSets(const CardInfo
} }
if (descendingSort) { if (descendingSort) {
std::reverse(sortedCardInfoPerSets.begin(), sortedCardInfoPerSets.end()); std::reverse(sortedPrintings.begin(), sortedPrintings.end());
} }
return sortedCardInfoPerSets; return sortedPrintings;
} }
/** /**
@ -126,81 +126,81 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::sortSets(const CardInfo
* text. If the search text matches either the long or short name of a card set, that set is included in the filtered * text. If the search text matches either the long or short name of a card set, that set is included in the filtered
* list. * list.
* *
* @param sets The list of card sets to be filtered. * @param printings The list of printings to be filtered.
* @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> &printings,
const QString &searchText) const QString &searchText)
{ {
if (searchText.isEmpty()) { if (searchText.isEmpty()) {
return sets; return printings;
} }
QList<CardInfoPerSet> filteredSets; QList<PrintingInfo> filteredPrintings;
for (const auto &set : sets) { for (const auto &printing : printings) {
const QString longName = set.getPtr()->getLongName().toLower(); const QString longName = printing.getSet()->getLongName().toLower();
const QString shortName = set.getPtr()->getShortName().toLower(); const QString shortName = printing.getSet()->getShortName().toLower();
if (longName.contains(searchText) || shortName.contains(searchText)) { if (longName.contains(searchText) || shortName.contains(searchText)) {
filteredSets << set; filteredPrintings << printing;
} }
} }
return filteredSets; return filteredPrintings;
} }
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPinnedPrintings(const QList<CardInfoPerSet> &sets, QList<PrintingInfo> PrintingSelectorCardSortingWidget::prependPinnedPrintings(const QList<PrintingInfo> &printings,
const QString &cardName) const QString &cardName)
{ {
auto setsToUse = sets; auto printingsToUse = printings;
const auto &cardProviderId = SettingsCache::instance().cardOverrides().getCardPreferenceOverride(cardName); const auto &cardProviderId = SettingsCache::instance().cardOverrides().getCardPreferenceOverride(cardName);
if (!cardProviderId.isEmpty()) { if (!cardProviderId.isEmpty()) {
for (int i = 0; i < setsToUse.size(); ++i) { for (int i = 0; i < printingsToUse.size(); ++i) {
const auto &card = setsToUse[i]; const auto &card = printingsToUse[i];
if (card.getProperty("uuid") == cardProviderId) { if (card.getProperty("uuid") == cardProviderId) {
setsToUse.move(i, 0); printingsToUse.move(i, 0);
break; break;
} }
} }
} }
return setsToUse; return printingsToUse;
} }
/** /**
* @brief Prepend card printings that are contained in the deck to the list of card sets. * @brief Prepend card printings that are contained in the deck to the list of printings.
* *
* This function adjusts the list of card sets by moving the printings that are already contained in the deck to the * This function adjusts the list of printings by moving the printings that are already contained in the deck to the
* beginning of the list, sorted by the count of cards in the deck. * beginning of the list, sorted by the count of cards in the deck.
* *
* @param sets The original list of card sets. * @param printings The original list of printings.
* @param selectedCard The currently selected card. * @param selectedCard The currently selected card.
* @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 printings with the printings contained in the deck prepended.
*/ */
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPrintingsInDeck(const QList<CardInfoPerSet> &sets, QList<PrintingInfo> PrintingSelectorCardSortingWidget::prependPrintingsInDeck(const QList<PrintingInfo> &printings,
const CardInfoPtr &selectedCard, const CardInfoPtr &selectedCard,
DeckListModel *deckModel) DeckListModel *deckModel)
{ {
if (!selectedCard) { if (!selectedCard) {
return {}; return {};
} }
CardInfoPerSetMap cardInfoPerSets = selectedCard->getSets(); SetToPrintingsMap setMap = 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 &printingList : setMap) {
for (const auto &cardInfoPerSet : cardInfoPerSetList) { for (const auto &printing : printingList) {
QModelIndex find_card = QModelIndex find_card =
deckModel->findCard(selectedCard->getName(), DECK_ZONE_MAIN, cardInfoPerSet.getProperty("uuid")); deckModel->findCard(selectedCard->getName(), DECK_ZONE_MAIN, printing.getProperty("uuid"));
if (find_card.isValid()) { if (find_card.isValid()) {
int count = int count =
deckModel->data(find_card, Qt::DisplayRole).toInt(); // Ensure the count is treated as an integer deckModel->data(find_card, Qt::DisplayRole).toInt(); // Ensure the count is treated as an integer
if (count > 0) { if (count > 0) {
countList.append(qMakePair(cardInfoPerSet, count)); countList.append(qMakePair(printing, count));
} }
} }
break; break;
@ -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 = printings;
// 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,12 +12,12 @@ 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 SetToPrintingsMap &setMap);
QList<CardInfoPerSet> filterSets(const QList<CardInfoPerSet> &sets, const QString &searchText); QList<PrintingInfo> filterSets(const QList<PrintingInfo> &printings, const QString &searchText);
QList<CardInfoPerSet> prependPinnedPrintings(const QList<CardInfoPerSet> &sets, const QString &cardName); QList<PrintingInfo> prependPinnedPrintings(const QList<PrintingInfo> &printings, const QString &cardName);
QList<CardInfoPerSet> prependPrintingsInDeck(const QList<CardInfoPerSet> &sets, QList<PrintingInfo> prependPrintingsInDeck(const QList<PrintingInfo> &printings,
const CardInfoPtr &selectedCard, const CardInfoPtr &selectedCard,
DeckListModel *deckModel); DeckListModel *deckModel);
public slots: public slots:
void updateSortOrder(); void updateSortOrder();

View file

@ -230,11 +230,11 @@ 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(); SetToPrintingsMap setMap = info->getSets();
if (setMap.contains(setFilter->term())) { if (setMap.contains(setFilter->term())) {
for (CardInfoPerSet cardSetInstance : setMap[setFilter->term()]) { for (PrintingInfo printing : setMap[setFilter->term()]) {
addCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId( addCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
name.toString(), cardSetInstance.getProperty("uuid"))); name.toString(), printing.getProperty("uuid")));
} }
} }
} else { } else {
@ -296,11 +296,11 @@ 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(); SetToPrintingsMap setMap = info->getSets();
if (setMap.contains(setFilter->term())) { if (setMap.contains(setFilter->term())) {
for (CardInfoPerSet cardSetInstance : setMap[setFilter->term()]) { for (PrintingInfo printing : setMap[setFilter->term()]) {
addCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId( addCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
name.toString(), cardSetInstance.getProperty("uuid"))); name.toString(), printing.getProperty("uuid")));
} }
} }
} else { } else {

View file

@ -367,17 +367,16 @@ QModelIndex DeckListModel::findCard(const QString &cardName,
QModelIndex DeckListModel::addPreferredPrintingCard(const QString &cardName, const QString &zoneName, bool abAddAnyway) QModelIndex DeckListModel::addPreferredPrintingCard(const QString &cardName, const QString &zoneName, bool abAddAnyway)
{ {
return addCard(cardName, CardDatabaseManager::getInstance()->getPreferredSetForCard(cardName), zoneName, return addCard(cardName, CardDatabaseManager::getInstance()->getPreferredPrinting(cardName), zoneName, abAddAnyway);
abAddAnyway);
} }
QModelIndex DeckListModel::addCard(const QString &cardName, QModelIndex DeckListModel::addCard(const QString &cardName,
const CardInfoPerSet &cardInfoSet, const PrintingInfo &printingInfo,
const QString &zoneName, const QString &zoneName,
bool abAddAnyway) bool abAddAnyway)
{ {
CardInfoPtr cardInfo = CardInfoPtr cardInfo =
CardDatabaseManager::getInstance()->getCardByNameAndProviderId(cardName, cardInfoSet.getProperty("uuid")); CardDatabaseManager::getInstance()->getCardByNameAndProviderId(cardName, printingInfo.getProperty("uuid"));
if (cardInfo == nullptr) { if (cardInfo == nullptr) {
if (abAddAnyway) { if (abAddAnyway) {
@ -398,15 +397,15 @@ QModelIndex DeckListModel::addCard(const QString &cardName,
const QModelIndex parentIndex = nodeToIndex(groupNode); const QModelIndex parentIndex = nodeToIndex(groupNode);
auto *cardNode = dynamic_cast<DecklistModelCardNode *>(groupNode->findCardChildByNameProviderIdAndNumber( auto *cardNode = dynamic_cast<DecklistModelCardNode *>(groupNode->findCardChildByNameProviderIdAndNumber(
cardName, cardInfoSet.getProperty("uuid"), cardInfoSet.getProperty("num"))); cardName, printingInfo.getProperty("uuid"), printingInfo.getProperty("num")));
const auto cardSetName = cardInfoSet.getPtr().isNull() ? "" : cardInfoSet.getPtr()->getCorrectedShortName(); const auto cardSetName = printingInfo.getSet().isNull() ? "" : printingInfo.getSet()->getCorrectedShortName();
if (!cardNode) { if (!cardNode) {
// Determine the correct index // Determine the correct index
int insertRow = findSortedInsertRow(groupNode, cardInfo); int insertRow = findSortedInsertRow(groupNode, cardInfo);
auto *decklistCard = deckList->addCard(cardInfo->getName(), zoneName, insertRow, cardSetName, auto *decklistCard = deckList->addCard(cardInfo->getName(), zoneName, insertRow, cardSetName,
cardInfoSet.getProperty("num"), cardInfoSet.getProperty("uuid")); printingInfo.getProperty("num"), printingInfo.getProperty("uuid"));
beginInsertRows(parentIndex, insertRow, insertRow); beginInsertRows(parentIndex, insertRow, insertRow);
cardNode = new DecklistModelCardNode(decklistCard, groupNode, insertRow); cardNode = new DecklistModelCardNode(decklistCard, groupNode, insertRow);
@ -414,8 +413,8 @@ QModelIndex DeckListModel::addCard(const QString &cardName,
} else { } else {
cardNode->setNumber(cardNode->getNumber() + 1); cardNode->setNumber(cardNode->getNumber() + 1);
cardNode->setCardSetShortName(cardSetName); cardNode->setCardSetShortName(cardSetName);
cardNode->setCardCollectorNumber(cardInfoSet.getProperty("num")); cardNode->setCardCollectorNumber(printingInfo.getProperty("num"));
cardNode->setCardProviderId(cardInfoSet.getProperty("uuid")); cardNode->setCardProviderId(printingInfo.getProperty("uuid"));
deckList->refreshDeckHash(); deckList->refreshDeckHash();
} }
sort(lastKnownColumn, lastKnownOrder); sort(lastKnownColumn, lastKnownOrder);

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 &printingInfo,
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,12 +324,12 @@ 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 preferredPrinting = CardDatabaseManager::getInstance()->getSpecificPrinting(
card->getName(), card->getName(),
CardDatabaseManager::getInstance()->getPreferredPrintingProviderIdForCard(card->getName())); CardDatabaseManager::getInstance()->getPreferredPrintingProviderIdForCard(card->getName()));
QString providerId = preferredSet.getProperty("uuid"); QString providerId = preferredPrinting.getProperty("uuid");
QString setShortName = preferredSet.getPtr()->getShortName(); QString setShortName = preferredPrinting.getSet()->getShortName();
QString collectorNumber = preferredSet.getProperty("num"); QString collectorNumber = preferredPrinting.getProperty("num");
card->setCardProviderId(providerId); card->setCardProviderId(providerId);
card->setCardCollectorNumber(collectorNumber); card->setCardCollectorNumber(collectorNumber);
@ -360,7 +360,7 @@ void DeckLoader::resolveSetNameAndNumberToProviderID()
// Retrieve the providerId based on setName and collectorNumber // Retrieve the providerId based on setName and collectorNumber
QString providerId = QString providerId =
CardDatabaseManager::getInstance() CardDatabaseManager::getInstance()
->getSpecificSetForCard(card->getName(), card->getCardSetShortName(), card->getCardCollectorNumber()) ->getSpecificPrinting(card->getName(), card->getCardSetShortName(), card->getCardCollectorNumber())
.getProperty("uuid"); .getProperty("uuid");
// Set the providerId on the card // Set the providerId on the card

View file

@ -162,8 +162,8 @@ void DlgEditTokens::actAddToken()
} }
QString setName = CardSet::TOKENS_SETNAME; QString setName = CardSet::TOKENS_SETNAME;
CardInfoPerSetMap sets; SetToPrintingsMap 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

@ -152,7 +152,7 @@ void DlgSelectSetForCards::actOK()
continue; continue;
} }
model->removeRow(find_card.row(), find_card.parent()); model->removeRow(find_card.row(), find_card.parent());
model->addCard(card, CardDatabaseManager::getInstance()->getSpecificSetForCard(card, modifiedSet, ""), model->addCard(card, CardDatabaseManager::getInstance()->getSpecificPrinting(card, modifiedSet, ""),
DECK_ZONE_MAIN); DECK_ZONE_MAIN);
} }
} }
@ -226,8 +226,8 @@ QMap<QString, int> DlgSelectSetForCards::getSetsForCards()
if (!infoPtr) if (!infoPtr)
continue; continue;
CardInfoPerSetMap infoPerSetMap = infoPtr->getSets(); SetToPrintingsMap setMap = infoPtr->getSets();
for (auto it = infoPerSetMap.begin(); it != infoPerSetMap.end(); ++it) { for (auto it = setMap.begin(); it != setMap.end(); ++it) {
setCounts[it.key()]++; setCounts[it.key()]++;
} }
} }
@ -297,7 +297,7 @@ void DlgSelectSetForCards::updateCardLists()
} else { } else {
CardInfoPtr infoPtr = CardDatabaseManager::getInstance()->getCardByNameAndProviderId( CardInfoPtr infoPtr = CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
currentCard->getName(), CardDatabaseManager::getInstance() currentCard->getName(), CardDatabaseManager::getInstance()
->getSpecificSetForCard(currentCard->getName(), foundSetName, "") ->getSpecificPrinting(currentCard->getName(), foundSetName, "")
.getProperty("uuid")); .getProperty("uuid"));
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(modifiedCardsFlowWidget); CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(modifiedCardsFlowWidget);
picture_widget->setCard(infoPtr); picture_widget->setCard(infoPtr);
@ -380,8 +380,8 @@ QMap<QString, QStringList> DlgSelectSetForCards::getCardsForSets()
if (!infoPtr) if (!infoPtr)
continue; continue;
CardInfoPerSetMap infoPerSetMap = infoPtr->getSets(); SetToPrintingsMap setMap = infoPtr->getSets();
for (auto it = infoPerSetMap.begin(); it != infoPerSetMap.end(); ++it) { for (auto it = setMap.begin(); it != setMap.end(); ++it) {
setCards[it.key()].append(currentCard->getName()); setCards[it.key()].append(currentCard->getName());
} }
} }
@ -628,7 +628,7 @@ void SetEntryWidget::updateCardDisplayWidgets()
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(cardListContainer); CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(cardListContainer);
picture_widget->setCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId( picture_widget->setCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
cardName, cardName,
CardDatabaseManager::getInstance()->getSpecificSetForCard(cardName, setName, nullptr).getProperty("uuid"))); CardDatabaseManager::getInstance()->getSpecificPrinting(cardName, setName, nullptr).getProperty("uuid")));
cardListContainer->addWidget(picture_widget); cardListContainer->addWidget(picture_widget);
} }
@ -636,7 +636,7 @@ void SetEntryWidget::updateCardDisplayWidgets()
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(alreadySelectedCardListContainer); CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(alreadySelectedCardListContainer);
picture_widget->setCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId( picture_widget->setCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
cardName, cardName,
CardDatabaseManager::getInstance()->getSpecificSetForCard(cardName, setName, nullptr).getProperty("uuid"))); CardDatabaseManager::getInstance()->getSpecificPrinting(cardName, setName, nullptr).getProperty("uuid")));
alreadySelectedCardListContainer->addWidget(picture_widget); alreadySelectedCardListContainer->addWidget(picture_widget);
} }
} }

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); SetToPrintingsMap(), 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

@ -73,9 +73,9 @@ void CardDatabase::addCard(CardInfoPtr card)
// if card already exists just add the new set property // if card already exists just add the new set property
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 &printings : card->getSets()) {
for (const CardInfoPerSet &set : cardInfoPerSetList) { for (const PrintingInfo &printing : printings) {
sameCard->addToSet(set.getPtr(), set); sameCard->addToSet(printing.getSet(), printing);
} }
} }
return; return;
@ -147,12 +147,12 @@ CardInfoPtr CardDatabase::getCardByNameAndProviderId(const QString &cardName, co
return info; return info;
} }
for (const auto &cardInfoPerSetList : info->getSets()) { for (const auto &printings : info->getSets()) {
for (const auto &set : cardInfoPerSetList) { for (const auto &printing : printings) {
if (set.getProperty("uuid") == providerId) { if (printing.getProperty("uuid") == providerId) {
CardInfoPtr cardFromSpecificSet = info->clone(); CardInfoPtr cardFromSpecificSet = info->clone();
cardFromSpecificSet->setPixmapCacheKey(QLatin1String("card_") + QString(info->getName()) + cardFromSpecificSet->setPixmapCacheKey(QLatin1String("card_") + QString(info->getName()) +
QString("_") + QString(set.getProperty("uuid"))); QString("_") + QString(printing.getProperty("uuid")));
return cardFromSpecificSet; return cardFromSpecificSet;
} }
} }
@ -309,53 +309,53 @@ void CardDatabase::refreshPreferredPrintings()
} }
} }
CardInfoPerSet CardDatabase::getPreferredSetForCard(const QString &cardName) const PrintingInfo CardDatabase::getPreferredPrinting(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(); SetToPrintingsMap setMap = cardInfo->getSets();
if (setMap.empty()) { if (setMap.empty()) {
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
CardSetPtr preferredSet = nullptr; CardSetPtr preferredSet = nullptr;
CardInfoPerSet preferredCard; PrintingInfo preferredPrinting;
SetPriorityComparator comparator; SetPriorityComparator comparator;
for (const auto &cardInfoPerSetList : setMap) { for (const auto &printings : setMap) {
for (auto &cardInfoForSet : cardInfoPerSetList) { for (auto &printing : printings) {
CardSetPtr currentSet = cardInfoForSet.getPtr(); CardSetPtr currentSet = printing.getSet();
if (!preferredSet || comparator(currentSet, preferredSet)) { if (!preferredSet || comparator(currentSet, preferredSet)) {
preferredSet = currentSet; preferredSet = currentSet;
preferredCard = cardInfoForSet; preferredPrinting = printing;
} }
} }
} }
if (preferredSet) { if (preferredSet) {
return preferredCard; return preferredPrinting;
} }
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
CardInfoPerSet CardDatabase::getSpecificSetForCard(const QString &cardName, const QString &providerId) const PrintingInfo CardDatabase::getSpecificPrinting(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(); SetToPrintingsMap setMap = cardInfo->getSets();
if (setMap.empty()) { if (setMap.empty()) {
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
for (const auto &cardInfoPerSetList : setMap) { for (const auto &printings : setMap) {
for (auto &cardInfoForSet : cardInfoPerSetList) { for (auto &cardInfoForSet : printings) {
if (cardInfoForSet.getProperty("uuid") == providerId) { if (cardInfoForSet.getProperty("uuid") == providerId) {
return cardInfoForSet; return cardInfoForSet;
} }
@ -363,48 +363,48 @@ CardInfoPerSet CardDatabase::getSpecificSetForCard(const QString &cardName, cons
} }
if (providerId.isNull()) { if (providerId.isNull()) {
return getPreferredSetForCard(cardName); return getPreferredPrinting(cardName);
} }
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
CardInfoPerSet CardDatabase::getSpecificSetForCard(const QString &cardName, PrintingInfo CardDatabase::getSpecificPrinting(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(); SetToPrintingsMap setMap = cardInfo->getSets();
if (setMap.empty()) { if (setMap.empty()) {
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
for (const auto &cardInfoPerSetList : setMap) { for (const auto &printings : setMap) {
for (auto &cardInfoForSet : cardInfoPerSetList) { for (auto &cardInfoForSet : printings) {
if (collectorNumber != nullptr) { if (collectorNumber != nullptr) {
if (cardInfoForSet.getPtr()->getShortName() == setShortName && if (cardInfoForSet.getSet()->getShortName() == setShortName &&
cardInfoForSet.getProperty("num") == collectorNumber) { cardInfoForSet.getProperty("num") == collectorNumber) {
return cardInfoForSet; return cardInfoForSet;
} }
} else { } else {
if (cardInfoForSet.getPtr()->getShortName() == setShortName) { if (cardInfoForSet.getSet()->getShortName() == setShortName) {
return cardInfoForSet; return cardInfoForSet;
} }
} }
} }
} }
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
QString CardDatabase::getPreferredPrintingProviderIdForCard(const QString &cardName) QString CardDatabase::getPreferredPrintingProviderIdForCard(const QString &cardName)
{ {
CardInfoPerSet preferredSetCardInfo = getPreferredSetForCard(cardName); PrintingInfo preferredPrinting = getPreferredPrinting(cardName);
QString preferredPrintingProviderId = preferredSetCardInfo.getProperty(QString("uuid")); QString preferredPrintingProviderId = preferredPrinting.getProperty(QString("uuid"));
if (preferredPrintingProviderId.isEmpty()) { if (preferredPrintingProviderId.isEmpty()) {
CardInfoPtr defaultCardInfo = getCard(cardName); CardInfoPtr defaultCardInfo = getCard(cardName);
if (defaultCardInfo.isNull()) { if (defaultCardInfo.isNull()) {
@ -424,15 +424,15 @@ 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 SetToPrintingsMap &setMap = _card->getSets();
if (setMap.empty()) { if (setMap.empty()) {
return CardInfoPerSet(nullptr); return PrintingInfo(nullptr);
} }
for (const auto &cardInfoPerSetList : setMap) { for (const auto &printings : setMap) {
for (const auto &cardInfoForSet : cardInfoPerSetList) { for (const auto &cardInfoForSet : printings) {
if (QLatin1String("card_") + _card->getName() + QString("_") + cardInfoForSet.getProperty("uuid") == if (QLatin1String("card_") + _card->getName() + QString("_") + cardInfoForSet.getProperty("uuid") ==
_card->getPixmapCacheKey()) { _card->getPixmapCacheKey()) {
return cardInfoForSet; return cardInfoForSet;
@ -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,10 +69,10 @@ 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 getPreferredPrinting(const QString &cardName) const;
[[nodiscard]] CardInfoPerSet getSpecificSetForCard(const QString &cardName, const QString &providerId) const; [[nodiscard]] PrintingInfo getSpecificPrinting(const QString &cardName, const QString &providerId) const;
CardInfoPerSet PrintingInfo
getSpecificSetForCard(const QString &cardName, const QString &setShortName, const QString &collectorNumber) const; getSpecificPrinting(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

@ -98,9 +98,9 @@ bool CardDatabaseModel::checkCardHasAtLeastOneEnabledSet(CardInfoPtr card)
if (!showOnlyCardsFromEnabledSets) if (!showOnlyCardsFromEnabledSets)
return true; return true;
for (const auto &cardInfoPerSetList : card->getSets()) { for (const auto &printings : card->getSets()) {
for (const auto &set : cardInfoPerSetList) { for (const auto &printing : printings) {
if (set.getPtr()->getEnabled()) if (printing.getSet()->getEnabled())
return true; return true;
} }
} }

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 = SetToPrintingsMap();
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 SetToPrintingsMap setMap = info->getSets();
for (const auto &cardInfoPerSetList : sets) { for (const auto &printings : setMap) {
for (const CardInfoPerSet &set : cardInfoPerSetList) { for (const PrintingInfo &set : printings) {
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"));
@ -361,7 +361,7 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
xml.writeAttribute("picURL", tmpString); xml.writeAttribute("picURL", tmpString);
} }
xml.writeCharacters(set.getPtr()->getShortName()); xml.writeCharacters(set.getSet()->getShortName());
xml.writeEndElement(); xml.writeEndElement();
} }
} }

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 = SetToPrintingsMap();
int tableRow = 0; int tableRow = 0;
bool cipt = false; bool cipt = false;
bool landscapeOrientation = false; bool landscapeOrientation = false;
@ -184,12 +184,12 @@ 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 printingInfo(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")
attrName = "picurl"; attrName = "picurl";
setInfo.setProperty(attrName, attr.value().toString()); printingInfo.setProperty(attrName, attr.value().toString());
} }
// This is very much a hack and not the right place to // This is very much a hack and not the right place to
@ -199,8 +199,8 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
// However, this is also true of the `set->getEnabled()` // However, this is also true of the `set->getEnabled()`
// check above (which is currently bugged as well), so // check above (which is currently bugged as well), so
// we'll fix both at the same time. // we'll fix both at the same time.
if (includeRebalancedCards || setInfo.getProperty("isRebalanced") != "true") { if (includeRebalancedCards || printingInfo.getProperty("isRebalanced") != "true") {
_sets[setName].append(setInfo); _sets[setName].append(printingInfo);
} }
} }
// related cards // related cards
@ -309,14 +309,14 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
xml.writeEndElement(); xml.writeEndElement();
// sets // sets
for (const auto &cardInfoPerSetList : info->getSets()) { for (const auto &printings : info->getSets()) {
for (const CardInfoPerSet &set : cardInfoPerSetList) { for (const PrintingInfo &set : printings) {
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));
} }
xml.writeCharacters(set.getPtr()->getShortName()); xml.writeCharacters(set.getSet()->getShortName());
xml.writeEndElement(); xml.writeEndElement();
} }
} }

View file

@ -215,7 +215,7 @@ void SetList::defaultSort()
}); });
} }
CardInfoPerSet::CardInfoPerSet(const CardSetPtr &_set) : set(_set) PrintingInfo::PrintingInfo(const CardSetPtr &_set) : set(_set)
{ {
} }
@ -225,13 +225,13 @@ 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, SetToPrintingsMap _sets,
bool _cipt, bool _cipt,
bool _landscapeOrientation, bool _landscapeOrientation,
int _tableRow, int _tableRow,
bool _upsideDownArt) bool _upsideDownArt)
: name(_name), text(_text), isToken(_isToken), properties(std::move(_properties)), relatedCards(_relatedCards), : name(_name), text(_text), isToken(_isToken), properties(std::move(_properties)), relatedCards(_relatedCards),
reverseRelatedCards(_reverseRelatedCards), sets(std::move(_sets)), cipt(_cipt), reverseRelatedCards(_reverseRelatedCards), setsToPrintings(std::move(_sets)), cipt(_cipt),
landscapeOrientation(_landscapeOrientation), tableRow(_tableRow), upsideDownArt(_upsideDownArt) landscapeOrientation(_landscapeOrientation), tableRow(_tableRow), upsideDownArt(_upsideDownArt)
{ {
pixmapCacheKey = QLatin1String("card_") + name; pixmapCacheKey = QLatin1String("card_") + name;
@ -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); SetToPrintingsMap(), 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, SetToPrintingsMap _sets,
bool _cipt, bool _cipt,
bool _landscapeOrientation, bool _landscapeOrientation,
int _tableRow, int _tableRow,
@ -267,9 +267,9 @@ CardInfoPtr CardInfo::newInstance(const QString &_name,
_sets, _cipt, _landscapeOrientation, _tableRow, _upsideDownArt)); _sets, _cipt, _landscapeOrientation, _tableRow, _upsideDownArt));
ptr->setSmartPointer(ptr); ptr->setSmartPointer(ptr);
for (const auto &cardInfoPerSetList : _sets) { for (const auto &printings : _sets) {
for (const CardInfoPerSet &set : cardInfoPerSetList) { for (const PrintingInfo &printing : printings) {
set.getPtr()->append(ptr); printing.getSet()->append(ptr);
break; break;
} }
} }
@ -289,13 +289,13 @@ 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);
} }
if (!sets[_set->getShortName()].contains(_info)) { if (!setsToPrintings[_set->getShortName()].contains(_info)) {
sets[_set->getShortName()].append(_info); setsToPrintings[_set->getShortName()].append(_info);
} }
refreshCachedSetNames(); refreshCachedSetNames();
@ -316,10 +316,10 @@ void CardInfo::refreshCachedSetNames()
{ {
QStringList setList; QStringList setList;
// update the cached list of set names // update the cached list of set names
for (const auto &cardInfoPerSetList : sets) { for (const auto &printings : setsToPrintings) {
for (const auto &set : cardInfoPerSetList) { for (const auto &printing : printings) {
if (set.getPtr()->getEnabled()) { if (printing.getSet()->getEnabled()) {
setList << set.getPtr()->getShortName(); setList << printing.getSet()->getShortName();
} }
break; break;
} }

View file

@ -15,15 +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 QMap<QString, QString> QStringMap;
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>> SetToPrintingsMap;
typedef QHash<QString, CardInfoPtr> CardNameMap; typedef QHash<QString, CardInfoPtr> CardNameMap;
typedef QHash<QString, CardSetPtr> SetNameMap; typedef QHash<QString, CardSetPtr> SetNameMap;
@ -143,32 +142,35 @@ 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:
const CardSetPtr getPtr() const CardSetPtr getSet() const
{ {
return set; return set;
} }
const QStringList getProperties() const QStringList getProperties() const
{ {
return properties.keys(); return properties.keys();
} }
const QString getProperty(const QString &propertyName) const QString getProperty(const QString &propertyName) const
{ {
return properties.value(propertyName).toString(); return properties.value(propertyName).toString();
} }
@ -202,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; SetToPrintingsMap setsToPrintings;
// cached set names // cached set names
QString setsNames; QString setsNames;
// positioning properties; used by UI // positioning properties; used by UI
@ -218,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, SetToPrintingsMap _sets,
bool _cipt, bool _cipt,
bool _landscapeOrientation, bool _landscapeOrientation,
int _tableRow, int _tableRow,
@ -227,7 +229,7 @@ public:
: QObject(other.parent()), name(other.name), simpleName(other.simpleName), pixmapCacheKey(other.pixmapCacheKey), : QObject(other.parent()), name(other.name), simpleName(other.simpleName), pixmapCacheKey(other.pixmapCacheKey),
text(other.text), isToken(other.isToken), properties(other.properties), relatedCards(other.relatedCards), text(other.text), isToken(other.isToken), properties(other.properties), relatedCards(other.relatedCards),
reverseRelatedCards(other.reverseRelatedCards), reverseRelatedCardsToMe(other.reverseRelatedCardsToMe), reverseRelatedCards(other.reverseRelatedCards), reverseRelatedCardsToMe(other.reverseRelatedCardsToMe),
sets(other.sets), setsNames(other.setsNames), cipt(other.cipt), setsToPrintings(other.setsToPrintings), setsNames(other.setsNames), cipt(other.cipt),
landscapeOrientation(other.landscapeOrientation), tableRow(other.tableRow), upsideDownArt(other.upsideDownArt) landscapeOrientation(other.landscapeOrientation), tableRow(other.tableRow), upsideDownArt(other.upsideDownArt)
{ {
} }
@ -241,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, SetToPrintingsMap _sets,
bool _cipt, bool _cipt,
bool _landscapeOrientation, bool _landscapeOrientation,
int _tableRow, int _tableRow,
@ -292,11 +294,11 @@ public:
{ {
return isToken; return isToken;
} }
const QStringList getProperties() const QStringList getProperties() const
{ {
return properties.keys(); return properties.keys();
} }
const QString getProperty(const QString &propertyName) const QString getProperty(const QString &propertyName) const
{ {
return properties.value(propertyName).toString(); return properties.value(propertyName).toString();
} }
@ -309,27 +311,27 @@ public:
{ {
return properties.contains(propertyName); return properties.contains(propertyName);
} }
const CardInfoPerSetMap &getSets() const const SetToPrintingsMap &getSets() const
{ {
return sets; return setsToPrintings;
} }
const QString &getSetsNames() const const QString &getSetsNames() const
{ {
return setsNames; return setsNames;
} }
const QString getSetProperty(const QString &setName, const QString &propertyName) const QString getSetProperty(const QString &setName, const QString &propertyName) const
{ {
if (!sets.contains(setName)) if (!setsToPrintings.contains(setName))
return ""; return "";
for (const auto &set : sets[setName]) { for (const auto &set : setsToPrintings[setName]) {
if (QLatin1String("card_") + this->getName() + QString("_") + QString(set.getProperty("uuid")) == if (QLatin1String("card_") + this->getName() + QString("_") + QString(set.getProperty("uuid")) ==
this->getPixmapCacheKey()) { this->getPixmapCacheKey()) {
return set.getProperty(propertyName); return set.getProperty(propertyName);
} }
} }
return sets[setName][0].getProperty(propertyName); return setsToPrintings[setName][0].getProperty(propertyName);
} }
// related cards // related cards
@ -345,7 +347,7 @@ public:
{ {
return reverseRelatedCardsToMe; return reverseRelatedCardsToMe;
} }
const QList<CardRelation *> getAllRelatedCards() const QList<CardRelation *> getAllRelatedCards() const
{ {
QList<CardRelation *> result; QList<CardRelation *> result;
result.append(getRelatedCards()); result.append(getRelatedCards());
@ -399,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 &printings : x->getSets()) {
for (const auto &cardInfoPerSet : setsValue) { for (const auto &printing : printings) {
infos.append(cardInfoPerSet); infos.append(printing);
} }
} }
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

@ -215,10 +215,10 @@ bool FilterItem::acceptText(const CardInfoPtr info) const
bool FilterItem::acceptSet(const CardInfoPtr info) const bool FilterItem::acceptSet(const CardInfoPtr info) const
{ {
bool status = false; bool status = false;
for (const auto &cardInfoPerSetList : info->getSets()) { for (const auto &printings : info->getSets()) {
for (const auto &set : cardInfoPerSetList) { for (const auto &set : printings) {
if (set.getPtr()->getShortName().compare(term, Qt::CaseInsensitive) == 0 || if (set.getSet()->getShortName().compare(term, Qt::CaseInsensitive) == 0 ||
set.getPtr()->getLongName().compare(term, Qt::CaseInsensitive) == 0) { set.getSet()->getLongName().compare(term, Qt::CaseInsensitive) == 0) {
status = true; status = true;
break; break;
} }
@ -350,9 +350,9 @@ bool FilterItem::acceptRarity(const CardInfoPtr info) const
} }
} }
for (const auto &cardInfoPerSetList : info->getSets()) { for (const auto &printings : info->getSets()) {
for (const auto &set : cardInfoPerSetList) { for (const auto &printing : printings) {
if (set.getProperty("rarity").compare(converted_term, Qt::CaseInsensitive) == 0) { if (printing.getProperty("rarity").compare(converted_term, Qt::CaseInsensitive) == 0) {
return true; return true;
} }
} }

View file

@ -47,12 +47,12 @@ 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.getSet()->getEnabled()) {
return !b.getPtr()->getEnabled() || a.getPtr()->getSortKey() < b.getPtr()->getSortKey(); return !b.getSet()->getEnabled() || a.getSet()->getSortKey() < b.getSet()->getSortKey();
} else { } else {
return !b.getPtr()->getEnabled() && a.getPtr()->getSortKey() < b.getPtr()->getSortKey(); return !b.getSet()->getEnabled() && a.getSet()->getSortKey() < b.getSet()->getSortKey();
} }
} }
}; };

View file

@ -12,8 +12,8 @@
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 &_printingInfo)
: name(_name), text(_text), properties(_properties), setInfo(_setInfo) : name(_name), text(_text), properties(_properties), printingInfo(_printingInfo)
{ {
} }
@ -129,14 +129,14 @@ 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 &printingInfo)
{ {
// Workaround for card name weirdness // Workaround for card name weirdness
name = name.replace("Æ", "AE"); name = name.replace("Æ", "AE");
name = name.replace("", "'"); name = name.replace("", "'");
if (cards.contains(name)) { if (cards.contains(name)) {
CardInfoPtr card = cards.value(name); CardInfoPtr card = cards.value(name);
card->addToSet(setInfo.getPtr(), setInfo); card->addToSet(printingInfo.getSet(), printingInfo);
if (card->getProperties().filter(formatRegex).empty()) { if (card->getProperties().filter(formatRegex).empty()) {
card->combineLegalities(properties); card->combineLegalities(properties);
} }
@ -200,13 +200,13 @@ 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; SetToPrintingsMap setsInfo;
setsInfo[setInfo.getPtr()->getShortName()].append(setInfo); setsInfo[printingInfo.getSet()->getShortName()].append(printingInfo);
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);
if (name.isEmpty()) { if (name.isEmpty()) {
qDebug() << "warning: an empty card was added to set" << setInfo.getPtr()->getShortName(); qDebug() << "warning: an empty card was added to set" << printingInfo.getSet()->getShortName();
} }
cards.insert(name, newCard); cards.insert(name, newCard);
@ -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 printingInfo;
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); printingInfo = PrintingInfo(currentSet);
QMapIterator it2(setInfoProperties); QMapIterator it2(setInfoProperties);
while (it2.hasNext()) { while (it2.hasNext()) {
it2.next(); it2.next();
@ -289,7 +289,7 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
QString xmlPropertyName = it2.value(); QString xmlPropertyName = it2.value();
QString propertyValue = getStringPropertyFromMap(card, mtgjsonProperty); QString propertyValue = getStringPropertyFromMap(card, mtgjsonProperty);
if (!propertyValue.isEmpty()) if (!propertyValue.isEmpty())
setInfo.setProperty(xmlPropertyName, propertyValue); printingInfo.setProperty(xmlPropertyName, propertyValue);
} }
// Identifiers // Identifiers
@ -300,12 +300,12 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
auto xmlPropertyName = it3.value(); auto xmlPropertyName = it3.value();
auto propertyValue = getStringPropertyFromMap(card.value("identifiers").toMap(), mtgjsonProperty); auto propertyValue = getStringPropertyFromMap(card.value("identifiers").toMap(), mtgjsonProperty);
if (!propertyValue.isEmpty()) { if (!propertyValue.isEmpty()) {
setInfo.setProperty(xmlPropertyName, propertyValue); printingInfo.setProperty(xmlPropertyName, propertyValue);
} }
} }
QString numComponent; QString numComponent;
const QString numProperty = setInfo.getProperty("num"); const QString numProperty = printingInfo.getProperty("num");
const QChar lastChar = numProperty.isEmpty() ? QChar() : numProperty.back(); const QChar lastChar = numProperty.isEmpty() ? QChar() : numProperty.back();
// Un-Sets do some wonky stuff. Split up these cards as individual entries. // Un-Sets do some wonky stuff. Split up these cards as individual entries.
@ -353,7 +353,7 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
// split cards are considered a single card, enqueue for later merging // split cards are considered a single card, enqueue for later merging
if (layout == "split" || layout == "aftermath" || layout == "adventure") { if (layout == "split" || layout == "aftermath" || layout == "adventure") {
auto _faceName = getStringPropertyFromMap(card, "faceName"); auto _faceName = getStringPropertyFromMap(card, "faceName");
SplitCardPart split(_faceName, text, properties, setInfo); SplitCardPart split(_faceName, text, properties, printingInfo);
auto found_iter = splitCards.find(name + numProperty); auto found_iter = splitCards.find(name + numProperty);
if (found_iter == splitCards.end()) { if (found_iter == splitCards.end()) {
splitCards.insert(name + numProperty, {{split}, name}); splitCards.insert(name + numProperty, {{split}, name});
@ -404,7 +404,7 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
} }
} }
CardInfoPtr newCard = addCard(name + numComponent, text, isToken, properties, relatedCards, setInfo); CardInfoPtr newCard = addCard(name + numComponent, text, isToken, properties, relatedCards, printingInfo);
numCards++; numCards++;
} }
} }
@ -430,7 +430,7 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
if (properties.isEmpty()) { if (properties.isEmpty()) {
properties = tmp.getProperties(); properties = tmp.getProperties();
setInfo = tmp.getSetInfo(); printingInfo = tmp.getPrintingInfo();
} else { } else {
const QVariantHash &tmpProps = tmp.getProperties(); const QVariantHash &tmpProps = tmp.getProperties();
for (const QString &prop : tmpProps.keys()) { for (const QString &prop : tmpProps.keys()) {
@ -451,7 +451,7 @@ int OracleImporter::importCardsFromSet(const CardSetPtr &currentSet, const QList
} }
} }
} }
CardInfoPtr newCard = addCard(name, text, isToken, properties, relatedCards, setInfo); CardInfoPtr newCard = addCard(name, text, isToken, properties, relatedCards, printingInfo);
numCards++; numCards++;
} }

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 &_printingInfo);
inline const QString &getName() const inline const QString &getName() const
{ {
return name; return name;
@ -108,16 +108,16 @@ public:
{ {
return properties; return properties;
} }
inline const CardInfoPerSet &getSetInfo() const inline const PrintingInfo &getPrintingInfo() const
{ {
return setInfo; return printingInfo;
} }
private: private:
QString name; QString name;
QString text; QString text;
QVariantHash properties; QVariantHash properties;
CardInfoPerSet setInfo; PrintingInfo printingInfo;
}; };
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 &printingInfo);
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);