Warning, file /plasma/plasma-workspace/kcms/region_language/localelistmodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *  localelistmodel.h
0003  *  Copyright 2014 Sebastian Kügler <sebas@kde.org>
0004  *  Copyright 2021 Han Young <hanyoung@protonmail.com>
0005  *
0006  *  This program is free software; you can redistribute it and/or modify
0007  *  it under the terms of the GNU General Public License as published by
0008  *  the Free Software Foundation; either version 2 of the License, or
0009  *  (at your option) any later version.
0010  *
0011  *  This program is distributed in the hope that it will be useful,
0012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  *  GNU General Public License for more details.
0015  *
0016  *  You should have received a copy of the GNU General Public License
0017  *  along with this program; if not, write to the Free Software
0018  */
0019 #pragma once
0020 
0021 #include "settingtype.h"
0022 
0023 #include <QAbstractListModel>
0024 #include <QLocale>
0025 #include <QSortFilterProxyModel>
0026 
0027 struct LocaleData {
0028     QString nativeName;
0029     QString englishName;
0030     QString nativeCountryName;
0031     QString englishCountryName;
0032     QString countryCode;
0033     QLocale locale;
0034 };
0035 
0036 class LocaleListModel : public QAbstractListModel
0037 {
0038     Q_OBJECT
0039     Q_PROPERTY(int selectedConfig READ selectedConfig WRITE setSelectedConfig NOTIFY selectedConfigChanged)
0040 public:
0041     enum RoleName { DisplayName = Qt::DisplayRole, LocaleName, FlagIcon, Example, FilterRole };
0042     explicit LocaleListModel(QObject *parent = nullptr);
0043 
0044     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0045     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0046     QHash<int, QByteArray> roleNames() const override;
0047     int selectedConfig() const;
0048     void setSelectedConfig(int config);
0049     Q_INVOKABLE void setLang(const QString &lang);
0050 
0051 Q_SIGNALS:
0052     void selectedConfigChanged();
0053 
0054 private:
0055     void getExample();
0056     std::vector<LocaleData> m_localeData;
0057     KCM_RegionAndLang::SettingType m_configType = KCM_RegionAndLang::Lang;
0058 };