Warning, file /libraries/ktextaddons/textedittexttospeech/texttospeechlanguagecombobox.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2015-2023 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "texttospeechlanguagecombobox.h" 0008 using namespace TextEditTextToSpeech; 0009 0010 TextToSpeechLanguageComboBox::TextToSpeechLanguageComboBox(QWidget *parent) 0011 : QComboBox(parent) 0012 { 0013 } 0014 0015 TextToSpeechLanguageComboBox::~TextToSpeechLanguageComboBox() = default; 0016 0017 void TextToSpeechLanguageComboBox::selectLocaleName(const QString &localeName) 0018 { 0019 const int countItem(count()); 0020 for (int i = 0; i < countItem; ++i) { 0021 if (itemData(i).toLocale().name() == localeName) { 0022 setCurrentIndex(i); 0023 break; 0024 } 0025 } 0026 } 0027 0028 void TextToSpeechLanguageComboBox::updateAvailableLocales(const QVector<QLocale> &locales, const QLocale ¤t) 0029 { 0030 clear(); 0031 for (const QLocale &locale : locales) { 0032 const QVariant localeVariant(locale); 0033 addItem(QLocale::languageToString(locale.language()), localeVariant); 0034 if (locale.name() == current.name()) { 0035 setCurrentIndex(count() - 1); 0036 } 0037 } 0038 setSizeAdjustPolicy(QComboBox::AdjustToContents); 0039 // Sort it after loading list. 0040 model()->sort(0, Qt::AscendingOrder); 0041 } 0042 0043 #include "moc_texttospeechlanguagecombobox.cpp"