Kirigami2

CardsListView.qml
1/*
2 * SPDX-FileCopyrightText: 2018 Marco Martin <mart@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7import QtQuick
8import org.kde.kirigami as Kirigami
9
10/**
11 * CardsListView is a ListView which can have AbstractCard as its delegate: it will
12 * automatically assign the proper spacings and margins around the cards adhering
13 * to the design guidelines.
14 *
15 * CardsListView should be used only with cards which can look good at any
16 * horizontal size, so it is recommended to directly use AbstractCard with an
17 * appropriate layout inside, because they are stretching for the whole list width.
18 *
19 * Therefore, it is discouraged to use it with the Card type.
20 *
21 * The choice between using this view with AbstractCard or a normal ListView
22 * is purely a choice based on aesthetics alone.
23 *
24 * It is recommended to use default values.
25 *
26 * @inherit QtQuick.ListView
27 * @since 2.4
28 */
29ListView {
30 id: root
31 spacing: Kirigami.Units.largeSpacing * 2
32 topMargin: headerPositioning !== ListView.InlineHeader ? spacing : 0
33 rightMargin: Kirigami.Units.largeSpacing * 2
34 leftMargin: Kirigami.Units.largeSpacing * 2
35 reuseItems: true
36
37 headerPositioning: ListView.OverlayHeader
38
39 Keys.onPressed: event => {
40 if (event.key === Qt.Key_Home) {
41 positionViewAtBeginning();
42 currentIndex = 0;
43 event.accepted = true;
44 }
45 else if (event.key === Qt.Key_End) {
46 positionViewAtEnd();
47 currentIndex = count - 1;
48 event.accepted = true;
49 }
50 }
51}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.