Warning, file /utilities/skanpage/src/OCRLanguageModel.h 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: 2022 by Alexander Stippich <a.stippich@gmx.net>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef OCR_LANGUAGE_MODEL_H
0008 #define OCR_LANGUAGE_MODEL_H
0009 
0010 #include <QAbstractListModel>
0011 
0012 struct LanguageItem {
0013     QString name;
0014     QString code;
0015     bool use;
0016 };
0017 
0018 class OCRLanguageModel : public QAbstractListModel 
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023 
0024     enum LanguageModelRoles {
0025         NameRole = Qt::UserRole + 1,
0026         CodeRole,
0027         UseRole
0028     };
0029 
0030     explicit OCRLanguageModel(QObject *parent = nullptr);
0031 
0032     ~OCRLanguageModel();
0033 
0034     QHash<int, QByteArray> roleNames() const override;
0035 
0036     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0037 
0038     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0039 
0040     bool setData(const QModelIndex &index, const QVariant &value, int role) override;
0041     
0042     void setLanguages(const std::vector<std::string> &availableLanguages);
0043 
0044     std::string getLanguagesString() const;
0045 
0046 private:
0047     QList<LanguageItem> m_languages;
0048 };
0049 
0050 #endif // OCR_LANGUAGE_MODEL_H