Debian Codegraph @

src/imports/Components/1.2/PageHeadSections.qml

raw
1 /*
2 * Copyright 2014-2015 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
19 /*!
20 \qmltype PageHeadSections
21 \inqmlmodule Lomiri.Components
22 \ingroup lomiri
23 \since Lomiri.Components 1.1
24 \brief PageHeadSections is used to configure the sections for a \l Page.
25
26 These sections will be shown in the bottom part of the header. This component does not
27 need to be instantiated by the developer, it is automatically part of \l PageHeadConfiguration.
28 */
29 QtObject {
30 // To be used inside PageHeadConfiguration
31 id: sections
32
33 /*!
34 Set this property to false to disable user interaction to change the selected section.
35 Default value: true
36 */
37 property bool enabled: true
38
39 /*!
40 List of strings that represent section names. Example:
41 \qml
42 import Lomiri.Components 1.2
43 import QtQuick 2.4
44
45 MainView {
46 width: units.gu(50)
47 height: units.gu(80)
48
49 Page {
50 id: page
51 title: "Sections"
52 head {
53 sections {
54 model: ["one", "two", "three"]
55 }
56 }
57
58 Label {
59 anchors.centerIn: parent
60 text: "Section " + page.head.sections.selectedIndex
61 }
62 }
63 }
64 \endqml
65 It is strongly recommended to limit the number of sections to two or three.
66 */
67 property var model
68 onModelChanged: {
69 if (model && model.length > 3) {
70 console.warn("It is not recommended or supported to use more than three sections in Page.head.sections.model.");
71 }
72 }
73
74 /*!
75 The index of the currently selected section in \l model.
76 */
77 property int selectedIndex: model ? 0 : -1
78 }