2 * Copyright (C) 2014 Canonical Ltd.
3 * Copyright (C) 2020-2026 UBports Foundation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19import Lomiri.Components 1.3
20import "../../../Components"
24 property alias expanded: row.expanded
25 property alias finishedExpanding: row.finishedExpanding
26 property alias interactive: row.interactive
27 property alias model: row.model
28 property alias unitProgress: row.unitProgress
29 property alias enableLateralChanges: row.enableLateralChanges
30 property alias overFlowWidth: row.overFlowWidth
31 readonly property alias currentItemIndex: row.currentItemIndex
32 property real lateralPosition: -1
33 property int alignment: Qt.AlignRight
34 readonly property int rowContentX: row.contentX
35 property alias screenIndex: row.screenIndex
36 property alias orientation: row.screenOrientation
38 property alias hideRow: row.hideRow
39 property alias rowItemDelegate: row.delegate
41 implicitWidth: row.contentWidth
43 function selectItemAt(lateralPosition) {
45 row.resetCurrentItem();
47 var mapped = root.mapToItem(row, lateralPosition, 0);
48 row.selectItemAt(mapped.x);
51 function selectPreviousItem() {
53 row.resetCurrentItem();
55 row.selectPreviousItem();
58 function selectNextItem() {
60 row.resetCurrentItem();
65 function setCurrentItemIndex(index) {
67 row.resetCurrentItem();
69 row.setCurrentItemIndex(index);
72 function addScrollOffset(scrollAmount) {
73 if (root.alignment == Qt.AlignLeft) {
74 scrollAmount = -scrollAmount;
76 // If we are scrolling left and we are already on the first item, stop if the item is fully on screen
77 // this is necessary because of a hack in PanelItemRow (adds extra space to row.contentWidth)
78 if (scrollAmount < 0 && row.currentItemIndex === 0 && row.currentItem.mapToItem(root, 0, 0).x > 0) {
81 row.contentX = Math.min(Math.max(row.contentX - scrollAmount, 0), row.contentWidth);
82 root.lateralPositionChanged();
88 clip: expanded || row.width > rowContainer.width
92 objectName: "panelItemRow"
96 if (root.lateralPosition == -1) return -1;
98 var mapped = root.mapToItem(row, root.lateralPosition, 0);
99 return Math.min(Math.max(mapped.x, 0), row.width);
104 enabled: root.expanded
105 propagateComposedEvents: true
107 row.selectItemAt(mouse.x);
108 mouse.accepted = false;
111 row.selectItemAt(mouse.x);
112 mouse.accepted = false;