Commit 1b5c2ca5 authored by Fabian Vogt's avatar Fabian Vogt
Browse files

Pass Qt::MatchExactly when calling QAbstractItemModel::match for strings

It defaults to Qt::MatchStartsWith and thus returns the wrong result.
parent d2333a70
......@@ -177,7 +177,7 @@ void KCMKeys::addApplication(QQuickItem *ctx)
if (result == QDialog::Accepted && dialog->service()) {
const KService::Ptr service = dialog->service();
const QString desktopFileName = service->desktopEntryName() + ".desktop";
if (m_globalAccelModel->match(m_shortcutsModel->index(0, 0), BaseModel::ComponentRole, desktopFileName).isEmpty()) {
if (m_globalAccelModel->match(m_shortcutsModel->index(0, 0), BaseModel::ComponentRole, desktopFileName, 1, Qt::MatchExactly).isEmpty()) {
m_globalAccelModel->addApplication(desktopFileName, service->name());
} else {
qCDebug(KCMKEYS) << "Already have component" << service->storageId();
......
......@@ -172,7 +172,7 @@ KCM.AbstractKCM {
onToggled: {
const checked = sectionCheckbox.checked
const startIndex = kcm.shortcutsModel.index(0, 0)
const indices = kcm.shortcutsModel.match(startIndex, Private.BaseModel.SectionRole, section, -1)
const indices = kcm.shortcutsModel.match(startIndex, Private.BaseModel.SectionRole, section, -1, Qt.MatchExactly)
for (const index of indices) {
kcm.shortcutsModel.setData(index, checked, Private.BaseModel.CheckedRole)
}
......@@ -182,7 +182,7 @@ KCM.AbstractKCM {
target: kcm.shortcutsModel
function onDataChanged (topLeft, bottomRight, roles) {
const startIndex = kcm.shortcutsModel.index(0, 0)
const indices = kcm.shortcutsModel.match(startIndex, Private.BaseModel.SectionRole, section, -1)
const indices = kcm.shortcutsModel.match(startIndex, Private.BaseModel.SectionRole, section, -1, Qt.MatchExactly)
sectionCheckbox.checked = indices.reduce((acc, index) => acc && kcm.shortcutsModel.data(index, Private.BaseModel.CheckedRole), true)
}
}
......
......@@ -131,7 +131,7 @@ void KCMSplashScreen::save()
int KCMSplashScreen::pluginIndex(const QString &pluginName) const
{
const auto results = m_model->match(m_model->index(0, 0), PluginNameRole, pluginName);
const auto results = m_model->match(m_model->index(0, 0), PluginNameRole, pluginName, 1, Qt::MatchExactly);
if (results.count() == 1) {
return results.first().row();
}
......
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