Commit edf0b4ae 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 3b0dd143
......@@ -243,7 +243,7 @@ void KCMColors::installSchemeFile(const QString &path)
m_model->load();
const auto results = m_model->match(m_model->index(0, 0), ColorsModel::SchemeNameRole, newName);
const auto results = m_model->match(m_model->index(0, 0), ColorsModel::SchemeNameRole, newName, 1, Qt::MatchExactly);
if (!results.isEmpty()) {
m_model->setSelectedScheme(newName);
}
......
......@@ -49,7 +49,7 @@ void FilterProxyModel::setSelectedScheme(const QString &scheme)
int FilterProxyModel::selectedSchemeIndex() const
{
// We must search in the source model and then map the index to our proxy model.
const auto results = sourceModel()->match(sourceModel()->index(0, 0), ColorsModel::SchemeNameRole, m_selectedScheme);
const auto results = sourceModel()->match(sourceModel()->index(0, 0), ColorsModel::SchemeNameRole, m_selectedScheme, 1, Qt::MatchExactly);
if (results.count() == 1) {
const QModelIndex result = mapFromSource(results.first());
......
......@@ -53,7 +53,7 @@ void FilterProxyModel::setSelectedTheme(const QString &pluginName)
int FilterProxyModel::selectedThemeIndex() const
{
// We must search in the source model and then map the index to our proxy model.
const auto results = sourceModel()->match(sourceModel()->index(0, 0), ThemesModel::PluginNameRole, m_selectedTheme);
const auto results = sourceModel()->match(sourceModel()->index(0, 0), ThemesModel::PluginNameRole, m_selectedTheme, 1, Qt::MatchExactly);
if (results.count() == 1) {
const QModelIndex result = mapFromSource(results.first());
......
......@@ -135,7 +135,7 @@ void ThemesModel::setSelectedTheme(const QString &pluginName)
int ThemesModel::pluginIndex(const QString &pluginName) const
{
const auto results = match(index(0, 0), PluginNameRole, pluginName);
const auto results = match(index(0, 0), PluginNameRole, pluginName, 1, Qt::MatchExactly);
if (results.count() == 1) {
return results.first().row();
}
......
......@@ -494,7 +494,7 @@ QPixmap IconModule::getBestIcon(KIconTheme &theme, const QStringList &iconNames,
int IconModule::pluginIndex(const QString &themeName) const
{
const auto results = m_model->match(m_model->index(0, 0), ThemeNameRole, themeName);
const auto results = m_model->match(m_model->index(0, 0), ThemeNameRole, themeName, 1, Qt::MatchExactly);
if (results.count() == 1) {
return results.first().row();
}
......
......@@ -406,7 +406,7 @@ void KGlobalShortcutsEditor::activateComponent(const QString &component)
Q_ASSERT(iter != d->components.end());
return;
} else {
QModelIndexList results = d->proxyModel->match(d->proxyModel->index(0, 0), Qt::DisplayRole, component);
QModelIndexList results = d->proxyModel->match(d->proxyModel->index(0, 0), Qt::DisplayRole, component, 1, Qt::MatchExactly);
Q_ASSERT(!results.isEmpty());
if (results.first().isValid()) {
// Known component. Get it.
......@@ -831,7 +831,7 @@ void KGlobalShortcutsEditor::KGlobalShortcutsEditorPrivate::removeComponent(
if (components.value(text)->uniqueName() == componentUnique)
{
// Remove from QComboBox
QModelIndexList results = proxyModel->match(proxyModel->index(0, 0), Qt::DisplayRole, text);
QModelIndexList results = proxyModel->match(proxyModel->index(0, 0), Qt::DisplayRole, text, 1, Qt::MatchExactly);
Q_ASSERT(!results.isEmpty());
model->removeRow(proxyModel->mapToSource(results.first()).row());
......
......@@ -132,7 +132,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();
}
......
......@@ -121,7 +121,7 @@ QStandardItemModel *KCMLookandFeel::lookAndFeelModel() const
int KCMLookandFeel::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();
}
......
Markdown is supported
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