9import QtQuick.Controls as QQC2
11import org.kde.kirigami as Kirigami
15 property bool editable: false
17 property int rating: 0
18 property real starSize: Kirigami.Units.gridUnit
19 property bool reverseLayout: false
24 readonly property int ratingIndex: Math.floor((theRepeater.count * view.rating) / view.max)
25 readonly property bool ratingHalf: (theRepeater.count * view.rating) % view.max >= view.max / 2
28 Layout.minimumWidth: view.starSize
29 Layout.minimumHeight: view.starSize
30 visible: view.reverseLayout
31 text: ratingAsText.text
34 visible: view.reverseLayout
35 Layout.minimumHeight: view.starSize;
36 Layout.minimumWidth:
Kirigami.Units.smallSpacing;
37 Layout.maximumWidth:
Kirigami.Units.smallSpacing;
43 Layout.minimumWidth: view.starSize
44 Layout.minimumHeight: view.starSize
45 Layout.preferredWidth: view.starSize
46 Layout.preferredHeight: view.starSize
48 source: index < view.ratingIndex
50 : (view.ratingHalf && index === view.ratingIndex
51 ? (view.LayoutMirroring.enabled ?
"rating-half-rtl" :
"rating-half")
53 opacity: (view.editable && mouse.item.containsMouse) ? 0.7 : 1
59 condition: view.editable
60 componentTrue: MouseArea {
63 rating = (max/theRepeater.model*(index+1));
71 visible: !view.reverseLayout
72 Layout.minimumHeight: view.starSize;
73 Layout.minimumWidth:
Kirigami.Units.smallSpacing;
74 Layout.maximumWidth:
Kirigami.Units.smallSpacing;
78 Layout.minimumWidth: view.starSize
79 Layout.minimumHeight: view.starSize
80 visible: !view.reverseLayout
81 text:
i18ndc(
"knewstuff6",
"A text representation of the rating, shown as a fraction of the max value",
"(%1/%2)", view.rating / 10, view.max / 10)
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)