blob: 7460042d5a0c2a6c35a42f091c06a41b7066c040 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/**
* @licence app begin@
* SPDX-License-Identifier: MPL-2.0
*
*
* \file NavigationAppHMIList.qml
*
* \brief This file is part of the navigation hmi.
*
* \author Martin Schaller <martin.schaller@it-schaller.de>
*
* \version
*
* This Source Code Form is subject to the terms of the
* Mozilla Public License (MPL), v. 2.0.
* If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* For further information see http://www.genivi.org/.
*
* List of changes:
* <date>, <name>, <description of change>
*
* @licence end@
*/
import QtQuick 2.1
Rectangle {
id:rectangle
property alias delegate: view.delegate
property alias model: view.model
property alias next: view.next
property alias prev: view.prev
signal selected(variant what)
color: "#141414"
function takeFocus(dir) {
view.takeFocus(dir);
}
ListView {
id:view
property Item prev
property Item next
property Item prevsave
property Item nextsave
highlightFollowsCurrentItem:false
property bool hasFocus:false
// interactive:false
signal mclicked()
anchors.fill: parent
model: ListModel{}
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
clip: true
onMclicked: {
rectangle.selected(view.currentItem);
}
MouseArea {
anchors.fill: parent
onPressed: {
view.highlightFollowsCurrentItem=true;
view.currentIndex=view.indexAt(view.contentX+mouse.x,view.contentY+mouse.y);
}
onCanceled: {
view.currentIndex=-1;
}
onClicked: {
view.currentIndex=view.indexAt(view.contentX+mouse.x,view.contentY+mouse.y);
rectangle.selected(view.currentItem);
}
}
function takeFocus(dir) {
var max=view.model.count-1;
if (!hasFocus) {
forceActiveFocus();
hasFocus=true;
nextsave=next;
prevsave=prev;
next=view;
prev=view;
highlightFollowsCurrentItem=true;
if (dir > 0) {
view.positionViewAtBeginning();
currentIndex=0;
} else {
view.positionViewAtEnd();
currentIndex=max;
}
return;
}
prev=view;
next=view;
if (dir > 0) {
if (currentIndex < max) {
currentIndex++;
return;
}
} else {
if (currentIndex > 0) {
currentIndex--;
return;
}
}
hasFocus=false;
highlightFollowsCurrentItem=false;
next=nextsave;
prev=prevsave;
if (dir > 0)
menu.focus_next();
else
menu.focus_prev();
}
function giveFocus() {
currentIndex=-1;
}
}
}
|