Make "create token" dialog's card name a filter
* There is a circular update loop I had to cut off where the name field updates the filter and then the currentRowChanged signal is firing without a row. * I chose to make a private method to show intent instead of relying on other QLineEdit methods (textEdited) that don't fire signals. * Some other shenanigans may be at hand that are causing this workaround, but my familiarity with Qt is pretty low.
This commit is contained in:
parent
7bc14b594d
commit
8dd8b434b2
2 changed files with 16 additions and 1 deletions
|
@ -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:"));
|
||||||
|
@ -135,7 +136,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());
|
||||||
|
@ -149,6 +150,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