1 /***************************************************************************
2 
3                ----------------------------------------------------
4               date                 : 17.8.2015
5               copyright            : (C) 2015 by Matthias Kuhn
6               email                : matthias (at) opengis.ch
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 
16 #ifndef QGSWELCOMEPAGEITEMSMODEL_H
17 #define QGSWELCOMEPAGEITEMSMODEL_H
18 
19 #include <QAbstractListModel>
20 #include <QStringList>
21 #include <QStyledItemDelegate>
22 
23 class QgsMapCanvas;
24 
25 class QgsRecentProjectItemsModel : public QAbstractListModel
26 {
27     Q_OBJECT
28 
29   public:
30     struct RecentProjectData
31     {
32       bool operator==( const RecentProjectData &other ) const { return other.path == this->path; }
33       QString path;
34       QString title;
35       QString previewImagePath;
36       QString crs;
37       mutable bool pin = false;
38       mutable bool checkedExists = false;
39       mutable bool exists = false;
40     };
41 
42     explicit QgsRecentProjectItemsModel( QObject *parent = nullptr );
43 
44     void setRecentProjects( const QList<RecentProjectData> &recentProjects );
45 
46     int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
47     QVariant data( const QModelIndex &index, int role ) const override;
48     Qt::ItemFlags flags( const QModelIndex &index ) const override;
49 
50     void pinProject( const QModelIndex &index );
51     void unpinProject( const QModelIndex &index );
52     void removeProject( const QModelIndex &index );
53     void recheckProject( const QModelIndex &index );
54 
55   private:
56     QList<RecentProjectData> mRecentProjects;
57 };
58 
59 #endif // QGSRECENTPROJECTITEMSMODEL_H
60