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:
commit
cf3e172d25
4 changed files with 22 additions and 4 deletions
|
@ -186,6 +186,10 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
|
|||
if (((isToken == ShowTrue) && !info->getIsToken()) || ((isToken == ShowFalse) && info->getIsToken()))
|
||||
return false;
|
||||
|
||||
return rowMatchesCardName(info);
|
||||
}
|
||||
|
||||
bool CardDatabaseDisplayModel::rowMatchesCardName(CardInfo const *info) const {
|
||||
if (!cardName.isEmpty() && !info->getName().contains(cardName, Qt::CaseInsensitive))
|
||||
return false;
|
||||
|
||||
|
@ -233,8 +237,7 @@ TokenDisplayModel::TokenDisplayModel(QObject *parent)
|
|||
bool TokenDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
|
||||
{
|
||||
CardInfo const *info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
|
||||
|
||||
return info->getIsToken();
|
||||
return info->getIsToken() && rowMatchesCardName(info);
|
||||
}
|
||||
|
||||
int TokenDisplayModel::rowCount(const QModelIndex &parent) const
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
protected:
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
||||
|
||||
bool rowMatchesCardName(CardInfo const *info) const;
|
||||
bool canFetchMore(const QModelIndex &parent) const;
|
||||
void fetchMore(const QModelIndex &parent);
|
||||
private slots:
|
||||
|
|
|
@ -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 ¤t, 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 ¤t, 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)
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
bool getDestroy() const;
|
||||
private slots:
|
||||
void tokenSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
void updateSearch(const QString &search);
|
||||
void actChooseTokenFromAll(bool checked);
|
||||
void actChooseTokenFromDeck(bool checked);
|
||||
void actOk();
|
||||
|
@ -37,6 +38,8 @@ private:
|
|||
QLineEdit *nameEdit, *ptEdit, *annotationEdit;
|
||||
QCheckBox *destroyCheckBox;
|
||||
QRadioButton *chooseTokenFromAllRadioButton, *chooseTokenFromDeckRadioButton;
|
||||
|
||||
void updateSearchFieldWithoutUpdatingFilter(const QString &newValue) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue