~nick-dedekind/unity8/indicators.hint-interval

« back to all changes in this revision

Viewing changes to qml/Dash/Previews/PreviewRatingDisplay.qml

  • Committer: Nick Dedekind
  • Date: 2014-03-07 15:54:57 UTC
  • mfrom: (638.1.118 unity8)
  • Revision ID: nicholas.dedekind@gmail.com-20140307155457-f0s1zu5ll2czt3rq
merged with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
21
/*! \brief Preview widget for rating display.
 
22
 
 
23
    The widget can show a rating widget and a field showing a comment.
 
24
    The icons used in the rating widget can be customised with
 
25
    widgetData["rating-icon-empty"], widgetData["rating-icon-full"]
 
26
    and widgetData["rating-icon-half"].
 
27
 
 
28
    This widget shows reviews contained in widgetData["reviews"], each of which should be of the form:
 
29
 
 
30
    \code{.json}
 
31
    {
 
32
      "rating": null,
 
33
      "review": null,
 
34
      "author": null
 
35
    }
 
36
    \endcode
 
37
 */
 
38
 
 
39
PreviewWidget {
 
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
                    color: Theme.palette.selected.backgroundText
 
75
                    opacity: .8
 
76
                    text: modelData["author"] || ""
 
77
                    visible: text !== ""
 
78
                    wrapMode: Text.Wrap
 
79
                }
 
80
 
 
81
                Label {
 
82
                    id: reviewLabel
 
83
                    objectName: "reviewLabel"
 
84
                    anchors { left: parent.left; right: parent.right }
 
85
                    color: Theme.palette.selected.backgroundText
 
86
                    opacity: .8
 
87
                    text: modelData["review"] || ""
 
88
                    visible: text !== ""
 
89
                    wrapMode: Text.Wrap
 
90
                }
 
91
 
 
92
                Item {
 
93
                    id: spacing
 
94
                    anchors { left: parent.left; right: parent.right }
 
95
                    height: units.gu(2)
 
96
                    visible: rating.visible || authorLabel.visible || reviewLabel.visible
 
97
                }
 
98
            }
 
99
        }
 
100
    }
 
101
}