Kirigami2

CardsListView.qml
1 /*
2  * SPDX-FileCopyrightText: 2018 Marco Martin <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 import QtQuick 2.15
8 import QtQuick.Layouts 1.2
9 import org.kde.kirigami 2.4 as Kirigami
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, unless it has
20  * headerOrientation set to ``Qt.Horizontal``.
21  *
22  * The choice between using this view with AbstractCard or a normal ListView
23  * with AbstractListItem/BasicListItem is purely a choice based on aesthetics alone.
24  *
25  * It is recommended to use default values.
26  *
27  * @inherit QtQuick.ListView
28  * @since 2.4
29  */
30 ListView {
31  id: root
32  spacing: Kirigami.Units.largeSpacing * 2
33  topMargin: headerPositioning !== ListView.InlineHeader ? spacing : 0
34  rightMargin: Kirigami.Units.largeSpacing * 2
35  leftMargin: Kirigami.Units.largeSpacing * 2
36  reuseItems: true
37 
38  headerPositioning: ListView.OverlayHeader
39 
40  Keys.onPressed: event => {
41  if (event.key === Qt.Key_Home) {
42  positionViewAtBeginning();
43  currentIndex = 0;
44  event.accepted = true;
45  }
46  else if (event.key === Qt.Key_End) {
47  positionViewAtEnd();
48  currentIndex = count - 1;
49  event.accepted = true;
50  }
51  }
52 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:14:23 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.