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 "quickitemsmodel.h"
11
12#include <entry.h>
13
14#include <QQmlParserStatus>
15#include <QSortFilterProxyModel>
16
17#include <memory>
18
19namespace KNewStuffQuick
20{
21class CommentsModelPrivate;
22/**
23 * @short Encapsulates a KNSCore::CommentsModel for use in Qt Quick
24 *
25 * This class takes care of initialisation of a KNSCore::CommentsModel when assigned an engine,
26 * providerId and entryId. If the data is not yet cached, it will be requested from the provider,
27 * and updated for display
28 * @since 5.63
29 */
31{
34 /**
35 * The KNewStuffQuick::ItemsModel to interact with servers through
36 */
37 Q_PROPERTY(ItemsModel *itemsModel READ itemsModel WRITE setItemsModel NOTIFY itemsModelChanged)
38 /**
39 * The index in the model of the entry to fetch comments for
40 */
41 Q_PROPERTY(KNSCore::Entry entry READ entry WRITE setEntry NOTIFY entryChanged)
42 /**
43 * Which types of comments should be included
44 * @default AllComments
45 * @since 5.65
46 */
48public:
49 /**
50 * The options which can be set for which comments to include
51 * @since 5.65
52 */
54 IncludeAllComments = 0, //< All comments should be included
55 IncludeOnlyReviews = 1, //< Only comments which have a rating (and thus is considered a review) should be included
56 IncludeReviewsAndReplies = 2, //< Reviews (as OnlyReviews), except child comments are also included
57 };
58 Q_ENUM(IncludedComments)
59
60 explicit CommentsModel(QObject *parent = nullptr);
61 ~CommentsModel() override;
62 void classBegin() override;
63 void componentComplete() override;
64
65 ItemsModel *itemsModel() const;
66 void setItemsModel(ItemsModel *newItemsModel);
67 Q_SIGNAL void itemsModelChanged();
68
69 KNSCore::Entry entry() const;
70 void setEntry(const KNSCore::Entry &entry);
71 Q_SIGNAL void entryChanged();
72
73 /**
74 * Which comments should be included
75 * @since 5.65
76 */
78 /**
79 * Set which comments should be included
80 * @since 5.65
81 */
83 /**
84 * Fired when the value of includedComments changes
85 * @since 5.65
86 */
88
89 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
90
91private:
92 const std::unique_ptr<CommentsModelPrivate> d;
93};
94}
95
96#endif // KNSQUICK_COMMENTSMODEL_H
A model which shows the contents found in an Engine.
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.
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.
ItemsModel * itemsModel
The KNewStuffQuick::ItemsModel to interact with servers through.
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 Sat Dec 21 2024 17:02:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.