File indexing completed on 2024-12-08 12:53:31
0001 /* 0002 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "autotranslate/autotranslatelanguages.h" 0010 #include "libruqolacore_export.h" 0011 #include <QAbstractListModel> 0012 0013 class LIBRUQOLACORE_EXPORT AutotranslateLanguagesModel : public QAbstractListModel 0014 { 0015 Q_OBJECT 0016 public: 0017 enum AutoTranslateLanguesRoles { 0018 LanguageName = Qt::UserRole + 1, 0019 DisplayName, 0020 }; 0021 Q_ENUM(AutoTranslateLanguesRoles) 0022 0023 explicit AutotranslateLanguagesModel(QObject *parent = nullptr); 0024 ~AutotranslateLanguagesModel() override; 0025 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0026 [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0027 0028 void parseLanguages(const QJsonObject &obj); 0029 0030 [[nodiscard]] int currentLanguage(const QString &lang) const; 0031 [[nodiscard]] QString selectedLanguage(int index) const; 0032 0033 private: 0034 AutotranslateLanguages mAutoTranslateLanguages; 0035 };