File indexing completed on 2025-02-16 07:50:32
0001 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com> 0002 // SPDX-License-Identifier: GPL-3.0-or-later 0003 0004 #pragma once 0005 0006 #include <QtQml> 0007 0008 struct Time { 0009 QString name; 0010 int time = 0; 0011 }; 0012 0013 class PollTimeModel : public QAbstractListModel 0014 { 0015 Q_OBJECT 0016 QML_ELEMENT 0017 0018 public: 0019 enum CustomRoles { TextRole = Qt::UserRole + 1, TimeRole }; 0020 0021 explicit PollTimeModel(QObject *parent = nullptr); 0022 0023 QVariant data(const QModelIndex &index, int role) const override; 0024 int rowCount(const QModelIndex &parent) const override; 0025 QHash<int, QByteArray> roleNames() const override; 0026 0027 Q_INVOKABLE int getTime(int index); 0028 0029 private: 0030 QList<Time> m_times; 0031 };