libosmscout 1.1.1
Loading...
Searching...
No Matches
InstalledVoicesModel.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_CLIENT_QT_INSTALLEDVOICESMODEL_H
2#define OSMSCOUT_CLIENT_QT_INSTALLEDVOICESMODEL_H
3
4/*
5 OSMScout - a Qt backend for libosmscout and libosmscout-map
6 Copyright (C) 2020 Lukas Karas
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/
22
23#include <osmscoutclient/Settings.h>
24
28
29#include <QAbstractListModel>
30#include <QList>
31#include <QMediaPlayer>
32#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
33#include <QMediaPlaylist>
34#endif
35
36namespace osmscout {
37
46class OSMSCOUT_CLIENT_QT_API InstalledVoicesModel : public QAbstractListModel {
47 Q_OBJECT
48
49private:
50 Slot<std::string> voiceDirSlot{
51 [this](const std::string &dir){ onVoiceChanged(QString::fromStdString(dir)); }
52 };
53
54signals:
55 void voiceChanged(const QString);
56
57public slots:
58 void update();
59 void onVoiceChanged(const QString&);
60
61public:
63
65
66 enum Roles {
67 NameRole = Qt::UserRole, // name
68 LangRole = Qt::UserRole + 1, //
69 GenderRole = Qt::UserRole + 2, // male or female (for now :-))
70 ValidRole = Qt::UserRole + 3, // true if it real voice, false when placeholder for no-voice configuration
71 LicenseRole = Qt::UserRole + 4,
72 AuthorRole = Qt::UserRole + 5,
73 DescriptionRole = Qt::UserRole + 6,
74 SelectedRole = Qt::UserRole + 7 // true when this voice is selected
75 };
76 Q_ENUM(Roles)
77
78 Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const override;
79 Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override;
80 QHash<int, QByteArray> roleNames() const override;
81 Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const override;
82
83 Q_INVOKABLE void select(const QModelIndex &index);
84 Q_INVOKABLE void playSample(const QModelIndex &index, const QStringList &sample);
85private:
86 QString voiceDir;
87 QList<Voice> voices;
88 VoiceManagerRef voiceManager;
89 SettingsRef settings;
90
91 // we setup QObject parents, objects are cleaned after Module destruction
92#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
93 QMediaPlaylist *currentPlaylist{nullptr};
94#endif
95 QMediaPlayer *mediaPlayer{nullptr};
96};
97}
98#endif //OSMSCOUT_CLIENT_QT_INSTALLEDVOICESMODEL_H
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const override
Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const override
Q_INVOKABLE void select(const QModelIndex &index)
void voiceChanged(const QString)
Q_INVOKABLE void playSample(const QModelIndex &index, const QStringList &sample)
void onVoiceChanged(const QString &)
Roles
Definition InstalledVoicesModel.h:66
@ NameRole
Definition InstalledVoicesModel.h:67
@ LangRole
Definition InstalledVoicesModel.h:68
@ AuthorRole
Definition InstalledVoicesModel.h:72
@ LicenseRole
Definition InstalledVoicesModel.h:71
@ DescriptionRole
Definition InstalledVoicesModel.h:73
@ ValidRole
Definition InstalledVoicesModel.h:70
@ SelectedRole
Definition InstalledVoicesModel.h:74
@ GenderRole
Definition InstalledVoicesModel.h:69
Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override
QHash< int, QByteArray > roleNames() const override
Definition Signal.h:98
Definition Voice.h:119
std::shared_ptr< VoiceManager > VoiceManagerRef
Definition VoiceManager.h:125
Definition Area.h:39