diff --git a/discover/qml/ReviewDelegate.qml b/discover/qml/ReviewDelegate.qml
--- a/discover/qml/ReviewDelegate.qml
+++ b/discover/qml/ReviewDelegate.qml
@@ -23,8 +23,7 @@
import org.kde.discover 2.0
import org.kde.kirigami 2.0 as Kirigami
-ColumnLayout
-{
+RowLayout {
id: item
visible: model.shouldShow
property bool compact: false
@@ -38,52 +37,73 @@
: i18n("%1 out of %2 people found this review useful", favorable, total)
}
- RowLayout {
- Layout.fillWidth: true
+ Repeater {
+ model: depth
+ delegate: Rectangle {
+ Layout.fillHeight: true
+ Layout.minimumWidth: Kirigami.Units.largeSpacing
+ Layout.maximumWidth: Kirigami.Units.largeSpacing
+ color: Qt.tint(Kirigami.Theme.textColor, Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.8))
+ Rectangle {
+ anchors {
+ top: parent.top
+ bottom: parent.bottom
+ left: parent.left
+ }
+ width: 1
+ color: Kirigami.Theme.backgroundColor
+ }
+ }
+ }
+ ColumnLayout
+ {
+ RowLayout {
+ Layout.fillWidth: true
+ Label {
+ id: content
+ Layout.fillWidth: true
+ elide: Text.ElideRight
+ readonly property string author: reviewer ? reviewer : i18n("unknown reviewer")
+ text: summary ? i18n("%1 by %2", summary, author) : i18n("Comment by %1", author)
+ }
+ Rating {
+ id: rating
+ rating: model.rating
+ starSize: content.font.pointSize
+ }
+ }
Label {
- id: content
Layout.fillWidth: true
- elide: Text.ElideRight
- readonly property string author: reviewer ? reviewer : i18n("unknown reviewer")
- text: summary ? i18n("%1 by %2", summary, author) : i18n("Comment by %1", author)
+ text: display
+ maximumLineCount: item.compact ? 3 : undefined
+ wrapMode: Text.Wrap
}
- Rating {
- id: rating
- rating: model.rating
- starSize: content.font.pointSize
+ Label {
+ visible: !item.compact
+ text: item.usefulnessToString(usefulnessFavorable, usefulnessTotal)
}
- }
- Label {
- Layout.fillWidth: true
- text: display
- maximumLineCount: item.compact ? 3 : undefined
- wrapMode: Text.Wrap
- }
- Label {
- visible: !item.compact
- text: usefulnessToString(usefulnessFavorable, usefulnessTotal)
- }
- Label {
- visible: !item.compact
- Layout.alignment: Qt.AlignRight
- text: {
- switch(usefulChoice) {
- case ReviewsModel.Yes:
- i18n("Useful? Yes/No")
- break;
- case ReviewsModel.No:
- i18n("Useful? Yes/No")
- break;
- default:
- i18n("Useful? Yes/No")
- break;
+ Label {
+ visible: !item.compact
+ Layout.alignment: Qt.AlignRight
+ text: {
+ switch(usefulChoice) {
+ case ReviewsModel.Yes:
+ i18n("Useful? Yes/No")
+ break;
+ case ReviewsModel.No:
+ i18n("Useful? Yes/No")
+ break;
+ default:
+ i18n("Useful? Yes/No")
+ break;
+ }
}
+ onLinkActivated: item.markUseful(link=='true')
+ }
+ Kirigami.Separator {
+ visible: item.separator
+ Layout.fillWidth: true
}
- onLinkActivated: item.markUseful(link=='true')
- }
- Kirigami.Separator {
- visible: item.separator
- Layout.fillWidth: true
}
}
diff --git a/libdiscover/ReviewsBackend/ReviewsModel.h b/libdiscover/ReviewsBackend/ReviewsModel.h
--- a/libdiscover/ReviewsBackend/ReviewsModel.h
+++ b/libdiscover/ReviewsBackend/ReviewsModel.h
@@ -45,7 +45,8 @@
UsefulnessFavorable,
UsefulChoice,
Rating,
- Summary
+ Summary,
+ Depth
};
enum UserChoice {
None,
diff --git a/libdiscover/ReviewsBackend/ReviewsModel.cpp b/libdiscover/ReviewsBackend/ReviewsModel.cpp
--- a/libdiscover/ReviewsBackend/ReviewsModel.cpp
+++ b/libdiscover/ReviewsBackend/ReviewsModel.cpp
@@ -46,6 +46,7 @@
roles.insert(UsefulChoice, "usefulChoice");
roles.insert(Rating, "rating");
roles.insert(Summary, "summary");
+ roles.insert(Depth, "depth");
return roles;
}
@@ -72,6 +73,8 @@
return m_reviews.at(index.row())->rating();
case Summary:
return m_reviews.at(index.row())->summary();
+ case Depth:
+ return m_reviews.at(index.row())->getMetadata(QStringLiteral("NumberOfParents")).toInt();
}
return QVariant();
}
diff --git a/libdiscover/backends/KNSBackend/KNSReviews.cpp b/libdiscover/backends/KNSBackend/KNSReviews.cpp
--- a/libdiscover/backends/KNSBackend/KNSReviews.cpp
+++ b/libdiscover/backends/KNSBackend/KNSReviews.cpp
@@ -78,21 +78,29 @@
m_fetching++;
}
-void KNSReviews::commentsReceived(Attica::BaseJob* j)
-{
- m_fetching--;
- Attica::ListJob* job = static_cast*>(j);
- Attica::Comment::List comments = job->itemList();
-
+static QVector createReviewList(AbstractResource* app, Attica::Comment::List comments, int depth = 0) {
QVector reviews;
- AbstractResource* app = job->property("app").value();
foreach(const Attica::Comment& comment, comments) {
//TODO: language lookup?
ReviewPtr r(new Review(app->name(), app->packageName(), QStringLiteral("en"), comment.subject(), comment.text(), comment.user(),
comment.date(), true, comment.id().toInt(), comment.score()/10, 0, 0, QString()
));
+ r->addMetadata(QStringLiteral("NumberOfParents"), depth);
reviews += r;
+ if (comment.childCount() > 0) {
+ reviews += createReviewList(app, comment.children(), depth + 1);
+ }
}
+ return reviews;
+}
+
+void KNSReviews::commentsReceived(Attica::BaseJob* j)
+{
+ m_fetching--;
+ Attica::ListJob* job = static_cast*>(j);
+
+ AbstractResource* app = job->property("app").value();
+ QVector reviews = createReviewList(app, job->itemList());
emit reviewsReady(app, reviews, !reviews.isEmpty());
}