mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
rename class
This commit is contained in:
parent
a6216c2912
commit
3c5ace00be
28 changed files with 111 additions and 108 deletions
|
|
@ -24,7 +24,7 @@ AllZonesCardAmountWidget::AllZonesCardAmountWidget(QWidget *parent,
|
|||
QTreeView *deckView,
|
||||
QSlider *cardSizeSlider,
|
||||
CardInfoPtr rootCard,
|
||||
CardInfoPerSet setInfoForCard)
|
||||
PrintingInfo setInfoForCard)
|
||||
: QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), cardSizeSlider(cardSizeSlider),
|
||||
rootCard(rootCard), setInfoForCard(setInfoForCard)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public:
|
|||
QTreeView *deckView,
|
||||
QSlider *cardSizeSlider,
|
||||
CardInfoPtr rootCard,
|
||||
CardInfoPerSet setInfoForCard);
|
||||
PrintingInfo setInfoForCard);
|
||||
int getMainboardAmount();
|
||||
int getSideboardAmount();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
|
|
@ -36,7 +36,7 @@ private:
|
|||
QTreeView *deckView;
|
||||
QSlider *cardSizeSlider;
|
||||
CardInfoPtr rootCard;
|
||||
CardInfoPerSet setInfoForCard;
|
||||
PrintingInfo setInfoForCard;
|
||||
QLabel *zoneLabelMainboard;
|
||||
CardAmountWidget *buttonBoxMainboard;
|
||||
QLabel *zoneLabelSideboard;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ CardAmountWidget::CardAmountWidget(QWidget *parent,
|
|||
QTreeView *deckView,
|
||||
QSlider *cardSizeSlider,
|
||||
CardInfoPtr &rootCard,
|
||||
CardInfoPerSet &setInfoForCard,
|
||||
PrintingInfo &setInfoForCard,
|
||||
const QString &zoneName)
|
||||
: QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView), cardSizeSlider(cardSizeSlider),
|
||||
rootCard(rootCard), setInfoForCard(setInfoForCard), zoneName(zoneName), hovered(false)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public:
|
|||
QTreeView *deckView,
|
||||
QSlider *cardSizeSlider,
|
||||
CardInfoPtr &rootCard,
|
||||
CardInfoPerSet &setInfoForCard,
|
||||
PrintingInfo &setInfoForCard,
|
||||
const QString &zoneName);
|
||||
int countCardsInZone(const QString &deckZone);
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ private:
|
|||
QTreeView *deckView;
|
||||
QSlider *cardSizeSlider;
|
||||
CardInfoPtr rootCard;
|
||||
CardInfoPerSet setInfoForCard;
|
||||
PrintingInfo setInfoForCard;
|
||||
QString zoneName;
|
||||
QHBoxLayout *layout;
|
||||
DynamicFontSizePushButton *incrementButton;
|
||||
|
|
|
|||
|
|
@ -224,11 +224,11 @@ void PrintingSelector::getAllSetsForCurrentCard()
|
|||
return;
|
||||
}
|
||||
|
||||
CardInfoPerSetMap cardInfoPerSets = selectedCard->getSets();
|
||||
const QList<CardInfoPerSet> sortedSets = sortToolBar->sortSets(cardInfoPerSets);
|
||||
const QList<CardInfoPerSet> filteredSets =
|
||||
PrintingInfoPerSetMap cardInfoPerSets = selectedCard->getSets();
|
||||
const QList<PrintingInfo> sortedSets = sortToolBar->sortSets(cardInfoPerSets);
|
||||
const QList<PrintingInfo> filteredSets =
|
||||
sortToolBar->filterSets(sortedSets, searchBar->getSearchText().trimmed().toLower());
|
||||
QList<CardInfoPerSet> setsToUse;
|
||||
QList<PrintingInfo> setsToUse;
|
||||
|
||||
if (SettingsCache::instance().getBumpSetsWithCardsInDeckToTop()) {
|
||||
setsToUse = sortToolBar->prependPrintingsInDeck(filteredSets, selectedCard, deckModel);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ PrintingSelectorCardDisplayWidget::PrintingSelectorCardDisplayWidget(QWidget *pa
|
|||
QTreeView *_deckView,
|
||||
QSlider *_cardSizeSlider,
|
||||
CardInfoPtr _rootCard,
|
||||
const CardInfoPerSet &_setInfoForCard,
|
||||
const PrintingInfo &_setInfoForCard,
|
||||
QString &_currentZone)
|
||||
: QWidget(parent), deckEditor(_deckEditor), deckModel(_deckModel), deckView(_deckView),
|
||||
cardSizeSlider(_cardSizeSlider), rootCard(std::move(_rootCard)), setInfoForCard(_setInfoForCard),
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public:
|
|||
QTreeView *_deckView,
|
||||
QSlider *_cardSizeSlider,
|
||||
CardInfoPtr _rootCard,
|
||||
const CardInfoPerSet &_setInfoForCard,
|
||||
const PrintingInfo &_setInfoForCard,
|
||||
QString &_currentZone);
|
||||
|
||||
public slots:
|
||||
|
|
@ -39,7 +39,7 @@ private:
|
|||
QSlider *cardSizeSlider;
|
||||
CardInfoPtr rootCard;
|
||||
CardInfoPtr setCard;
|
||||
CardInfoPerSet setInfoForCard;
|
||||
PrintingInfo setInfoForCard;
|
||||
QString currentZone;
|
||||
PrintingSelectorCardOverlayWidget *overlayWidget;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ PrintingSelectorCardOverlayWidget::PrintingSelectorCardOverlayWidget(QWidget *pa
|
|||
QTreeView *_deckView,
|
||||
QSlider *_cardSizeSlider,
|
||||
CardInfoPtr _rootCard,
|
||||
const CardInfoPerSet &_setInfoForCard)
|
||||
const PrintingInfo &_setInfoForCard)
|
||||
: QWidget(parent), deckEditor(_deckEditor), deckModel(_deckModel), deckView(_deckView),
|
||||
cardSizeSlider(_cardSizeSlider), rootCard(std::move(_rootCard)), setInfoForCard(_setInfoForCard)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public:
|
|||
QTreeView *_deckView,
|
||||
QSlider *_cardSizeSlider,
|
||||
CardInfoPtr _rootCard,
|
||||
const CardInfoPerSet &_setInfoForCard);
|
||||
const PrintingInfo &_setInfoForCard);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
|
@ -45,7 +45,7 @@ private:
|
|||
QSlider *cardSizeSlider;
|
||||
CardInfoPtr rootCard;
|
||||
CardInfoPtr setCard;
|
||||
CardInfoPerSet setInfoForCard;
|
||||
PrintingInfo setInfoForCard;
|
||||
};
|
||||
|
||||
#endif // PRINTING_SELECTOR_CARD_OVERLAY_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ void PrintingSelectorCardSortingWidget::updateSortSetting()
|
|||
* @param cardInfoPerSets The list of card sets to be sorted.
|
||||
* @return A sorted list of card sets.
|
||||
*/
|
||||
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::sortSets(const CardInfoPerSetMap &cardInfoPerSets)
|
||||
QList<PrintingInfo> PrintingSelectorCardSortingWidget::sortSets(const PrintingInfoPerSetMap &cardInfoPerSets)
|
||||
{
|
||||
QList<CardSetPtr> sortedSets;
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::sortSets(const CardInfo
|
|||
std::sort(sortedSets.begin(), sortedSets.end(), SetReleaseDateComparator());
|
||||
}
|
||||
|
||||
QList<CardInfoPerSet> sortedCardInfoPerSets;
|
||||
QList<PrintingInfo> sortedCardInfoPerSets;
|
||||
// Reconstruct sorted list of CardInfoPerSet
|
||||
for (const auto &set : sortedSets) {
|
||||
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.
|
||||
* @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)
|
||||
{
|
||||
if (searchText.isEmpty()) {
|
||||
return sets;
|
||||
}
|
||||
|
||||
QList<CardInfoPerSet> filteredSets;
|
||||
QList<PrintingInfo> filteredSets;
|
||||
|
||||
for (const auto &set : sets) {
|
||||
const QString longName = set.getPtr()->getLongName().toLower();
|
||||
|
|
@ -151,7 +151,7 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::filterSets(const QList<
|
|||
return filteredSets;
|
||||
}
|
||||
|
||||
QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPinnedPrintings(const QList<CardInfoPerSet> &sets,
|
||||
QList<PrintingInfo> PrintingSelectorCardSortingWidget::prependPinnedPrintings(const QList<PrintingInfo> &sets,
|
||||
const QString &cardName)
|
||||
{
|
||||
auto setsToUse = sets;
|
||||
|
|
@ -180,7 +180,7 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPinnedPrintings(
|
|||
* @param deckModel The model representing the deck.
|
||||
* @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,
|
||||
DeckListModel *deckModel)
|
||||
{
|
||||
|
|
@ -188,8 +188,8 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPrintingsInDeck(
|
|||
return {};
|
||||
}
|
||||
|
||||
CardInfoPerSetMap cardInfoPerSets = selectedCard->getSets();
|
||||
QList<QPair<CardInfoPerSet, int>> countList;
|
||||
PrintingInfoPerSetMap cardInfoPerSets = selectedCard->getSets();
|
||||
QList<QPair<PrintingInfo, int>> countList;
|
||||
|
||||
// Collect sets with their counts
|
||||
for (const auto &cardInfoPerSetList : cardInfoPerSets) {
|
||||
|
|
@ -209,16 +209,16 @@ QList<CardInfoPerSet> PrintingSelectorCardSortingWidget::prependPrintingsInDeck(
|
|||
|
||||
// Sort sets by count in descending numerical order
|
||||
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
|
||||
});
|
||||
|
||||
// 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
|
||||
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");
|
||||
});
|
||||
if (it != result.end()) {
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ class PrintingSelectorCardSortingWidget : public QWidget
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit PrintingSelectorCardSortingWidget(PrintingSelector *parent);
|
||||
QList<CardInfoPerSet> sortSets(const CardInfoPerSetMap &cardInfoPerSets);
|
||||
QList<CardInfoPerSet> filterSets(const QList<CardInfoPerSet> &sets, const QString &searchText);
|
||||
QList<CardInfoPerSet> prependPinnedPrintings(const QList<CardInfoPerSet> &sets, const QString &cardName);
|
||||
QList<CardInfoPerSet> prependPrintingsInDeck(const QList<CardInfoPerSet> &sets,
|
||||
QList<PrintingInfo> sortSets(const PrintingInfoPerSetMap &cardInfoPerSets);
|
||||
QList<PrintingInfo> filterSets(const QList<PrintingInfo> &sets, const QString &searchText);
|
||||
QList<PrintingInfo> prependPinnedPrintings(const QList<PrintingInfo> &sets, const QString &cardName);
|
||||
QList<PrintingInfo> prependPrintingsInDeck(const QList<PrintingInfo> &sets,
|
||||
const CardInfoPtr &selectedCard,
|
||||
DeckListModel *deckModel);
|
||||
|
||||
|
|
|
|||
|
|
@ -230,9 +230,9 @@ void VisualDatabaseDisplayWidget::populateCards()
|
|||
|
||||
if (CardInfoPtr info = CardDatabaseManager::getInstance()->getCard(name.toString())) {
|
||||
if (setFilter) {
|
||||
CardInfoPerSetMap setMap = info->getSets();
|
||||
PrintingInfoPerSetMap setMap = info->getSets();
|
||||
if (setMap.contains(setFilter->term())) {
|
||||
for (CardInfoPerSet cardSetInstance : setMap[setFilter->term()]) {
|
||||
for (PrintingInfo cardSetInstance : setMap[setFilter->term()]) {
|
||||
addCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
|
||||
name.toString(), cardSetInstance.getProperty("uuid")));
|
||||
}
|
||||
|
|
@ -296,9 +296,9 @@ void VisualDatabaseDisplayWidget::loadNextPage()
|
|||
QVariant name = databaseDisplayModel->data(index, Qt::DisplayRole);
|
||||
if (CardInfoPtr info = CardDatabaseManager::getInstance()->getCard(name.toString())) {
|
||||
if (setFilter) {
|
||||
CardInfoPerSetMap setMap = info->getSets();
|
||||
PrintingInfoPerSetMap setMap = info->getSets();
|
||||
if (setMap.contains(setFilter->term())) {
|
||||
for (CardInfoPerSet cardSetInstance : setMap[setFilter->term()]) {
|
||||
for (PrintingInfo cardSetInstance : setMap[setFilter->term()]) {
|
||||
addCard(CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
|
||||
name.toString(), cardSetInstance.getProperty("uuid")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ QModelIndex DeckListModel::addPreferredPrintingCard(const QString &cardName, con
|
|||
}
|
||||
|
||||
QModelIndex DeckListModel::addCard(const QString &cardName,
|
||||
const CardInfoPerSet &cardInfoSet,
|
||||
const PrintingInfo &cardInfoSet,
|
||||
const QString &zoneName,
|
||||
bool abAddAnyway)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public:
|
|||
const QString &cardNumber = "") const;
|
||||
QModelIndex addPreferredPrintingCard(const QString &cardName, const QString &zoneName, bool abAddAnyway);
|
||||
QModelIndex addCard(const ::QString &cardName,
|
||||
const CardInfoPerSet &cardInfoSet,
|
||||
const PrintingInfo &cardInfoSet,
|
||||
const QString &zoneName,
|
||||
bool abAddAnyway = false);
|
||||
int findSortedInsertRow(InnerDecklistNode *parent, CardInfoPtr cardInfo) const;
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ struct SetProviderIdToPreferred
|
|||
void operator()(const InnerDecklistNode *node, DecklistCardNode *card) const
|
||||
{
|
||||
Q_UNUSED(node);
|
||||
CardInfoPerSet preferredSet = CardDatabaseManager::getInstance()->getSpecificSetForCard(
|
||||
PrintingInfo preferredSet = CardDatabaseManager::getInstance()->getSpecificSetForCard(
|
||||
card->getName(),
|
||||
CardDatabaseManager::getInstance()->getPreferredPrintingProviderIdForCard(card->getName()));
|
||||
QString providerId = preferredSet.getProperty("uuid");
|
||||
|
|
|
|||
|
|
@ -162,8 +162,8 @@ void DlgEditTokens::actAddToken()
|
|||
}
|
||||
|
||||
QString setName = CardSet::TOKENS_SETNAME;
|
||||
CardInfoPerSetMap sets;
|
||||
sets[setName].append(CardInfoPerSet(databaseModel->getDatabase()->getSet(setName)));
|
||||
PrintingInfoPerSetMap sets;
|
||||
sets[setName].append(PrintingInfo(databaseModel->getDatabase()->getSet(setName)));
|
||||
CardInfoPtr card = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(),
|
||||
QList<CardRelation *>(), sets, false, false, -1, false);
|
||||
card->setCardType("Token");
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ QMap<QString, int> DlgSelectSetForCards::getSetsForCards()
|
|||
if (!infoPtr)
|
||||
continue;
|
||||
|
||||
CardInfoPerSetMap infoPerSetMap = infoPtr->getSets();
|
||||
PrintingInfoPerSetMap infoPerSetMap = infoPtr->getSets();
|
||||
for (auto it = infoPerSetMap.begin(); it != infoPerSetMap.end(); ++it) {
|
||||
setCounts[it.key()]++;
|
||||
}
|
||||
|
|
@ -380,7 +380,7 @@ QMap<QString, QStringList> DlgSelectSetForCards::getCardsForSets()
|
|||
if (!infoPtr)
|
||||
continue;
|
||||
|
||||
CardInfoPerSetMap infoPerSetMap = infoPtr->getSets();
|
||||
PrintingInfoPerSetMap infoPerSetMap = infoPtr->getSets();
|
||||
for (auto it = infoPerSetMap.begin(); it != infoPerSetMap.end(); ++it) {
|
||||
setCards[it.key()].append(currentCard->getName());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ void AbstractCardItem::refreshCardInfo()
|
|||
QVariantHash properties = QVariantHash();
|
||||
|
||||
info = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(), QList<CardRelation *>(),
|
||||
CardInfoPerSetMap(), false, false, -1, false);
|
||||
PrintingInfoPerSetMap(), false, false, -1, false);
|
||||
}
|
||||
if (info.data()) {
|
||||
connect(info.data(), &CardInfo::pixmapUpdated, this, &AbstractCardItem::pixmapUpdated);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ void CardDatabase::addCard(CardInfoPtr card)
|
|||
if (cards.contains(card->getName())) {
|
||||
CardInfoPtr sameCard = cards[card->getName()];
|
||||
for (const auto &cardInfoPerSetList : card->getSets()) {
|
||||
for (const CardInfoPerSet &set : cardInfoPerSetList) {
|
||||
for (const PrintingInfo &set : cardInfoPerSetList) {
|
||||
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);
|
||||
if (!cardInfo) {
|
||||
return CardInfoPerSet(nullptr);
|
||||
return PrintingInfo(nullptr);
|
||||
}
|
||||
|
||||
CardInfoPerSetMap setMap = cardInfo->getSets();
|
||||
PrintingInfoPerSetMap setMap = cardInfo->getSets();
|
||||
if (setMap.empty()) {
|
||||
return CardInfoPerSet(nullptr);
|
||||
return PrintingInfo(nullptr);
|
||||
}
|
||||
|
||||
CardSetPtr preferredSet = nullptr;
|
||||
CardInfoPerSet preferredCard;
|
||||
PrintingInfo preferredCard;
|
||||
SetPriorityComparator comparator;
|
||||
|
||||
for (const auto &cardInfoPerSetList : setMap) {
|
||||
|
|
@ -339,19 +339,19 @@ CardInfoPerSet CardDatabase::getPreferredSetForCard(const QString &cardName) con
|
|||
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);
|
||||
if (!cardInfo) {
|
||||
return CardInfoPerSet(nullptr);
|
||||
return PrintingInfo(nullptr);
|
||||
}
|
||||
|
||||
CardInfoPerSetMap setMap = cardInfo->getSets();
|
||||
PrintingInfoPerSetMap setMap = cardInfo->getSets();
|
||||
if (setMap.empty()) {
|
||||
return CardInfoPerSet(nullptr);
|
||||
return PrintingInfo(nullptr);
|
||||
}
|
||||
|
||||
for (const auto &cardInfoPerSetList : setMap) {
|
||||
|
|
@ -366,21 +366,21 @@ CardInfoPerSet CardDatabase::getSpecificSetForCard(const QString &cardName, cons
|
|||
return getPreferredSetForCard(cardName);
|
||||
}
|
||||
|
||||
return CardInfoPerSet(nullptr);
|
||||
return PrintingInfo(nullptr);
|
||||
}
|
||||
|
||||
CardInfoPerSet CardDatabase::getSpecificSetForCard(const QString &cardName,
|
||||
const QString &setShortName,
|
||||
const QString &collectorNumber) const
|
||||
PrintingInfo CardDatabase::getSpecificSetForCard(const QString &cardName,
|
||||
const QString &setShortName,
|
||||
const QString &collectorNumber) const
|
||||
{
|
||||
CardInfoPtr cardInfo = getCard(cardName);
|
||||
if (!cardInfo) {
|
||||
return CardInfoPerSet(nullptr);
|
||||
return PrintingInfo(nullptr);
|
||||
}
|
||||
|
||||
CardInfoPerSetMap setMap = cardInfo->getSets();
|
||||
PrintingInfoPerSetMap setMap = cardInfo->getSets();
|
||||
if (setMap.empty()) {
|
||||
return CardInfoPerSet(nullptr);
|
||||
return PrintingInfo(nullptr);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
CardInfoPerSet preferredSetCardInfo = getPreferredSetForCard(cardName);
|
||||
PrintingInfo preferredSetCardInfo = getPreferredSetForCard(cardName);
|
||||
QString preferredPrintingProviderId = preferredSetCardInfo.getProperty(QString("uuid"));
|
||||
if (preferredPrintingProviderId.isEmpty()) {
|
||||
CardInfoPtr defaultCardInfo = getCard(cardName);
|
||||
|
|
@ -424,11 +424,11 @@ bool CardDatabase::isProviderIdForPreferredPrinting(const QString &cardName, con
|
|||
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()) {
|
||||
return CardInfoPerSet(nullptr);
|
||||
return PrintingInfo(nullptr);
|
||||
}
|
||||
|
||||
for (const auto &cardInfoPerSetList : setMap) {
|
||||
|
|
@ -440,7 +440,7 @@ CardInfoPerSet CardDatabase::getSetInfoForCard(const CardInfoPtr &_card)
|
|||
}
|
||||
}
|
||||
|
||||
return CardInfoPerSet(nullptr);
|
||||
return PrintingInfo(nullptr);
|
||||
}
|
||||
|
||||
void CardDatabase::refreshCachedReverseRelatedCards()
|
||||
|
|
|
|||
|
|
@ -69,9 +69,9 @@ public:
|
|||
[[nodiscard]] QList<CardInfoPtr> getCards(const QStringList &cardNames) const;
|
||||
QList<CardInfoPtr> getCardsByNameAndProviderId(const QMap<QString, QString> &cardNames) const;
|
||||
[[nodiscard]] CardInfoPtr getCardByNameAndProviderId(const QString &cardName, const QString &providerId) const;
|
||||
[[nodiscard]] CardInfoPerSet getPreferredSetForCard(const QString &cardName) const;
|
||||
[[nodiscard]] CardInfoPerSet getSpecificSetForCard(const QString &cardName, const QString &providerId) const;
|
||||
CardInfoPerSet
|
||||
[[nodiscard]] PrintingInfo getPreferredSetForCard(const QString &cardName) const;
|
||||
[[nodiscard]] PrintingInfo getSpecificSetForCard(const QString &cardName, const QString &providerId) const;
|
||||
PrintingInfo
|
||||
getSpecificSetForCard(const QString &cardName, const QString &setShortName, const QString &collectorNumber) const;
|
||||
QString getPreferredPrintingProviderIdForCard(const QString &cardName);
|
||||
[[nodiscard]] CardInfoPtr guessCard(const QString &cardName, const QString &providerId = QString()) const;
|
||||
|
|
@ -84,7 +84,7 @@ public:
|
|||
|
||||
CardSetPtr getSet(const QString &setName);
|
||||
bool isProviderIdForPreferredPrinting(const QString &cardName, const QString &providerId);
|
||||
static CardInfoPerSet getSetInfoForCard(const CardInfoPtr &_card);
|
||||
static PrintingInfo getSetInfoForCard(const CardInfoPtr &_card);
|
||||
const CardNameMap &getCardList() const
|
||||
{
|
||||
return cards;
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
|
|||
QVariantHash properties = QVariantHash();
|
||||
QString colors = QString("");
|
||||
QList<CardRelation *> relatedCards, reverseRelatedCards;
|
||||
auto _sets = CardInfoPerSetMap();
|
||||
auto _sets = PrintingInfoPerSetMap();
|
||||
int tableRow = 0;
|
||||
bool cipt = false;
|
||||
bool landscapeOrientation = false;
|
||||
|
|
@ -209,7 +209,7 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
|
|||
// NOTE: attributes must be read before readElementText()
|
||||
QXmlStreamAttributes attrs = xml.attributes();
|
||||
QString setName = xml.readElementText(QXmlStreamReader::IncludeChildElements);
|
||||
CardInfoPerSet setInfo(internalAddSet(setName));
|
||||
PrintingInfo setInfo(internalAddSet(setName));
|
||||
if (attrs.hasAttribute("muId")) {
|
||||
setInfo.setProperty("muid", attrs.value("muId").toString());
|
||||
}
|
||||
|
|
@ -343,9 +343,9 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
|
|||
}
|
||||
|
||||
// sets
|
||||
const CardInfoPerSetMap sets = info->getSets();
|
||||
const PrintingInfoPerSetMap sets = info->getSets();
|
||||
for (const auto &cardInfoPerSetList : sets) {
|
||||
for (const CardInfoPerSet &set : cardInfoPerSetList) {
|
||||
for (const PrintingInfo &set : cardInfoPerSetList) {
|
||||
xml.writeStartElement("set");
|
||||
xml.writeAttribute("rarity", set.getProperty("rarity"));
|
||||
xml.writeAttribute("muId", set.getProperty("muid"));
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
|
|||
QString text = QString("");
|
||||
QVariantHash properties = QVariantHash();
|
||||
QList<CardRelation *> relatedCards, reverseRelatedCards;
|
||||
auto _sets = CardInfoPerSetMap();
|
||||
auto _sets = PrintingInfoPerSetMap();
|
||||
int tableRow = 0;
|
||||
bool cipt = false;
|
||||
bool landscapeOrientation = false;
|
||||
|
|
@ -184,7 +184,7 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
|
|||
QString setName = xml.readElementText(QXmlStreamReader::IncludeChildElements);
|
||||
auto set = internalAddSet(setName);
|
||||
if (set->getEnabled()) {
|
||||
CardInfoPerSet setInfo(set);
|
||||
PrintingInfo setInfo(set);
|
||||
for (QXmlStreamAttribute attr : attrs) {
|
||||
QString attrName = attr.name().toString();
|
||||
if (attrName == "picURL")
|
||||
|
|
@ -310,7 +310,7 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
|
|||
|
||||
// sets
|
||||
for (const auto &cardInfoPerSetList : info->getSets()) {
|
||||
for (const CardInfoPerSet &set : cardInfoPerSetList) {
|
||||
for (const PrintingInfo &set : cardInfoPerSetList) {
|
||||
xml.writeStartElement("set");
|
||||
for (const QString &propName : set.getProperties()) {
|
||||
xml.writeAttribute(propName, set.getProperty(propName));
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
const QList<CardRelation *> &_relatedCards,
|
||||
const QList<CardRelation *> &_reverseRelatedCards,
|
||||
CardInfoPerSetMap _sets,
|
||||
PrintingInfoPerSetMap _sets,
|
||||
bool _cipt,
|
||||
bool _landscapeOrientation,
|
||||
int _tableRow,
|
||||
|
|
@ -248,7 +248,7 @@ CardInfo::~CardInfo()
|
|||
CardInfoPtr CardInfo::newInstance(const QString &_name)
|
||||
{
|
||||
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,
|
||||
|
|
@ -257,7 +257,7 @@ CardInfoPtr CardInfo::newInstance(const QString &_name,
|
|||
QVariantHash _properties,
|
||||
const QList<CardRelation *> &_relatedCards,
|
||||
const QList<CardRelation *> &_reverseRelatedCards,
|
||||
CardInfoPerSetMap _sets,
|
||||
PrintingInfoPerSetMap _sets,
|
||||
bool _cipt,
|
||||
bool _landscapeOrientation,
|
||||
int _tableRow,
|
||||
|
|
@ -268,7 +268,7 @@ CardInfoPtr CardInfo::newInstance(const QString &_name,
|
|||
ptr->setSmartPointer(ptr);
|
||||
|
||||
for (const auto &cardInfoPerSetList : _sets) {
|
||||
for (const CardInfoPerSet &set : cardInfoPerSetList) {
|
||||
for (const PrintingInfo &set : cardInfoPerSetList) {
|
||||
set.getPtr()->append(ptr);
|
||||
break;
|
||||
}
|
||||
|
|
@ -289,7 +289,7 @@ QString CardInfo::getCorrectedName() const
|
|||
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)) {
|
||||
_set->append(smartThis);
|
||||
|
|
|
|||
|
|
@ -15,14 +15,14 @@
|
|||
inline Q_LOGGING_CATEGORY(CardInfoLog, "card_info");
|
||||
|
||||
class CardInfo;
|
||||
class CardInfoPerSet;
|
||||
class PrintingInfo;
|
||||
class CardSet;
|
||||
class CardRelation;
|
||||
class ICardDatabaseParser;
|
||||
|
||||
typedef QSharedPointer<CardInfo> CardInfoPtr;
|
||||
typedef QSharedPointer<CardSet> CardSetPtr;
|
||||
typedef QMap<QString, QList<CardInfoPerSet>> CardInfoPerSetMap;
|
||||
typedef QMap<QString, QList<PrintingInfo>> PrintingInfoPerSetMap;
|
||||
|
||||
typedef QHash<QString, CardInfoPtr> CardNameMap;
|
||||
typedef QHash<QString, CardSetPtr> SetNameMap;
|
||||
|
|
@ -142,20 +142,23 @@ public:
|
|||
void defaultSort();
|
||||
};
|
||||
|
||||
class CardInfoPerSet
|
||||
/**
|
||||
* Info relating to a specific printing for a card.
|
||||
*/
|
||||
class PrintingInfo
|
||||
{
|
||||
public:
|
||||
explicit CardInfoPerSet(const CardSetPtr &_set = QSharedPointer<CardSet>(nullptr));
|
||||
~CardInfoPerSet() = default;
|
||||
explicit PrintingInfo(const CardSetPtr &_set = QSharedPointer<CardSet>(nullptr));
|
||||
~PrintingInfo() = default;
|
||||
|
||||
bool operator==(const CardInfoPerSet &other) const
|
||||
bool operator==(const PrintingInfo &other) const
|
||||
{
|
||||
return this->set == other.set && this->properties == other.properties;
|
||||
}
|
||||
|
||||
private:
|
||||
CardSetPtr set;
|
||||
// per-set card properties;
|
||||
// per-printing card properties;
|
||||
QVariantHash properties;
|
||||
|
||||
public:
|
||||
|
|
@ -201,7 +204,7 @@ private:
|
|||
// the cards thare are reverse-related to me
|
||||
QList<CardRelation *> reverseRelatedCardsToMe;
|
||||
// card sets
|
||||
CardInfoPerSetMap sets;
|
||||
PrintingInfoPerSetMap sets;
|
||||
// cached set names
|
||||
QString setsNames;
|
||||
// positioning properties; used by UI
|
||||
|
|
@ -217,7 +220,7 @@ public:
|
|||
QVariantHash _properties,
|
||||
const QList<CardRelation *> &_relatedCards,
|
||||
const QList<CardRelation *> &_reverseRelatedCards,
|
||||
CardInfoPerSetMap _sets,
|
||||
PrintingInfoPerSetMap _sets,
|
||||
bool _cipt,
|
||||
bool _landscapeOrientation,
|
||||
int _tableRow,
|
||||
|
|
@ -240,7 +243,7 @@ public:
|
|||
QVariantHash _properties,
|
||||
const QList<CardRelation *> &_relatedCards,
|
||||
const QList<CardRelation *> &_reverseRelatedCards,
|
||||
CardInfoPerSetMap _sets,
|
||||
PrintingInfoPerSetMap _sets,
|
||||
bool _cipt,
|
||||
bool _landscapeOrientation,
|
||||
int _tableRow,
|
||||
|
|
@ -308,7 +311,7 @@ public:
|
|||
{
|
||||
return properties.contains(propertyName);
|
||||
}
|
||||
const CardInfoPerSetMap &getSets() const
|
||||
const PrintingInfoPerSetMap &getSets() const
|
||||
{
|
||||
return sets;
|
||||
}
|
||||
|
|
@ -398,7 +401,7 @@ public:
|
|||
return getSetProperty(set, "picurl");
|
||||
}
|
||||
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 emitPixmapUpdated()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -129,14 +129,14 @@ static void setupParserRules()
|
|||
search["RarityQuery"] = [](const peg::SemanticValues &sv) -> Filter {
|
||||
const auto rarity = std::any_cast<QString>(sv[0]);
|
||||
return [=](const CardData &x) -> bool {
|
||||
QList<CardInfoPerSet> infos;
|
||||
QList<PrintingInfo> infos;
|
||||
for (const auto &setsValue : x->getSets().values()) {
|
||||
for (const auto &cardInfoPerSet : setsValue) {
|
||||
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);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public:
|
|||
* Enabled sets have priority over disabled sets
|
||||
* 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()) {
|
||||
return !b.getPtr()->getEnabled() || a.getPtr()->getSortKey() < b.getPtr()->getSortKey();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
SplitCardPart::SplitCardPart(const QString &_name,
|
||||
const QString &_text,
|
||||
const QVariantHash &_properties,
|
||||
const CardInfoPerSet &_setInfo)
|
||||
const PrintingInfo &_setInfo)
|
||||
: name(_name), text(_text), properties(_properties), setInfo(_setInfo)
|
||||
{
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ CardInfoPtr OracleImporter::addCard(QString name,
|
|||
bool isToken,
|
||||
QVariantHash properties,
|
||||
const QList<CardRelation *> &relatedCards,
|
||||
const CardInfoPerSet &setInfo)
|
||||
const PrintingInfo &setInfo)
|
||||
{
|
||||
// Workaround for card name weirdness
|
||||
name = name.replace("Æ", "AE");
|
||||
|
|
@ -200,7 +200,7 @@ CardInfoPtr OracleImporter::addCard(QString name,
|
|||
|
||||
// insert the card and its properties
|
||||
QList<CardRelation *> reverseRelatedCards;
|
||||
CardInfoPerSetMap setsInfo;
|
||||
PrintingInfoPerSetMap setsInfo;
|
||||
setsInfo[setInfo.getPtr()->getShortName()].append(setInfo);
|
||||
CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards,
|
||||
setsInfo, cipt, landscapeOrientation, tableRow, upsideDown);
|
||||
|
|
@ -242,7 +242,7 @@ int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet, const QList
|
|||
static constexpr bool isToken = false;
|
||||
static const QList<QString> setsWithCardsWithSameNameButDifferentText = {"UST"};
|
||||
QVariantHash properties;
|
||||
CardInfoPerSet setInfo;
|
||||
PrintingInfo setInfo;
|
||||
QList<CardRelation *> relatedCards;
|
||||
QList<QString> allNameProps;
|
||||
|
||||
|
|
@ -281,7 +281,7 @@ int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet, const QList
|
|||
}
|
||||
|
||||
// per-set properties
|
||||
setInfo = CardInfoPerSet(currentSet);
|
||||
setInfo = PrintingInfo(currentSet);
|
||||
QMapIterator it2(setInfoProperties);
|
||||
while (it2.hasNext()) {
|
||||
it2.next();
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public:
|
|||
SplitCardPart(const QString &_name,
|
||||
const QString &_text,
|
||||
const QVariantHash &_properties,
|
||||
const CardInfoPerSet &setInfo);
|
||||
const PrintingInfo &setInfo);
|
||||
inline const QString &getName() const
|
||||
{
|
||||
return name;
|
||||
|
|
@ -108,7 +108,7 @@ public:
|
|||
{
|
||||
return properties;
|
||||
}
|
||||
inline const CardInfoPerSet &getSetInfo() const
|
||||
inline const PrintingInfo &getSetInfo() const
|
||||
{
|
||||
return setInfo;
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ private:
|
|||
QString name;
|
||||
QString text;
|
||||
QVariantHash properties;
|
||||
CardInfoPerSet setInfo;
|
||||
PrintingInfo setInfo;
|
||||
};
|
||||
|
||||
class OracleImporter : public QObject
|
||||
|
|
@ -143,7 +143,7 @@ private:
|
|||
bool isToken,
|
||||
QVariantHash properties,
|
||||
const QList<CardRelation *> &relatedCards,
|
||||
const CardInfoPerSet &setInfo);
|
||||
const PrintingInfo &setInfo);
|
||||
signals:
|
||||
void setIndexChanged(int cardsImported, int setIndex, const QString &setName);
|
||||
void dataReadProgress(int bytesRead, int totalBytes);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue