1 | /* |
2 | SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <admin@leinir.dk> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
5 | */ |
6 | |
7 | #ifndef KNSQUICK_COMMENTSMODEL_H |
8 | #define |
9 | |
10 | #include <QQmlParserStatus> |
11 | #include <QSortFilterProxyModel> |
12 | #include <entry.h> |
13 | |
14 | #include <memory> |
15 | |
16 | namespace KNewStuffQuick |
17 | { |
18 | class ; |
19 | /** |
20 | * @short Encapsulates a KNSCore::CommentsModel for use in Qt Quick |
21 | * |
22 | * This class takes care of initialisation of a KNSCore::CommentsModel when assigned an engine, |
23 | * providerId and entryId. If the data is not yet cached, it will be requested from the provider, |
24 | * and updated for display |
25 | * @since 5.63 |
26 | */ |
27 | class : public QSortFilterProxyModel, public QQmlParserStatus |
28 | { |
29 | Q_OBJECT |
30 | Q_INTERFACES(QQmlParserStatus) |
31 | /** |
32 | * The KNewStufQuick::ItemsModel to interact with servers through |
33 | */ |
34 | Q_PROPERTY(QObject *itemsModel READ itemsModel WRITE setItemsModel NOTIFY itemsModelChanged) |
35 | /** |
36 | * The index in the model of the entry to fetch comments for |
37 | */ |
38 | Q_PROPERTY(KNSCore::Entry entry READ entry WRITE setEntry NOTIFY entryChanged) |
39 | /** |
40 | * Which types of comments should be included |
41 | * @default AllComments |
42 | * @since 5.65 |
43 | */ |
44 | Q_PROPERTY(KNewStuffQuick::CommentsModel::IncludedComments includedComments READ includedComments WRITE setIncludedComments NOTIFY includedCommentsChanged) |
45 | public: |
46 | /** |
47 | * The options which can be set for which comments to include |
48 | * @since 5.65 |
49 | */ |
50 | enum { |
51 | = 0, //< All comments should be included |
52 | = 1, //< Only comments which have a rating (and thus is considered a review) should be included |
53 | IncludeReviewsAndReplies = 2, //< Reviews (as OnlyReviews), except child comments are also included |
54 | }; |
55 | Q_ENUM(IncludedComments) |
56 | |
57 | explicit (QObject *parent = nullptr); |
58 | () override; |
59 | void () override; |
60 | void () override; |
61 | |
62 | QObject *() const; |
63 | void (QObject *newItemsModel); |
64 | Q_SIGNAL void (); |
65 | |
66 | KNSCore::Entry () const; |
67 | void (const KNSCore::Entry &entry); |
68 | Q_SIGNAL void (); |
69 | |
70 | /** |
71 | * Which comments should be included |
72 | * @since 5.65 |
73 | */ |
74 | CommentsModel::IncludedComments () const; |
75 | /** |
76 | * Set which comments should be included |
77 | * @since 5.65 |
78 | */ |
79 | void (CommentsModel::IncludedComments ); |
80 | /** |
81 | * Fired when the value of includedComments changes |
82 | * @since 5.65 |
83 | */ |
84 | Q_SIGNAL void (); |
85 | |
86 | bool (int sourceRow, const QModelIndex &sourceParent) const override; |
87 | |
88 | private: |
89 | const std::unique_ptr<CommentsModelPrivate> ; |
90 | }; |
91 | } |
92 | |
93 | #endif // KNSQUICK_COMMENTSMODEL_H |
94 | |