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 QtQuick.Layouts 1.1
19 import Ubuntu.Components 1.3
24 signal requestFavorite(string scopeId, bool favorite)
25 signal handlePressed(var handle)
26 signal handleReleased(var handle)
28 property real topMargin: 0
29 property alias icon: shapeImage.source
30 property alias text: titleLabel.text
31 property alias subtext: subtitleLabel.text
33 property bool showStar: false
34 property bool isFavorite: false
35 property bool hideChildren: false
40 anchors.topMargin: root.topMargin
46 leftMargin: units.gu(1)
47 verticalCenter: parent.verticalCenter
51 visible: !hideChildren
52 sourceFillMode: UbuntuShape.PreserveAspectCrop
56 sourceSize { width: shape.width; height: shape.height }
61 visible: !hideChildren
64 leftMargin: units.gu(1)
66 verticalCenter: parent.verticalCenter
70 Layout.fillWidth: true
71 elide: Text.ElideRight
74 verticalAlignment: Text.AlignHCenter
78 Layout.fillWidth: true
79 elide: Text.ElideRight
83 verticalAlignment: Text.AlignHCenter
89 objectName: "starArea"
92 anchors.right: parent.right
93 onClicked: if (!editMode) root.requestFavorite(model.scopeId, !isFavorite);
94 onPressed: if (editMode) root.handlePressed(starArea);
95 onReleased: if (editMode) root.handleReleased(starArea);
96 visible: editMode || showStar
99 anchors.centerIn: parent
102 visible: !hideChildren
103 // TODO is view-grid-symbolic what we really want here? Looks good but seems semantically wrong
104 source: editMode ? "image://theme/view-grid-symbolic" : isFavorite ? "image://theme/starred" : "image://theme/non-starred"