KNewStuff

quickitemsmodel.h
1 /*
2  SPDX-FileCopyrightText: 2016 Dan Leinir Turthra Jensen <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #ifndef ITEMSMODEL_H
8 #define ITEMSMODEL_H
9 
10 #include <QAbstractListModel>
11 
51 {
52  Q_OBJECT
56  Q_PROPERTY(QObject* engine READ engine WRITE setEngine NOTIFY engineChanged)
62 public:
63  explicit ItemsModel(QObject *parent = nullptr);
64  virtual ~ItemsModel();
65 
66  enum Roles {
67  NameRole = Qt::UserRole + 1,
68  UniqueIdRole,
69  CategoryRole,
70  HomepageRole,
71  AuthorRole,
72  LicenseRole,
73  ShortSummaryRole,
74  SummaryRole,
75  ChangelogRole,
76  VersionRole,
77  ReleaseDateRole,
78  UpdateVersionRole,
79  UpdateReleaseDateRole,
80  PayloadRole,
81  PreviewsSmallRole,
84  UnInstalledFilesRole,
85  RatingRole,
86  NumberOfCommentsRole,
87  DownloadCountRole,
88  NumberFansRole,
89  NumberKnowledgebaseEntriesRole,
90  KnowledgebaseLinkRole,
91  DownloadLinksRole,
92  DonationLinkRole,
93  ProviderIdRole,
94  SourceRole,
95  StatusRole,
96  CommentsModelRole,
97  };
98  Q_ENUM(Roles)
99  enum ItemStatus {
100  InvalidStatus,
101  DownloadableStatus,
102  InstalledStatus,
103  UpdateableStatus,
104  DeletedStatus,
105  InstallingStatus,
106  UpdatingStatus,
107  };
108  Q_ENUM(ItemStatus)
109  // The lists in OCS are one-indexed, and that isn't how one usually does things in C++.
110  // Consequently, this enum removes what would seem like magic numbers from the code, and
111  // makes their meaning more explicit.
112  enum LinkId {
113  AutoDetectLinkId = -1,
114  FirstLinkId = 1,
115  };
116  Q_ENUM(LinkId)
117 
118  QHash< int, QByteArray > roleNames() const override;
119  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
120  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
121  bool canFetchMore(const QModelIndex & parent) const override;
122  void fetchMore(const QModelIndex & parent) override;
123 
124  QObject *engine() const;
125  void setEngine(QObject *newEngine);
126  Q_SIGNAL void engineChanged();
127 
132  bool isLoadingData() const;
138 
151  Q_INVOKABLE void installItem(int index, int linkId);
163  Q_INVOKABLE void updateItem(int index);
173  Q_INVOKABLE void uninstallItem(int index);
174 
182  Q_INVOKABLE void adoptItem(int index);
183 
189  Q_SIGNAL void entryChanged(int index);
190 private:
191  class Private;
192  Private *d;
193 };
194 Q_DECLARE_METATYPE(ItemsModel::ItemStatus)
195 
196 #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-2021 The KDE developers.
Generated on Mon Jan 18 2021 22:43:50 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.