File indexing completed on 2024-12-08 12:55:20

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 <QAbstractListModel>
0007 #include <QLocale>
0008 #include <QSortFilterProxyModel>
0009 
0010 struct Time {
0011     QString name;
0012     int time = 0;
0013 };
0014 
0015 class PollTimeModel : public QAbstractListModel
0016 {
0017     Q_OBJECT
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 };