aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml
blob: 01abaf1909dc6730c7b48aa9bbaf5b7e1ea256d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//![0]
import QtQuick
import QtQml.Models

ListView {
    id: view
    width: 300
    height: 400

    model: DelegateModel {
        model: fileSystemModel

        delegate: Rectangle {
            width: 200; height: 25
            Text { text: filePath }

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    if (model.hasModelChildren)
                        view.model.rootIndex = view.model.modelIndex(index)
                }
            }
        }
    }
}
//![0]