| 1 |
/* |
| 2 |
* Copyright (C) 2017 Stefano Verzegnassi |
| 3 |
* |
| 4 |
* This program is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License version 3 as |
| 6 |
* published by the Free Software Foundation. |
| 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 General Public License for more details. |
| 12 |
* |
| 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/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
import Lomiri.Components 1.3 |
| 19 |
|
| 20 |
ListItem { |
| 21 |
id: rootItem |
| 22 |
height: layout.height |
| 23 |
|
| 24 |
property int selectedIndex: -1 |
| 25 |
property var model |
| 26 |
|
| 27 |
property string title |
| 28 |
property string subtitle |
| 29 |
property string summary |
| 30 |
|
| 31 |
ListItemLayout { |
| 32 |
id: layout |
| 33 |
|
| 34 |
anchors { left: parent.left; right: parent.right } |
| 35 |
anchors.leftMargin: units.gu(-2) |
| 36 |
anchors.rightMargin: units.gu(-2) |
| 37 |
|
| 38 |
title.text: rootItem.title |
| 39 |
title.textSize: Label.Medium |
| 40 |
subtitle.text: rootItem.subtitle |
| 41 |
subtitle.textSize: Label.Medium |
| 42 |
summary.text: rootItem.summary |
| 43 |
summary.textSize: Label.Medium |
| 44 |
|
| 45 |
Row { |
| 46 |
id: choicesRow |
| 47 |
SlotsLayout.position: SlotsLayout.Last |
| 48 |
height: units.gu(4) |
| 49 |
|
| 50 |
Repeater { |
| 51 |
model: rootItem.model |
| 52 |
|
| 53 |
delegate: AbstractButton { |
| 54 |
id: del |
| 55 |
property bool isSelected: model.index == rootItem.selectedIndex |
| 56 |
|
| 57 |
onClicked: rootItem.selectedIndex = model.index |
| 58 |
|
| 59 |
width: delLabel.width + units.gu(2) |
| 60 |
height: parent.height |
| 61 |
|
| 62 |
Rectangle { |
| 63 |
anchors.fill: parent |
| 64 |
color: theme.palette.selected.base |
| 65 |
visible: del.pressed |
| 66 |
} |
| 67 |
|
| 68 |
Label { |
| 69 |
id: delLabel |
| 70 |
anchors.centerIn: parent |
| 71 |
text: modelData |
| 72 |
textSize: Label.Medium |
| 73 |
color: isSelected ? theme.palette.normal.backgroundText : theme.palette.disabled.backgroundText |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
} |