File indexing completed on 2024-05-26 16:08:49

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "bannerinfo.h"
0010 #include "libruqolacore_export.h"
0011 #include <QDebug>
0012 #include <QVector>
0013 
0014 class LIBRUQOLACORE_EXPORT BannerInfos
0015 {
0016 public:
0017     struct UnreadInformation {
0018         QString identifier;
0019         QString i18nMessage;
0020         [[nodiscard]] bool operator==(const UnreadInformation &other) const
0021         {
0022             return identifier == other.identifier && i18nMessage == other.i18nMessage;
0023         }
0024         [[nodiscard]] bool operator!=(const UnreadInformation &other) const
0025         {
0026             return !operator==(other);
0027         }
0028     };
0029 
0030     BannerInfos();
0031     ~BannerInfos();
0032 
0033     [[nodiscard]] const QVector<BannerInfo> &banners() const;
0034     void setBanners(const QVector<BannerInfo> &newBanners);
0035 
0036     void parseBannerInfos(const QJsonObject &object);
0037 
0038     void clear();
0039 
0040     void updateBannerReadInfo(const QString &name, bool readStatus);
0041 
0042     [[nodiscard]] int count() const;
0043 
0044     [[nodiscard]] bool isEmpty() const;
0045 
0046     [[nodiscard]] BannerInfo at(int index) const;
0047 
0048     [[nodiscard]] QVector<BannerInfos::UnreadInformation> bannerUnreadInformations() const;
0049 
0050 private:
0051     [[nodiscard]] LIBRUQOLACORE_NO_EXPORT QString generateText(const BannerInfo &info) const;
0052     QVector<BannerInfo> mBanners;
0053 };
0054 
0055 Q_DECLARE_METATYPE(BannerInfos)
0056 Q_DECLARE_METATYPE(BannerInfos::UnreadInformation)
0057 Q_DECLARE_TYPEINFO(BannerInfos::UnreadInformation, Q_MOVABLE_TYPE);
0058 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const BannerInfos &t);