Debian Codegraph @

src/imports/Lomiri/Contacts/ringtonemodel.h

raw
1 /*
2 * Copyright (C) 2023 Ubports Foundation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #ifndef RINGTONEMODEL_H
18 #define RINGTONEMODEL_H
19
20 #include <QtCore/QAbstractListModel>
21 #include <QObject>
22
23 class Ringtone
24 {
25 public:
26 Ringtone(const QString &name, const QString &path, bool readonly);
27
28 QString name() const;
29 QString path() const;
30 bool readonly() const;
31
32 private:
33 QString mName;
34 QString mPath;
35 bool mReadonly;
36 };
37
38 class RingtoneModel : public QAbstractListModel
39 {
40 Q_OBJECT
41 Q_PROPERTY(int ringToneType WRITE setRingToneType)
42
43
44 public:
45 RingtoneModel(QObject* parent=0);
46
47 enum Roles {
48 Name = Qt::UserRole + 1,
49 Path,
50 ReadOnly
51 };
52
53 void setRingToneType(int ringToneType);
54 Q_INVOKABLE int getIndex(const QString &path);
55 Q_INVOKABLE QString soundPath(int ringtoneField);
56 Q_INVOKABLE void addFile(const QString &file);
57 Q_INVOKABLE void removeFile(const QString &path);
58
59 // reimplemented from QAbstractListModel
60 QHash<int, QByteArray> roleNames() const;
61 int rowCount(const QModelIndex& parent=QModelIndex()) const;
62 QVariant data(const QModelIndex& index, int role) const;
63
64 Q_SIGNALS:
65 void ringtoneTypeChanged();
66
67 private Q_SLOTS:
68 void populatesData();
69
70 private:
71
72 QList<Ringtone> mRingtones;
73 int mRingToneType;
74 QString mAudioRingtonePath;
75 QString mVibrationRingtonePath;
76 QString mVideoRingtonePath;
77 };
78
79
80
81 #endif // RINGTONEMODEL_H