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()))
|
if (((isToken == ShowTrue) && !info->getIsToken()) || ((isToken == ShowFalse) && info->getIsToken()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
return rowMatchesCardName(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CardDatabaseDisplayModel::rowMatchesCardName(CardInfo const *info) const {
|
||||||
if (!cardName.isEmpty() && !info->getName().contains(cardName, Qt::CaseInsensitive))
|
if (!cardName.isEmpty() && !info->getName().contains(cardName, Qt::CaseInsensitive))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -233,8 +237,7 @@ TokenDisplayModel::TokenDisplayModel(QObject *parent)
|
||||||
bool TokenDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
|
bool TokenDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
|
||||||
{
|
{
|
||||||
CardInfo const *info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
|
CardInfo const *info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
|
||||||
|
return info->getIsToken() && rowMatchesCardName(info);
|
||||||
return info->getIsToken();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TokenDisplayModel::rowCount(const QModelIndex &parent) const
|
int TokenDisplayModel::rowCount(const QModelIndex &parent) const
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
||||||
|
bool rowMatchesCardName(CardInfo const *info) const;
|
||||||
bool canFetchMore(const QModelIndex &parent) const;
|
bool canFetchMore(const QModelIndex &parent) const;
|
||||||
void fetchMore(const QModelIndex &parent);
|
void fetchMore(const QModelIndex &parent);
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -23,6 +23,7 @@ DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *pa
|
||||||
nameLabel = new QLabel(tr("&Name:"));
|
nameLabel = new QLabel(tr("&Name:"));
|
||||||
nameEdit = new QLineEdit(tr("Token"));
|
nameEdit = new QLineEdit(tr("Token"));
|
||||||
nameEdit->selectAll();
|
nameEdit->selectAll();
|
||||||
|
connect(nameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateSearch(const QString &)));
|
||||||
nameLabel->setBuddy(nameEdit);
|
nameLabel->setBuddy(nameEdit);
|
||||||
|
|
||||||
colorLabel = new QLabel(tr("C&olor:"));
|
colorLabel = new QLabel(tr("C&olor:"));
|
||||||
|
@ -132,7 +133,7 @@ void DlgCreateToken::tokenSelectionChanged(const QModelIndex ¤t, const QMo
|
||||||
|
|
||||||
if(cardInfo)
|
if(cardInfo)
|
||||||
{
|
{
|
||||||
nameEdit->setText(cardInfo->getName());
|
updateSearchFieldWithoutUpdatingFilter(cardInfo->getName());
|
||||||
const QChar cardColor = cardInfo->getColorChar();
|
const QChar cardColor = cardInfo->getColorChar();
|
||||||
colorEdit->setCurrentIndex(colorEdit->findData(cardColor, Qt::UserRole, Qt::MatchFixedString));
|
colorEdit->setCurrentIndex(colorEdit->findData(cardColor, Qt::UserRole, Qt::MatchFixedString));
|
||||||
ptEdit->setText(cardInfo->getPowTough());
|
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)
|
void DlgCreateToken::actChooseTokenFromAll(bool checked)
|
||||||
{
|
{
|
||||||
if (checked)
|
if (checked)
|
||||||
|
|
|
@ -25,6 +25,7 @@ public:
|
||||||
bool getDestroy() const;
|
bool getDestroy() const;
|
||||||
private slots:
|
private slots:
|
||||||
void tokenSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
void tokenSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
|
void updateSearch(const QString &search);
|
||||||
void actChooseTokenFromAll(bool checked);
|
void actChooseTokenFromAll(bool checked);
|
||||||
void actChooseTokenFromDeck(bool checked);
|
void actChooseTokenFromDeck(bool checked);
|
||||||
void actOk();
|
void actOk();
|
||||||
|
@ -37,6 +38,8 @@ private:
|
||||||
QLineEdit *nameEdit, *ptEdit, *annotationEdit;
|
QLineEdit *nameEdit, *ptEdit, *annotationEdit;
|
||||||
QCheckBox *destroyCheckBox;
|
QCheckBox *destroyCheckBox;
|
||||||
QRadioButton *chooseTokenFromAllRadioButton, *chooseTokenFromDeckRadioButton;
|
QRadioButton *chooseTokenFromAllRadioButton, *chooseTokenFromDeckRadioButton;
|
||||||
|
|
||||||
|
void updateSearchFieldWithoutUpdatingFilter(const QString &newValue) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue