Files

42 lines
1.1 KiB
QML

import QtQuick 2.0
import Sailfish.Silica 1.0
Dialog {
id: dialog
property var model: []
property int selectedIndex: 0
SilicaListView {
anchors.fill: parent
header: DialogHeader { title: qsTr("Table of contents") }
model: dialog.model
delegate: ListItem {
id: item
contentHeight: Theme.itemSizeMedium
Label {
anchors.left: parent.left
anchors.leftMargin: Theme.horizontalPageMargin
anchors.right: parent.right
anchors.rightMargin: Theme.horizontalPageMargin
anchors.verticalCenter: parent.verticalCenter
text: (modelData.index + 1) + ". " + modelData.title
color: item.highlighted ? Theme.highlightColor : Theme.primaryColor
truncationMode: TruncationMode.Elide
}
onClicked: {
dialog.selectedIndex = modelData.index
dialog.accept()
}
}
ViewPlaceholder {
enabled: dialog.model.length === 0
text: qsTr("No chapters")
}
}
}