Warning, /frameworks/kirigami/src/controls/CardsListView.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *  SPDX-FileCopyrightText: 2018 Marco Martin <mart@kde.org>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick 2.15
0008 import QtQuick.Layouts 1.2
0009 import org.kde.kirigami 2.4 as Kirigami
0010 /**
0011  * CardsListView is a ListView intended to be used with
0012  * AbstractCard component as its delegate.
0013  *
0014  * It will automatically assign the proper spacings and margins around the
0015  * cards adhering to the design guidelines.
0016  *
0017  * CardsListView should be used only with cards which can look good at any
0018  * horizontal size, so it is recommended to directly use AbstractCard with an
0019  * appropriate layout inside, because they are stretching for the whole list width.
0020  *
0021  * Therefore, it is discouraged to use it with the Card type, unless it has
0022  * AbstractCard::headerOrientation set to ``Qt.Horizontal``.
0023  *
0024  * The choice between using this view with AbstractCard or a normal QtQuick.ListView
0025  * with AbstractListItem / BasicListItem is purely a choice based on aesthetics alone.
0026  *
0027  * It is recommended to use default values.
0028  *
0029  * @since org.kde.kirigami 2.4
0030  * @inherit QtQuick.ListView
0031  */
0032 ListView {
0033     id: root
0034     spacing: Kirigami.Units.largeSpacing * 2
0035     topMargin: headerPositioning !== ListView.InlineHeader ? spacing : 0
0036     rightMargin: Kirigami.Units.largeSpacing * 2
0037     leftMargin: Kirigami.Units.largeSpacing * 2
0038     reuseItems: true
0039 
0040     headerPositioning: ListView.OverlayHeader
0041 
0042     Keys.onPressed: event => {
0043         if (event.key === Qt.Key_Home) {
0044             positionViewAtBeginning();
0045             currentIndex = 0;
0046             event.accepted = true;
0047         }
0048         else if (event.key === Qt.Key_End) {
0049             positionViewAtEnd();
0050             currentIndex = count - 1;
0051             event.accepted = true;
0052         }
0053     }
0054 }