Token dialog fixes (#3711)

* Token dialog fixes

* clangify

* edit custom tokens

* Fix in-game token dialog
This commit is contained in:
ctrlaltca 2019-05-09 09:37:27 +02:00 committed by GitHub
parent 3830c85ce6
commit 6c21855f98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 11 deletions

View file

@ -61,7 +61,7 @@ DlgEditTokens::DlgEditTokens(QWidget *parent) : QDialog(parent), currentCard(nul
databaseModel = new CardDatabaseModel(db, false, this);
databaseModel->setObjectName("databaseModel");
cardDatabaseDisplayModel = new TokenDisplayModel(this);
cardDatabaseDisplayModel = new TokenEditModel(this);
cardDatabaseDisplayModel->setSourceModel(databaseModel);
cardDatabaseDisplayModel->setIsToken(CardDatabaseDisplayModel::ShowTrue);
@ -110,7 +110,7 @@ DlgEditTokens::DlgEditTokens(QWidget *parent) : QDialog(parent), currentCard(nul
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);
setWindowTitle(tr("Edit tokens"));
setWindowTitle(tr("Edit custom tokens"));
}
void DlgEditTokens::tokenSelectionChanged(const QModelIndex &current, const QModelIndex & /* previous */)
@ -123,7 +123,7 @@ void DlgEditTokens::tokenSelectionChanged(const QModelIndex &current, const QMod
currentCard.clear();
}
if (!currentCard) {
if (currentCard) {
nameEdit->setText(currentCard->getName());
const QChar cardColor = currentCard->getColorChar();
colorEdit->setCurrentIndex(colorEdit->findData(cardColor, Qt::UserRole, Qt::MatchFixedString));
@ -154,9 +154,12 @@ void DlgEditTokens::actAddToken()
}
} while (askAgain);
CardInfoPtr card = CardInfo::newInstance(name, "", true);
QString setName = CardDatabase::TOKENS_SETNAME;
CardInfoPerSetMap sets;
sets.insert(setName, CardInfoPerSet(databaseModel->getDatabase()->getSet(setName)));
CardInfoPtr card = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(),
QList<CardRelation *>(), sets, false, -1, false);
card->setCardType("Token");
card->addToSet(databaseModel->getDatabase()->getSet(CardDatabase::TOKENS_SETNAME));
databaseModel->getDatabase()->addCard(card);
}