File indexing completed on 2024-03-03 15:47:12

0001 /*
0002    SPDX-FileCopyrightText: 2020-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 "roominfo.h"
0011 #include <QDebug>
0012 #include <QVector>
0013 class LIBRUQOLACORE_EXPORT RoomsInfo
0014 {
0015 public:
0016     enum ParseType {
0017         Administrator,
0018         Directory,
0019     };
0020     RoomsInfo();
0021 
0022     [[nodiscard]] bool isEmpty() const;
0023     void clear();
0024     [[nodiscard]] int count() const;
0025     [[nodiscard]] RoomInfo at(int index) const;
0026 
0027     [[nodiscard]] int offset() const;
0028     void setOffset(int offset);
0029 
0030     [[nodiscard]] int total() const;
0031     void setTotal(int total);
0032 
0033     void parseRooms(const QJsonObject &obj, RoomsInfo::ParseType type);
0034     void parseMoreRooms(const QJsonObject &obj, RoomsInfo::ParseType type);
0035 
0036     [[nodiscard]] QVector<RoomInfo> rooms() const;
0037     void setRooms(const QVector<RoomInfo> &rooms);
0038 
0039     [[nodiscard]] int roomsCount() const;
0040     void setRoomsCount(int adminroomsCount);
0041 
0042     RoomInfo takeAt(int index);
0043     void insertRoom(int index, const RoomInfo &room);
0044 
0045 private:
0046     LIBRUQOLACORE_NO_EXPORT void parseListRooms(const QJsonObject &commandsObj, ParseType type);
0047     QVector<RoomInfo> mRooms;
0048     int mRoomsCount = 0;
0049     int mOffset = 0;
0050     int mTotal = 0;
0051 };
0052 
0053 Q_DECLARE_METATYPE(RoomsInfo)
0054 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const RoomsInfo &t);