mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
Merge remote-tracking branch 'origin/master' into editor-sorting-v5
This commit is contained in:
commit
e99c1bbe6d
88 changed files with 4775 additions and 2615 deletions
|
|
@ -169,8 +169,7 @@ Qt::ItemFlags DeckListModel::flags(const QModelIndex &index) const
|
|||
return 0;
|
||||
|
||||
Qt::ItemFlags result = Qt::ItemIsEnabled;
|
||||
if (getNode<DecklistModelCardNode *>(index))
|
||||
result |= Qt::ItemIsSelectable;
|
||||
result |= Qt::ItemIsSelectable;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -236,6 +235,38 @@ InnerDecklistNode *DeckListModel::createNodeIfNeeded(const QString &name, InnerD
|
|||
return newNode;
|
||||
}
|
||||
|
||||
DecklistModelCardNode *DeckListModel::findCardNode(const QString &cardName, const QString &zoneName) const
|
||||
{
|
||||
InnerDecklistNode *zoneNode, *typeNode;
|
||||
CardInfo *info;
|
||||
QString cardType;
|
||||
|
||||
zoneNode = dynamic_cast<InnerDecklistNode *>(root->findChild(zoneName));
|
||||
if(!zoneNode)
|
||||
return NULL;
|
||||
|
||||
info = db->getCard(cardName);
|
||||
if(!info)
|
||||
return NULL;
|
||||
|
||||
cardType = info->getMainCardType();
|
||||
typeNode = dynamic_cast<InnerDecklistNode *>(zoneNode->findChild(cardType));
|
||||
if(!typeNode)
|
||||
return NULL;
|
||||
|
||||
return dynamic_cast<DecklistModelCardNode *>(typeNode->findChild(cardName));
|
||||
}
|
||||
|
||||
QModelIndex DeckListModel::findCard(const QString &cardName, const QString &zoneName) const
|
||||
{
|
||||
DecklistModelCardNode *cardNode;
|
||||
|
||||
cardNode = findCardNode(cardName, zoneName);
|
||||
if(!cardNode)
|
||||
return QModelIndex();
|
||||
return nodeToIndex(cardNode);
|
||||
}
|
||||
|
||||
QModelIndex DeckListModel::addCard(const QString &cardName, const QString &zoneName)
|
||||
{
|
||||
InnerDecklistNode *zoneNode = createNodeIfNeeded(zoneName, root);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue