/* SPDX-FileCopyrightText: 2023 Noah Davis * SPDX-FileCopyrightText: 2023 Tanbir Jishan * SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once #include class SectionsModel : public QAbstractListModel { Q_OBJECT // Constant because we rely on sectionsChanged in AbstractModel Q_PROPERTY(int count READ rowCount CONSTANT FINAL) public: SectionsModel(QObject *parent = nullptr); enum { FirstIndexRole = Qt::UserRole + 1, }; QHash roleNames() const override; QVariant data(const QModelIndex &index, int role) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; QString lastSection() const; // Not using standard QAbstractItemModel functions for these to keep them from being exposed to QML. void clear(); void append(const QString §ion, int firstIndex); private: struct Item { QString section; int firstIndex; }; QList m_data; QHash m_roleNames; };