Allow non-db cards to be moved around (#2960)

This commit is contained in:
Zach H 2017-12-18 14:17:54 -05:00 committed by GitHub
parent 2abfd3b4a9
commit b75882b6b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 21 deletions

View file

@ -264,11 +264,44 @@ QModelIndex DeckListModel::findCard(const QString &cardName, const QString &zone
return nodeToIndex(cardNode);
}
QModelIndex DeckListModel::addCard(const QString &cardName, const QString &zoneName)
QModelIndex DeckListModel::addCard(const QString &cardName, const QString &zoneName, bool abAddAnyway)
{
CardInfo *info = db->getCard(cardName);
if (info == nullptr)
return QModelIndex();
{
if (abAddAnyway)
{
// We need to keep this card added no matter what
// This is usually called from tab_deck_editor
// So we'll create a new CardInfo with the name
// and default values for all fields
info = new CardInfo(
cardName,
false,
nullptr,
nullptr,
"unknown",
nullptr,
nullptr,
QStringList(),
QList<CardRelation *>(),
QList<CardRelation *>(),
false,
0,
false,
0,
SetList(),
QStringMap(),
MuidMap(),
QStringMap(),
QStringMap()
);
}
else
{
return QModelIndex();
}
}
InnerDecklistNode *zoneNode = createNodeIfNeeded(zoneName, root);