File indexing completed on 2024-02-25 16:44:41

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libruqolacore_export.h"
0010 #include "teams/teamroom.h"
0011 #include <QAbstractListModel>
0012 #include <QVector>
0013 class LIBRUQOLACORE_EXPORT TeamRoomsModel : public QAbstractListModel
0014 {
0015     Q_OBJECT
0016 public:
0017     enum TeamRoomsRoles {
0018         Name = Qt::UserRole + 1,
0019         AutoJoin,
0020         Identifier,
0021     };
0022     Q_ENUM(TeamRoomsRoles)
0023 
0024     explicit TeamRoomsModel(QObject *parent = nullptr);
0025     ~TeamRoomsModel() override;
0026 
0027     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0028     [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
0029 
0030     [[nodiscard]] QVector<TeamRoom> teamRooms() const;
0031     void setTeamRooms(const QVector<TeamRoom> &teamRooms);
0032 
0033     void setRoomChanged(const TeamRoom &teamRoom);
0034 
0035     void insertRooms(const QVector<TeamRoom> &teamRooms);
0036 
0037     bool setData(const QModelIndex &index, const QVariant &value, int role) override;
0038     Qt::ItemFlags flags(const QModelIndex &index) const override;
0039 
0040     [[nodiscard]] bool isCheckable() const;
0041     void setIsCheckable(bool isCheckable);
0042 
0043 private:
0044     Q_DISABLE_COPY(TeamRoomsModel)
0045     QVector<TeamRoom> mTeamRooms;
0046     QStringList mRoomSelected;
0047     bool mIsCheckable = false;
0048 };