File indexing completed on 2024-05-05 04:50:48

0001 /*
0002  * SPDX-FileCopyrightText: 2023 George Florea Bănuș <georgefb899@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #ifndef CHAPTERSMODEL_H
0008 #define CHAPTERSMODEL_H
0009 
0010 #include <QAbstractListModel>
0011 #include <QtQml/qqmlregistration.h>
0012 
0013 struct Chapter {
0014     QString title;
0015     double startTime;
0016 };
0017 
0018 class ChaptersModel : public QAbstractListModel
0019 {
0020     Q_OBJECT
0021     QML_NAMED_ELEMENT(ChaptersModel)
0022 
0023 public:
0024     explicit ChaptersModel(QObject *parent = nullptr);
0025 
0026     enum Roles {
0027         TitleRole = Qt::UserRole + 1,
0028         StartTimeRole,
0029     };
0030 
0031     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0032     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0033     virtual QHash<int, QByteArray> roleNames() const override;
0034 
0035     void setChapters(QList<Chapter> &_chapters);
0036 
0037 private:
0038     QList<Chapter> m_chapters;
0039 };
0040 
0041 #endif // CHAPTERSMODEL_H