Warning, /frameworks/qqc2-desktop-style/tests/HeaderViews.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2023 Marco Martin <mart@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick
0008 import QtQuick.Layouts 1.4
0009 import QtQuick.Controls 2.15 as QQC2
0010 import org.kde.kirigami as Kirigami
0011 import org.kde.plasma.components 3 as PC3
0012 import Qt.labs.qmlmodels 1.0
0013 
0014 GridLayout {
0015     id: root
0016     width: 500
0017     height: 300
0018     rows: 2
0019     columns: 2
0020     rowSpacing: 0
0021     columnSpacing: 0
0022 
0023     Item {}
0024     QQC2.HorizontalHeaderView {
0025         syncView: table
0026         Layout.fillWidth: true
0027     }
0028     QQC2.VerticalHeaderView {
0029         syncView: table
0030         Layout.fillWidth: true
0031     }
0032     TableView {
0033         id: table
0034         Layout.fillWidth: true
0035         Layout.fillHeight: true
0036         alternatingRows: true
0037 
0038         selectionModel: ItemSelectionModel {}
0039 
0040         model: TableModel {
0041             TableModelColumn { display: "A" }
0042             TableModelColumn { display: "B" }
0043             TableModelColumn { display: "C" }
0044             TableModelColumn { display: "D" }
0045 
0046             rows: [
0047                 {
0048                     A: "A1",
0049                     B: "B1",
0050                     C: "C1",
0051                     D: "D1"
0052                 },
0053                 {
0054                     A: "A2",
0055                     B: "B2",
0056                     C: "C2",
0057                     D: "D2"
0058                 },
0059                 {
0060                     A: "A3",
0061                     B: "B3",
0062                     C: "C3",
0063                     D: "D3"
0064                 }
0065             ]
0066         }
0067         delegate: QQC2.ItemDelegate {
0068             required property var model
0069             required property bool selected
0070             text: model.display
0071             checkable: true
0072             checked: selected
0073             highlighted: checked
0074             onClicked: {
0075                 table.selectionModel.select(table.model.index(model.row, model.column), checked ? ItemSelectionModel.Select : ItemSelectionModel.Deselect)
0076             }
0077         }
0078     }
0079 
0080 }
0081