summaryrefslogtreecommitdiff
path: root/src/hmi/qml/NavigationAppEntry.qml
blob: 885aa4a3a7e25a5ff6af1e9fd5408b43d6481c6a (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/**
* @licence app begin@
* SPDX-License-Identifier: MPL-2.0
*
*
* \file Entry.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 
import "Core"
import "Core/genivi.js" as Genivi;
import "Core/style-sheets/style-constants.js" as Constants;
import lbs.plugin.dbusif 1.0

HMIMenu {
	id: menu
    property string pagefile:"Entry"

    color: Constants.MENU_BACKGROUND_COLOR

    //property Item currentSelectionCriterionSignal;
    property Item searchStatusSignal;
    property Item searchResultListSignal;
    //property Item contentUpdatedSignal;
	property Item spellResultSignal;
	property real criterion;
	property string extraspell;

	DBusIf {
                id:dbusIf
        }

	function searchStatus(args)
    { //locationInputHandle 1, statusValue 3
        Genivi.hookSignal("searchStatus");
        var statusValue=args[3];
        if (statusValue == Genivi.NAVIGATIONCORE_SEARCHING) {
			view.model.clear();
            text.color='red';  //(Searching)
        } else {
            if (statusValue == Genivi.NAVIGATIONCORE_FINISHED)
            {
                text.color='white';
                Genivi.locationinput_RequestListUpdate(dbusIf,0,10);
            }
        }
	}

	function searchResultList(args)
    {//locationInputHandle 1, totalSize 3, windowOffset 5, windowSize 7, resultListWindow 9
        Genivi.hookSignal("searchResultList");
        var model=view.model;
        var windowOffset=args[5];
        var resultListWindow=args[9];
        var offset=args[5];
        var array=args[9];
        for (var i=0 ; i < resultListWindow.length ; i+=2) {
            for (var j = 0 ; j < resultListWindow[i+1].length ; j+=4) {
                if (resultListWindow[i+1][j+1] == criterion) {
                    model.append({"name":resultListWindow[i+1][j+3][3][1],"number":(i/2)+windowOffset+1});
                }
            }
        }
	}

	function spellResult(args)
    {//locationInputHandle 1, uniqueString 3, validCharacters 5, fullMatch 7
        Genivi.hookSignal("spellResult");
        var uniqueString=args[3];
        var validCharacters=args[5];
        if (text.text.length < uniqueString.length) {
            extraspell=uniqueString.substr(text.text.length);
            text.text=uniqueString;
        }
        keyboard.setactivekeys('\b'+validCharacters,true);
	}

	function spell(input)
	{
		input=extraspell+input;
		extraspell='';
        Genivi.locationinput_Spell(dbusIf,input,10);
	}

	function connectSignals()
	{
        searchStatusSignal=Genivi.connect_searchStatusSignal(dbusIf,menu);
        searchResultListSignal=Genivi.connect_searchResultListSignal(dbusIf,menu);
        spellResultSignal=Genivi.connect_spellResultSignal(dbusIf,menu);
	}
	
	function disconnectSignals()
	{
		searchStatusSignal.destroy();
		searchResultListSignal.destroy();
		spellResultSignal.destroy();
	}

	Keys.onPressed: {
		if (event.text) {
			if (event.text == '\b') {
				if (text.text.length) {
					text.text=text.text.slice(0,-1);
				}
			} else {
				text.text+=event.text;
			}
			spell(event.text);
		}
	}
	Column {
		id:content
		anchors { fill: parent; topMargin: menu.hspc/2 }
		Row {
			id:textrow
			spacing:menu.hspc/4;
			anchors.topMargin: 100;
			Rectangle {
				color:'black';
                width:content.width-back.width-menu.hspc/4-menu.hspc/8;
				height:back.height;
				Text {
					anchors.fill:parent;
					id: text
					font.pixelSize: 40;
					color: "white"; smooth: true
					focus: true
				}
			}
			StdButton { id:back; text: "Back"; onClicked: {
				disconnectSignals();
                Genivi.entrycancel=true;
                Genivi.preloadMode=true;
                leaveMenu();
			} next:view; prev:keyboard}
		}

		Component {
			id: listDelegate
			Text {
				property real index:number;
				width: 180;
				height: 20;
				id:text;
				text: name;
				font.pixelSize: 20;
				style: Text.Sunken;
				color: "white";
				styleColor: "black";
				smooth: true
			}
		}

		HMIList {
			property real selectedEntry
			height:parent.height-keyboard.height-textrow.height;
			width:parent.width;
			id:view
			delegate: listDelegate
			next:keyboard
			prev:back
			onSelected:{
				Genivi.entrydest=null;
				disconnectSignals();
				Genivi.entryselectedentry=what.index;
                leaveMenu();
			}
		}

		Keyboard {
			id: keyboard
			height: 200;
			width: menu.width;
			destination: text;
			firstLayout: "ABC";
			secondLayout: "abc";
			next: back;
			prev: view;
			onKeypress: { spell(what); }
		}
	}
	Component.onCompleted: {
		view.forceActiveFocus();
        if (Genivi.entrycriterion) {
            criterion=Genivi.entrycriterion;
            Genivi.entrycriterion=0;
            Genivi.locationinput_SetSelectionCriterion(dbusIf,criterion);
        }
        extraspell='';
        if(criterion != Genivi.NAVIGATIONCORE_STREET)
        {
            spell('');
        }

        connectSignals();
	}
}