Add sound manager initial source code
[staging/soundmanager.git] / sample / mediaplayer / app / playlistwithmetadata.h
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef PLAYLISTWITHMETADATA_H
18 #define PLAYLISTWITHMETADATA_H
19
20 #include <QtCore/QAbstractListModel>
21
22 class PlaylistWithMetadata : public QAbstractListModel
23 {
24     Q_OBJECT
25     Q_PROPERTY(QAbstractListModel *source READ source WRITE setSource NOTIFY sourceChanged)
26 public:
27     PlaylistWithMetadata(QObject *parent = nullptr);
28     ~PlaylistWithMetadata();
29
30     enum {
31         TitleRole = Qt::DisplayRole
32         , ArtistRole = Qt::UserRole + 1
33         , CoverArtRole
34         , SourceRole
35         , DurationRole
36     };
37
38     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
39     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
40     QHash<int, QByteArray> roleNames() const override;
41
42     QAbstractListModel *source() const;
43
44 public slots:
45     void setSource(QAbstractListModel *source);
46
47 signals:
48     void sourceChanged(QAbstractListModel *source);
49
50 private:
51     class Private;
52     Private *d;
53 };
54
55 #endif // PLAYLISTWITHMETADATA_H