mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 09:33:57 -07:00
make group criteria method static
This commit is contained in:
parent
1113eb4abe
commit
86371ce837
2 changed files with 11 additions and 12 deletions
|
|
@ -18,13 +18,19 @@ DeckListModel::~DeckListModel()
|
||||||
delete root;
|
delete root;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DeckListModel::getGroupCriteriaForCard(CardInfoPtr info) const
|
/**
|
||||||
|
* @brief Extract the value from the card that is used for the group criteria.
|
||||||
|
* @param info Pointer to card information.
|
||||||
|
* @param criteria The group criteria
|
||||||
|
* @return String representing the value of the criteria.
|
||||||
|
*/
|
||||||
|
static QString extractGroupCriteriaValue(const CardInfoPtr &info, DeckListModelGroupCriteria::Type criteria)
|
||||||
{
|
{
|
||||||
if (!info) {
|
if (!info) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (activeGroupCriteria) {
|
switch (criteria) {
|
||||||
case DeckListModelGroupCriteria::MAIN_TYPE:
|
case DeckListModelGroupCriteria::MAIN_TYPE:
|
||||||
return info->getMainCardType();
|
return info->getMainCardType();
|
||||||
case DeckListModelGroupCriteria::MANA_COST:
|
case DeckListModelGroupCriteria::MANA_COST:
|
||||||
|
|
@ -56,7 +62,7 @@ void DeckListModel::rebuildTree()
|
||||||
}
|
}
|
||||||
|
|
||||||
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(currentCard->getName());
|
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(currentCard->getName());
|
||||||
QString groupCriteria = getGroupCriteriaForCard(info);
|
QString groupCriteria = extractGroupCriteriaValue(info, activeGroupCriteria);
|
||||||
|
|
||||||
auto *groupNode = dynamic_cast<InnerDecklistNode *>(node->findChild(groupCriteria));
|
auto *groupNode = dynamic_cast<InnerDecklistNode *>(node->findChild(groupCriteria));
|
||||||
|
|
||||||
|
|
@ -353,7 +359,7 @@ DecklistModelCardNode *DeckListModel::findCardNode(const QString &cardName,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString groupCriteria = getGroupCriteriaForCard(info);
|
QString groupCriteria = extractGroupCriteriaValue(info, activeGroupCriteria);
|
||||||
InnerDecklistNode *groupNode = dynamic_cast<InnerDecklistNode *>(zoneNode->findChild(groupCriteria));
|
InnerDecklistNode *groupNode = dynamic_cast<InnerDecklistNode *>(zoneNode->findChild(groupCriteria));
|
||||||
if (!groupNode) {
|
if (!groupNode) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -406,7 +412,7 @@ QModelIndex DeckListModel::addCard(const ExactCard &card, const QString &zoneNam
|
||||||
CardInfoPtr cardInfo = card.getCardPtr();
|
CardInfoPtr cardInfo = card.getCardPtr();
|
||||||
PrintingInfo printingInfo = card.getPrinting();
|
PrintingInfo printingInfo = card.getPrinting();
|
||||||
|
|
||||||
QString groupCriteria = getGroupCriteriaForCard(cardInfo);
|
QString groupCriteria = extractGroupCriteriaValue(cardInfo, activeGroupCriteria);
|
||||||
InnerDecklistNode *groupNode = createNodeIfNeeded(groupCriteria, zoneNode);
|
InnerDecklistNode *groupNode = createNodeIfNeeded(groupCriteria, zoneNode);
|
||||||
|
|
||||||
const QModelIndex parentIndex = nodeToIndex(groupNode);
|
const QModelIndex parentIndex = nodeToIndex(groupNode);
|
||||||
|
|
|
||||||
|
|
@ -251,13 +251,6 @@ public:
|
||||||
return nodeToIndex(root);
|
return nodeToIndex(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the value of the grouping category for a card based on the current criteria.
|
|
||||||
* @param info Pointer to card information.
|
|
||||||
* @return String representing the value of the current grouping criteria for the card.
|
|
||||||
*/
|
|
||||||
[[nodiscard]] QString getGroupCriteriaForCard(CardInfoPtr info) const;
|
|
||||||
|
|
||||||
// Qt model overrides
|
// Qt model overrides
|
||||||
[[nodiscard]] int rowCount(const QModelIndex &parent) const override;
|
[[nodiscard]] int rowCount(const QModelIndex &parent) const override;
|
||||||
[[nodiscard]] int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override;
|
[[nodiscard]] int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const override;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue