KNewStuff

EntryCommentsPage.qml
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/**
8 * @brief A Kirigami.Page component used for displaying a NewStuff entry's comments
9 */
10
11import QtQuick
12import QtQuick.Layouts
14import org.kde.kirigami as Kirigami
15
16import org.kde.newstuff as NewStuff
17
18Kirigami.ScrollablePage {
19 id: component
20
21 property string entryName
22 property string entryAuthorId
23 property string entryProviderId
24 property alias entry: commentsModel.entry
25 property alias itemsModel: commentsModel.itemsModel
26
27 title: i18ndc("knewstuff6", "Title for the page containing a view of the comments for the entry", "Comments and Reviews for %1", component.entryName)
28 actions: [
29 Kirigami.Action {
30 text: i18ndc("knewstuff6", "Title for the item which is checked when all comments should be shown", "Show All Comments")
31 checked: commentsModel.includedComments === NewStuff.CommentsModel.IncludeAllComments
32 checkable: true
33 onTriggered: source => {
34 commentsModel.includedComments = NewStuff.CommentsModel.IncludeAllComments;
35 }
36 },
37 Kirigami.Action {
38 text: i18ndc("knewstuff6", "Title for the item which is checked when only comments which are reviews should be shown", "Show Reviews Only")
39 checked: commentsModel.includedComments === NewStuff.CommentsModel.IncludeOnlyReviews
40 checkable: true
41 onTriggered: source => {
42 commentsModel.includedComments = NewStuff.CommentsModel.IncludeOnlyReviews;
43 }
44 },
45 Kirigami.Action {
46 text: i18ndc("knewstuff6", "Title for the item which is checked when comments which are reviews, and their children should be shown", "Show Reviews and Replies")
47 checked: commentsModel.includedComments === NewStuff.CommentsModel.IncludeReviewsAndReplies
48 checkable: true
49 onTriggered: source => {
50 commentsModel.includedComments = NewStuff.CommentsModel.IncludeReviewsAndReplies;
51 }
52 }
53 ]
54 ErrorDisplayer {
55 engine: component.itemsModel.engine
56 active: component.isCurrentPage
57 }
58 ListView {
59 id: commentsView
60 model: NewStuff.CommentsModel {
61 id: commentsModel
62 }
63 Layout.fillWidth: true
64 header: Item {
65 anchors {
66 left: parent.left
67 right: parent.right
68 }
69 height: Kirigami.Units.largeSpacing
70 }
71
72 leftMargin: Kirigami.Units.largeSpacing
73 rightMargin: Kirigami.Units.largeSpacing
74
75 delegate: EntryCommentDelegate {
76 width: {
77 const view = ListView.view;
78 return view ? view.width - view.leftMargin - view.rightMargin : 0;
79 }
80 engine: component.itemsModel.engine
81 entryAuthorId: component.entryAuthorId
82 entryProviderId: component.entryProviderId
83 author: model.username
84 score: model.score
85 title: model.subject
86 reviewText: model.text
87 depth: model.depth
88 }
89 }
90}
A card based delegate for showing a comment from a KNewStuffQuick::QuickCommentsModel.
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
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.