/*
* Copyright (C) 2016 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authored by: Florian Boucault
*/
import QtQuick 2.4
import QtQuick.Layouts 1.3
import QtQml.Models 2.2
import Lomiri.Components 1.3
SettingsSection {
id: section
margins: units.gu(4)
ColumnLayout {
anchors {
right: parent.right
left: parent.left
top: parent.top
margins: section.margins
}
height: Math.min(parent.height - section.margins * 2, units.gu(60))
spacing: units.gu(2)
RowLayout {
Layout.fillWidth: true
Layout.preferredHeight: searchField.height
spacing: units.gu(2)
TextFieldStyled {
id: searchField
primaryItem: Icon {
height: parent.height / 2
width: height
name: "find"
asynchronous: true
color: theme.palette.normal.baseText
}
}
Label {
Layout.fillWidth: true
verticalAlignment: Text.AlignVCenter
text: i18n.tr("Showing %1 of %2").arg(shortcutsList.count)
.arg(allShortcutsModel.count)
elide: Text.ElideRight
color: theme.palette.normal.base
visible: searchField.text
}
}
ListView {
id: shortcutsList
Layout.fillHeight: true
Layout.fillWidth: true
Rectangle {
anchors.fill: parent
radius: units.dp(3)
border.color: theme.palette.normal.base
border.width: units.dp(1)
color: "transparent"
}
clip: true
Scrollbar {
flickableItem: shortcutsList
align: Qt.AlignTrailing
}
focus: true
section {
property: "section"
delegate: Item {
width: parent.width
implicitHeight: units.gu(4)
Label {
anchors {
fill: parent
leftMargin: units.gu(2)
}
verticalAlignment: Text.AlignVCenter
text: i18n.tr(section)
elide: Text.ElideRight
}
Rectangle {
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
height: units.dp(1)
color: theme.palette.normal.base
}
}
}
model: DelegateModel {
filterOnGroup: filteringGroup.criteria ? "filtered" : ""
groups: [
DelegateModelGroup {
id: filteringGroup
includeByDefault: true
name: "filtered"
property string criteria: searchField.text
onCriteriaChanged: update()
function update() {
if (count != 0) {
remove(0, count);
}
for ( var i=0; i