2
* Copyright (C) 2014 Canonical, Ltd.
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.
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.
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/>.
18
import Ubuntu.Components 0.1
25
model: styledItem.size
27
property int indexHalfValue: {
28
var integerPart = Math.floor(styledItem.effectiveValue);
29
var fractionalPart = styledItem.effectiveValue - integerPart;
31
if (fractionalPart < 0.5) return -1;
32
else return integerPart;
34
property url urlIconEmpty: styledItem.urlIconEmpty || "graphics/icon_star_empty.png"
35
property url urlIconFull: styledItem.urlIconFull || "graphics/icon_star_full.png"
36
property url urlIconHalf: styledItem.urlIconHalf || "graphics/icon_star_half.png"
39
opacity: styledItem.value < 0 ? 0.4 : 1 // Let's make the stars look inactive for a not-set value
41
if (index === repeater.indexHalfValue) return repeater.urlIconHalf;
42
else if (index < styledItem.effectiveValue) return repeater.urlIconFull;
43
else return repeater.urlIconEmpty;