| 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 |
import Lomiri.Components 1.3 |
| 19 |
|
| 20 |
/*! |
| 21 |
\qmltype PageHeadSections |
| 22 |
\inqmlmodule Lomiri.Components |
| 23 |
\ingroup lomiri |
| 24 |
\since Lomiri.Components 1.1 |
| 25 |
\deprecated |
| 26 |
\brief PageHeadSections is used to configure the sections for a \l Page. |
| 27 |
|
| 28 |
These sections will be shown in the bottom part of the header. This component does not |
| 29 |
need to be instantiated by the developer, it is automatically part of \l PageHeadConfiguration. |
| 30 |
|
| 31 |
See also \l Sections. |
| 32 |
*/ |
| 33 |
QtObject { |
| 34 |
// To be used inside PageHeadConfiguration |
| 35 |
id: sections |
| 36 |
|
| 37 |
/*! |
| 38 |
Set this property to false to disable user interaction to change the selected section. |
| 39 |
Default value: true |
| 40 |
*/ |
| 41 |
property bool enabled: true |
| 42 |
|
| 43 |
/*! |
| 44 |
The input model for the sections. By default model takes the \l actions |
| 45 |
as input, but if no trigger functions need to be specified, it can be |
| 46 |
simplified to a list of strings naming the sections: |
| 47 |
\qml |
| 48 |
import Lomiri.Components 1.3 |
| 49 |
import QtQuick 2.4 |
| 50 |
|
| 51 |
MainView { |
| 52 |
width: units.gu(50) |
| 53 |
height: units.gu(80) |
| 54 |
|
| 55 |
Page { |
| 56 |
id: page |
| 57 |
title: "Sections" |
| 58 |
head { |
| 59 |
sections { |
| 60 |
model: ["one", "two", "three"] |
| 61 |
} |
| 62 |
} |
| 63 |
Label { |
| 64 |
anchors.centerIn: parent |
| 65 |
text: "Section " + page.head.sections.selectedIndex |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
\endqml |
| 70 |
It is strongly recommended to limit the number of sections to two or three. |
| 71 |
*/ |
| 72 |
property var model: actions |
| 73 |
|
| 74 |
/*! |
| 75 |
List of actions that represent the sections. |
| 76 |
The text of each action is displayed as the section name and clicking |
| 77 |
a section will update the \l selectedIndex. |
| 78 |
|
| 79 |
When \l selectedIndex is changed (by user interaction or by setting |
| 80 |
the value), actions[selectedIndex] will be triggered. |
| 81 |
|
| 82 |
\since Lomiri.Components 1.3 |
| 83 |
*/ |
| 84 |
property list<Action> actions |
| 85 |
|
| 86 |
/*! |
| 87 |
The index of the currently selected section in \l model. |
| 88 |
*/ |
| 89 |
property int selectedIndex: model ? 0 : -1 |
| 90 |
} |