Unity 8
 All Classes Functions Properties
PreviewRatingDisplay.qml
1 /*
2  * Copyright (C) 2014 Canonical, Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 import QtQuick 2.0
18 import Ubuntu.Components 0.1
19 import "../../Components"
20 
40  id: root
41  height: childrenRect.height
42 
43  Column {
44  anchors { left: parent.left; right: parent.right; }
45  visible: reviewsRepeater.count > 0
46 
47  Repeater {
48  id: reviewsRepeater
49  objectName: "reviewsRepeater"
50  model: root.widgetData["reviews"]
51 
52  delegate: Column {
53  id: reviewItem
54  objectName: "reviewItem" + index
55  anchors { left: parent.left; right: parent.right;}
56  spacing: units.gu(1)
57 
58  Rating {
59  id: rating
60  objectName: "rating"
61  size: 5
62  value: modelData["rating"] || -1
63  visible: value >= 0
64 
65  property var urlIconEmpty: widgetData["rating-icon-empty"]
66  property var urlIconFull: widgetData["rating-icon-full"]
67  property var urlIconHalf: widgetData["rating-icon-half"]
68  }
69 
70  Label {
71  id: authorLabel
72  objectName: "authorLabel"
73  anchors { left: parent.left; right: parent.right }
74  // TODO cimi: Yet another fix requiring Palette update.
75  color: "grey" //Theme.palette.selected.backgroundText
76  opacity: .8
77  text: modelData["author"] || ""
78  visible: text !== ""
79  wrapMode: Text.Wrap
80  }
81 
82  Label {
83  id: reviewLabel
84  objectName: "reviewLabel"
85  anchors { left: parent.left; right: parent.right }
86  // TODO cimi: Yet another fix requiring Palette update.
87  color: "grey" //Theme.palette.selected.backgroundText
88  opacity: .8
89  text: modelData["review"] || ""
90  visible: text !== ""
91  wrapMode: Text.Wrap
92  }
93 
94  Item {
95  id: spacing
96  anchors { left: parent.left; right: parent.right }
97  height: units.gu(2)
98  visible: rating.visible || authorLabel.visible || reviewLabel.visible
99  }
100  }
101  }
102  }
103 }
var widgetData
Variable used to contain widget's data.