KNewStuff

qtquick/commentsmodel.h
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 KNSQUICK_COMMENTSMODEL_H
9
10#include <QQmlParserStatus>
11#include <QSortFilterProxyModel>
12#include <entry.h>
13
14#include <memory>
15
16namespace KNewStuffQuick
17{
18class CommentsModelPrivate;
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 */
28{
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 */
45public:
46 /**
47 * The options which can be set for which comments to include
48 * @since 5.65
49 */
51 IncludeAllComments = 0, //< All comments should be included
52 IncludeOnlyReviews = 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 CommentsModel(QObject *parent = nullptr);
58 ~CommentsModel() override;
59 void classBegin() override;
60 void componentComplete() override;
61
62 QObject *itemsModel() const;
63 void setItemsModel(QObject *newItemsModel);
64 Q_SIGNAL void itemsModelChanged();
65
66 KNSCore::Entry entry() const;
67 void setEntry(const KNSCore::Entry &entry);
68 Q_SIGNAL void entryChanged();
69
70 /**
71 * Which comments should be included
72 * @since 5.65
73 */
75 /**
76 * Set which comments should be included
77 * @since 5.65
78 */
80 /**
81 * Fired when the value of includedComments changes
82 * @since 5.65
83 */
85
86 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
87
88private:
89 const std::unique_ptr<CommentsModelPrivate> d;
90};
91}
92
93#endif // KNSQUICK_COMMENTSMODEL_H
KNewStuff data entry container.
Definition entry.h:48
Encapsulates a KNSCore::CommentsModel for use in Qt Quick.
KNewStuffQuick::CommentsModel::IncludedComments includedComments
Which types of comments should be included @default AllComments.
QObject * itemsModel
The KNewStufQuick::ItemsModel to interact with servers through.
KNSCore::Entry entry
The index in the model of the entry to fetch comments for.
IncludedComments
The options which can be set for which comments to include.
void setIncludedComments(CommentsModel::IncludedComments includedComments)
Set which comments should be included.
Q_SIGNAL void includedCommentsChanged()
Fired when the value of includedComments changes.
Q_ENUM(...)
Q_INTERFACES(...)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALQ_SIGNAL
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:21:35 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.