mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-11 12:33:25 -08:00
Fix signatures
This commit is contained in:
parent
598da954fc
commit
d8213088e4
66 changed files with 143 additions and 132 deletions
|
|
@ -108,7 +108,7 @@ void DeckStatsInterface::analyzeDeck(const DeckList &deck)
|
||||||
void DeckStatsInterface::copyDeckWithoutTokens(const DeckList &source, DeckList &destination)
|
void DeckStatsInterface::copyDeckWithoutTokens(const DeckList &source, DeckList &destination)
|
||||||
{
|
{
|
||||||
auto copyIfNotAToken = [&destination](const auto node, const auto card) {
|
auto copyIfNotAToken = [&destination](const auto node, const auto card) {
|
||||||
CardInfoPtr dbCard = CardDatabaseManager::query()->getCardInfo(card->getName());
|
CardInfoPtr dbCard = CardDatabaseManager::query().getCardInfo(card->getName());
|
||||||
// Missing local card data is not evidence that a card is a token. Keep
|
// Missing local card data is not evidence that a card is a token. Keep
|
||||||
// its original name and quantity so the service analyzes the whole deck.
|
// its original name and quantity so the service analyzes the whole deck.
|
||||||
if ((!dbCard || !dbCard->getIsToken()) && node->getName() != DECK_ZONE_MAYBEBOARD) {
|
if ((!dbCard || !dbCard->getIsToken()) && node->getName() != DECK_ZONE_MAYBEBOARD) {
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ void TappedOutInterface::analyzeDeck(const DeckList &deck)
|
||||||
void TappedOutInterface::copyDeckSplitMainAndSide(const DeckList &source, DeckList &mainboard, DeckList &sideboard)
|
void TappedOutInterface::copyDeckSplitMainAndSide(const DeckList &source, DeckList &mainboard, DeckList &sideboard)
|
||||||
{
|
{
|
||||||
auto copyMainOrSide = [&mainboard, &sideboard](const auto node, const auto card) {
|
auto copyMainOrSide = [&mainboard, &sideboard](const auto node, const auto card) {
|
||||||
CardInfoPtr dbCard = CardDatabaseManager::query()->getCardInfo(card->getName());
|
CardInfoPtr dbCard = CardDatabaseManager::query().getCardInfo(card->getName());
|
||||||
// Exclude confirmed tokens, but preserve cards missing from the local
|
// Exclude confirmed tokens, but preserve cards missing from the local
|
||||||
// database, including newly released cards in an imported deck.
|
// database, including newly released cards in an imported deck.
|
||||||
if ((dbCard && dbCard->getIsToken()) || node->getName() == DECK_ZONE_MAYBEBOARD) {
|
if ((dbCard && dbCard->getIsToken()) || node->getName() == DECK_ZONE_MAYBEBOARD) {
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ static void setupParserRules()
|
||||||
int count = 0;
|
int count = 0;
|
||||||
auto cardNodes = data.deck->deckList.getCardNodes();
|
auto cardNodes = data.deck->deckList.getCardNodes();
|
||||||
for (auto node : cardNodes) {
|
for (auto node : cardNodes) {
|
||||||
auto cardInfoPtr = CardDatabaseManager::query()->getCardInfo(node->getName());
|
auto cardInfoPtr = CardDatabaseManager::query().getCardInfo(node->getName());
|
||||||
if (!cardInfoPtr.isNull() && cardFilter.check(cardInfoPtr)) {
|
if (!cardInfoPtr.isNull() && cardFilter.check(cardInfoPtr)) {
|
||||||
count += node->getNumber();
|
count += node->getNumber();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -413,7 +413,7 @@ void DeckViewContainer::deckSelectFinished(const Response &r)
|
||||||
{
|
{
|
||||||
const Response_DeckDownload &resp = r.GetExtension(Response_DeckDownload::ext);
|
const Response_DeckDownload &resp = r.GetExtension(Response_DeckDownload::ext);
|
||||||
DeckList newDeck = DeckList(QString::fromStdString(resp.deck()));
|
DeckList newDeck = DeckList(QString::fromStdString(resp.deck()));
|
||||||
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query()->getCards(newDeck.getCardRefList()));
|
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query().getCards(newDeck.getCardRefList()));
|
||||||
setDeck(newDeck);
|
setDeck(newDeck);
|
||||||
switchToDeckLoadedView();
|
switchToDeckLoadedView();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ void DlgCreateToken::tokenSelectionChanged(const QModelIndex ¤t, const QMo
|
||||||
annotationEdit->setText("");
|
annotationEdit->setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
pic->setCard(CardDatabaseManager::query()->getPreferredCard(cardInfo));
|
pic->setCard(CardDatabaseManager::query().getPreferredCard(cardInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DlgCreateToken::updateSearchFieldWithoutUpdatingFilter(const QString &newValue) const
|
void DlgCreateToken::updateSearchFieldWithoutUpdatingFilter(const QString &newValue) const
|
||||||
|
|
|
||||||
|
|
@ -403,7 +403,7 @@ void CardMenu::addRelatedCardView()
|
||||||
bool atLeastOneGoodRelationFound = false;
|
bool atLeastOneGoodRelationFound = false;
|
||||||
QList<CardRelation *> relatedCards = exactCard.getInfo().getAllRelatedCards();
|
QList<CardRelation *> relatedCards = exactCard.getInfo().getAllRelatedCards();
|
||||||
for (const CardRelation *cardRelation : relatedCards) {
|
for (const CardRelation *cardRelation : relatedCards) {
|
||||||
CardInfoPtr relatedCard = CardDatabaseManager::query()->getCardInfo(cardRelation->getName());
|
CardInfoPtr relatedCard = CardDatabaseManager::query().getCardInfo(cardRelation->getName());
|
||||||
if (relatedCard != nullptr) {
|
if (relatedCard != nullptr) {
|
||||||
atLeastOneGoodRelationFound = true;
|
atLeastOneGoodRelationFound = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -448,9 +448,9 @@ void CardMenu::addRelatedCardActions()
|
||||||
QAction *createRelatedCards = nullptr;
|
QAction *createRelatedCards = nullptr;
|
||||||
for (const CardRelation *cardRelation : relatedCards) {
|
for (const CardRelation *cardRelation : relatedCards) {
|
||||||
ExactCard relatedCard =
|
ExactCard relatedCard =
|
||||||
CardDatabaseManager::query()->getCardFromSameSet(cardRelation->getName(), card->getCard().getPrinting());
|
CardDatabaseManager::query().getCardFromSameSet(cardRelation->getName(), card->getCard().getPrinting());
|
||||||
if (!relatedCard) {
|
if (!relatedCard) {
|
||||||
relatedCard = CardDatabaseManager::query()->getCard({cardRelation->getName()});
|
relatedCard = CardDatabaseManager::query().getCard({cardRelation->getName()});
|
||||||
}
|
}
|
||||||
if (!relatedCard) {
|
if (!relatedCard) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -461,7 +461,7 @@ void PlayerGraphicsItem::updatePlaymat()
|
||||||
playmatParams = params;
|
playmatParams = params;
|
||||||
scaledPlaymatKey = QSize(); // the art crop depends on the params, drop any cached scale
|
scaledPlaymatKey = QSize(); // the art crop depends on the params, drop any cached scale
|
||||||
|
|
||||||
ExactCard card = CardDatabaseManager::query()->getCard(playmatCard);
|
ExactCard card = CardDatabaseManager::query().getCard(playmatCard);
|
||||||
if (!card) {
|
if (!card) {
|
||||||
clearPlaymat();
|
clearPlaymat();
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ inline QString displayNameFor(const QString &cardName)
|
||||||
if (cardName.isEmpty()) {
|
if (cardName.isEmpty()) {
|
||||||
return cardName;
|
return cardName;
|
||||||
}
|
}
|
||||||
const QString localizedName = displayName(CardDatabaseManager::query()->getCardInfo(cardName));
|
const QString localizedName = displayName(CardDatabaseManager::query().getCardInfo(cardName));
|
||||||
return localizedName.isEmpty() ? cardName : localizedName;
|
return localizedName.isEmpty() ? cardName : localizedName;
|
||||||
}
|
}
|
||||||
} // namespace CardLocalization
|
} // namespace CardLocalization
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
void CardNodeFunction::SetProviderIdToPreferred::operator()(const InnerDecklistNode *node, DecklistCardNode *card) const
|
void CardNodeFunction::SetProviderIdToPreferred::operator()(const InnerDecklistNode *node, DecklistCardNode *card) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(node);
|
Q_UNUSED(node);
|
||||||
PrintingInfo preferredPrinting = CardDatabaseManager::query()->getPreferredPrinting(card->getName());
|
PrintingInfo preferredPrinting = CardDatabaseManager::query().getPreferredPrinting(card->getName());
|
||||||
CardSetPtr preferredSet = preferredPrinting.getSet();
|
CardSetPtr preferredSet = preferredPrinting.getSet();
|
||||||
if (!preferredSet) {
|
if (!preferredSet) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -40,7 +40,7 @@ void CardNodeFunction::ResolveProviderId::operator()(const InnerDecklistNode *no
|
||||||
QString providerId =
|
QString providerId =
|
||||||
CardDatabaseManager::getInstance()
|
CardDatabaseManager::getInstance()
|
||||||
->query()
|
->query()
|
||||||
->getSpecificPrinting(card->getName(), card->getCardSetShortName(), card->getCardCollectorNumber())
|
.getSpecificPrinting(card->getName(), card->getCardSetShortName(), card->getCardCollectorNumber())
|
||||||
.getUuid();
|
.getUuid();
|
||||||
|
|
||||||
// Set the providerId on the card
|
// Set the providerId on the card
|
||||||
|
|
|
||||||
|
|
@ -433,7 +433,7 @@ void DeckLoader::saveToStream_DeckZone(QTextStream &out,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(card->getName());
|
CardInfoPtr info = CardDatabaseManager::query().getCardInfo(card->getName());
|
||||||
QString cardType = info ? info->getMainCardType() : "unknown";
|
QString cardType = info ? info->getMainCardType() : "unknown";
|
||||||
|
|
||||||
cardsByType.insert(cardType, card);
|
cardsByType.insert(cardType, card);
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ Intent *IntentUrlParser::createOpenDeckIntent(const QUrlQuery &query, PendingInt
|
||||||
// The open deck intent owns the context and the credential lookup; once
|
// The open deck intent owns the context and the credential lookup; once
|
||||||
// the chain finishes (or fails) it deletes the whole tree.
|
// the chain finishes (or fails) it deletes the whole tree.
|
||||||
auto openDeckIntent =
|
auto openDeckIntent =
|
||||||
new IntentOpenSharedDeck(mainWindow->getTabSupervisor(), client, CardDatabaseManager::query(), std::move(ctx));
|
new IntentOpenSharedDeck(mainWindow->getTabSupervisor(), client, &CardDatabaseManager::query(), std::move(ctx));
|
||||||
openDeckIntent->setParent(this);
|
openDeckIntent->setParent(this);
|
||||||
chain.intents.append(openDeckIntent);
|
chain.intents.append(openDeckIntent);
|
||||||
connect(openDeckIntent, &Intent::failed, this, [showError](const QString &reason) { showError(reason); });
|
connect(openDeckIntent, &Intent::failed, this, [showError](const QString &reason) { showError(reason); });
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#include <libcockatrice/deck_list/deck_list.h>
|
#include <libcockatrice/deck_list/deck_list.h>
|
||||||
#include <libcockatrice/deck_list/tree/inner_deck_list_node.h>
|
#include <libcockatrice/deck_list/tree/inner_deck_list_node.h>
|
||||||
|
|
||||||
QString getDeckColorIdentity(const DeckList &deck, const CardDatabaseQuerier *db)
|
QString getDeckColorIdentity(const DeckList &deck, const CardDatabaseQuerier &db)
|
||||||
{
|
{
|
||||||
const QStringList cardList = deck.getCardList({DECK_ZONE_MAIN, DECK_ZONE_SIDE});
|
const QStringList cardList = deck.getCardList({DECK_ZONE_MAIN, DECK_ZONE_SIDE});
|
||||||
if (cardList.isEmpty()) {
|
if (cardList.isEmpty()) {
|
||||||
|
|
@ -20,7 +20,7 @@ QString getDeckColorIdentity(const DeckList &deck, const CardDatabaseQuerier *db
|
||||||
QSet<QChar> colorSet; // A set to collect unique color symbols (e.g., W, U, B, R, G)
|
QSet<QChar> colorSet; // A set to collect unique color symbols (e.g., W, U, B, R, G)
|
||||||
|
|
||||||
for (const QString &cardName : cardList) {
|
for (const QString &cardName : cardList) {
|
||||||
CardInfoPtr currentCard = db->getCardInfo(cardName);
|
CardInfoPtr currentCard = db.getCardInfo(cardName);
|
||||||
if (currentCard) {
|
if (currentCard) {
|
||||||
const QString colors = currentCard->getColors(); // returns something like "WUB"
|
const QString colors = currentCard->getColors(); // returns something like "WUB"
|
||||||
for (const QChar &color : colors) {
|
for (const QChar &color : colors) {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,6 @@ class DeckList;
|
||||||
*
|
*
|
||||||
* @param db Card database used to look up card color symbols.
|
* @param db Card database used to look up card color symbols.
|
||||||
*/
|
*/
|
||||||
QString getDeckColorIdentity(const DeckList &deck, const CardDatabaseQuerier *db);
|
QString getDeckColorIdentity(const DeckList &deck, const CardDatabaseQuerier &db);
|
||||||
|
|
||||||
#endif // COCKATRICE_DECK_COLOR_IDENTITY_H
|
#endif // COCKATRICE_DECK_COLOR_IDENTITY_H
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ QWidget *CardGroupDisplayWidget::constructWidgetForIndex(QPersistentModelIndex i
|
||||||
|
|
||||||
auto widget = new CardInfoPictureWithTextOverlayWidget(getLayoutParent(), true);
|
auto widget = new CardInfoPictureWithTextOverlayWidget(getLayoutParent(), true);
|
||||||
widget->setScaleFactor(cardSizeWidget->getSlider()->value());
|
widget->setScaleFactor(cardSizeWidget->getSlider()->value());
|
||||||
widget->setCard(CardDatabaseManager::query()->getCard({cardName, cardProviderId}));
|
widget->setCard(CardDatabaseManager::query().getCard({cardName, cardProviderId}));
|
||||||
|
|
||||||
connect(widget, &CardInfoPictureWithTextOverlayWidget::cardClicked, this, &CardGroupDisplayWidget::cardClicked);
|
connect(widget, &CardInfoPictureWithTextOverlayWidget::cardClicked, this, &CardGroupDisplayWidget::cardClicked);
|
||||||
connect(widget, &CardInfoPictureWithTextOverlayWidget::hoveredOnCard, this, &CardGroupDisplayWidget::cardHovered);
|
connect(widget, &CardInfoPictureWithTextOverlayWidget::hoveredOnCard, this, &CardGroupDisplayWidget::cardHovered);
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ void CardInfoDisplayWidget::setCard(const ExactCard &card)
|
||||||
|
|
||||||
void CardInfoDisplayWidget::setCard(const CardRef &cardRef)
|
void CardInfoDisplayWidget::setCard(const CardRef &cardRef)
|
||||||
{
|
{
|
||||||
setCard(CardDatabaseManager::query()->guessCard(cardRef));
|
setCard(CardDatabaseManager::query().guessCard(cardRef));
|
||||||
if (exactCard.isEmpty()) {
|
if (exactCard.isEmpty()) {
|
||||||
text->setInvalidCardName(cardRef.name);
|
text->setInvalidCardName(cardRef.name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -170,12 +170,12 @@ void CardInfoFrameWidget::setCard(const ExactCard &card)
|
||||||
|
|
||||||
void CardInfoFrameWidget::setCard(const QString &cardName)
|
void CardInfoFrameWidget::setCard(const QString &cardName)
|
||||||
{
|
{
|
||||||
setCard(CardDatabaseManager::query()->guessCard({cardName}));
|
setCard(CardDatabaseManager::query().guessCard({cardName}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardInfoFrameWidget::setCard(const CardRef &cardRef)
|
void CardInfoFrameWidget::setCard(const CardRef &cardRef)
|
||||||
{
|
{
|
||||||
setCard(CardDatabaseManager::query()->getCard(cardRef));
|
setCard(CardDatabaseManager::query().getCard(cardRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardInfoFrameWidget::setCard(AbstractCardItem *card)
|
void CardInfoFrameWidget::setCard(AbstractCardItem *card)
|
||||||
|
|
|
||||||
|
|
@ -398,7 +398,7 @@ QMenu *CardInfoPictureWidget::createViewRelatedCardsMenu()
|
||||||
QList<CardRelation *> relatedCards = exactCard.getInfo().getAllRelatedCards();
|
QList<CardRelation *> relatedCards = exactCard.getInfo().getAllRelatedCards();
|
||||||
|
|
||||||
auto relatedCardExists = [](const CardRelation *cardRelation) {
|
auto relatedCardExists = [](const CardRelation *cardRelation) {
|
||||||
return CardDatabaseManager::query()->getCardInfo(cardRelation->getName()) != nullptr;
|
return CardDatabaseManager::query().getCardInfo(cardRelation->getName()) != nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool atLeastOneGoodRelationFound = std::any_of(relatedCards.begin(), relatedCards.end(), relatedCardExists);
|
bool atLeastOneGoodRelationFound = std::any_of(relatedCards.begin(), relatedCards.end(), relatedCardExists);
|
||||||
|
|
@ -413,7 +413,7 @@ QMenu *CardInfoPictureWidget::createViewRelatedCardsMenu()
|
||||||
QAction *viewCard = viewRelatedCards->addAction(relatedCardName);
|
QAction *viewCard = viewRelatedCards->addAction(relatedCardName);
|
||||||
connect(viewCard, &QAction::triggered, this, [this, &relatedCardName] {
|
connect(viewCard, &QAction::triggered, this, [this, &relatedCardName] {
|
||||||
emit cardChanged(
|
emit cardChanged(
|
||||||
CardDatabaseManager::query()->getCard({relatedCardName, exactCard.getPrinting().getUuid()}));
|
CardDatabaseManager::query().getCard({relatedCardName, exactCard.getPrinting().getUuid()}));
|
||||||
});
|
});
|
||||||
viewRelatedCards->addAction(viewCard);
|
viewRelatedCards->addAction(viewCard);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ QList<QString> DeckCardZoneDisplayWidget::getGroupCriteriaValueList()
|
||||||
QList<const DecklistCardNode *> nodes = deckListModel->getCardNodesForZone(zoneName);
|
QList<const DecklistCardNode *> nodes = deckListModel->getCardNodesForZone(zoneName);
|
||||||
|
|
||||||
for (auto node : nodes) {
|
for (auto node : nodes) {
|
||||||
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(node->getName());
|
CardInfoPtr info = CardDatabaseManager::query().getCardInfo(node->getName());
|
||||||
if (info) {
|
if (info) {
|
||||||
groupCriteriaValues.append(info->getProperty(activeGroupCriteria));
|
groupCriteriaValues.append(info->getProperty(activeGroupCriteria));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ void DrawProbabilityWidget::updateFilterOptions()
|
||||||
|
|
||||||
const auto nodes = analyzer->getModel()->getCardNodes();
|
const auto nodes = analyzer->getModel()->getCardNodes();
|
||||||
for (auto *node : nodes) {
|
for (auto *node : nodes) {
|
||||||
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(node->getName());
|
CardInfoPtr info = CardDatabaseManager::query().getCardInfo(node->getName());
|
||||||
if (!info) {
|
if (!info) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ void DeckListStatisticsAnalyzer::analyze()
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto node : nodes) {
|
for (auto node : nodes) {
|
||||||
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(node->getName());
|
CardInfoPtr info = CardDatabaseManager::query().getCardInfo(node->getName());
|
||||||
if (!info) {
|
if (!info) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ void CardDatabaseView::saveDbHeaderState()
|
||||||
|
|
||||||
void CardDatabaseView::openCustomMenu(QPoint point)
|
void CardDatabaseView::openCustomMenu(QPoint point)
|
||||||
{
|
{
|
||||||
CardInfoPtr card = CardDatabaseManager::query()->getCardInfo(currentCardName());
|
CardInfoPtr card = CardDatabaseManager::query().getCardInfo(currentCardName());
|
||||||
|
|
||||||
if (!card) {
|
if (!card) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -125,19 +125,19 @@ void DeckEditorDatabaseDisplayWidget::actAddCardToSideboard()
|
||||||
void DeckEditorDatabaseDisplayWidget::addCard(const QString &cardName, const QString &zoneName)
|
void DeckEditorDatabaseDisplayWidget::addCard(const QString &cardName, const QString &zoneName)
|
||||||
{
|
{
|
||||||
highlightAllSearchEdit();
|
highlightAllSearchEdit();
|
||||||
ExactCard exactCard = CardDatabaseManager::query()->getPreferredCard(cardName);
|
ExactCard exactCard = CardDatabaseManager::query().getPreferredCard(cardName);
|
||||||
emit cardAdded(exactCard, zoneName);
|
emit cardAdded(exactCard, zoneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckEditorDatabaseDisplayWidget::decrementCard(const QString &cardName, const QString &zoneName)
|
void DeckEditorDatabaseDisplayWidget::decrementCard(const QString &cardName, const QString &zoneName)
|
||||||
{
|
{
|
||||||
ExactCard exactCard = CardDatabaseManager::query()->getPreferredCard(cardName);
|
ExactCard exactCard = CardDatabaseManager::query().getPreferredCard(cardName);
|
||||||
emit cardDecremented(exactCard, zoneName);
|
emit cardDecremented(exactCard, zoneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckEditorDatabaseDisplayWidget::updateCard(const QString &cardName)
|
void DeckEditorDatabaseDisplayWidget::updateCard(const QString &cardName)
|
||||||
{
|
{
|
||||||
ExactCard exactCard = CardDatabaseManager::query()->getPreferredCard(cardName);
|
ExactCard exactCard = CardDatabaseManager::query().getPreferredCard(cardName);
|
||||||
emit cardChanged(exactCard);
|
emit cardChanged(exactCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,6 +159,6 @@ void DeckEditorDatabaseDisplayWidget::highlightAllSearchEdit()
|
||||||
|
|
||||||
void DeckEditorDatabaseDisplayWidget::onRelatedCardClicked(const QString &relatedCard)
|
void DeckEditorDatabaseDisplayWidget::onRelatedCardClicked(const QString &relatedCard)
|
||||||
{
|
{
|
||||||
ExactCard exactCard = CardDatabaseManager::query()->guessCard({relatedCard});
|
ExactCard exactCard = CardDatabaseManager::query().guessCard({relatedCard});
|
||||||
emit cardInfoRequested(exactCard);
|
emit cardInfoRequested(exactCard);
|
||||||
}
|
}
|
||||||
|
|
@ -361,7 +361,7 @@ void DeckEditorDeckDockWidget::createDeckDock()
|
||||||
|
|
||||||
void DeckEditorDeckDockWidget::initializeFormats()
|
void DeckEditorDeckDockWidget::initializeFormats()
|
||||||
{
|
{
|
||||||
QStringList allFormats = CardDatabaseManager::query()->getAllFormatsWithCount().keys();
|
QStringList allFormats = CardDatabaseManager::query().getAllFormatsWithCount().keys();
|
||||||
|
|
||||||
// Rebuilding the list is a view update, not a user edit. In particular,
|
// Rebuilding the list is a view update, not a user edit. In particular,
|
||||||
// clear() emits currentIndexChanged(-1), which must not clear the deck.
|
// clear() emits currentIndexChanged(-1), which must not clear the deck.
|
||||||
|
|
@ -413,7 +413,7 @@ ExactCard DeckEditorDeckDockWidget::getCurrentCard()
|
||||||
const QString zoneName = gparent.siblingAtColumn(DeckListModelColumns::CARD_NAME).data(Qt::EditRole).toString();
|
const QString zoneName = gparent.siblingAtColumn(DeckListModelColumns::CARD_NAME).data(Qt::EditRole).toString();
|
||||||
|
|
||||||
if (!current.model()->hasChildren(current.siblingAtColumn(DeckListModelColumns::CARD_AMOUNT))) {
|
if (!current.model()->hasChildren(current.siblingAtColumn(DeckListModelColumns::CARD_AMOUNT))) {
|
||||||
if (ExactCard selectedCard = CardDatabaseManager::query()->getCard({cardName, cardProviderID})) {
|
if (ExactCard selectedCard = CardDatabaseManager::query().getCard({cardName, cardProviderID})) {
|
||||||
return selectedCard;
|
return selectedCard;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -466,7 +466,7 @@ void DeckEditorDeckDockWidget::updateBannerCardComboBox()
|
||||||
QList<CardRef> cardsInDeck = getModel()->getCardRefs();
|
QList<CardRef> cardsInDeck = getModel()->getCardRefs();
|
||||||
|
|
||||||
for (auto cardRef : cardsInDeck) {
|
for (auto cardRef : cardsInDeck) {
|
||||||
if (!CardDatabaseManager::query()->getCard(cardRef)) {
|
if (!CardDatabaseManager::query().getCard(cardRef)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ static bool doSwapCard(DeckListModel *model,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ExactCard card = CardDatabaseManager::query()->getCard({cardName, providerId})) {
|
if (ExactCard card = CardDatabaseManager::query().getCard({cardName, providerId})) {
|
||||||
model->addCard(card, otherZone);
|
model->addCard(card, otherZone);
|
||||||
} else {
|
} else {
|
||||||
// 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
|
||||||
|
|
@ -367,7 +367,7 @@ bool DeckStateManager::moveCardToZone(const QModelIndex &idx, const QString &tar
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tokens only live in the tokens zone and cannot be moved into decks.
|
// Tokens only live in the tokens zone and cannot be moved into decks.
|
||||||
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(cardName);
|
CardInfoPtr info = CardDatabaseManager::query().getCardInfo(cardName);
|
||||||
if (info && info->getIsToken()) {
|
if (info && info->getIsToken()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -398,7 +398,7 @@ bool DeckStateManager::moveCardToZone(const QModelIndex &idx, const QString &tar
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ExactCard card = CardDatabaseManager::query()->getCard({cardName, providerId})) {
|
if (ExactCard card = CardDatabaseManager::query().getCard({cardName, providerId})) {
|
||||||
for (int i = 0; i < copies; ++i) {
|
for (int i = 0; i < copies; ++i) {
|
||||||
model->addCard(card, targetZoneName);
|
model->addCard(card, targetZoneName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ void DlgEditTokens::actAddToken()
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (databaseModel->getDatabase()->query()->getCardInfo(name)) {
|
if (databaseModel->getDatabase()->query().getCardInfo(name)) {
|
||||||
QMessageBox::critical(this, tr("Error"),
|
QMessageBox::critical(this, tr("Error"),
|
||||||
tr("The chosen name conflicts with an existing card or token.\nMake sure to enable "
|
tr("The chosen name conflicts with an existing card or token.\nMake sure to enable "
|
||||||
"the 'Token' set in the \"Manage sets\" dialog to display them correctly."));
|
"the 'Token' set in the \"Manage sets\" dialog to display them correctly."));
|
||||||
|
|
|
||||||
|
|
@ -176,8 +176,8 @@ static bool swapPrinting(DeckListModel *model, const QString &modifiedSet, const
|
||||||
}
|
}
|
||||||
int amount = model->data(idx.siblingAtColumn(DeckListModelColumns::CARD_AMOUNT), Qt::DisplayRole).toInt();
|
int amount = model->data(idx.siblingAtColumn(DeckListModelColumns::CARD_AMOUNT), Qt::DisplayRole).toInt();
|
||||||
model->removeCardAtIndex(idx);
|
model->removeCardAtIndex(idx);
|
||||||
CardInfoPtr cardInfo = CardDatabaseManager::query()->getCardInfo(cardName);
|
CardInfoPtr cardInfo = CardDatabaseManager::query().getCardInfo(cardName);
|
||||||
PrintingInfo printing = CardDatabaseManager::query()->getSpecificPrinting(cardName, modifiedSet, "");
|
PrintingInfo printing = CardDatabaseManager::query().getSpecificPrinting(cardName, modifiedSet, "");
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
model->addCard(ExactCard(cardInfo, printing), DECK_ZONE_MAIN);
|
model->addCard(ExactCard(cardInfo, printing), DECK_ZONE_MAIN);
|
||||||
}
|
}
|
||||||
|
|
@ -259,7 +259,7 @@ QMap<QString, int> DlgSelectSetForCards::getSetsForCards()
|
||||||
QList<QString> cardNames = deckStateManager->getModel()->getCardNames();
|
QList<QString> cardNames = deckStateManager->getModel()->getCardNames();
|
||||||
|
|
||||||
for (auto cardName : cardNames) {
|
for (auto cardName : cardNames) {
|
||||||
CardInfoPtr infoPtr = CardDatabaseManager::query()->getCardInfo(cardName);
|
CardInfoPtr infoPtr = CardDatabaseManager::query().getCardInfo(cardName);
|
||||||
if (!infoPtr) {
|
if (!infoPtr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -313,16 +313,16 @@ void DlgSelectSetForCards::updateCardLists()
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
// The card was not in any selected set
|
// The card was not in any selected set
|
||||||
ExactCard card = CardDatabaseManager::query()->getCard({cardName});
|
ExactCard card = CardDatabaseManager::query().getCard({cardName});
|
||||||
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(uneditedCardsFlowWidget);
|
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(uneditedCardsFlowWidget);
|
||||||
picture_widget->setCard(card);
|
picture_widget->setCard(card);
|
||||||
uneditedCardsFlowWidget->addWidget(picture_widget);
|
uneditedCardsFlowWidget->addWidget(picture_widget);
|
||||||
} else {
|
} else {
|
||||||
ExactCard card =
|
ExactCard card =
|
||||||
CardDatabaseManager::query()->getCard({cardName, CardDatabaseManager::getInstance()
|
CardDatabaseManager::query().getCard({cardName, CardDatabaseManager::getInstance()
|
||||||
->query()
|
->query()
|
||||||
->getSpecificPrinting(cardName, foundSetName, "")
|
.getSpecificPrinting(cardName, foundSetName, "")
|
||||||
.getUuid()});
|
.getUuid()});
|
||||||
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(modifiedCardsFlowWidget);
|
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(modifiedCardsFlowWidget);
|
||||||
picture_widget->setCard(card);
|
picture_widget->setCard(card);
|
||||||
modifiedCardsFlowWidget->addWidget(picture_widget);
|
modifiedCardsFlowWidget->addWidget(picture_widget);
|
||||||
|
|
@ -378,7 +378,7 @@ QMap<QString, QStringList> DlgSelectSetForCards::getCardsForSets()
|
||||||
QList<QString> cardNames = deckStateManager->getModel()->getCardNames();
|
QList<QString> cardNames = deckStateManager->getModel()->getCardNames();
|
||||||
|
|
||||||
for (auto cardName : cardNames) {
|
for (auto cardName : cardNames) {
|
||||||
CardInfoPtr infoPtr = CardDatabaseManager::query()->getCardInfo(cardName);
|
CardInfoPtr infoPtr = CardDatabaseManager::query().getCardInfo(cardName);
|
||||||
if (!infoPtr) {
|
if (!infoPtr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -625,15 +625,15 @@ void SetEntryWidget::updateCardDisplayWidgets()
|
||||||
|
|
||||||
for (const QString &cardName : possibleCards) {
|
for (const QString &cardName : possibleCards) {
|
||||||
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(cardListContainer);
|
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(cardListContainer);
|
||||||
QString providerId = CardDatabaseManager::query()->getSpecificPrinting(cardName, setName, nullptr).getUuid();
|
QString providerId = CardDatabaseManager::query().getSpecificPrinting(cardName, setName, nullptr).getUuid();
|
||||||
picture_widget->setCard(CardDatabaseManager::query()->getCard({cardName, providerId}));
|
picture_widget->setCard(CardDatabaseManager::query().getCard({cardName, providerId}));
|
||||||
cardListContainer->addWidget(picture_widget);
|
cardListContainer->addWidget(picture_widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const QString &cardName : unusedCards) {
|
for (const QString &cardName : unusedCards) {
|
||||||
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(alreadySelectedCardListContainer);
|
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(alreadySelectedCardListContainer);
|
||||||
QString providerId = CardDatabaseManager::query()->getSpecificPrinting(cardName, setName, nullptr).getUuid();
|
QString providerId = CardDatabaseManager::query().getSpecificPrinting(cardName, setName, nullptr).getUuid();
|
||||||
picture_widget->setCard(CardDatabaseManager::query()->getCard({cardName, providerId}));
|
picture_widget->setCard(CardDatabaseManager::query().getCard({cardName, providerId}));
|
||||||
alreadySelectedCardListContainer->addWidget(picture_widget);
|
alreadySelectedCardListContainer->addWidget(picture_widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ void HomeWidget::setRandomCard(ExactCard &newCard)
|
||||||
{
|
{
|
||||||
static constexpr int ATTEMPTS = 10;
|
static constexpr int ATTEMPTS = 10;
|
||||||
for (int i = 0; i < ATTEMPTS; ++i) {
|
for (int i = 0; i < ATTEMPTS; ++i) {
|
||||||
ExactCard tmpCard = CardDatabaseManager::query()->getRandomCard();
|
ExactCard tmpCard = CardDatabaseManager::query().getRandomCard();
|
||||||
if (tmpCard != backgroundSourceCard->getCard() && tmpCard.getCardPtr()->getProperty("layout") == "normal" &&
|
if (tmpCard != backgroundSourceCard->getCard() && tmpCard.getCardPtr()->getProperty("layout") == "normal" &&
|
||||||
tmpCard.getPrinting().getSet() != nullptr) {
|
tmpCard.getPrinting().getSet() != nullptr) {
|
||||||
newCard = tmpCard;
|
newCard = tmpCard;
|
||||||
|
|
@ -244,17 +244,17 @@ void HomeWidget::updateRandomCard()
|
||||||
|
|
||||||
if (!cardRefs.empty()) {
|
if (!cardRefs.empty()) {
|
||||||
if (cardRefs.size() == 1) {
|
if (cardRefs.size() == 1) {
|
||||||
newCard = CardDatabaseManager::query()->getCard(cardRefs.first());
|
newCard = CardDatabaseManager::query().getCard(cardRefs.first());
|
||||||
} else {
|
} else {
|
||||||
// Keep picking until different
|
// Keep picking until different
|
||||||
do {
|
do {
|
||||||
int idx = QRandomGenerator::global()->bounded(cardRefs.size());
|
int idx = QRandomGenerator::global()->bounded(cardRefs.size());
|
||||||
newCard = CardDatabaseManager::query()->getCard(cardRefs.at(idx));
|
newCard = CardDatabaseManager::query().getCard(cardRefs.at(idx));
|
||||||
} while (newCard == oldCard);
|
} while (newCard == oldCard);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
newCard = CardDatabaseManager::query()->getRandomCard();
|
newCard = CardDatabaseManager::query().getRandomCard();
|
||||||
} while (newCard == oldCard);
|
} while (newCard == oldCard);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ void PlaymatSettingsDialog::populateProviderCombo(const QString &cardName)
|
||||||
{
|
{
|
||||||
providerComboBox->clear();
|
providerComboBox->clear();
|
||||||
|
|
||||||
auto card = CardDatabaseManager::query()->getCard({cardName});
|
auto card = CardDatabaseManager::query().getCard({cardName});
|
||||||
|
|
||||||
const auto &sets = card.getInfo().getSets();
|
const auto &sets = card.getInfo().getSets();
|
||||||
|
|
||||||
|
|
@ -239,7 +239,7 @@ void PlaymatSettingsDialog::onCardNameChanged(const QString &name)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExactCard card = CardDatabaseManager::query()->getCard({name});
|
const ExactCard card = CardDatabaseManager::query().getCard({name});
|
||||||
if (!card) {
|
if (!card) {
|
||||||
currentPixmap = QPixmap();
|
currentPixmap = QPixmap();
|
||||||
preview->setPixmap(currentPixmap);
|
preview->setPixmap(currentPixmap);
|
||||||
|
|
@ -268,7 +268,7 @@ void PlaymatSettingsDialog::reloadPreview()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExactCard card = CardDatabaseManager::query()->getCard({currentCard.name, currentCard.providerId});
|
ExactCard card = CardDatabaseManager::query().getCard({currentCard.name, currentCard.providerId});
|
||||||
if (!card) {
|
if (!card) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -398,7 +398,7 @@ void PrintingSelectorCardOverlayWidget::customMenu(QPoint point)
|
||||||
const QString &relatedCardName = rel->getName();
|
const QString &relatedCardName = rel->getName();
|
||||||
QAction *relatedCard = relatedMenu->addAction(relatedCardName);
|
QAction *relatedCard = relatedMenu->addAction(relatedCardName);
|
||||||
connect(relatedCard, &QAction::triggered, deckEditor, [this, relatedCardName] {
|
connect(relatedCard, &QAction::triggered, deckEditor, [this, relatedCardName] {
|
||||||
deckEditor->updateCard(CardDatabaseManager::query()->getCard({relatedCardName}));
|
deckEditor->updateCard(CardDatabaseManager::query().getCard({relatedCardName}));
|
||||||
deckEditor->showPrintingSelector();
|
deckEditor->showPrintingSelector();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ void ChatView::appendCardTag(QTextCursor &cursor, const QString &cardName)
|
||||||
QTextCharFormat cardFormat = oldFormat;
|
QTextCharFormat cardFormat = oldFormat;
|
||||||
cardFormat.setFontItalic(true);
|
cardFormat.setFontItalic(true);
|
||||||
|
|
||||||
const CardInfoPtr card = CardDatabaseManager::query()->lookupCardByName(cardName);
|
const CardInfoPtr card = CardDatabaseManager::query().lookupCardByName(cardName);
|
||||||
if (card.isNull()) {
|
if (card.isNull()) {
|
||||||
cardFormat.setForeground(unresolvedCardTagColor);
|
cardFormat.setForeground(unresolvedCardTagColor);
|
||||||
cursor.setCharFormat(cardFormat);
|
cursor.setCharFormat(cardFormat);
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ void UserCardArtProvider::processQueue()
|
||||||
const QString cardName = parts.at(1);
|
const QString cardName = parts.at(1);
|
||||||
const QString providerId = parts.at(2);
|
const QString providerId = parts.at(2);
|
||||||
|
|
||||||
ExactCard card = CardDatabaseManager::query()->getCard({cardName, providerId});
|
ExactCard card = CardDatabaseManager::query().getCard({cardName, providerId});
|
||||||
|
|
||||||
if (!card) {
|
if (!card) {
|
||||||
pending.remove(key);
|
pending.remove(key);
|
||||||
|
|
|
||||||
|
|
@ -487,7 +487,7 @@ void UserCardArtSettingsDialog::populateProviderCombo(const QString &cardName)
|
||||||
{
|
{
|
||||||
providerComboBox->clear();
|
providerComboBox->clear();
|
||||||
|
|
||||||
auto card = CardDatabaseManager::query()->getCard({cardName});
|
auto card = CardDatabaseManager::query().getCard({cardName});
|
||||||
|
|
||||||
const auto &sets = card.getInfo().getSets();
|
const auto &sets = card.getInfo().getSets();
|
||||||
|
|
||||||
|
|
@ -517,7 +517,7 @@ void UserCardArtSettingsDialog::onCardNameChanged(const QString &name)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExactCard card = CardDatabaseManager::query()->getCard({name});
|
const ExactCard card = CardDatabaseManager::query().getCard({name});
|
||||||
if (!card) {
|
if (!card) {
|
||||||
currentPixmap = QPixmap();
|
currentPixmap = QPixmap();
|
||||||
preview->setPixmap(currentPixmap);
|
preview->setPixmap(currentPixmap);
|
||||||
|
|
@ -547,7 +547,7 @@ void UserCardArtSettingsDialog::reloadPreview()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExactCard card = CardDatabaseManager::query()->getCard({currentParams.cardName, currentParams.cardProviderId});
|
ExactCard card = CardDatabaseManager::query().getCard({currentParams.cardName, currentParams.cardProviderId});
|
||||||
if (!card) {
|
if (!card) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,8 +190,8 @@ void UserInfoHeaderWidget::setUserData(const ServerInfo_User &_user,
|
||||||
attribution.clear();
|
attribution.clear();
|
||||||
if (user.has_card_art_params()) {
|
if (user.has_card_art_params()) {
|
||||||
const ExactCard card =
|
const ExactCard card =
|
||||||
CardDatabaseManager::query()->getCard({QString::fromStdString(user.card_art_params().card_name()),
|
CardDatabaseManager::query().getCard({QString::fromStdString(user.card_art_params().card_name()),
|
||||||
QString::fromStdString(user.card_art_params().card_provider_id())});
|
QString::fromStdString(user.card_art_params().card_provider_id())});
|
||||||
if (card) {
|
if (card) {
|
||||||
attribution = buildArtAttribution(card);
|
attribution = buildArtAttribution(card);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ void AbstractTabDeckEditor::openDeck(const LoadedDeck &deck)
|
||||||
void AbstractTabDeckEditor::setDeck(const LoadedDeck &_deck)
|
void AbstractTabDeckEditor::setDeck(const LoadedDeck &_deck)
|
||||||
{
|
{
|
||||||
deckStateManager->replaceDeck(_deck);
|
deckStateManager->replaceDeck(_deck);
|
||||||
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query()->getCards(_deck.deckList.getCardRefList()));
|
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query().getCards(_deck.deckList.getCardRefList()));
|
||||||
|
|
||||||
dockToActions.value(deckDockWidget).aVisible->setChecked(true);
|
dockToActions.value(deckDockWidget).aVisible->setChecked(true);
|
||||||
deckDockWidget->setVisible(dockToActions.value(deckDockWidget).aVisible->isChecked());
|
deckDockWidget->setVisible(dockToActions.value(deckDockWidget).aVisible->isChecked());
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ EdhrecApiResponseCardDetailsDisplayWidget::EdhrecApiResponseCardDetailsDisplayWi
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
cardPictureWidget = new CardInfoPictureWidget(this);
|
cardPictureWidget = new CardInfoPictureWidget(this);
|
||||||
cardPictureWidget->setCard(CardDatabaseManager::query()->guessCard({toDisplay.sanitized}));
|
cardPictureWidget->setCard(CardDatabaseManager::query().guessCard({toDisplay.sanitized}));
|
||||||
|
|
||||||
nameLabel = new QLabel(this);
|
nameLabel = new QLabel(this);
|
||||||
nameLabel->setText(toDisplay.name);
|
nameLabel->setText(toDisplay.name);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ EdhrecCommanderResponseCommanderDetailsDisplayWidget::EdhrecCommanderResponseCom
|
||||||
navigationAndPricesLayout = new QVBoxLayout();
|
navigationAndPricesLayout = new QVBoxLayout();
|
||||||
|
|
||||||
commanderPicture = new CardInfoPictureWidget(this);
|
commanderPicture = new CardInfoPictureWidget(this);
|
||||||
commanderPicture->setCard(CardDatabaseManager::query()->getCard({commanderDetails.getName()}));
|
commanderPicture->setCard(CardDatabaseManager::query().getCard({commanderDetails.getName()}));
|
||||||
|
|
||||||
auto *parentTab = QtUtils::findParentOfType<TabEdhRecMain>(this);
|
auto *parentTab = QtUtils::findParentOfType<TabEdhRecMain>(this);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ void TabEdhRecMain::retranslateUi()
|
||||||
|
|
||||||
void TabEdhRecMain::doSearch()
|
void TabEdhRecMain::doSearch()
|
||||||
{
|
{
|
||||||
CardInfoPtr searchedCard = CardDatabaseManager::query()->getCardInfo(searchBar->text());
|
CardInfoPtr searchedCard = CardDatabaseManager::query().getCardInfo(searchBar->text());
|
||||||
if (!searchedCard) {
|
if (!searchedCard) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ void TabCardArtRules::populateProviderCombo(const QString &cardName)
|
||||||
{
|
{
|
||||||
providerComboBox->clear();
|
providerComboBox->clear();
|
||||||
|
|
||||||
auto card = CardDatabaseManager::query()->getCard({cardName});
|
auto card = CardDatabaseManager::query().getCard({cardName});
|
||||||
|
|
||||||
const auto &sets = card.getInfo().getSets();
|
const auto &sets = card.getInfo().getSets();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -973,7 +973,7 @@ void TabGame::loadDeckForLocalPlayer(PlayerLogic *localPlayer, int playerId, Ser
|
||||||
TabbedDeckViewContainer *deckViewContainer = deckViewContainers.value(playerId);
|
TabbedDeckViewContainer *deckViewContainer = deckViewContainers.value(playerId);
|
||||||
if (playerInfo.has_deck_list()) {
|
if (playerInfo.has_deck_list()) {
|
||||||
DeckList deckList = DeckList(QString::fromStdString(playerInfo.deck_list()));
|
DeckList deckList = DeckList(QString::fromStdString(playerInfo.deck_list()));
|
||||||
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query()->getCards(deckList.getCardRefList()));
|
CardPictureLoader::cacheCardPixmaps(CardDatabaseManager::query().getCards(deckList.getCardRefList()));
|
||||||
deckViewContainer->playerDeckView->setDeck(deckList);
|
deckViewContainer->playerDeckView->setDeck(deckList);
|
||||||
localPlayer->setDeck(deckList);
|
localPlayer->setDeck(deckList);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ QString CardCompleterDelegate::setCodeForCard(const QSharedPointer<CardInfo> &ca
|
||||||
|
|
||||||
QString code;
|
QString code;
|
||||||
|
|
||||||
const PrintingInfo printing = CardDatabaseManager::query()->getPreferredPrinting(card);
|
const PrintingInfo printing = CardDatabaseManager::query().getPreferredPrinting(card);
|
||||||
|
|
||||||
if (auto set = printing.getSet()) {
|
if (auto set = printing.getSet()) {
|
||||||
code = set->getShortName();
|
code = set->getShortName();
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,7 @@ void CardCompleterStyler::updatePreview(const QModelIndex &index)
|
||||||
preview->setWindowOpacity(0.0);
|
preview->setWindowOpacity(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExactCard exact = CardDatabaseManager::query()->getCard({card->getName()});
|
const ExactCard exact = CardDatabaseManager::query().getCard({card->getName()});
|
||||||
|
|
||||||
if (!exact) {
|
if (!exact) {
|
||||||
hidePreview();
|
hidePreview();
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ VisualDatabaseDisplayFormatLegalityFilterWidget::VisualDatabaseDisplayFormatLega
|
||||||
FilterTreeModel *_filterModel)
|
FilterTreeModel *_filterModel)
|
||||||
: QWidget(parent), filterModel(_filterModel)
|
: QWidget(parent), filterModel(_filterModel)
|
||||||
{
|
{
|
||||||
allFormatsWithCount = CardDatabaseManager::query()->getAllFormatsWithCount();
|
allFormatsWithCount = CardDatabaseManager::query().getAllFormatsWithCount();
|
||||||
int maxValue = std::numeric_limits<int>::min();
|
int maxValue = std::numeric_limits<int>::min();
|
||||||
for (int value : allFormatsWithCount) {
|
for (int value : allFormatsWithCount) {
|
||||||
maxValue = std::max(maxValue, value);
|
maxValue = std::max(maxValue, value);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ VisualDatabaseDisplayMainTypeFilterWidget::VisualDatabaseDisplayMainTypeFilterWi
|
||||||
: QWidget(parent), filterModel(_filterModel)
|
: QWidget(parent), filterModel(_filterModel)
|
||||||
{
|
{
|
||||||
// Get all main card types with their count
|
// Get all main card types with their count
|
||||||
allMainCardTypesWithCount = CardDatabaseManager::query()->getAllMainCardTypesWithCount();
|
allMainCardTypesWithCount = CardDatabaseManager::query().getAllMainCardTypesWithCount();
|
||||||
setMinimumWidth(300);
|
setMinimumWidth(300);
|
||||||
setMaximumHeight(200);
|
setMaximumHeight(200);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ VisualDatabaseDisplaySubTypeFilterWidget::VisualDatabaseDisplaySubTypeFilterWidg
|
||||||
FilterTreeModel *_filterModel)
|
FilterTreeModel *_filterModel)
|
||||||
: QWidget(parent), filterModel(_filterModel)
|
: QWidget(parent), filterModel(_filterModel)
|
||||||
{
|
{
|
||||||
allSubCardTypesWithCount = CardDatabaseManager::query()->getAllSubCardTypesWithCount();
|
allSubCardTypesWithCount = CardDatabaseManager::query().getAllSubCardTypesWithCount();
|
||||||
|
|
||||||
setMinimumWidth(300);
|
setMinimumWidth(300);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ VisualDatabaseDisplayWidget::VisualDatabaseDisplayWidget(QWidget *parent,
|
||||||
|
|
||||||
// The visual grid is a real view on a flattened model: one row per displayed
|
// The visual grid is a real view on a flattened model: one row per displayed
|
||||||
// card picture, painted on demand.
|
// card picture, painted on demand.
|
||||||
visualDisplayModel = new CardDatabaseVisualDisplayModel(databaseDisplayModel, CardDatabaseManager::query(), this);
|
visualDisplayModel = new CardDatabaseVisualDisplayModel(databaseDisplayModel, &CardDatabaseManager::query(), this);
|
||||||
|
|
||||||
cardView = new CardDatabaseVisualView(visualDisplayModel, this);
|
cardView = new CardDatabaseVisualView(visualDisplayModel, this);
|
||||||
cardView->setObjectName("visualCardView");
|
cardView->setObjectName("visualCardView");
|
||||||
|
|
@ -300,24 +300,24 @@ void VisualDatabaseDisplayWidget::onSearchModelChanged()
|
||||||
|
|
||||||
void VisualDatabaseDisplayWidget::onSelectedCardChanged(const QString &cardName)
|
void VisualDatabaseDisplayWidget::onSelectedCardChanged(const QString &cardName)
|
||||||
{
|
{
|
||||||
emit cardHoveredDatabaseDisplay(CardDatabaseManager::query()->getPreferredCard(cardName));
|
emit cardHoveredDatabaseDisplay(CardDatabaseManager::query().getPreferredCard(cardName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualDatabaseDisplayWidget::actAddCard(const QString &cardName, const QString &zoneName)
|
void VisualDatabaseDisplayWidget::actAddCard(const QString &cardName, const QString &zoneName)
|
||||||
{
|
{
|
||||||
highlightAllSearchEdit();
|
highlightAllSearchEdit();
|
||||||
ExactCard exactCard = CardDatabaseManager::query()->getPreferredCard(cardName);
|
ExactCard exactCard = CardDatabaseManager::query().getPreferredCard(cardName);
|
||||||
emit cardAdded(exactCard, zoneName);
|
emit cardAdded(exactCard, zoneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualDatabaseDisplayWidget::actDecrementCard(const QString &cardName, const QString &zoneName)
|
void VisualDatabaseDisplayWidget::actDecrementCard(const QString &cardName, const QString &zoneName)
|
||||||
{
|
{
|
||||||
ExactCard exactCard = CardDatabaseManager::query()->getPreferredCard(cardName);
|
ExactCard exactCard = CardDatabaseManager::query().getPreferredCard(cardName);
|
||||||
emit cardDecremented(exactCard, zoneName);
|
emit cardDecremented(exactCard, zoneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualDatabaseDisplayWidget::onRelatedCardClicked(const QString &relatedCard)
|
void VisualDatabaseDisplayWidget::onRelatedCardClicked(const QString &relatedCard)
|
||||||
{
|
{
|
||||||
ExactCard exactCard = CardDatabaseManager::query()->guessCard({relatedCard});
|
ExactCard exactCard = CardDatabaseManager::query().guessCard({relatedCard});
|
||||||
emit cardInfoRequested(exactCard);
|
emit cardInfoRequested(exactCard);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ static QList<ExactCard> cardNodesToExactCards(QList<const DecklistCardNode *> no
|
||||||
{
|
{
|
||||||
QList<ExactCard> cards;
|
QList<ExactCard> cards;
|
||||||
for (auto node : nodes) {
|
for (auto node : nodes) {
|
||||||
ExactCard card = CardDatabaseManager::query()->getCard(node->toCardRef());
|
ExactCard card = CardDatabaseManager::query().getCard(node->toCardRef());
|
||||||
if (card) {
|
if (card) {
|
||||||
for (int k = 0; k < node->getNumber(); ++k) {
|
for (int k = 0; k < node->getNumber(); ++k) {
|
||||||
cards.append(card);
|
cards.append(card);
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ void VisualDeckEditorWidget::initializeSearchBarAndCompleter()
|
||||||
|
|
||||||
void VisualDeckEditorWidget::addCardFromSearch()
|
void VisualDeckEditorWidget::addCardFromSearch()
|
||||||
{
|
{
|
||||||
ExactCard card = CardDatabaseManager::query()->getCard({searchBar->text()});
|
ExactCard card = CardDatabaseManager::query().getCard({searchBar->text()});
|
||||||
if (!card) {
|
if (!card) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,7 @@ void DeckPreviewWidget::syncFromModel()
|
||||||
|
|
||||||
const CardRef bannerCardRef = data.deck.deckList.getBannerCard();
|
const CardRef bannerCardRef = data.deck.deckList.getBannerCard();
|
||||||
const ExactCard bannerCard =
|
const ExactCard bannerCard =
|
||||||
bannerCardRef.name.isEmpty() ? ExactCard() : CardDatabaseManager::query()->getCard(bannerCardRef);
|
bannerCardRef.name.isEmpty() ? ExactCard() : CardDatabaseManager::query().getCard(bannerCardRef);
|
||||||
|
|
||||||
bannerCardDisplayWidget->setCard(bannerCard);
|
bannerCardDisplayWidget->setCard(bannerCard);
|
||||||
refreshBannerCardText();
|
refreshBannerCardText();
|
||||||
|
|
@ -419,7 +419,7 @@ void DeckPreviewWidget::setBannerCard(int /* changedIndex */)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
model->setBannerCard(r, cardRef);
|
model->setBannerCard(r, cardRef);
|
||||||
bannerCardDisplayWidget->setCard(CardDatabaseManager::query()->getCard(cardRef));
|
bannerCardDisplayWidget->setCard(CardDatabaseManager::query().getCard(cardRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckPreviewWidget::imageClickedEvent(QMouseEvent *event, DeckPreviewCardPictureWidget *instance)
|
void DeckPreviewWidget::imageClickedEvent(QMouseEvent *event, DeckPreviewCardPictureWidget *instance)
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ void PublicDeckPreviewWidget::setEntry(const RemotePublicDecksModel::DeckEntry &
|
||||||
const ExactCard bannerCard =
|
const ExactCard bannerCard =
|
||||||
entry.bannerCardName.isEmpty()
|
entry.bannerCardName.isEmpty()
|
||||||
? ExactCard()
|
? ExactCard()
|
||||||
: CardDatabaseManager::query()->getCard(CardRef{entry.bannerCardName, entry.bannerCardProvider});
|
: CardDatabaseManager::query().getCard(CardRef{entry.bannerCardName, entry.bannerCardProvider});
|
||||||
bannerCardDisplayWidget->setCard(bannerCard);
|
bannerCardDisplayWidget->setCard(bannerCard);
|
||||||
|
|
||||||
// The deck name is the overlay text on the banner, like the local preview.
|
// The deck name is the overlay text on the banner, like the local preview.
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@ CardDatabase::CardDatabase(QObject *parent,
|
||||||
ICardPreferenceProvider *prefs,
|
ICardPreferenceProvider *prefs,
|
||||||
ICardDatabasePathProvider *pathProvider,
|
ICardDatabasePathProvider *pathProvider,
|
||||||
ICardSetPriorityController *_setPriorityController)
|
ICardSetPriorityController *_setPriorityController)
|
||||||
: QObject(parent), setPriorityController(_setPriorityController), loadStatus(NotLoaded),
|
: QObject(parent), setPriorityController(_setPriorityController), loadStatus(NotLoaded), querier(this, prefs)
|
||||||
querier(this, prefs)
|
|
||||||
{
|
{
|
||||||
qRegisterMetaType<CardInfoPtr>("CardInfoPtr");
|
qRegisterMetaType<CardInfoPtr>("CardInfoPtr");
|
||||||
qRegisterMetaType<CardInfoPtr>("CardSetPtr");
|
qRegisterMetaType<CardInfoPtr>("CardSetPtr");
|
||||||
|
|
@ -45,6 +44,17 @@ CardDatabase::CardDatabase(QObject *parent,
|
||||||
// that cross-thread loads are delivered via the event loop while same-thread/
|
// that cross-thread loads are delivered via the event loop while same-thread/
|
||||||
// synchronous callers get the swap immediately.
|
// synchronous callers get the swap immediately.
|
||||||
connect(loader, &CardDatabaseLoader::databaseDataReady, this, &CardDatabase::swapInDatabaseData);
|
connect(loader, &CardDatabaseLoader::databaseDataReady, this, &CardDatabase::swapInDatabaseData);
|
||||||
|
|
||||||
|
// The querier is a plain (non-QObject) member, so its cache invalidation is
|
||||||
|
// driven from here instead of by connecting its own slots.
|
||||||
|
connect(this, &CardDatabase::cardAdded, this, &CardDatabase::invalidateQuerierCaches);
|
||||||
|
connect(this, &CardDatabase::cardRemoved, this, &CardDatabase::invalidateQuerierCaches);
|
||||||
|
connect(this, &CardDatabase::cardDatabaseReset, this, &CardDatabase::invalidateQuerierCaches);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardDatabase::invalidateQuerierCaches()
|
||||||
|
{
|
||||||
|
querier.invalidateCaches();
|
||||||
}
|
}
|
||||||
|
|
||||||
CardDatabase::~CardDatabase()
|
CardDatabase::~CardDatabase()
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "../set/card_set_list.h"
|
#include "../set/card_set_list.h"
|
||||||
#include "card_database_loader.h"
|
#include "card_database_loader.h"
|
||||||
|
#include "card_database_querier.h"
|
||||||
|
|
||||||
// IWYU pragma: keep
|
// IWYU pragma: keep
|
||||||
// CardDatabaseData is passed by value to the swapInDatabaseData() slot, and
|
// CardDatabaseData is passed by value to the swapInDatabaseData() slot, and
|
||||||
|
|
@ -18,7 +19,6 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
class CardDatabaseQuerier;
|
|
||||||
class ICardDatabasePathProvider;
|
class ICardDatabasePathProvider;
|
||||||
class ICardPreferenceProvider;
|
class ICardPreferenceProvider;
|
||||||
class ICardSetPriorityController;
|
class ICardSetPriorityController;
|
||||||
|
|
@ -62,6 +62,7 @@ protected:
|
||||||
/** @brief Querier for higher-level card lookups. */
|
/** @brief Querier for higher-level card lookups. */
|
||||||
CardDatabaseQuerier querier;
|
CardDatabaseQuerier querier;
|
||||||
|
|
||||||
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief Refreshes the cached reverse-related cards for all cards.
|
* @brief Refreshes the cached reverse-related cards for all cards.
|
||||||
*/
|
*/
|
||||||
|
|
@ -94,6 +95,11 @@ protected:
|
||||||
QBasicMutex *clearDatabaseMutex = new QBasicMutex(), *addCardMutex = new QBasicMutex(),
|
QBasicMutex *clearDatabaseMutex = new QBasicMutex(), *addCardMutex = new QBasicMutex(),
|
||||||
*removeCardMutex = new QBasicMutex();
|
*removeCardMutex = new QBasicMutex();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Invalidates the querier's cached count maps after the database contents change.
|
||||||
|
*/
|
||||||
|
void invalidateQuerierCaches();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructs a new CardDatabase instance.
|
* @brief Constructs a new CardDatabase instance.
|
||||||
|
|
@ -142,7 +148,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Returns the querier for performing card lookups. */
|
/** @brief Returns the querier for performing card lookups. */
|
||||||
[[nodiscard]] CardDatabaseQuerier const &query() const
|
[[nodiscard]] const CardDatabaseQuerier &query() const
|
||||||
{
|
{
|
||||||
return querier;
|
return querier;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ CardDatabase *CardDatabaseManager::getInstance()
|
||||||
return &instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardDatabaseQuerier const &CardDatabaseManager::query()
|
const CardDatabaseQuerier &CardDatabaseManager::query()
|
||||||
{
|
{
|
||||||
return getInstance()->query();
|
return getInstance()->query();
|
||||||
}
|
}
|
||||||
|
|
@ -61,9 +61,9 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the CardDatabaseQuerier of the singleton database.
|
* @brief Returns the CardDatabaseQuerier of the singleton database.
|
||||||
* @return Pointer to CardDatabaseQuerier.
|
* @return Reference to the singleton database querier.
|
||||||
*/
|
*/
|
||||||
static CardDatabaseQuerier const &query();
|
static const CardDatabaseQuerier &query();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** @brief Private default constructor to enforce singleton. */
|
/** @brief Private default constructor to enforce singleton. */
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,6 @@
|
||||||
CardDatabaseQuerier::CardDatabaseQuerier(const CardDatabase *_db, const ICardPreferenceProvider *prefs)
|
CardDatabaseQuerier::CardDatabaseQuerier(const CardDatabase *_db, const ICardPreferenceProvider *prefs)
|
||||||
: db(_db), prefs(prefs)
|
: db(_db), prefs(prefs)
|
||||||
{
|
{
|
||||||
// Invalidate the cached count maps whenever the database contents change.
|
|
||||||
connect(db, &CardDatabase::cardAdded, this, &CardDatabaseQuerier::invalidateCaches);
|
|
||||||
connect(db, &CardDatabase::cardRemoved, this, &CardDatabaseQuerier::invalidateCaches);
|
|
||||||
connect(db, &CardDatabase::cardDatabaseReset, this, &CardDatabaseQuerier::invalidateCaches);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardDatabaseQuerier::invalidateCaches()
|
void CardDatabaseQuerier::invalidateCaches()
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,8 @@
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QObject>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <qtmetamacros.h>
|
|
||||||
|
|
||||||
class CardDatabase;
|
class CardDatabase;
|
||||||
class ICardPreferenceProvider;
|
class ICardPreferenceProvider;
|
||||||
|
|
@ -232,8 +230,9 @@ private:
|
||||||
mutable QMap<QString, int> subCardTypeCountsCache;
|
mutable QMap<QString, int> subCardTypeCountsCache;
|
||||||
mutable QMap<QString, int> formatsCountCache;
|
mutable QMap<QString, int> formatsCountCache;
|
||||||
|
|
||||||
private slots:
|
|
||||||
void invalidateCaches();
|
void invalidateCaches();
|
||||||
|
|
||||||
|
friend class CardDatabase;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCKATRICE_CARD_DATABASE_QUERIER_H
|
#endif // COCKATRICE_CARD_DATABASE_QUERIER_H
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
static QString getCompleteCardName(const QString &cardName)
|
static QString getCompleteCardName(const QString &cardName)
|
||||||
{
|
{
|
||||||
ExactCard temp = CardDatabaseManager::query()->guessCard({cardName});
|
ExactCard temp = CardDatabaseManager::query().guessCard({cardName});
|
||||||
if (temp) {
|
if (temp) {
|
||||||
return temp.getName();
|
return temp.getName();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ void CardState::setCardRef(const CardRef &_cardRef)
|
||||||
|
|
||||||
void CardState::refreshCardInfo()
|
void CardState::refreshCardInfo()
|
||||||
{
|
{
|
||||||
exactCard = CardDatabaseManager::query()->getCard(cardRef);
|
exactCard = CardDatabaseManager::query().getCard(cardRef);
|
||||||
|
|
||||||
if (!exactCard && !cardRef.name.isEmpty()) {
|
if (!exactCard && !cardRef.name.isEmpty()) {
|
||||||
CardInfo::UiAttributes attributes = {.tableRow = -1};
|
CardInfo::UiAttributes attributes = {.tableRow = -1};
|
||||||
|
|
@ -231,7 +231,7 @@ void CardState::setAttachedTo(CardState *_attachedTo)
|
||||||
parentZone->reorganizeCards();
|
parentZone->reorganizeCards();
|
||||||
}
|
}
|
||||||
} else if (getZone() != nullptr) {
|
} else if (getZone() != nullptr) {
|
||||||
emit getZone() -> cardAdded(this);
|
emit getZone()->cardAdded(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getZone() != nullptr) {
|
if (getZone() != nullptr) {
|
||||||
|
|
|
||||||
|
|
@ -946,7 +946,7 @@ void PlayerActions::actCreateToken(TokenInfo tokenToCreate)
|
||||||
{
|
{
|
||||||
lastTokenInfo = tokenToCreate;
|
lastTokenInfo = tokenToCreate;
|
||||||
|
|
||||||
ExactCard correctedCard = CardDatabaseManager::query()->guessCard({lastTokenInfo.name, lastTokenInfo.providerId});
|
ExactCard correctedCard = CardDatabaseManager::query().guessCard({lastTokenInfo.name, lastTokenInfo.providerId});
|
||||||
if (correctedCard) {
|
if (correctedCard) {
|
||||||
lastTokenInfo.name = correctedCard.getName();
|
lastTokenInfo.name = correctedCard.getName();
|
||||||
int tableRow = lastTokenInfo.faceDown ? 2 : correctedCard.getInfo().getUiAttributes().tableRow;
|
int tableRow = lastTokenInfo.faceDown ? 2 : correctedCard.getInfo().getUiAttributes().tableRow;
|
||||||
|
|
@ -1011,7 +1011,7 @@ void PlayerActions::setLastTokenInfo(CardInfoPtr cardInfo)
|
||||||
void PlayerActions::actCreatePredefinedToken()
|
void PlayerActions::actCreatePredefinedToken()
|
||||||
{
|
{
|
||||||
auto *action = static_cast<QAction *>(sender());
|
auto *action = static_cast<QAction *>(sender());
|
||||||
CardInfoPtr cardInfo = CardDatabaseManager::query()->getCardInfo(action->text());
|
CardInfoPtr cardInfo = CardDatabaseManager::query().getCardInfo(action->text());
|
||||||
if (!cardInfo) {
|
if (!cardInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1115,7 +1115,7 @@ void PlayerActions::actCreateAllRelatedCards(const CardState *sourceCard)
|
||||||
* then assign the first to the "Create another" shortcut.
|
* then assign the first to the "Create another" shortcut.
|
||||||
*/
|
*/
|
||||||
if (cardRelation != nullptr && cardRelation->getCanCreateAnother()) {
|
if (cardRelation != nullptr && cardRelation->getCanCreateAnother()) {
|
||||||
CardInfoPtr cardInfo = CardDatabaseManager::query()->getCardInfo(cardRelation->getName());
|
CardInfoPtr cardInfo = CardDatabaseManager::query().getCardInfo(cardRelation->getName());
|
||||||
setLastToken(cardInfo);
|
setLastToken(cardInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1193,7 +1193,7 @@ void PlayerActions::onRelatedCardCreated(const CardState *sourceCard, const Card
|
||||||
}
|
}
|
||||||
|
|
||||||
ExactCard relatedCard =
|
ExactCard relatedCard =
|
||||||
CardDatabaseManager::query()->getCardFromSameSet(cardRelation->getName(), sourceCard->getCard().getPrinting());
|
CardDatabaseManager::query().getCardFromSameSet(cardRelation->getName(), sourceCard->getCard().getPrinting());
|
||||||
|
|
||||||
setLastToken(relatedCard.getCardPtr());
|
setLastToken(relatedCard.getCardPtr());
|
||||||
}
|
}
|
||||||
|
|
@ -1204,7 +1204,7 @@ void PlayerActions::createCard(const CardState *sourceCard,
|
||||||
bool persistent,
|
bool persistent,
|
||||||
bool faceDown)
|
bool faceDown)
|
||||||
{
|
{
|
||||||
CardInfoPtr cardInfo = CardDatabaseManager::query()->getCardInfo(dbCardName);
|
CardInfoPtr cardInfo = CardDatabaseManager::query().getCardInfo(dbCardName);
|
||||||
|
|
||||||
if (cardInfo == nullptr || sourceCard == nullptr) {
|
if (cardInfo == nullptr || sourceCard == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1240,7 +1240,7 @@ void PlayerActions::createCard(const CardState *sourceCard,
|
||||||
cmd.set_face_down(faceDown);
|
cmd.set_face_down(faceDown);
|
||||||
|
|
||||||
ExactCard relatedCard =
|
ExactCard relatedCard =
|
||||||
CardDatabaseManager::query()->getCardFromSameSet(cardInfo->getName(), sourceCard->getCard().getPrinting());
|
CardDatabaseManager::query().getCardFromSameSet(cardInfo->getName(), sourceCard->getCard().getPrinting());
|
||||||
|
|
||||||
switch (attachType) {
|
switch (attachType) {
|
||||||
case CardRelationType::DoesNotAttach:
|
case CardRelationType::DoesNotAttach:
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ void PlayerEventHandler::eventCreateToken(const Event_CreateToken &event)
|
||||||
// use db PT if not provided in event and not face-down
|
// use db PT if not provided in event and not face-down
|
||||||
QString pt = QString::fromStdString(event.pt());
|
QString pt = QString::fromStdString(event.pt());
|
||||||
if (pt.isEmpty() && !event.face_down()) {
|
if (pt.isEmpty() && !event.face_down()) {
|
||||||
ExactCard dbCard = CardDatabaseManager::query()->getCard(cardRef);
|
ExactCard dbCard = CardDatabaseManager::query().getCard(cardRef);
|
||||||
if (dbCard) {
|
if (dbCard) {
|
||||||
pt = dbCard.getInfo().getPowTough();
|
pt = dbCard.getInfo().getPowTough();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
static constexpr int REBUILD_COALESCE_MS = 30;
|
static constexpr int REBUILD_COALESCE_MS = 30;
|
||||||
|
|
||||||
CardDatabaseVisualDisplayModel::CardDatabaseVisualDisplayModel(CardDatabaseDisplayModel *_displayModel,
|
CardDatabaseVisualDisplayModel::CardDatabaseVisualDisplayModel(CardDatabaseDisplayModel *_displayModel,
|
||||||
CardDatabaseQuerier *_querier,
|
const CardDatabaseQuerier *_querier,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: QAbstractListModel(parent), displayModel(_displayModel), querier(_querier)
|
: QAbstractListModel(parent), displayModel(_displayModel), querier(_querier)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ public:
|
||||||
* @param parent Parent object.
|
* @param parent Parent object.
|
||||||
*/
|
*/
|
||||||
explicit CardDatabaseVisualDisplayModel(CardDatabaseDisplayModel *_displayModel,
|
explicit CardDatabaseVisualDisplayModel(CardDatabaseDisplayModel *_displayModel,
|
||||||
CardDatabaseQuerier *_querier,
|
const CardDatabaseQuerier *_querier,
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -81,7 +81,7 @@ private:
|
||||||
void appendPrintingsFor(const CardInfoPtr &info);
|
void appendPrintingsFor(const CardInfoPtr &info);
|
||||||
|
|
||||||
QPointer<CardDatabaseDisplayModel> displayModel;
|
QPointer<CardDatabaseDisplayModel> displayModel;
|
||||||
CardDatabaseQuerier *querier;
|
const CardDatabaseQuerier *querier;
|
||||||
QStringList setFilterTerms;
|
QStringList setFilterTerms;
|
||||||
QList<Entry> entries;
|
QList<Entry> entries;
|
||||||
QTimer rebuildTimer;
|
QTimer rebuildTimer;
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ void DeckListModel::rebuildTree()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(currentCard->getName());
|
CardInfoPtr info = CardDatabaseManager::query().getCardInfo(currentCard->getName());
|
||||||
QString groupCriteria = extractGroupCriteriaValue(info, activeGroupCriteria);
|
QString groupCriteria = extractGroupCriteriaValue(info, activeGroupCriteria);
|
||||||
|
|
||||||
auto *groupNode = dynamic_cast<InnerDecklistNode *>(node->findChild(groupCriteria));
|
auto *groupNode = dynamic_cast<InnerDecklistNode *>(node->findChild(groupCriteria));
|
||||||
|
|
@ -221,7 +221,7 @@ QVariant DeckListModel::data(const QModelIndex &index, int role) const
|
||||||
return card->getNumber();
|
return card->getNumber();
|
||||||
case DeckListModelColumns::CARD_NAME: {
|
case DeckListModelColumns::CARD_NAME: {
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(card->getName());
|
CardInfoPtr info = CardDatabaseManager::query().getCardInfo(card->getName());
|
||||||
if (info) {
|
if (info) {
|
||||||
return info->getLocalizedName(displayLang);
|
return info->getLocalizedName(displayLang);
|
||||||
}
|
}
|
||||||
|
|
@ -438,7 +438,7 @@ DecklistModelCardNode *DeckListModel::findCardNode(const QString &cardName,
|
||||||
const QString &providerId,
|
const QString &providerId,
|
||||||
const QString &cardNumber) const
|
const QString &cardNumber) const
|
||||||
{
|
{
|
||||||
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(cardName);
|
CardInfoPtr info = CardDatabaseManager::query().getCardInfo(cardName);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
@ -493,7 +493,7 @@ 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)
|
||||||
{
|
{
|
||||||
ExactCard card = CardDatabaseManager::query()->getCard({cardName});
|
ExactCard card = CardDatabaseManager::query().getCard({cardName});
|
||||||
|
|
||||||
if (!card) {
|
if (!card) {
|
||||||
if (abAddAnyway) {
|
if (abAddAnyway) {
|
||||||
|
|
@ -910,7 +910,7 @@ static bool isCardQuantityLegalForFormat(const QString &format, const CardInfo &
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto formatRules = CardDatabaseManager::query()->getFormat(format);
|
auto formatRules = CardDatabaseManager::query().getFormat(format);
|
||||||
|
|
||||||
// if format has no custom rules, then just do the default check
|
// if format has no custom rules, then just do the default check
|
||||||
if (!formatRules) {
|
if (!formatRules) {
|
||||||
|
|
@ -949,7 +949,7 @@ static bool isCardNodeLegalForFormat(const QString &format, const InnerDecklistN
|
||||||
}
|
}
|
||||||
|
|
||||||
// unknown cards are not legal
|
// unknown cards are not legal
|
||||||
ExactCard exactCard = CardDatabaseManager::query()->getCard(card->toCardRef());
|
ExactCard exactCard = CardDatabaseManager::query().getCard(card->toCardRef());
|
||||||
if (!exactCard) {
|
if (!exactCard) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ bool DeckListSortFilterProxyModel::lessThan(const QModelIndex &left, const QMode
|
||||||
auto *lNode = static_cast<DecklistModelCardNode *>(left.internalPointer());
|
auto *lNode = static_cast<DecklistModelCardNode *>(left.internalPointer());
|
||||||
auto *rNode = static_cast<DecklistModelCardNode *>(right.internalPointer());
|
auto *rNode = static_cast<DecklistModelCardNode *>(right.internalPointer());
|
||||||
|
|
||||||
CardInfoPtr lInfo = CardDatabaseManager::query()->guessCard({lNode->getName()}).getCardPtr();
|
CardInfoPtr lInfo = CardDatabaseManager::query().guessCard({lNode->getName()}).getCardPtr();
|
||||||
CardInfoPtr rInfo = CardDatabaseManager::query()->guessCard({rNode->getName()}).getCardPtr();
|
CardInfoPtr rInfo = CardDatabaseManager::query().guessCard({rNode->getName()}).getCardPtr();
|
||||||
|
|
||||||
// Example: multiple tie-break criteria (colors > cmc > name)
|
// Example: multiple tie-break criteria (colors > cmc > name)
|
||||||
for (const QString &crit : sortCriteria) {
|
for (const QString &crit : sortCriteria) {
|
||||||
|
|
|
||||||
|
|
@ -48,21 +48,21 @@ TEST(CardDatabaseTest, LoadXml)
|
||||||
// ensure the card database is empty at start
|
// ensure the card database is empty at start
|
||||||
ASSERT_EQ(0, db->getCardList().size()) << "Cards not empty at start";
|
ASSERT_EQ(0, db->getCardList().size()) << "Cards not empty at start";
|
||||||
ASSERT_EQ(0, db->getSetList().size()) << "Sets not empty at start";
|
ASSERT_EQ(0, db->getSetList().size()) << "Sets not empty at start";
|
||||||
ASSERT_EQ(0, db->query()->getAllMainCardTypes().size()) << "Types not empty at start";
|
ASSERT_EQ(0, db->query().getAllMainCardTypes().size()) << "Types not empty at start";
|
||||||
ASSERT_EQ(NotLoaded, db->getLoadStatus()) << "Incorrect status at start";
|
ASSERT_EQ(NotLoaded, db->getLoadStatus()) << "Incorrect status at start";
|
||||||
|
|
||||||
// load dummy cards and test result
|
// load dummy cards and test result
|
||||||
db->loadCardDatabases();
|
db->loadCardDatabases();
|
||||||
ASSERT_EQ(9, db->getCardList().size()) << "Wrong card count after load";
|
ASSERT_EQ(9, db->getCardList().size()) << "Wrong card count after load";
|
||||||
ASSERT_EQ(5, db->getSetList().size()) << "Wrong sets count after load";
|
ASSERT_EQ(5, db->getSetList().size()) << "Wrong sets count after load";
|
||||||
ASSERT_EQ(3, db->query()->getAllMainCardTypes().size()) << "Wrong types count after load";
|
ASSERT_EQ(3, db->query().getAllMainCardTypes().size()) << "Wrong types count after load";
|
||||||
ASSERT_EQ(Ok, db->getLoadStatus()) << "Wrong status after load";
|
ASSERT_EQ(Ok, db->getLoadStatus()) << "Wrong status after load";
|
||||||
|
|
||||||
// ensure the card database is empty after clear()
|
// ensure the card database is empty after clear()
|
||||||
db->clear();
|
db->clear();
|
||||||
ASSERT_EQ(0, db->getCardList().size()) << "Cards not empty after clear";
|
ASSERT_EQ(0, db->getCardList().size()) << "Cards not empty after clear";
|
||||||
ASSERT_EQ(0, db->getSetList().size()) << "Sets not empty after clear";
|
ASSERT_EQ(0, db->getSetList().size()) << "Sets not empty after clear";
|
||||||
ASSERT_EQ(0, db->query()->getAllMainCardTypes().size()) << "Types not empty after clear";
|
ASSERT_EQ(0, db->query().getAllMainCardTypes().size()) << "Types not empty after clear";
|
||||||
ASSERT_EQ(NotLoaded, db->getLoadStatus()) << "Incorrect status after clear";
|
ASSERT_EQ(NotLoaded, db->getLoadStatus()) << "Incorrect status after clear";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@ TEST(CardDatabaseTest, GuessCardWithProviderIdOnUnknownCardReturnsEmpty)
|
||||||
NoopCardSetPriorityController controller;
|
NoopCardSetPriorityController controller;
|
||||||
CardDatabase db(nullptr, &prefs, &pathProvider, &controller);
|
CardDatabase db(nullptr, &prefs, &pathProvider, &controller);
|
||||||
|
|
||||||
const ExactCard guessed = db.query()->guessCard({"Not a Card", "card_Not a Card_fixture"});
|
const ExactCard guessed = db.query().guessCard({"Not a Card", "card_Not a Card_fixture"});
|
||||||
|
|
||||||
EXPECT_TRUE(guessed.isEmpty());
|
EXPECT_TRUE(guessed.isEmpty());
|
||||||
EXPECT_FALSE(guessed);
|
EXPECT_FALSE(guessed);
|
||||||
|
|
@ -125,7 +125,7 @@ TEST(CardDatabaseTest, FindPrintingWithIdOnNullCardInfoReturnsEmpty)
|
||||||
NoopCardSetPriorityController controller;
|
NoopCardSetPriorityController controller;
|
||||||
CardDatabase db(nullptr, &prefs, &pathProvider, &controller);
|
CardDatabase db(nullptr, &prefs, &pathProvider, &controller);
|
||||||
|
|
||||||
EXPECT_TRUE(db.query()->findPrintingWithId(nullptr, "card_Not a Card_fixture").isEmpty());
|
EXPECT_TRUE(db.query().findPrintingWithId(nullptr, "card_Not a Card_fixture").isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CardInfoTest, ClearDirectRelationsDropsRawPointers)
|
TEST(CardInfoTest, ClearDirectRelationsDropsRawPointers)
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,10 @@ protected:
|
||||||
new TestCardDatabasePathProvider(), new NoopCardSetPriorityController());
|
new TestCardDatabasePathProvider(), new NoopCardSetPriorityController());
|
||||||
db->loadCardDatabases();
|
db->loadCardDatabases();
|
||||||
|
|
||||||
cat = db->query()->getCardBySimpleName("Cat");
|
cat = db->query().getCardBySimpleName("Cat");
|
||||||
notDeadAfterAll = db->query()->getCardBySimpleName("Not Dead");
|
notDeadAfterAll = db->query().getCardBySimpleName("Not Dead");
|
||||||
truth = db->query()->getCardBySimpleName("Truth");
|
truth = db->query().getCardBySimpleName("Truth");
|
||||||
doctor = db->query()->getCardBySimpleName("Doctor");
|
doctor = db->query().getCardBySimpleName("Doctor");
|
||||||
}
|
}
|
||||||
// void TearDown() override {}
|
// void TearDown() override {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ protected:
|
||||||
cardModel = std::make_unique<CardDatabaseModel>(db.get(), false);
|
cardModel = std::make_unique<CardDatabaseModel>(db.get(), false);
|
||||||
displayModel = std::make_unique<CardDatabaseDisplayModel>();
|
displayModel = std::make_unique<CardDatabaseDisplayModel>();
|
||||||
displayModel->setSourceModel(cardModel.get());
|
displayModel->setSourceModel(cardModel.get());
|
||||||
visualModel = std::make_unique<CardDatabaseVisualDisplayModel>(displayModel.get(), db->query());
|
visualModel = std::make_unique<CardDatabaseVisualDisplayModel>(displayModel.get(), &db->query());
|
||||||
visualModel->refresh();
|
visualModel->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue