diff options
author | akashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2010-04-02 13:37:16 +0000 |
---|---|---|
committer | akashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2010-04-02 13:37:16 +0000 |
commit | 75d0d0eff939ad2adef7108037e077d3760d20a6 (patch) | |
tree | 4e4dd76d5ba36dd69f2fe2fe65caec0af2047a36 | |
parent | 424eceb55b3359e32167fb5c421a1c3420acb5e8 (diff) | |
download | navit-svn-75d0d0eff939ad2adef7108037e077d3760d20a6.tar.gz |
Fix:gui/qml:Poi viewer work in progress
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/navit@3117 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r-- | gui/qml/ngqpoint.h | 19 | ||||
-rw-r--r-- | gui/qml/skins/navit/PagePoi.qml | 80 |
2 files changed, 79 insertions, 20 deletions
diff --git a/gui/qml/ngqpoint.h b/gui/qml/ngqpoint.h index f31bfc39..67c222f0 100644 --- a/gui/qml/ngqpoint.h +++ b/gui/qml/ngqpoint.h @@ -70,7 +70,6 @@ public slots: return QString(""); } QString getAttrList(const QString &attr_name) { - NGQStandardItemModel* ret=new NGQStandardItemModel(this); struct attr attr; struct item* item; struct mapset_handle *h; @@ -103,7 +102,6 @@ public slots: if ( item_coord_get_pro(item, &c, 1, this->c.pro) && coord_rect_contains(&sel->u.c_rect, &c) && (idist=transform_distance(this->c.pro, ¢er, &c)) < dist ) { char* label; QString rs; - QString pointXml="<point>"; if (item_attr_get(item, attr_label, &attr)) { label=map_convert_string(m, attr.u.str); if (QString(item_to_name(item->type)).startsWith(QString("poi_"))) { @@ -123,11 +121,14 @@ public slots: map_convert_free(label); } else rs=item_to_name(item->type); - pointXml+="<name>"+rs+"</name>"; - pointXml+="<type>"+QString(item_to_name(item->type))+"</type>"; - pointXml+="</point>"; - - retXml+=pointXml; + if (rs.length()>0) { + QString pointXml="<point>"; + pointXml+="<name>"+rs+"</name>"; + pointXml+="<type>"+QString(item_to_name(item->type))+"</type>"; + pointXml+="</point>"; + + retXml+=pointXml; + } } } } @@ -135,9 +136,7 @@ public slots: } map_selection_destroy(sel); mapset_close(h); - - this->object->guiWidget->rootContext()->setContextProperty("listModel",static_cast<QObject*>(ret)); - + retXml+=QString("</%1>").arg(attr_name); dbg(0,"Reulsting xml: %s\n",retXml.toLocal8Bit().constData()); return retXml; diff --git a/gui/qml/skins/navit/PagePoi.qml b/gui/qml/skins/navit/PagePoi.qml index 0b668fd4..6c49020d 100644 --- a/gui/qml/skins/navit/PagePoi.qml +++ b/gui/qml/skins/navit/PagePoi.qml @@ -3,6 +3,8 @@ import Qt 4.6 Rectangle { id: page + property string poiFilter: "" + width: gui.width; height: gui.height color: "Black" opacity: 0 @@ -17,6 +19,57 @@ Rectangle { } } + function calculateFilter() { + page.poiFilter='/points/point[type="point_begin" or '; + if (bankBtn.state=="on") { + page.poiFilter+='type="poi_bank" or '; + } + if (fuelBtn.state=="on") { + page.poiFilter+='type="poi_fuel" or '; + page.poiFilter+='type="poi_autoservice" or '; + page.poiFilter+='type="poi_repair_service" or '; + } + if (hotelBtn.state=="on") { + page.poiFilter+='type="poi_hotel" or '; + page.poiFilter+='type="poi_camp_rv" or '; + page.poiFilter+='type="poi_camping" or '; + page.poiFilter+='type="poi_resort" or '; + page.poiFilter+='type="poi_motel" or '; + page.poiFilter+='type="poi_hostel" or '; + } + if (foodBtn.state=="on") { + page.poiFilter+='type="poi_bar" or '; + page.poiFilter+='type="poi_picnic" or '; + page.poiFilter+='type="poi_burgerking" or '; + page.poiFilter+='type="poi_fastfood" or '; + page.poiFilter+='type="poi_restaurant" or '; + } + if (shopBtn.state=="on") { + page.poiFilter+='type="poi_shop_grocery" or '; + page.poiFilter+='type="poi_mall" or '; + } + if (serviceBtn.state=="on") { + page.poiFilter+='type="poi_marina" or '; + page.poiFilter+='type="poi_hospital" or '; + page.poiFilter+='type="poi_public_utilities" or '; + page.poiFilter+='type="poi_police" or '; + page.poiFilter+='type="poi_information" or '; + page.poiFilter+='type="poi_personal_service" or '; + page.poiFilter+='type="poi_restroom" or '; + } + if (parkingBtn.state=="on") { + page.poiFilter+='type="poi_car_parking" or '; + } + if (landBtn.state=="on") { + page.poiFilter+='type="poi_land_feature" or '; + page.poiFilter+='type="poi_rock" or '; + page.poiFilter+='type="poi_dam" or '; + } + page.poiFilter+='type="point_end"]'; + listModel.query=page.poiFilter; + listModel.reload(); + } + function pageOpen() { page.opacity = 1; } @@ -36,14 +89,14 @@ Rectangle { VisualItemModel { id: selectorsModel - ToggleButton { id: bankBtn; text: "Bank"; icon: "bank.svg";stOn: "true"; } - ToggleButton { id: fuelBtn; text: "Fuel"; icon: "fuel.svg";stOn: "true"; } - ToggleButton { id: hotelBtn; text: "Hotel"; icon: "bar.svg";stOn: "true"; } - ToggleButton { id: foodBtn; text: "Food"; icon: "fastfood.svg";stOn: "true"; } - ToggleButton { id: shopBtn; text: "Shop"; icon: "shopping.svg";stOn: "true"; } - ToggleButton { id: serviceBtn; text: "Service"; icon: "hospital.svg";stOn: "true"; } - ToggleButton { id: parkingBtn; text: "Parking"; icon: "police.svg";stOn: "true"; } - ToggleButton { id: landBtn; text: "Land features"; icon: "peak.svg";stOn: "true"; } + ToggleButton { id: bankBtn; text: "Bank"; icon: "bank.svg";stOn: "true"; onChanged: calculateFilter(); } + ToggleButton { id: fuelBtn; text: "Fuel"; icon: "fuel.svg";stOn: "true"; onChanged: calculateFilter(); } + ToggleButton { id: hotelBtn; text: "Hotel"; icon: "bar.svg";stOn: "true"; onChanged: calculateFilter(); } + ToggleButton { id: foodBtn; text: "Food"; icon: "fastfood.svg";stOn: "true"; onChanged: calculateFilter(); } + ToggleButton { id: shopBtn; text: "Shop"; icon: "shopping.svg";stOn: "true"; onChanged: calculateFilter(); } + ToggleButton { id: serviceBtn; text: "Service"; icon: "hospital.svg";stOn: "true"; onChanged: calculateFilter(); } + ToggleButton { id: parkingBtn; text: "Parking"; icon: "police.svg";stOn: "true"; onChanged: calculateFilter(); } + ToggleButton { id: landBtn; text: "Land features"; icon: "peak.svg";stOn: "true"; onChanged: calculateFilter(); } } ListView { @@ -54,11 +107,18 @@ Rectangle { } Slider { - id: distanceSlider; minValue: 1; maxValue: 250; value: gui.getAttr("radius"); text: "Distance"; onChanged: { gui.setAttr("radius",distanceSlider.value); point.getAttrList("points"); } + id: distanceSlider; minValue: 1; maxValue: 250; value: gui.getAttr("radius"); text: "Distance"; onChanged: { gui.setAttr("radius",distanceSlider.value); listModel.xml=point.getAttrList("points"); listModel.reload(); } anchors.top: selectorsList.bottom; anchors.horizontalCenter: page.horizontalCenter; } - ListSelector { + XmlListModel { + id: listModel + xml: point.getAttrList("points") + query: "/points/point" + XmlRole { name: "itemName"; query: "name/string()" } + XmlRole { name: "itemType"; query: "type/string()" } + } + ListSelectorXml { id:layoutList; text: ""; itemId: point.getAttrList("points"); onChanged: console.log("Poi clicked"); anchors.top: distanceSlider.bottom; anchors.left: parent.left; anchors.leftMargin: 3 |