KTextAddons

voskspeechtotextmodel.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 "libvoskspeechtotext_export.h"
9#include "voskengineutils.h"
10
11#include "voskspeechtotextinfo.h"
12#include <QAbstractListModel>
13
14class LIBVOSKSPEECHTOTEXT_EXPORT VoskSpeechToTextModel : public QAbstractListModel
15{
16 Q_OBJECT
17public:
18 enum VoskRoles {
19 Identifier,
20 LangText,
21 Size,
22 SizeByte,
23 CheckSum,
24 Installed,
25 AvailableVersion,
26 InstalledVersion,
27 NeedToUpdateLanguage,
28 Name,
29 Url,
30 LastColumn = Url,
31 };
32
33 Q_ENUM(VoskRoles)
34
35 explicit VoskSpeechToTextModel(QObject *parent = nullptr);
36 ~VoskSpeechToTextModel() override;
37
38 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
39 [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
40
41 void clear();
42
43 [[nodiscard]] QVector<VoskSpeechToTextInfo> speechToTextInfos() const;
44 void setSpeechToTextInfos(const QVector<VoskSpeechToTextInfo> &newSpeechToTextInfo);
45
46 void updateInstalledLanguage();
47
48 void removeLanguage(const QString &name);
49
50protected:
51 QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
52 int columnCount(const QModelIndex &parent) const override;
53
54private:
55 [[nodiscard]] bool isInstalled(const QString &shortName) const;
56 [[nodiscard]] QString versionInstalled(const QString &shortName) const;
57 [[nodiscard]] bool needToUpdateLanguageModel(const VoskSpeechToTextInfo &language) const;
58 QVector<VoskSpeechToTextInfo> mSpeechToTextInfos;
60};
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 18 2024 12:19:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.