Merge pull request #1981 from MarkyMarkMcDonald/feature/create-token-dialog-uses-name-as-search

Create token dialog uses name as search
This commit is contained in:
ctrlaltca 2016-05-17 21:49:49 +02:00
commit cf3e172d25
4 changed files with 22 additions and 4 deletions

View file

@ -23,6 +23,7 @@ DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *pa
nameLabel = new QLabel(tr("&Name:"));
nameEdit = new QLineEdit(tr("Token"));
nameEdit->selectAll();
connect(nameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateSearch(const QString &)));
nameLabel->setBuddy(nameEdit);
colorLabel = new QLabel(tr("C&olor:"));
@ -132,7 +133,7 @@ void DlgCreateToken::tokenSelectionChanged(const QModelIndex &current, const QMo
if(cardInfo)
{
nameEdit->setText(cardInfo->getName());
updateSearchFieldWithoutUpdatingFilter(cardInfo->getName());
const QChar cardColor = cardInfo->getColorChar();
colorEdit->setCurrentIndex(colorEdit->findData(cardColor, Qt::UserRole, Qt::MatchFixedString));
ptEdit->setText(cardInfo->getPowTough());
@ -146,6 +147,17 @@ void DlgCreateToken::tokenSelectionChanged(const QModelIndex &current, const QMo
}
}
void DlgCreateToken::updateSearchFieldWithoutUpdatingFilter(const QString &newValue) const {
nameEdit->blockSignals(true);
nameEdit->setText(newValue);
nameEdit->blockSignals(false);
}
void DlgCreateToken::updateSearch(const QString &search)
{
cardDatabaseDisplayModel->setCardName(search);
}
void DlgCreateToken::actChooseTokenFromAll(bool checked)
{
if (checked)