KNewStuff

quickitemsmodel.h
1 /*
2  * Copyright (C) 2016 Dan Leinir Turthra Jensen <[email protected]>
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 
66 {
67  Q_OBJECT
71  Q_PROPERTY(QObject* engine READ engine WRITE setEngine NOTIFY engineChanged)
77 public:
78  explicit ItemsModel(QObject *parent = nullptr);
79  virtual ~ItemsModel();
80 
81  enum Roles {
82  NameRole = Qt::UserRole + 1,
83  UniqueIdRole,
84  CategoryRole,
85  HomepageRole,
86  AuthorRole,
87  LicenseRole,
88  ShortSummaryRole,
89  SummaryRole,
90  ChangelogRole,
91  VersionRole,
92  ReleaseDateRole,
93  UpdateVersionRole,
94  UpdateReleaseDateRole,
95  PayloadRole,
96  PreviewsSmallRole,
99  UnInstalledFilesRole,
100  RatingRole,
101  NumberOfCommentsRole,
102  DownloadCountRole,
103  NumberFansRole,
104  NumberKnowledgebaseEntriesRole,
105  KnowledgebaseLinkRole,
106  DownloadLinksRole,
107  DonationLinkRole,
108  ProviderIdRole,
109  SourceRole,
110  StatusRole,
111  CommentsModelRole
112  };
113  Q_ENUM(Roles)
114  enum ItemStatus {
115  InvalidStatus,
116  DownloadableStatus,
117  InstalledStatus,
118  UpdateableStatus,
119  DeletedStatus,
120  InstallingStatus,
121  UpdatingStatus
122  };
123  Q_ENUM(ItemStatus)
124  // The lists in OCS are one-indexed, and that isn't how one usually does things in C++.
125  // Consequently, this enum removes what would seem like magic numbers from the code, and
126  // makes their meaning more explicit.
127  enum LinkId {
128  AutoDetectLinkId = -1,
129  FirstLinkId = 1
130  };
131  Q_ENUM(LinkId)
132 
133  QHash< int, QByteArray > roleNames() const override;
134  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
135  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
136  bool canFetchMore(const QModelIndex & parent) const override;
137  void fetchMore(const QModelIndex & parent) override;
138 
139  QObject *engine() const;
140  void setEngine(QObject *newEngine);
141  Q_SIGNAL void engineChanged();
142 
147  bool isLoadingData() const;
153 
166  Q_INVOKABLE void installItem(int index, int linkId);
178  Q_INVOKABLE void updateItem(int index);
188  Q_INVOKABLE void uninstallItem(int index);
189 
197  Q_INVOKABLE void adoptItem(int index);
198 
204  Q_SIGNAL void entryChanged(int index);
205 private:
206  class Private;
207  Private *d;
208 };
209 Q_DECLARE_METATYPE(ItemsModel::ItemStatus)
210 
211 #endif//ITEMSMODEL_H
Q_ENUM(...)
bool isLoadingData() const
Whether or not the model is fetching information from a remote location.
< this will return a list here, rather than be tied so tightly to the remote api
< this will return a list here, rather than be tied so tightly to the remote api
Q_INVOKABLE void installItem(int index, int linkId)
This will install (or update, if already installed) the item at the given index.
Q_SIGNAL void isLoadingDataChanged()
Fired when the isLoadingData value changes.
Q_OBJECTQ_OBJECT
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
UserRole
Q_INVOKABLE void adoptItem(int index)
Run the adoption command on an already installed item.
A model which shows the contents found in an Engine.
Q_PROPERTY(...)
Q_SIGNALQ_SIGNAL
Q_SIGNAL void entryChanged(int index)
Fired when an entry&#39;s data changes.
QObject engine
The NewStuffQuickEngine to show items from.
Q_INVOKABLEQ_INVOKABLE
Q_INVOKABLE void uninstallItem(int index)
Uninstall an already installed item.
QObject * parent() const const
Q_INVOKABLE void updateItem(int index)
This will request an update of the given item.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Aug 9 2020 22:43:40 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.