From 9168f14fcf0794505f521067c0944aab81d49751 Mon Sep 17 00:00:00 2001 From: Wang Zichong Date: Mon, 13 Nov 2023 11:16:09 +0800 Subject: [PATCH] fix: lowercase item should appears first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 同为英文(ascii)字符时,小写应当在大写前面。 注:根据目前的测试,QCollator 的 compare 看上去并不满足这种排序要求... Issue: https://github.com/linuxdeepin/developer-center/issues/6159 Log: --- src/models/categorizedsortproxymodel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/models/categorizedsortproxymodel.cpp b/src/models/categorizedsortproxymodel.cpp index 6313ff02..50ab939c 100644 --- a/src/models/categorizedsortproxymodel.cpp +++ b/src/models/categorizedsortproxymodel.cpp @@ -70,6 +70,10 @@ bool CategorizedSortProxyModel::lessThan(const QModelIndex &source_left, const Q if ((l_start == ld_start && ld_start == rd_start) || (l_start != ld_start && l_start != rd_start)) { // display name both start with ascii letter, or both NOT start with ascii letter // use their transliterated form for sorting + if (!l_start.isNull() && l_transliterated.constData()[0] != r_transliterated.constData()[0]) { + // Since in ascii table, `A` is lower than `a`, we specially check to ensure `a` is lower here. + return l_transliterated.constData()[0].isLower(); + } return l_transliterated < r_transliterated; } else { // one of them are ascii letter and another of them is non-ascii letter.