Commit ae63802a authored by Nate Graham's avatar Nate Graham
Browse files

[kcms] Sort grid view KCMs case insensitively

Since these KCMs can display user and distro provided content, we can't
ensure that everything will begin with a capital letter. Accordingly, we
should sort the grid case-insensitively to prevent the entries starting
with lowercase letters from being shunted to the end.

CCBUG: 404608
parent 35345786
......@@ -217,7 +217,9 @@ void ColorsModel::load()
m_data.append(item);
}
// Sort case-insensitively
QCollator collator;
collator.setCaseSensitivity(Qt::CaseInsensitive);
std::sort(m_data.begin(), m_data.end(), [&collator](const ColorsModelData &a, const ColorsModelData &b) {
return collator.compare(a.display, b.display) < 0;
});
......
......@@ -87,7 +87,8 @@ CursorThemeConfig::CursorThemeConfig(QObject *parent, const QVariantList &args)
m_themeProxyModel = new SortProxyModel(this);
m_themeProxyModel->setSourceModel(m_themeModel);
m_themeProxyModel->setFilterCaseSensitivity(Qt::CaseSensitive);
// sort ordering is already case-insensitive; match that for filtering too
m_themeProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_themeProxyModel->sort(NameColumn, Qt::AscendingOrder);
m_sizesModel = new QStandardItemModel(this);
......
......@@ -36,7 +36,7 @@ int SortProxyModel::compare(const QModelIndex &left, const QModelIndex &right, i
QString first = model->data(left, role).toString();
QString second = model->data(right, role).toString();
if (filterCaseSensitivity() == Qt::CaseSensitive) {
if (filterCaseSensitivity() == Qt::CaseInsensitive) {
first = first.toLower();
second = second.toLower();
}
......
......@@ -216,7 +216,9 @@ void ThemesModel::load()
}
}
// Sort case-insensitively
QCollator collator;
collator.setCaseSensitivity(Qt::CaseInsensitive);
std::sort(m_data.begin(), m_data.end(), [&collator](const ThemesModelData &a, const ThemesModelData &b) {
return collator.compare(a.display, b.display) < 0;
});
......
......@@ -25,6 +25,7 @@
#include "iconsmodel.h"
#include <QCollator>
#include <QFileIconProvider>
#include <KIconTheme>
......@@ -141,8 +142,11 @@ void IconsModel::load()
m_data.append(item);
}
std::sort(m_data.begin(), m_data.end(), [](const IconsModelData &a, const IconsModelData &b) {
return a.display < b.display;
// Sort case-insensitively
QCollator collator;
collator.setCaseSensitivity(Qt::CaseInsensitive);
std::sort(m_data.begin(), m_data.end(), [&collator](const IconsModelData &a, const IconsModelData &b) {
return collator.compare(a.display, b.display) < 0;
});
endResetModel();
......
......@@ -174,7 +174,15 @@ void KCMLookandFeel::loadModel()
{
m_model->clear();
const QList<KPackage::Package> pkgs = availablePackages({"defaults", "layouts"});
QList<KPackage::Package> pkgs = availablePackages({"defaults", "layouts"});
// Sort case-insensitively
QCollator collator;
collator.setCaseSensitivity(Qt::CaseInsensitive);
std::sort(pkgs.begin(), pkgs.end(), [&collator](const KPackage::Package &a, const KPackage::Package &b) {
return collator.compare(a.metadata().name(), b.metadata().name()) < 0;
});
for (const KPackage::Package &pkg : pkgs) {
if (!pkg.metadata().isValid()) {
continue;
......@@ -225,7 +233,6 @@ void KCMLookandFeel::loadModel()
m_model->appendRow(row);
}
m_model->sort(0 /*column*/);
// Model has been cleared so pretend the selected look and fell changed to force view update
emit lookAndFeelSettings()->lookAndFeelPackageChanged();
......
......@@ -200,7 +200,9 @@ void StylesModel::load()
m_data = styleData.values().toVector();
// Sort case-insensitively
QCollator collator;
collator.setCaseSensitivity(Qt::CaseInsensitive);
std::sort(m_data.begin(), m_data.end(), [&collator](const StylesModelData &a, const StylesModelData &b) {
const QString aDisplay = !a.display.isEmpty() ? a.display : a.styleName;
const QString bDisplay = !b.display.isEmpty() ? b.display : b.styleName;
......
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