libosmscout
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
libosmscout-client-qt
include
osmscoutclientqt
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
25
#include <
osmscoutclientqt/VoiceManager.h
>
26
#include <
osmscoutclientqt/Voice.h
>
27
#include <
osmscoutclientqt/ClientQtImportExport.h
>
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
36
namespace
osmscout
{
37
46
class
OSMSCOUT_CLIENT_QT_API
InstalledVoicesModel
:
public
QAbstractListModel {
47
Q_OBJECT
48
49
private
:
50
Slot<std::string>
voiceDirSlot{
51
[
this
](
const
std::string &dir){
onVoiceChanged
(QString::fromStdString(dir)); }
52
};
53
54
signals:
55
void
voiceChanged
(
const
QString);
56
57
public
slots:
58
void
update
();
59
void
onVoiceChanged
(
const
QString&);
60
61
public
:
62
InstalledVoicesModel
();
63
64
~InstalledVoicesModel
()
override
;
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);
85
private:
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
ClientQtImportExport.h
OSMSCOUT_CLIENT_QT_API
#define OSMSCOUT_CLIENT_QT_API
Definition
ClientQtImportExport.h:45
Voice.h
VoiceManager.h
osmscout::InstalledVoicesModel::rowCount
Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const override
osmscout::InstalledVoicesModel::flags
Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const override
osmscout::InstalledVoicesModel::~InstalledVoicesModel
~InstalledVoicesModel() override
osmscout::InstalledVoicesModel::select
Q_INVOKABLE void select(const QModelIndex &index)
osmscout::InstalledVoicesModel::voiceChanged
void voiceChanged(const QString)
osmscout::InstalledVoicesModel::update
void update()
osmscout::InstalledVoicesModel::playSample
Q_INVOKABLE void playSample(const QModelIndex &index, const QStringList &sample)
osmscout::InstalledVoicesModel::InstalledVoicesModel
InstalledVoicesModel()
osmscout::InstalledVoicesModel::onVoiceChanged
void onVoiceChanged(const QString &)
osmscout::InstalledVoicesModel::Roles
Roles
Definition
InstalledVoicesModel.h:66
osmscout::InstalledVoicesModel::NameRole
@ NameRole
Definition
InstalledVoicesModel.h:67
osmscout::InstalledVoicesModel::LangRole
@ LangRole
Definition
InstalledVoicesModel.h:68
osmscout::InstalledVoicesModel::AuthorRole
@ AuthorRole
Definition
InstalledVoicesModel.h:72
osmscout::InstalledVoicesModel::LicenseRole
@ LicenseRole
Definition
InstalledVoicesModel.h:71
osmscout::InstalledVoicesModel::DescriptionRole
@ DescriptionRole
Definition
InstalledVoicesModel.h:73
osmscout::InstalledVoicesModel::ValidRole
@ ValidRole
Definition
InstalledVoicesModel.h:70
osmscout::InstalledVoicesModel::SelectedRole
@ SelectedRole
Definition
InstalledVoicesModel.h:74
osmscout::InstalledVoicesModel::GenderRole
@ GenderRole
Definition
InstalledVoicesModel.h:69
osmscout::InstalledVoicesModel::data
Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override
osmscout::InstalledVoicesModel::roleNames
QHash< int, QByteArray > roleNames() const override
osmscout::Slot
Definition
Signal.h:98
osmscout::Voice
Definition
Voice.h:119
osmscout::VoiceManagerRef
std::shared_ptr< VoiceManager > VoiceManagerRef
Definition
VoiceManager.h:125
osmscout
Definition
Area.h:39
Generated by
1.17.0