KTextAddons

translatormodel.h
1/*
2 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8#include "bergamotengineutils.h"
9#include "libbergamot_private_export.h"
10#include "translator.h"
11#include <QAbstractListModel>
12
13class LIBBERGAMOT_TESTS_EXPORT TranslatorModel : public QAbstractListModel
14{
15 Q_OBJECT
16public:
17 enum TranslatorRoles {
18 Source,
19 Target,
20 TypeTranslator,
22 InstalledVersion,
23 AvailableVersion,
24 Installed,
25 CheckSum,
26 Identifier,
27 NeedToUpdateLanguage,
28 Url,
29 LastColumn = Url,
30 };
31
32 Q_ENUM(TranslatorRoles)
33
34 explicit TranslatorModel(QObject *parent = nullptr);
35 ~TranslatorModel() override;
36
37 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
38 [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
39
40 void clear();
41
42 void insertTranslators(const QVector<Translator> &translators);
43
44 [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
45 [[nodiscard]] int columnCount(const QModelIndex &parent) const override;
46
47 void removeLanguage(const QString &identifier);
48
49 void updateInstalledLanguage();
50
51private:
52 [[nodiscard]] bool isInstalled(const QString &shortName) const;
53 [[nodiscard]] int versionInstalled(const QString &shortName) const;
54 [[nodiscard]] bool needToUpdateLanguageModel(const Translator &translator) const;
55 QVector<Translator> mTranslators;
57};
KGuiItem clear()
virtual int columnCount(const QModelIndex &parent) const const=0
virtual QVariant data(const QModelIndex &index, int role) const const=0
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const const
virtual int rowCount(const QModelIndex &parent) const const=0
Q_ENUM(...)
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:29:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.