File indexing completed on 2024-05-12 16:01:52
0001 /************************************************************************** 0002 ** 0003 ** This file is part of Qt Creator 0004 ** 0005 ** SPDX-FileCopyrightText: 2011 Nokia Corporation and /or its subsidiary(-ies). 0006 ** 0007 ** Contact: Nokia Corporation (qt-info@nokia.com) 0008 ** 0009 ** 0010 ** SPDX-License-Identifier: LGPL-2.1-only 0011 ** 0012 ** In addition, as a special exception, Nokia gives you certain additional 0013 ** rights. These rights are described in the Nokia Qt LGPL Exception 0014 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 0015 ** 0016 ** Other Usage 0017 ** 0018 ** Alternatively, this file may be used in accordance with the terms and 0019 ** conditions contained in a signed written agreement between you and Nokia. 0020 ** 0021 ** If you have questions regarding the use of this file, please contact 0022 ** Nokia at qt-info@nokia.com. 0023 ** 0024 **************************************************************************/ 0025 0026 #ifndef MULTIFEEDRSSMODEL_H 0027 #define MULTIFEEDRSSMODEL_H 0028 0029 #include <QAbstractListModel> 0030 #include <QStringList> 0031 #include <QDateTime> 0032 0033 #include <KisRssReader.h> 0034 0035 #include <kritaui_export.h> 0036 0037 0038 class QNetworkReply; 0039 class KisNetworkAccessManager; 0040 0041 class KRITAUI_EXPORT MultiFeedRssModel : public QAbstractListModel 0042 { 0043 Q_OBJECT 0044 Q_PROPERTY(int articleCount READ articleCount WRITE setArticleCount NOTIFY articleCountChanged) 0045 public: 0046 explicit MultiFeedRssModel(QObject *parent = 0); 0047 explicit MultiFeedRssModel(KisNetworkAccessManager* nam, QObject *parent = 0); 0048 ~MultiFeedRssModel() override; 0049 0050 QHash<int, QByteArray> roleNames() const override; 0051 virtual void addFeed(const QString& feed); 0052 void removeFeed(const QString& feed); 0053 0054 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0055 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0056 0057 int articleCount() const { 0058 return m_articleCount; 0059 } 0060 0061 public Q_SLOTS: 0062 void setArticleCount(int arg) { 0063 if (m_articleCount != arg) { 0064 m_articleCount = arg; 0065 emit articleCountChanged(arg); 0066 } 0067 } 0068 0069 Q_SIGNALS: 0070 void articleCountChanged(int arg); 0071 void feedDataChanged(); 0072 0073 private Q_SLOTS: 0074 void appendFeedData(QNetworkReply *reply); 0075 0076 private: 0077 QStringList m_sites; 0078 RssItemList m_aggregatedFeed; 0079 KisNetworkAccessManager *m_networkAccessManager; 0080 int m_articleCount; 0081 0082 void sortAggregatedFeed(); 0083 void initialize(); 0084 0085 friend class MockMultiFeedRssModel; 0086 }; 0087 0088 #endif // MULTIFEEDRSSMODEL_H 0089 0090