1 /*************************************************************************** 2 * Copyright (C) 2009 Matthias Fuchs <mat69@gmx.net> * 3 * * 4 * This program is free software; you can redistribute it and/or modify * 5 * it under the terms of the GNU General Public License as published by * 6 * the Free Software Foundation; either version 2 of the License, or * 7 * (at your option) any later version. * 8 * * 9 * This program is distributed in the hope that it will be useful, * 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 * GNU General Public License for more details. * 13 * * 14 * You should have received a copy of the GNU General Public License * 15 * along with this program; if not, write to the * 16 * Free Software Foundation, Inc., * 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 18 ***************************************************************************/ 19 20 #ifndef LOCALEMODELS_H 21 #define LOCALEMODELS_H 22 23 #include <QAbstractListModel> 24 25 #include <QIcon> 26 27 /** 28 * The following models are there to store the localized names and the codes of languages and countries 29 * Only codes supported by KDE are supported by these models 30 */ 31 32 /** 33 * The CountryModel stores localized names as well as the codes and the corresponding icons of countries 34 */ 35 class CountryModel : public QAbstractListModel 36 { 37 Q_OBJECT 38 39 public: 40 CountryModel(QObject *parent = nullptr); 41 42 int rowCount (const QModelIndex &parent = QModelIndex()) const override; 43 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 44 45 void setupModelData(); 46 47 private: 48 QStringList m_countryCodes; 49 QStringList m_countryNames; 50 QList<QIcon> m_countryIcons; 51 }; 52 53 /** 54 * The LanguageModel stores localized names as well as the codes of languages 55 */ 56 class LanguageModel : public QAbstractListModel 57 { 58 Q_OBJECT 59 60 public: 61 LanguageModel(QObject *parent = nullptr); 62 63 int rowCount (const QModelIndex &parent = QModelIndex()) const override; 64 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 65 66 void setupModelData(); 67 68 private: 69 QStringList m_languageCodes; 70 QStringList m_languageNames; 71 }; 72 73 #endif 74