summaryrefslogtreecommitdiff
path: root/src/hmi/qml/NavigationAppPOI.qml
blob: e8167675637b0302cfd3b22fe539aeaf2584572d (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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/**
* @licence app begin@
* SPDX-License-Identifier: MPL-2.0
*
* \copyright Copyright (C) 2013-2014, PCA Peugeot Citroen
*
* \file POI.qml
*
* \brief This file is part of the FSA hmi.
*
* \author Martin Schaller <martin.schaller@it-schaller.de>
* \author Philippe Colliot <philippe.colliot@mpsa.com>
*
* \version 1.1
*
* 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:
* 2014-03-05, Philippe Colliot, migration to the new HMI design
* <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 "Core/style-sheets/NavigationAppPOI-css.js" as StyleSheet;
import lbs.plugin.dbusif 1.0

NavigationAppHMIMenu {
	id: menu
    property string pagefile:"NavigationAppPOI"
    property string extraspell;
    property int type_poi_car_parking: 65842
    property int type_poi_hotel: 65835
    property int type_poi_restaurant: 65923
    property int type_poi_bar: 65848
    property int type_poi_fuel: 65834
    property string poiCategoryName

    DBusIf {
    	id: dbusIf
    }

    function update()
    {
        selectedValue.text="See details of \nthe POI \nhere"
    }

    function spell(input)
    {
        keyboardArea.destination.text = input;
    }

    function displayPOIList()
    {
        var model=view.model;
        for(var i=0;i<Genivi.categoriesIdNameList.length;i+=2)
        {
            model.append({"name":Genivi.categoriesIdNameList[i+1][3],"number":i/2});
        }
    }

    //------------------------------------------//
    // Management of "keyboard" configuration
    //------------------------------------------//
    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);
        }
    }

    NavigationAppHMIBgImage {
        image:StyleSheet.navigation_app_poi_background[Constants.SOURCE];
        anchors { fill: parent; topMargin: parent.headlineHeight }

        StdButton {
            source:StyleSheet.categoryKeyboard[Constants.SOURCE]; x:StyleSheet.categoryKeyboard[Constants.X]; y:StyleSheet.categoryKeyboard[Constants.Y]; width:StyleSheet.categoryKeyboard[Constants.WIDTH]; height:StyleSheet.categoryKeyboard[Constants.HEIGHT];
            id:categoryKeyboard; disabled:false; next:poiKeyboard; prev:back;
            onClicked: {
                keyboardArea.destination=categoryValue;
                poiValue.text="";
                categoryValue.text=poiCategoryName;
                poiFrame.visible=false;
                categoryFrame.visible=true;
                view.model.clear();
                displayPOIList();
            }
        }
        Image {
            source:StyleSheet.categoryFrame[Constants.SOURCE]; x:StyleSheet.categoryFrame[Constants.X]; y:StyleSheet.categoryFrame[Constants.Y]; width:StyleSheet.categoryFrame[Constants.WIDTH]; height:StyleSheet.categoryFrame[Constants.HEIGHT];
            id:categoryFrame;
            visible:false;
        }
        NavigationAppEntryField {
            x:StyleSheet.categoryValue[Constants.X]; y:StyleSheet.categoryValue[Constants.Y]; width: StyleSheet.categoryValue[Constants.WIDTH]; height: StyleSheet.categoryValue[Constants.HEIGHT];
            id: categoryValue
            globaldata: 'categoryValue'
            textfocus: true
            next: select_search
            prev: back
            onLeave:{}
        }
        StdButton {
            source:StyleSheet.poiKeyboard[Constants.SOURCE]; x:StyleSheet.poiKeyboard[Constants.X]; y:StyleSheet.poiKeyboard[Constants.Y]; width:StyleSheet.poiKeyboard[Constants.WIDTH]; height:StyleSheet.poiKeyboard[Constants.HEIGHT];
            id:poiKeyboard; disabled:false; next:select_search; prev:back;
            onClicked: {
                keyboardArea.destination=poiValue;
                poiValue.text="";
                categoryValue.text=poiCategoryName;
                poiFrame.visible=true;
                categoryFrame.visible=false;
                view.model.clear();
            }
        }
        Image {
            source:StyleSheet.poiFrame[Constants.SOURCE]; x:StyleSheet.poiFrame[Constants.X]; y:StyleSheet.poiFrame[Constants.Y]; width:StyleSheet.poiFrame[Constants.WIDTH]; height:StyleSheet.poiFrame[Constants.HEIGHT];
            id:poiFrame;
            visible:false;
        }
        NavigationAppEntryField {
            x:StyleSheet.poiValue[Constants.X]; y:StyleSheet.poiValue[Constants.Y]; width: StyleSheet.poiValue[Constants.WIDTH]; height: StyleSheet.poiValue[Constants.HEIGHT];
            id: poiValue
            globaldata: 'poiValue'
            textfocus: true
            next: select_search
            prev: back
            onLeave:{}
        }

        Text {
            x:StyleSheet.selectedValueTitle[Constants.X]; y:StyleSheet.selectedValueTitle[Constants.Y]; width:StyleSheet.selectedValueTitle[Constants.WIDTH]; height:StyleSheet.selectedValueTitle[Constants.HEIGHT];color:StyleSheet.selectedValueTitle[Constants.TEXTCOLOR];styleColor:StyleSheet.selectedValueTitle[Constants.STYLECOLOR]; font.pixelSize:StyleSheet.selectedValueTitle[Constants.PIXELSIZE];
            id:selectedValueTitle;
            style: Text.Sunken;
            smooth: true
            text: Genivi.gettext("Selected")
	   	}
		Text {
            x:StyleSheet.selectedValue[Constants.X]; y:StyleSheet.selectedValue[Constants.Y]; width:StyleSheet.selectedValue[Constants.WIDTH]; height:StyleSheet.selectedValue[Constants.HEIGHT];color:StyleSheet.selectedValue[Constants.TEXTCOLOR];styleColor:StyleSheet.selectedValue[Constants.STYLECOLOR]; font.pixelSize:StyleSheet.selectedValue[Constants.PIXELSIZE];
            id:selectedValue
            style: Text.Sunken;
            smooth: true
            clip: true
			text: " "
        }
		Component {
            id: searchResultList
            Text {
                width:StyleSheet.searchResultValue[Constants.WIDTH]; height:StyleSheet.searchResultValue[Constants.HEIGHT];color:StyleSheet.searchResultValue[Constants.TEXTCOLOR];styleColor:StyleSheet.searchResultValue[Constants.STYLECOLOR]; font.pixelSize:StyleSheet.searchResultValue[Constants.PIXELSIZE];
                id:searchResultValue;
				property real index:number;
				text: name;
				style: Text.Sunken;
				smooth: true
			}
		}
        NavigationAppHMIList {
            x:StyleSheet.searchResultList[Constants.X]; y:StyleSheet.searchResultList[Constants.Y]; width:StyleSheet.searchResultList[Constants.WIDTH]; height:StyleSheet.searchResultList[Constants.HEIGHT];
			property real selectedEntry
			id:view
            delegate: searchResultList
            next:select_search
			prev:back
			onSelected:{
                if(keyboardArea.destination===poiValue)
                {
                    if (what) {
                        Genivi.poi_id=what.index;
                        var poi_data=Genivi.poi_data[what.index];
                        selectedValue.text="Name:"+poi_data.name+"\nID:"+poi_data.id+"\nLat:"+poi_data.lat+"\nLon:"+poi_data.lon;
                        select_reroute.disabled=false;
                        select_display_on_map.disabled=false;
                        keyboardArea.destination.text=poi_data.name;
                    } else {
                        Genivi.poi_id=null;
                        selectedValue.text="";
                        select_reroute.disabled=true;
                        select_display_on_map.disabled=true;
                        keyboardArea.destination.text=""
                    }
                } else {
                   if (what) {
                       poiCategoryName=Genivi.categoriesIdNameList[((what.index)*2)+1][3];
                       Genivi.category_id=Genivi.categoriesIdNameList[((what.index)*2)+1][1];
                       keyboardArea.destination.text=poiCategoryName;
                       keyboardArea.destination=poiValue;
                       poiValue.text="";
                       categoryValue.text=poiCategoryName;
                       poiFrame.visible=true;
                       categoryFrame.visible=false;
                       view.model.clear();
                   } else {
                       keyboardArea.destination.text=""
                   }
                }

			}
		}       

        NavigationAppKeyboard {
            x:StyleSheet.keyboardArea[Constants.X]; y:StyleSheet.keyboardArea[Constants.Y]; width:StyleSheet.keyboardArea[Constants.WIDTH]; height:StyleSheet.keyboardArea[Constants.HEIGHT];
            id: keyboardArea;
            destination: poiValue;
            firstLayout: "ABC";
            secondLayout: "abc";
            next: select_search;
            prev: poiKeyboard;
            onKeypress: {   }
        }

        StdButton {
            source:StyleSheet.select_search[Constants.SOURCE]; x:StyleSheet.select_search[Constants.X]; y:StyleSheet.select_search[Constants.Y]; width:StyleSheet.select_search[Constants.WIDTH]; height:StyleSheet.select_search[Constants.HEIGHT];
            id:select_search
			onClicked: {
				var model=view.model;
				var ids=[];
                var position=Genivi.mapmatchedposition_GetPosition(dbusIf);
                var latitude=0;
                var longitude=0;
                for (var i=0;i<position[3].length;i+=4){
                    if ((position[3][i+1]== Genivi.NAVIGATIONCORE_LATITUDE) && (position[3][i+3][3][1] != 0)){
                        latitude=position[3][i+3][3][1];
                    } else {
                        if ((position[3][i+1]== Genivi.NAVIGATIONCORE_LONGITUDE) && (position[3][i+3][3][1] != 0)){
                            longitude=position[3][i+3][3][1];
                        }
                    }
                }
                if (!latitude && !longitude) {
					model.clear();
					model.append({"name":"No position available"});
					return;
				}
                var categoriesAndRadius=[];
                var categoriesAndRadiusList=[];
                categoriesAndRadius[0]=Genivi.category_id;
                categoriesAndRadius[1]=Genivi.radius;
                categoriesAndRadiusList.push(categoriesAndRadius);

                Genivi.poisearch_SetCenter(dbusIf,latitude,longitude,0);
                Genivi.poisearch_SetCategories(dbusIf,categoriesAndRadiusList);
                Genivi.poisearch_StartPoiSearch(dbusIf,"",Genivi.POISERVICE_SORT_BY_DISTANCE);
                var attributeList=[];
                attributeList[0]=0;
                var res=Genivi.poisearch_RequestResultList(dbusIf,Genivi.offset,Genivi.maxWindowSize,attributeList);
				var res_win=res[5];
                for (i = 0 ; i < res_win.length ; i+=2) {
                    var id=res_win[i+1][1];
                    ids.push(id);
					Genivi.poi_data[id]=[];
					Genivi.poi_data[id].id=id;
					Genivi.poi_data[id].distance=res_win[i+1][3];
				}
                var details=Genivi.poisearch_GetPoiDetails(dbusIf,ids);
                for (i = 0 ; i < details[1].length ; i+=2) {
					var poi_details=details[1][i+1];
                    id=poi_details[1][1];
					Genivi.poi_data[id].name=poi_details[1][3];
                    Genivi.poi_data[id].lat=poi_details[1][5][1];
                    Genivi.poi_data[id].lon=poi_details[1][5][3];
				}
				model.clear();
                for (i = 0 ; i < ids.length ; i+=1) {
                    id=ids[i];
					var poi_data=Genivi.poi_data[id];
					model.append({"name":Genivi.distance(poi_data.distance)+" "+poi_data.name,"number":id});
				}
			}
		}
		StdButton { 
            source:StyleSheet.select_reroute[Constants.SOURCE]; x:StyleSheet.select_reroute[Constants.X]; y:StyleSheet.select_reroute[Constants.Y]; width:StyleSheet.select_reroute[Constants.WIDTH]; height:StyleSheet.select_reroute[Constants.HEIGHT];
            id:select_reroute;
            
            disabled:true;
            next:select_display_on_map; prev:select_search
			onClicked: {
                var destination=Genivi.latlon_to_map(Genivi.poi_data[Genivi.poi_id]);
                var position="";
                Genivi.routing_SetWaypoints(dbusIf,true,position,destination);
				Genivi.data['calculate_route']=true;
				Genivi.data['lat']='';
				Genivi.data['lon']='';
                if (Genivi.guidance_activated == true)
                {
                    mapMenu();
                }
                else {
                    pageOpen("NavigationAppSearch");
                }
			}
		}
        StdButton {
            source:StyleSheet.select_display_on_map[Constants.SOURCE]; x:StyleSheet.select_display_on_map[Constants.X]; y:StyleSheet.select_display_on_map[Constants.Y]; width:StyleSheet.select_display_on_map[Constants.WIDTH]; height:StyleSheet.select_display_on_map[Constants.HEIGHT];
            id:select_display_on_map;
            
	    disabled:true;
            next:back; prev:select_reroute
			onClicked: {
				var poi_data=Genivi.poi_data[Genivi.poi_id];
                Genivi.data['position']['lat']=poi_data.lat;
                Genivi.data['position']['lon']=poi_data.lon;
                entryMenu("NavigationAppBrowseMap",menu);
            }
		}
        StdButton {
            source:StyleSheet.back[Constants.SOURCE]; x:StyleSheet.back[Constants.X]; y:StyleSheet.back[Constants.Y]; width:StyleSheet.back[Constants.WIDTH]; height:StyleSheet.back[Constants.HEIGHT];textColor:StyleSheet.backText[Constants.TEXTCOLOR]; pixelSize:StyleSheet.backText[Constants.PIXELSIZE];
            id:back;
			text: Genivi.gettext("Back"); 
			disabled:false; 
            next:select_search; prev:select_display_on_map;
            onClicked: {
                Genivi.preloadMode=true;
                leaveMenu();
            }
		}	
	}
	Component.onCompleted: {
        var categoriesIdNameAndRadius=[];
        var ret=Genivi.poisearch_GetAvailableCategories(dbusIf);
        var categories=ret[1];
        for (var i = 0 ; i < categories.length ; i+=2) {
            if (categories[i+1][3] == 'fuel') {
                Genivi.category_id=categories[i+1][1];
                poiCategoryName=categories[i+1][3];
            }
         }
        Genivi.categoriesIdNameList=categories;

        Genivi.poi_data=[];

        categoryValue.text=poiCategoryName;
        keyboardArea.destination=poiValue; // by default
        poiFrame.visible=true;

		update();
	}
}