1 /* 2 SPDX-FileCopyrightText: 2012-2013 Miquel Sabaté <mikisabate@gmail.com> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #ifndef GH_PROVIDERMODEL_H 8 #define GH_PROVIDERMODEL_H 9 10 11 #include <QUrl> 12 #include <QStandardItemModel> 13 14 namespace gh 15 { 16 17 /// Convenient enum to define the kind of the repo. 18 enum Repo { 19 Public = 0, 20 Private, 21 Fork 22 }; 23 24 /// Basic struct that represents a response from Github. 25 struct Response { 26 /// The name of the repo. 27 QString name; 28 29 /// The url of the repo. 30 QUrl url; 31 32 /// The kind of the repo (public, private, fork). 33 enum Repo kind; 34 }; 35 36 /** 37 * @class ProviderItem 38 * This class represents an item that is contained in the main list view 39 * and that stores a response from Github. 40 */ 41 class ProviderItem : public QStandardItem 42 { 43 public: 44 /// Constructor. \p r The response that this item stores. 45 explicit ProviderItem(const Response &r); 46 47 /// Re-implemented from QStandardItem. 48 QVariant data(int role = Qt::UserRole + 1) const override; 49 50 private: 51 Response m_data; 52 }; 53 54 /** 55 * @class ProviderModel 56 * The model to be used in the main list view. 57 */ 58 class ProviderModel : public QStandardItemModel 59 { 60 Q_OBJECT 61 62 public: 63 enum Role { VcsLocationRole = Qt::UserRole + 1 }; 64 65 /// Constructor. 66 explicit ProviderModel(QObject *parent = nullptr); 67 }; 68 69 } // End of namespace gh 70 71 72 #endif // GH_PROVIDERMODEL_H 73