Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/itemsmodel.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2016 Dan Leinir Turthra Jensen <admin@leinir.dk> | ||||
3 | * | ||||
4 | * This library is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU Lesser General Public | ||||
6 | * License as published by the Free Software Foundation; either | ||||
7 | * version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | * later version accepted by the membership of KDE e.V. (or its | ||||
9 | * successor approved by the membership of KDE e.V.), which shall | ||||
10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | * | ||||
12 | * This library is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | * Lesser General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU Lesser General Public | ||||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | * | ||||
20 | */ | ||||
21 | | ||||
22 | #ifndef ITEMSMODEL_H | ||||
23 | #define ITEMSMODEL_H | ||||
24 | | ||||
25 | #include <QAbstractListModel> | ||||
26 | | ||||
27 | class ItemsModel : public QAbstractListModel | ||||
28 | { | ||||
29 | Q_OBJECT | ||||
30 | Q_PROPERTY(QObject* engine READ engine WRITE setEngine NOTIFY engineChanged) | ||||
31 | public: | ||||
32 | explicit ItemsModel(QObject* parent = 0); | ||||
33 | virtual ~ItemsModel(); | ||||
34 | | ||||
35 | enum Roles { | ||||
36 | NameRole = Qt::UserRole + 1, | ||||
37 | UniqueIdRole, | ||||
38 | CategoryRole, | ||||
39 | HomepageRole, | ||||
40 | AuthorRole, | ||||
41 | LicenseRole, | ||||
42 | ShortSummaryRole, | ||||
43 | SummaryRole, | ||||
44 | ChangelogRole, | ||||
45 | VersionRole, | ||||
46 | ReleaseDateRole, | ||||
47 | UpdateVersionRole, | ||||
48 | UpdateReleaseDateRole, | ||||
49 | PayloadRole, | ||||
50 | PreviewsSmallRole, ///@< this will return a list here, rather than be tied so tightly to the remote api | ||||
51 | PreviewsRole, ///@< this will return a list here, rather than be tied so tightly to the remote api | ||||
52 | InstalledFilesRole, | ||||
53 | UnInstalledFilesRole, | ||||
54 | RatingRole, | ||||
55 | NumberOfCommentsRole, | ||||
56 | DownloadCountRole, | ||||
57 | NumberFansRole, | ||||
58 | NumberKnowledgebaseEntriesRole, | ||||
59 | KnowledgebaseLinkRole, | ||||
60 | DownloadLinksRole, | ||||
61 | DonationLinkRole, | ||||
62 | ProviderIdRole, | ||||
63 | SourceRole, | ||||
64 | StatusRole | ||||
65 | }; | ||||
66 | enum ItemStatus { | ||||
67 | InvalidStatus, | ||||
68 | DownloadableStatus, | ||||
69 | InstalledStatus, | ||||
70 | UpdateableStatus, | ||||
71 | DeletedStatus, | ||||
72 | InstallingStatus, | ||||
73 | UpdatingStatus | ||||
74 | }; | ||||
75 | Q_ENUMS(ItemStatus) | ||||
76 | | ||||
77 | virtual QHash< int, QByteArray > roleNames() const Q_DECL_OVERRIDE; | ||||
78 | virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; | ||||
79 | virtual int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||||
80 | virtual bool canFetchMore(const QModelIndex & parent) const Q_DECL_OVERRIDE; | ||||
81 | virtual void fetchMore(const QModelIndex & parent) Q_DECL_OVERRIDE; | ||||
82 | | ||||
83 | QObject* engine() const; | ||||
84 | void setEngine(QObject* newEngine); | ||||
85 | Q_SIGNAL void engineChanged(); | ||||
86 | | ||||
87 | /** | ||||
88 | * @brief This will install (or update, if already installed) the item at the given index | ||||
89 | * | ||||
90 | * There are no side effects of this function if it is called on an item which cannot be | ||||
91 | * installed or updated (that is, if the status is not one such that these are possible, | ||||
92 | * the function will simply return without performing any actions) | ||||
93 | * | ||||
94 | * @param index The index of the item to install or update | ||||
95 | */ | ||||
96 | Q_INVOKABLE void installItem(int index); | ||||
97 | /** | ||||
98 | * @brief Uninstall an already installed item | ||||
99 | * | ||||
100 | * There are no side effects of this function if it is called on an item which cannot be | ||||
101 | * uninstalled (that is, if the status is not one such that this is possible, | ||||
102 | * the function will simply return without performing any actions) | ||||
103 | * | ||||
104 | * @param index The index of the item to be uninstalled | ||||
105 | */ | ||||
106 | Q_INVOKABLE void uninstallItem(int index); | ||||
107 | private: | ||||
108 | class Private; | ||||
109 | Private* d; | ||||
110 | }; | ||||
111 | Q_DECLARE_METATYPE(ItemsModel::ItemStatus) | ||||
112 | | ||||
113 | #endif//ITEMSMODEL_H |