File indexing completed on 2024-05-05 04:39:54
0001 /* 0002 SPDX-FileCopyrightText: 2012-2013 Miquel Sabaté <mikisabate@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef GH_PROVIDERMODEL_H 0008 #define GH_PROVIDERMODEL_H 0009 0010 0011 #include <QUrl> 0012 #include <QStandardItemModel> 0013 0014 namespace gh 0015 { 0016 0017 /// Convenient enum to define the kind of the repo. 0018 enum Repo { 0019 Public = 0, 0020 Private, 0021 Fork 0022 }; 0023 0024 /// Basic struct that represents a response from Github. 0025 struct Response { 0026 /// The name of the repo. 0027 QString name; 0028 0029 /// The url of the repo. 0030 QUrl url; 0031 0032 /// The kind of the repo (public, private, fork). 0033 enum Repo kind; 0034 }; 0035 0036 /** 0037 * @class ProviderItem 0038 * This class represents an item that is contained in the main list view 0039 * and that stores a response from Github. 0040 */ 0041 class ProviderItem : public QStandardItem 0042 { 0043 public: 0044 /// Constructor. \p r The response that this item stores. 0045 explicit ProviderItem(const Response &r); 0046 0047 /// Re-implemented from QStandardItem. 0048 QVariant data(int role = Qt::UserRole + 1) const override; 0049 0050 private: 0051 Response m_data; 0052 }; 0053 0054 /** 0055 * @class ProviderModel 0056 * The model to be used in the main list view. 0057 */ 0058 class ProviderModel : public QStandardItemModel 0059 { 0060 Q_OBJECT 0061 0062 public: 0063 enum Role { VcsLocationRole = Qt::UserRole + 1 }; 0064 0065 /// Constructor. 0066 explicit ProviderModel(QObject *parent = nullptr); 0067 }; 0068 0069 } // End of namespace gh 0070 0071 0072 #endif // GH_PROVIDERMODEL_H