KTextAddons

autocorrectionlanguage.cpp
1/*
2 SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "autocorrectionlanguage.h"
8#include "autocorrectionlanguagemodel.h"
9#include <QSortFilterProxyModel>
10
11using namespace TextAutoCorrectionWidgets;
12
13AutoCorrectionLanguage::AutoCorrectionLanguage(QWidget *parent)
14 : QComboBox(parent)
15 , mAutoCorrectionLanguageModel(new AutoCorrectionLanguageModel(this))
16{
17 auto sortFilterModel = new QSortFilterProxyModel(this);
18 sortFilterModel->setSourceModel(mAutoCorrectionLanguageModel);
19 sortFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
20 sortFilterModel->setFilterRole(AutoCorrectionLanguageModel::LocaleI18n);
21 sortFilterModel->sort(0);
22
23 setModel(sortFilterModel);
24}
25
27{
28 return mAutoCorrectionLanguageModel->language(index);
29}
30
31AutoCorrectionLanguage::~AutoCorrectionLanguage() = default;
32
34{
35 return itemData(currentIndex(), AutoCorrectionLanguageModel::Locale).toString();
36}
37
39{
40 const int index = findData(language);
41 setCurrentIndex(index);
42}
void setLanguage(const QString &language)
setLanguage
int findData(const QVariant &data, int role, Qt::MatchFlags flags) const const
QVariant itemData(int index, int role) const const
CaseInsensitive
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:47:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.