fix: show card only found once by prefix
This commit is contained in:
parent
10ab53c4ac
commit
d55f6fdec1
1 changed files with 9 additions and 3 deletions
|
@ -718,12 +718,18 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
}
|
}
|
||||||
|
|
||||||
CardInfo *CardNameMap::findByPrefix(const std::string &prefix) {
|
CardInfo *CardNameMap::findByPrefix(const std::string &prefix) {
|
||||||
|
int count = 0;
|
||||||
|
CardInfo *found;
|
||||||
|
|
||||||
for (CardNameMap::iterator it = this->begin(); it != this->end(); ++it) {
|
for (CardNameMap::iterator it = this->begin(); it != this->end(); ++it) {
|
||||||
if (std::mismatch(prefix.begin(), prefix.end(),
|
if (std::mismatch(prefix.begin(), prefix.end(),
|
||||||
it.key().toStdString().begin()).first == prefix.end())
|
it.key().toStdString().begin()).first == prefix.end()) {
|
||||||
return it.value();
|
count++;
|
||||||
|
found = it.value();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
|
return (count == 1 ? found : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
CardInfo *CardDatabase::getCardFromMap(CardNameMap &cardMap, const QString &cardName, bool createIfNotFound) {
|
CardInfo *CardDatabase::getCardFromMap(CardNameMap &cardMap, const QString &cardName, bool createIfNotFound) {
|
||||||
|
|
Loading…
Reference in a new issue