/* * Copyright 2024 Evgeny Chesnokov * SPDX-License-Identifier: LGPL-2.0-or-later */ #pragma once #include class Book; class BookListModel : public QAbstractListModel { Q_OBJECT public: enum BookRoles { TitleRole = Qt::UserRole + 1, AuthorRole, YearRole, RatingRole, }; Q_ENUM(BookRoles) explicit BookListModel(const QList &books, QObject *parent = nullptr); int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; protected: QHash roleNames() const; private: QList m_books; };