Commit 757795f7 authored by Fabio Bas's avatar Fabio Bas
Browse files

Deck editor: skip unnecessary card name comparison when no search term is defined

parent b5b7ad89
...@@ -123,21 +123,23 @@ bool CardDatabaseDisplayModel::lessThan(const QModelIndex &left, const QModelInd ...@@ -123,21 +123,23 @@ bool CardDatabaseDisplayModel::lessThan(const QModelIndex &left, const QModelInd
QString leftString = sourceModel()->data(left).toString(); QString leftString = sourceModel()->data(left).toString();
QString rightString = sourceModel()->data(right).toString(); QString rightString = sourceModel()->data(right).toString();
if (leftString.compare(cardName, Qt::CaseInsensitive) == 0) {// exact match should be at top if (!cardName.isEmpty())
return true; {
} if (leftString.compare(cardName, Qt::CaseInsensitive) == 0) {// exact match should be at top
return true;
if (rightString.compare(cardName, Qt::CaseInsensitive) == 0) {// exact match should be at top }
return false;
}
bool isLeftType2 = leftString.startsWith(cardName, Qt::CaseInsensitive); if (rightString.compare(cardName, Qt::CaseInsensitive) == 0) {// exact match should be at top
bool isRightType2 = rightString.startsWith(cardName, Qt::CaseInsensitive); return false;
if (isLeftType2 && !isRightType2) }
return true;
if (isRightType2 && !isLeftType2)
return false;
bool isLeftType2 = leftString.startsWith(cardName, Qt::CaseInsensitive);
bool isRightType2 = rightString.startsWith(cardName, Qt::CaseInsensitive);
if (isLeftType2 && !isRightType2)
return true;
if (isRightType2 && !isLeftType2)
return false;
}
return QString::localeAwareCompare(leftString, rightString) < 0; return QString::localeAwareCompare(leftString, rightString) < 0;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment