Kirigami-addons

soundspickermodel.h
1// SPDX-FileCopyrightText: 2021 Han Young <hanyoung@protonmail.com>
2// SPDX-License-Identifier: LGPL-2.0-or-later
3#ifndef SoundsPickerModel_H
4#define SoundsPickerModel_H
5
6#include <QAbstractListModel>
7#include <qqmlregistration.h>
8
9#include <memory>
10
11class SoundsPickerModel : public QAbstractListModel
12{
14 QML_NAMED_ELEMENT(SoundsModel)
15
16 Q_PROPERTY(bool notification READ notification WRITE setNotification NOTIFY notificationChanged)
17 Q_PROPERTY(QStringList defaultAudio READ defaultAudio WRITE setDefaultAudio NOTIFY defaultAudioChanged)
18 Q_PROPERTY(QString theme READ theme WRITE setTheme NOTIFY themeChanged)
19public:
20 enum Roles {
21 NameRole = Qt::UserRole,
22 UrlRole
23 };
24
25 explicit SoundsPickerModel(QObject *parent = nullptr);
26 ~SoundsPickerModel();
27
28 bool notification() const;
29 void setNotification(bool notification);
30 Q_INVOKABLE QString initialSourceUrl(int index);
31 QHash<int, QByteArray> roleNames() const override;
32 QVariant data(const QModelIndex &index, int role) const override;
33 int rowCount(const QModelIndex& parent) const override;
34
35 const QStringList &defaultAudio() const;
36 void setDefaultAudio(const QStringList &audio);
37 const QString &theme() const;
38 void setTheme(const QString &theme);
39
41 void notificationChanged();
42 void defaultAudioChanged();
43 void themeChanged();
44
45private:
46 void loadFiles();
47 void rearrangeRingtoneOrder();
48 class Private;
49 std::unique_ptr<Private> d;
50};
51
52#endif // SoundsPickerModel_H
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:05:53 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.