Run formatter on all our files (#6942)

This commit is contained in:
RickyRister 2026-05-26 15:11:38 -07:00 committed by GitHub
parent b3c89167c5
commit 1d5d3f2d38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 153 additions and 81 deletions

View file

@ -19,8 +19,9 @@ int CardSearchModel::rowCount(const QModelIndex &parent) const
QVariant CardSearchModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.row() >= searchResults.size())
if (!index.isValid() || index.row() >= searchResults.size()) {
return QVariant();
}
if (role == Qt::DisplayRole) {
return searchResults.at(index.row()).card->getName();
@ -34,8 +35,9 @@ void CardSearchModel::updateSearchResults(const QString &query)
beginResetModel();
searchResults.clear();
if (query.isEmpty() || !sourceModel)
if (query.isEmpty() || !sourceModel) {
return;
}
// Set the filter for the display model
sourceModel->setCardName(query);
@ -46,13 +48,15 @@ void CardSearchModel::updateSearchResults(const QString &query)
QModelIndex sourceIndex = sourceModel->mapToSource(modelIndex);
CardDatabaseModel *sourceDbModel = qobject_cast<CardDatabaseModel *>(sourceModel->sourceModel());
if (!sourceDbModel || !sourceIndex.isValid())
if (!sourceDbModel || !sourceIndex.isValid()) {
return;
}
CardInfoPtr card = sourceDbModel->getCard(sourceIndex.row());
if (!card)
if (!card) {
continue;
}
int distance = levenshteinDistance(query.toLower(), card->getName().toLower());
searchResults.append({card, distance});
@ -63,8 +67,9 @@ void CardSearchModel::updateSearchResults(const QString &query)
[](const SearchResult &a, const SearchResult &b) { return a.distance < b.distance; });
// Keep only the top 5 results
if (searchResults.size() > 10)
if (searchResults.size() > 10) {
searchResults = searchResults.mid(0, 10);
}
emit dataChanged(index(0, 0), index(rowCount() - 1, 0));
emit layoutChanged();