Debian Codegraph @

src/imports/Components/ListItems/2.0/Subtitled.qml

raw
1 /*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.4
18 import Lomiri.Components
19
20 /*!
21 \qmltype MultiValue
22 \inqmlmodule Lomiri.Components.ListItems 1.0
23 \ingroup lomiri-listitems
24 \brief List item displaying a second string under the main label.
25 \note \b{The component is deprecated. Use ListItem component instead.}
26
27 Examples:
28 \qml
29 import Lomiri.Components.ListItems as ListItem
30 Column {
31 ListItem.Subtitled {
32 text: "Idle"
33 subText: "Secondary label"
34 }
35 ListItem.Subtitled {
36 text: "Disabled"
37 enabled: false
38 subText: "Secondary label"
39 }
40 ListItem.Subtitled {
41 text: "Selected"
42 selected: true
43 subText: "Secondary label"
44 }
45 ListItem.Subtitled {
46 text: "Progression"
47 subText: "Secondary label"
48 progression: true
49 }
50 ListItem.Subtitled {
51 text: "Icon"
52 subText: "Secondary label"
53 iconName: "compose"
54 }
55 ListItem.Subtitled {
56 text: "Multiple lines"
57 subText: "This is a multi-line subText.\nUp to 5 lines are supported."
58 }
59 ListItem.Subtitled {
60 text: "Multiple lines"
61 subText: "It also works well with icons and progression."
62 iconName: "compose"
63 progression: true
64 }
65 }
66 \endqml
67 */
68 Base {
69 id: subtitledListItem
70 __height: Math.max(middleVisuals.height, units.gu(6))
71
72 /*!
73 The list of strings that will be shown under the label text
74 \qmlproperty string subText
75 */
76 property alias subText: subLabel.text
77
78 Item {
79 id: middleVisuals
80 anchors {
81 left: parent.left
82 right: parent.right
83 verticalCenter: parent.verticalCenter
84 }
85 height: childrenRect.height + label.anchors.topMargin + subLabel.anchors.bottomMargin
86
87 LabelVisual {
88 id: label
89 text: subtitledListItem.text
90 selected: subtitledListItem.selected
91 anchors {
92 top: parent.top
93 left: parent.left
94 right: parent.right
95 }
96 }
97 LabelVisual {
98 id: subLabel
99 selected: subtitledListItem.selected
100 secondary: true
101 anchors {
102
103 left: parent.left
104 right: parent.right
105 top: label.bottom
106 }
107 textSize: Label.Small
108 wrapMode: Text.Wrap
109 maximumLineCount: 5
110 }
111 }
112 }