Add:gui/qml:Added xml based poi filter
authorakashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sat, 3 Apr 2010 12:55:19 +0000 (12:55 +0000)
committerakashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sat, 3 Apr 2010 12:55:19 +0000 (12:55 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3119 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/configure.in
navit/navit/gui/qml/gui_qml.cpp
navit/navit/gui/qml/ngqpoint.h
navit/navit/gui/qml/skins/navit/PagePoi.qml

index 6d4c2a6..4a03814 100644 (file)
@@ -787,7 +787,7 @@ AM_CONDITIONAL(GUI_WIN32, test "x${gui_win32}" = "xyes")
 AM_CONDITIONAL(QT_DECLARATIVE_NEWAPI,test "x${gui_qml}" = "xoldapi")
 AC_ARG_ENABLE(gui-qml, [  --disable-gui-qml              disable gui type QML], gui_qml=$enableval;gui_qml_reason="configure parameter")
 if test "x${gui_qml}" = "xyes" -a "x${QT_GUI_CFLAGS}" = "x" -a "x${QT_GUI_LIBS}" = "x"; then
-       PKG_CHECK_MODULES(QT_GUI, [QtGui QtCore], ,gui_qml=no;gui_qml_reason="Packages QtGui and/or QtCore missing")
+       PKG_CHECK_MODULES(QT_GUI, [QtGui QtCore QtXml], ,gui_qml=no;gui_qml_reason="Packages QtGui and/or QtCore missing")
 fi
 if test "x${gui_qml}" = "xyes" -a "x${QT_DECLARATIVE_CFLAGS}" = "x" -a "x${QT_DECLARATIVE_LIBS}" = "x"; then
        PKG_CHECK_MODULES(QT_DECLARATIVE, [QtDeclarative >= 4.6.0 ], ,gui_qml=no;gui_qml_reason="Packages QtDeclarative missing")
index 515593f..4d02aa0 100644 (file)
@@ -2,6 +2,7 @@
 #include <QtCore>
 #include <QtGui>
 #include <QtDeclarative>
+#include <QtXml>
 #ifdef HAVE_API_WIN32_BASE
 #include <windows.h>
 #endif
index 67c222f..6cdb485 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef NAVIT_GUI_QML_POINT_H
 #define NAVIT_GUI_QML_POINT_H
 
-enum NGQPointTypes {MapPoint,Bookmark};
+enum NGQPointTypes {MapPoint,Bookmark,Position,Destination};
 
 class NGQPoint : public QObject {
        Q_OBJECT;
@@ -66,6 +66,10 @@ public slots:
                     return QString("MapPoint");
             case Bookmark:
                     return QString("Bookmark");
+            case Position:
+                    return QString("Position");
+            case Destination:
+                    return QString("Destination");
             }
             return QString("");
     }
@@ -78,7 +82,8 @@ public slots:
             struct map *m;
             int idist,dist;
             struct coord center;
-            QString retXml;
+            QDomDocument retDoc(attr_name);
+            QDomElement entries;
 
             if (!gui_get_attr(this->object->gui,attr_radius,&attr,NULL)) {
                     return QString();
@@ -91,7 +96,8 @@ public slots:
             center.y=this->c.y;
             h=mapset_open(navit_get_mapset(this->object->nav));
 
-            retXml=QString("<%1>").arg(attr_name);
+            entries=retDoc.createElement(attr_name);
+            retDoc.appendChild(entries);
 
             while ((m=mapset_next(h, 1))) {
                     selm=map_selection_dup_pro(sel, this->c.pro, map_projection(m));
@@ -99,7 +105,7 @@ public slots:
                     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, &center, &c)) < dist ) {
+                                    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, &center, &c)) < dist && item->type<type_line) {
                                             char* label;
                                             QString rs;
                                             if (item_attr_get(item, attr_label, &attr)) {
@@ -122,12 +128,16 @@ public slots:
                                             } else
                                                     rs=item_to_name(item->type);
                                             if (rs.length()>0) {
-                                                    QString pointXml="<point>";
-                                                    pointXml+="<name>"+rs+"</name>";
-                                                    pointXml+="<type>"+QString(item_to_name(item->type))+"</type>";
-                                                    pointXml+="</point>";
-        
-                                                    retXml+=pointXml;
+                                                    QDomElement entry=retDoc.createElement("point");
+                                                    QDomElement nameTag=retDoc.createElement("name");
+                                                    QDomElement typeTag=retDoc.createElement("type");
+                                                    QDomText nameT=retDoc.createTextNode(rs);
+                                                    QDomText typeT=retDoc.createTextNode(QString(item_to_name(item->type)));
+                                                    nameTag.appendChild(nameT);
+                                                    typeTag.appendChild(typeT);
+                                                    entry.appendChild(nameTag);
+                                                    entry.appendChild(typeTag);
+                                                    entries.appendChild(entry);
                                             }
                                     }
                             }
@@ -137,9 +147,7 @@ public slots:
             map_selection_destroy(sel);
             mapset_close(h);
            
-            retXml+=QString("</%1>").arg(attr_name);
-            dbg(0,"Reulsting xml: %s\n",retXml.toLocal8Bit().constData());
-            return retXml;
+            return retDoc.toString();
     }
 protected:
         QString _coordString() {
index 6c49020..b66a952 100644 (file)
@@ -118,7 +118,7 @@ Rectangle {
                XmlRole { name: "itemName"; query: "name/string()" }
                XmlRole { name: "itemType"; query: "type/string()" }
        }
-    ListSelectorXml { 
+    ListSelector { 
        id:layoutList; text: ""; itemId: point.getAttrList("points"); onChanged: console.log("Poi clicked");
        anchors.top: distanceSlider.bottom;
        anchors.left: parent.left; anchors.leftMargin: 3