QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsnewsfeedmodel.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsnewsfeedmodel.h
3  ------------------
4  begin : July 2019
5  copyright : (C) 2019 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSNEWSFEEDMODEL_H
16 #define QGSNEWSFEEDMODEL_H
17 
18 #include "qgis_core.h"
19 #include "qgis_sip.h"
20 #include "qgsnewsfeedparser.h"
21 #include <QAbstractItemModel>
22 #include <QSortFilterProxyModel>
23 
33 class CORE_EXPORT QgsNewsFeedModel : public QAbstractItemModel
34 {
35  Q_OBJECT
36  public:
37 
41  enum Role
42  {
43  Key = Qt::UserRole + 1,
44  Title,
45  Content,
46  ImageUrl,
47  Image,
48  Link,
49  Sticky,
50  };
51 
58  QgsNewsFeedModel( QgsNewsFeedParser *parser, QObject *parent SIP_TRANSFERTHIS = nullptr );
59 
60  QVariant data( const QModelIndex &index, int role ) const override;
61  Qt::ItemFlags flags( const QModelIndex &index ) const override;
62  QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override;
63  QModelIndex parent( const QModelIndex &index ) const override;
64  int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
65  int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
66 
67  private slots:
68 
69  void onEntryAdded( const QgsNewsFeedParser::Entry &entry );
70  void onEntryRemoved( const QgsNewsFeedParser::Entry &entry );
71  void onImageFetched( int key, const QPixmap &pixmap );
72 
73  private:
74 
75  QgsNewsFeedParser *mParser = nullptr;
76  QList< QgsNewsFeedParser::Entry > mEntries;
77 };
78 
87 class CORE_EXPORT QgsNewsFeedProxyModel : public QSortFilterProxyModel
88 {
89  Q_OBJECT
90  public:
91 
98  explicit QgsNewsFeedProxyModel( QgsNewsFeedParser *parser, QObject *parent SIP_TRANSFERTHIS = nullptr );
99 
100  protected:
101  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override;
102 
103  private:
104 
105  QgsNewsFeedModel *mModel = nullptr;
106 
107 };
108 
109 #endif // QGSNEWSFEEDMODEL_H
QgsNewsFeedParser
Parser for published QGIS news feeds.
Definition: qgsnewsfeedparser.h:37
QgsNewsFeedProxyModel
A proxy model for use with QgsNewsFeedModel.
Definition: qgsnewsfeedmodel.h:87
QgsNewsFeedModel::Role
Role
Custom model roles.
Definition: qgsnewsfeedmodel.h:54
qgsnewsfeedparser.h
qgis_sip.h
QgsNewsFeedModel
A model for published QGIS news feeds.
Definition: qgsnewsfeedmodel.h:33
QgsNewsFeedParser::Entry
Represents a single entry from a news feed.
Definition: qgsnewsfeedparser.h:47
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53