From 3044995ed7880624c07dca2f2eae78259dd46bae Mon Sep 17 00:00:00 2001 From: akashihi Date: Fri, 2 Apr 2010 11:46:00 +0000 Subject: [PATCH] Add:gui/qml:POI viewer work in progress git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3116 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/gui/qml/ngqpoint.h | 73 ++++++++++++++++++++++ navit/navit/gui/qml/skins/navit/ButtonIcon.qml.in | 1 - .../navit/gui/qml/skins/navit/ListSelectorXml.qml | 72 +++++++++++++++++++++ navit/navit/gui/qml/skins/navit/Makefile.am | 2 +- navit/navit/gui/qml/skins/navit/PageNavigation.qml | 2 +- navit/navit/gui/qml/skins/navit/PagePoi.qml | 70 +++++++++++++++++++++ navit/navit/gui/qml/skins/navit/PageRoute.qml | 2 +- navit/navit/gui/qml/skins/navit/point.qml | 2 +- 8 files changed, 219 insertions(+), 5 deletions(-) create mode 100644 navit/navit/gui/qml/skins/navit/ListSelectorXml.qml create mode 100644 navit/navit/gui/qml/skins/navit/PagePoi.qml diff --git a/navit/navit/gui/qml/ngqpoint.h b/navit/navit/gui/qml/ngqpoint.h index 909844e..f31bfc3 100644 --- a/navit/navit/gui/qml/ngqpoint.h +++ b/navit/navit/gui/qml/ngqpoint.h @@ -69,6 +69,79 @@ 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; + struct map_selection *sel,*selm; + struct map_rect *mr; + struct map *m; + int idist,dist; + struct coord center; + QString retXml; + + if (!gui_get_attr(this->object->gui,attr_radius,&attr,NULL)) { + return QString(); + } + + dist=attr.u.num*1000; + + sel=map_selection_rect_new(&this->c, dist, 18); + center.x=this->c.x; + center.y=this->c.y; + h=mapset_open(navit_get_mapset(this->object->nav)); + + retXml=QString("<%1>").arg(attr_name); + + while ((m=mapset_next(h, 1))) { + selm=map_selection_dup_pro(sel, this->c.pro, map_projection(m)); + mr=map_rect_new(m, selm); + if (mr) { + while ((item=map_rect_get_item(mr))) { + struct coord c; + 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=""; + 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_"))) { + rs=QString::fromLocal8Bit(item_to_name(item->type)); + rs=rs.remove(QString("poi_")); + rs+=QString(" ")+QString::fromLocal8Bit(label); + + } else if (QString(item_to_name(item->type)).startsWith(QString("poly_"))) { + rs=QString::fromLocal8Bit(item_to_name(item->type)); + rs=rs.remove(QString("poly_")); + rs+=QString(" ")+QString::fromLocal8Bit(label); + + } else if (QString(item_to_name(item->type)).startsWith(QString("street_"))) { + rs="Street "; + rs+=QString::fromLocal8Bit(label); + } + map_convert_free(label); + } else + rs=item_to_name(item->type); + pointXml+=""+rs+""; + pointXml+=""+QString(item_to_name(item->type))+""; + pointXml+=""; + + retXml+=pointXml; + } + } + } + map_selection_destroy(selm); + } + map_selection_destroy(sel); + mapset_close(h); + + this->object->guiWidget->rootContext()->setContextProperty("listModel",static_cast(ret)); + + retXml+=QString("").arg(attr_name); + dbg(0,"Reulsting xml: %s\n",retXml.toLocal8Bit().constData()); + return retXml; + } protected: QString _coordString() { char latc='N',lngc='E'; diff --git a/navit/navit/gui/qml/skins/navit/ButtonIcon.qml.in b/navit/navit/gui/qml/skins/navit/ButtonIcon.qml.in index 4433be7..7c48032 100644 --- a/navit/navit/gui/qml/skins/navit/ButtonIcon.qml.in +++ b/navit/navit/gui/qml/skins/navit/ButtonIcon.qml.in @@ -35,7 +35,6 @@ Rectangle { transitions: Transition { NumberAnimation { matchProperties: "scale"; easing: "easeOutExpo"; duration: 200 } NumberAnimation { matchProperties: "opacity"; easing: "easeInQuad"; duration: 200 } - } } diff --git a/navit/navit/gui/qml/skins/navit/ListSelectorXml.qml b/navit/navit/gui/qml/skins/navit/ListSelectorXml.qml new file mode 100644 index 0000000..bc354a9 --- /dev/null +++ b/navit/navit/gui/qml/skins/navit/ListSelectorXml.qml @@ -0,0 +1,72 @@ + +import Qt 4.6 + +Rectangle { + id: listselector + width: parent.width; height: parent.height + color: "Black" + + + property string text: "ListSelector" + property string value: "" + property string itemId: "0" + signal changed + + function startup() { + console.log("model is: "+listModel); + } + Component.onCompleted: startup(); + + Component { + id: delegate + Item { + id: wrapper + width: list.width; height: 20 + Column { + x: 5; y: 5 + Text { text: itemName; color: "White" } + } + MouseRegion { + id:delegateMouse + anchors.fill: parent + onClicked: { list.currentIndex=itemId; listselector.value=itemName; listselector.changed() } + } + } + } + + Component { + id: highlight + Rectangle { + color: "lightsteelblue" + radius: 5 + } + } + + Text { + id: labelTxt; text: listselector.text; color: "White"; font.pointSize: 14; + anchors.horizontalCenter: list.horizontalCenter + anchors.verticalCenter: listselector.top + } + + ListView { + id: list; + width: listselector.width*0.8; height: listselector.height + anchors.top: labelTxt.bottom; + anchors.left: listselector.left + model: listModel + delegate: delegate + highlight: highlight + focus: true + clip: true + highlightFollowsCurrentItem: true + keyNavigationWraps: true + overShoot: false + currentIndex: listselector.itemId; + } + Rectangle { + id: listScroller + opacity: 0.5; anchors.left: list.right; anchors.leftMargin: 4; width: 6 + y: (list.visibleArea.yPosition * list.height)+(list.visibleArea.heightRatio * list.height/4) + height: list.visibleArea.heightRatio * list.height + } +} diff --git a/navit/navit/gui/qml/skins/navit/Makefile.am b/navit/navit/gui/qml/skins/navit/Makefile.am index 110c4e9..bae51e3 100644 --- a/navit/navit/gui/qml/skins/navit/Makefile.am +++ b/navit/navit/gui/qml/skins/navit/Makefile.am @@ -4,7 +4,7 @@ SKIN = navit qmldir=$(skinsdir)/$(SKIN) -qml_DATA = ButtonIcon.qml ToggleSwitch.qml ToggleButton.qml ListSelector.qml Slider.qml Cellar.qml main.qml point.qml command.qml PageAbout.qml PageBookmarksAdd.qml PageBookmarks.qml PageNavigation.qml PageRoute.qml PageSearch.qml PageSearchSelector.qml PageSettingsDisplay.qml PageSettingsLocale.qml PageSettings.qml PageSettingsRules.qml PageSettingsTools.qml PageSettingsVehicle.qml PagePoi.qml +qml_DATA = ButtonIcon.qml ToggleSwitch.qml ToggleButton.qml ListSelector.qml ListSelectorXml.qml Slider.qml Cellar.qml main.qml point.qml command.qml PageAbout.qml PageBookmarksAdd.qml PageBookmarks.qml PageNavigation.qml PageRoute.qml PageSearch.qml PageSearchSelector.qml PageSettingsDisplay.qml PageSettingsLocale.qml PageSettings.qml PageSettingsRules.qml PageSettingsTools.qml PageSettingsVehicle.qml PagePoi.qml qml_DATA += background.svg knob.svg do_button_subst = sed -e 's,matchProperties,properties,g' \ diff --git a/navit/navit/gui/qml/skins/navit/PageNavigation.qml b/navit/navit/gui/qml/skins/navit/PageNavigation.qml index d43213e..4b8aa05 100644 --- a/navit/navit/gui/qml/skins/navit/PageNavigation.qml +++ b/navit/navit/gui/qml/skins/navit/PageNavigation.qml @@ -44,7 +44,7 @@ Rectangle { anchors.top: parent.verticalCenter; anchors.topMargin: gui.height/16; spacing: gui.width/12 ButtonIcon { - id: btnPoi; text: "POIs near\nPosition"; icon: "attraction.svg"; onClicked: console.log("Implement me!"); + id: btnPoi; text: "POIs near\nPosition"; icon: "attraction.svg"; onClicked: gui.setPage("PagePoi.qml"); opacity: 0; } ButtonIcon { diff --git a/navit/navit/gui/qml/skins/navit/PagePoi.qml b/navit/navit/gui/qml/skins/navit/PagePoi.qml new file mode 100644 index 0000000..0b668fd --- /dev/null +++ b/navit/navit/gui/qml/skins/navit/PagePoi.qml @@ -0,0 +1,70 @@ +import Qt 4.6 + +Rectangle { + id: page + + width: gui.width; height: gui.height + color: "Black" + opacity: 0 + + function bookmarkClick(itemId,itemIcon,itemName,itemPath) { + if ( itemIcon=="yes" ) { + bookmarks.currentPath=itemPath; + bookmarks.getAttrList(""); + } else { + bookmarks.setPoint(itemId); + gui.setPage("point.qml"); + } + } + + function pageOpen() { + page.opacity = 1; + } + + Component.onCompleted: pageOpen(); + + opacity: Behavior { + NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true } + } + + Text { + id: labelTxt; text: "Points of interest"; color: "White"; font.pointSize: 14; + anchors.horizontalCenter: page.horizontalCenter + anchors.top: page.top + } + + 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"; } + } + + ListView { + id: selectorsList; model: selectorsModel + focus: true; clip: true; orientation: Qt.Horizontal + anchors.horizontalCenter: page.horizontalCenter; anchors.top: labelTxt.bottom + width: page.width; height: bankBtn.height*2 + } + + Slider { + id: distanceSlider; minValue: 1; maxValue: 250; value: gui.getAttr("radius"); text: "Distance"; onChanged: { gui.setAttr("radius",distanceSlider.value); point.getAttrList("points"); } + anchors.top: selectorsList.bottom; anchors.horizontalCenter: page.horizontalCenter; + } + + ListSelector { + id:layoutList; text: ""; itemId: point.getAttrList("points"); onChanged: console.log("Poi clicked"); + anchors.top: distanceSlider.bottom; + anchors.left: parent.left; anchors.leftMargin: 3 + anchors.topMargin: gui.height/16; anchors.leftMargin: gui.width/32 + width: page.width; height: page.height*0.25 + } + + Cellar {id: cellar; anchors.bottom: page.bottom; anchors.horizontalCenter: page.horizontalCenter; width: page.width } +} diff --git a/navit/navit/gui/qml/skins/navit/PageRoute.qml b/navit/navit/gui/qml/skins/navit/PageRoute.qml index 4667804..3964e36 100644 --- a/navit/navit/gui/qml/skins/navit/PageRoute.qml +++ b/navit/navit/gui/qml/skins/navit/PageRoute.qml @@ -45,7 +45,7 @@ Rectangle { id: btnSearch; text: "Search"; icon: "gui_town.svg"; onClicked: gui.setPage("PageSearch.qml"); } ButtonIcon { - id: btnPoi; text: "POIs near\nDestination"; icon: "attraction.svg"; onClicked: console.log("Implement me!"); + id: btnPoi; text: "POIs near\nDestination"; icon: "attraction.svg"; onClicked: gui.setPage("PagePoi.qml"); opacity: 0; } } diff --git a/navit/navit/gui/qml/skins/navit/point.qml b/navit/navit/gui/qml/skins/navit/point.qml index d183942..3d8e569 100644 --- a/navit/navit/gui/qml/skins/navit/point.qml +++ b/navit/navit/gui/qml/skins/navit/point.qml @@ -53,7 +53,7 @@ Rectangle { anchors.top: parent.verticalCenter; anchors.topMargin: gui.height/16; spacing: gui.width/12 ButtonIcon { - id: btnQuit; text: "Nearest\nPOIs"; icon: "attraction.svg"; onClicked: console.log("Implement me!"); + id: btnQuit; text: "Nearest\nPOIs"; icon: "attraction.svg"; onClicked: gui.setPage("PagePoi.qml"); } ButtonIcon { id: btnBookmark; text: "Add as\na Bookmark"; icon: "gui_bookmark.svg"; onClicked: gui.setPage("PageBookmarksAdd.qml") -- 2.7.4