1 /*
2   This file is part of Lokalize
3 
4   SPDX-FileCopyrightText: 2009 Nick Shaforostoff <shafff@ukr.net>
5   SPDX-FileCopyrightText: 2018-2019 Simon Depiets <sdepiets@gmail.com>
6 
7   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
8 */
9 
10 
11 #ifndef LANGUAGELISTMODEL_H
12 #define LANGUAGELISTMODEL_H
13 
14 #include <QStringListModel>
15 class QSortFilterProxyModel;
16 
17 class LanguageListModel: public QStringListModel
18 {
19     enum ModelType {
20         Default,
21         WithEmptyLang
22     };
23 public:
24     static LanguageListModel* instance();
25     static LanguageListModel* emptyLangInstance();
26 
27 private:
28     static LanguageListModel * _instance;
29     static LanguageListModel * _emptyLangInstance;
30     static void cleanupLanguageListModel();
31 
32     LanguageListModel(ModelType type = Default, QObject* parent = nullptr);
33     QSortFilterProxyModel* m_sortModel;
34 
35 public:
36     QVariant data(const QModelIndex& index, int role) const override;
37     QFlags< Qt::ItemFlag > flags(const QModelIndex& index) const override;
38 
sortModel()39     QSortFilterProxyModel* sortModel() const
40     {
41         return m_sortModel;
42     }
43     int sortModelRowForLangCode(const QString&);
44     QString langCodeForSortModelRow(int);
45 };
46 
47 QString getTargetLangCode(const QString& title, bool askUser = false);
48 
49 #endif // LANGUAGELISTMODEL_H
50