File indexing completed on 2024-05-19 04:50:13
0001 /**************************************************************************************** 0002 * Copyright (c) 2011 Stefan Derkits <stefan@derkits.at> * 0003 * Copyright (c) 2011 Christian Wagner <christian.wagner86@gmx.at> * 0004 * Copyright (c) 2011 Felix Winter <ixos01@gmail.com> * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify it under * 0007 * the terms of the GNU General Public License as published by the Free Software * 0008 * Foundation; either version 2 of the License, or (at your option) any later * 0009 * version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0013 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License along with * 0016 * this program. If not, see <http://www.gnu.org/licenses/>. * 0017 ****************************************************************************************/ 0018 0019 #ifndef GPODDERSERVICEMODEL_H_ 0020 #define GPODDERSERVICEMODEL_H_ 0021 0022 #include "GpodderTreeItem.h" 0023 #include <mygpo-qt5/ApiRequest.h> 0024 #include <mygpo-qt5/TagList.h> 0025 #include "NetworkAccessManagerProxy.h" 0026 0027 #include <QAbstractItemModel> 0028 #include <QStringList> 0029 0030 class GpodderTreeItem; 0031 0032 class GpodderServiceModel: public QAbstractItemModel 0033 { 0034 Q_OBJECT 0035 public: 0036 explicit GpodderServiceModel( mygpo::ApiRequest *request, QObject *parent = nullptr ); 0037 ~GpodderServiceModel() override; 0038 0039 // QAbstractItemModel methods 0040 QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override; 0041 QModelIndex parent( const QModelIndex &index ) const override; 0042 int rowCount( const QModelIndex &parent = QModelIndex() ) const override; 0043 int columnCount( const QModelIndex &parent = QModelIndex() ) const override; 0044 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; 0045 bool hasChildren( const QModelIndex &parent = QModelIndex() ) const override; 0046 0047 void insertPodcastList( mygpo::PodcastListPtr podcasts, const QModelIndex & parentItem ); 0048 0049 private Q_SLOTS: 0050 void topTagsRequestError( QNetworkReply::NetworkError error ); 0051 void topTagsParseError(); 0052 void insertTagList(); 0053 0054 void topPodcastsRequestError( QNetworkReply::NetworkError error ); 0055 void topPodcastsParseError(); 0056 0057 void suggestedPodcastsRequestError( QNetworkReply::NetworkError error ); 0058 void suggestedPodcastsParseError(); 0059 0060 void requestTopTags(); 0061 void requestTopPodcasts(); 0062 void requestSuggestedPodcasts(); 0063 0064 protected: 0065 bool canFetchMore( const QModelIndex &parent ) const override; 0066 void fetchMore( const QModelIndex &parent ) override; 0067 0068 private: 0069 GpodderTreeItem *m_rootItem; 0070 GpodderTreeItem *m_topTagsItem; 0071 GpodderTreeItem *m_topPodcastsItem; 0072 GpodderTreeItem *m_suggestedPodcastsItem; 0073 //The gpodder.net topTags 0074 mygpo::TagListPtr m_topTags; 0075 mygpo::ApiRequest *m_apiRequest; 0076 }; 0077 0078 #endif /* GPODDERSERVICEMODEL_H_ */