summaryrefslogtreecommitdiff
path: root/navit/gui
diff options
context:
space:
mode:
authorakashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220>2010-08-20 06:48:15 +0000
committerakashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220>2010-08-20 06:48:15 +0000
commitbb4e4523328b7566db8e9f1de17fa759d04f2c45 (patch)
tree52a9d9942cbfd5b89baaabf0c5dcaae8cdbbaeab /navit/gui
parent24a2ae757f107106bfe3ef4f1f00b993a3a04e7c (diff)
downloadnavit-svn-bb4e4523328b7566db8e9f1de17fa759d04f2c45.tar.gz
Fix:gui/qml:Implemented xml model for vehicle selection list
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@3537 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/gui')
-rw-r--r--navit/gui/qml/navitProxy.h35
-rw-r--r--navit/gui/qml/proxy.h9
-rw-r--r--navit/gui/qml/skins/navit/ButtonIcon.qml2
-rw-r--r--navit/gui/qml/skins/navit/Cellar.qml1
-rw-r--r--navit/gui/qml/skins/navit/ListSelector.qml7
-rw-r--r--navit/gui/qml/skins/navit/PageSettingsLocale.qml6
-rw-r--r--navit/gui/qml/skins/navit/PageSettingsVehicle.qml30
-rw-r--r--navit/gui/qml/skins/navit/ToggleSwitch.qml142
8 files changed, 130 insertions, 102 deletions
diff --git a/navit/gui/qml/navitProxy.h b/navit/gui/qml/navitProxy.h
index eb24ef4e..35900920 100644
--- a/navit/gui/qml/navitProxy.h
+++ b/navit/gui/qml/navitProxy.h
@@ -27,11 +27,15 @@ public slots:
return;
}
QString getAttrList(const QString &attr_name) {
- NGQStandardItemModel* ret=new NGQStandardItemModel(this);
struct attr attr;
struct attr_iter *iter;
int counter=0;
- QString currentValue, retId;
+ QString currentValue;
+ QDomDocument retDoc;
+ QDomElement entries;
+
+ entries=retDoc.createElement("attributes");
+ retDoc.appendChild(entries);
//Find current value
getAttrFunc(attr_from_name(attr_name.toStdString().c_str()), &attr, NULL) ;
@@ -42,7 +46,7 @@ public slots:
//Fill da list
iter=getIterFunc();
if (iter == NULL) {
- return retId;
+ return QString();
}
while (getAttrFunc(attr_from_name(attr_name.toStdString().c_str()), &attr, iter) ) {
@@ -53,27 +57,34 @@ public slots:
curItem->setData(QVariant(attr.u.layout->name),NGQStandardItemModel::ItemName);
curItem->setData(QVariant(attr.u.layout->name),NGQStandardItemModel::ItemValue);
if (currentValue==attr.u.layout->name) {
- retId.setNum(counter);
+ this->_itemId=counter;
}
}
if (attr.type==attr_vehicle) {
+ QStandardItem* curItem=new QStandardItem();
+ QDomElement entry=retDoc.createElement("vehicle");
+ entries.appendChild(entry);
+
this->object->currVehicle=attr.u.vehicle;
- curItem->setData(QVariant(counter),NGQStandardItemModel::ItemId);
curItem->setData(QVariant(this->object->vehicleProxy->getAttr("name")),NGQStandardItemModel::ItemName);
- curItem->setData(QVariant(this->object->vehicleProxy->getAttr("name")),NGQStandardItemModel::ItemValue);
- retId.setNum(0);
+ entry.appendChild(this->_fieldValueHelper(retDoc,QString("id"), QString::number(counter)));
+ entry.appendChild(this->_fieldValueHelper(retDoc,QString("name"), QString(this->object->vehicleProxy->getAttr("name"))));
+
+ //Detecting current vehicle
+ struct attr vehicle_attr;
+ navit_get_attr(this->object->nav, attr_vehicle, &vehicle_attr, NULL);
+ if (vehicle_attr.u.vehicle==attr.u.vehicle) {
+ this->_itemId=counter;
+ }
}
counter++;
- ret->appendRow(curItem);
}
dropIterFunc(iter);
- this->object->guiWidget->rootContext()->setContextProperty("listModel",static_cast<QObject*>(ret));
-
- dbg(0,"retId %s \n",retId.toStdString().c_str());
+ dbg(0,QString::number(_itemId).toStdString().c_str());
- return retId;
+ return retDoc.toString();
}
QString getDestination() {
struct attr attr;
diff --git a/navit/gui/qml/proxy.h b/navit/gui/qml/proxy.h
index 60d73d3e..ba45cb44 100644
--- a/navit/gui/qml/proxy.h
+++ b/navit/gui/qml/proxy.h
@@ -21,11 +21,15 @@ private:
class NGQProxy : public QObject {
Q_OBJECT;
+ Q_PROPERTY(int itemId READ itemId NOTIFY itemIdSignal);
public:
NGQProxy(struct gui_priv* this_,QObject *parent) : QObject(parent) {
this->object=this_;
}
+signals:
+ void itemIdSignal(int itemId);
+
public slots:
//Attribute read/write
QString getAttr(const QString &attr_name) {
@@ -78,9 +82,14 @@ public slots:
return;
}
+ int itemId() {
+ return _itemId;
+ }
protected:
struct gui_priv* object;
+ int _itemId;
+
virtual int setAttrFunc(struct attr *attr)=0;
virtual int getAttrFunc(enum attr_type type, struct attr *attr, struct attr_iter *iter)=0;
virtual struct attr_iter* getIterFunc() { return NULL; };
diff --git a/navit/gui/qml/skins/navit/ButtonIcon.qml b/navit/gui/qml/skins/navit/ButtonIcon.qml
index 1644cd22..f969ebb5 100644
--- a/navit/gui/qml/skins/navit/ButtonIcon.qml
+++ b/navit/gui/qml/skins/navit/ButtonIcon.qml
@@ -15,7 +15,7 @@ Rectangle {
Image {
id: imgItem; source: gui.iconPath+container.icon; anchors.top: container.top; anchors.horizontalCenter: container.horizontalCenter;
- width: gui.height/8; height: gui.height/8
+ width: gui.height/4; height: gui.height/4
}
Text {
diff --git a/navit/gui/qml/skins/navit/Cellar.qml b/navit/gui/qml/skins/navit/Cellar.qml
index dd54bc02..de4d3c14 100644
--- a/navit/gui/qml/skins/navit/Cellar.qml
+++ b/navit/gui/qml/skins/navit/Cellar.qml
@@ -6,7 +6,6 @@ Rectangle {
function onStartup(currentPage) {
btnBack.opacity=0;
btnQuit.opacity=0;
- console.log(gui.lengthPage());
if ( gui.lengthPage() > 1 ) {
btnBack.opacity=1;
}
diff --git a/navit/gui/qml/skins/navit/ListSelector.qml b/navit/gui/qml/skins/navit/ListSelector.qml
index 23fddcc7..09c927cf 100644
--- a/navit/gui/qml/skins/navit/ListSelector.qml
+++ b/navit/gui/qml/skins/navit/ListSelector.qml
@@ -8,7 +8,7 @@ Rectangle {
property string text: "ListSelector"
property string value: ""
- property int itemId
+ property int itemId: 0
property bool showScroller: false
signal changed
@@ -21,7 +21,7 @@ Rectangle {
Component.onCompleted: startup();
Text {
- id: labelTxt; text: listselector.text; color: "White"; font.pointSize: 14;
+ id: labelTxt; text: listselector.text; color: "White"; font.pointSize: 22;
anchors.horizontalCenter: list.horizontalCenter
anchors.verticalCenter: listselector.top
}
@@ -37,7 +37,8 @@ Rectangle {
clip: true
highlightFollowsCurrentItem: true
keyNavigationWraps: true
- currentIndex: listselector.itemId;
+
+ Component.onCompleted: { list.currentIndex=listselector.itemId; }
}
Rectangle {
id: listScroller
diff --git a/navit/gui/qml/skins/navit/PageSettingsLocale.qml b/navit/gui/qml/skins/navit/PageSettingsLocale.qml
index 868ca878..44124848 100644
--- a/navit/gui/qml/skins/navit/PageSettingsLocale.qml
+++ b/navit/gui/qml/skins/navit/PageSettingsLocale.qml
@@ -24,9 +24,9 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter;
anchors.verticalCenter: parent.verticalCenter;
- Text { id: lang; anchors.bottom: langname.top; text: gui.localeName; color: "White";font.pointSize: gui.height/24 }
- Text { id: langname; anchors.centerIn: parent; text: gui.langName; color: "White";font.pointSize: gui.height/24 }
- Text { id: ctryname; anchors.top: langname.bottom; text: gui.ctryName; color: "White";font.pointSize: gui.height/24 }
+ Text { id: lang; text: gui.localeName; color: "White";font.pointSize: gui.height/24 }
+ Text { id: langname; text: gui.langName; color: "White";font.pointSize: gui.height/24 }
+ Text { id: ctryname; text: gui.ctryName; color: "White";font.pointSize: gui.height/24 }
}
Cellar {anchors.bottom: page.bottom; anchors.horizontalCenter: page.horizontalCenter; width: page.width }
diff --git a/navit/gui/qml/skins/navit/PageSettingsVehicle.qml b/navit/gui/qml/skins/navit/PageSettingsVehicle.qml
index 637a5116..157afcb0 100644
--- a/navit/gui/qml/skins/navit/PageSettingsVehicle.qml
+++ b/navit/gui/qml/skins/navit/PageSettingsVehicle.qml
@@ -19,32 +19,40 @@ Rectangle {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
+ XmlListModel {
+ id: listModel
+ xml: navit.getAttrList("vehicle");
+ query: "/attributes/vehicle"
+ XmlRole { name: "itemId"; query: "id/string()" }
+ XmlRole { name: "itemName"; query: "name/string()" }
+ }
+
Component {
id: listDelegate
Item {
id: wrapper
- width: list.width; height: 20
+ width: list.width; height: txtItemName.height
Column {
x: 5; y: 5
- Text { id: txtItemName; text: itemName; color: "White" }
- Text { id: txtItemDist; text: itemDistance; color: "White"; anchors.leftMargin: 5; anchors.left: txtItemName.right;anchors.top: txtItemName.top }
- Text { id: txtItemDirect; text: itemDirection; color: "White"; anchors.leftMargin: 5; anchors.left: txtItemDist.right;anchors.top: txtItemDist.top }
+ Text { id: txtItemName; text: itemName; color: "White"; font.pointSize: 42 }
}
MouseArea {
id:delegateMouse
anchors.fill: parent
- onClicked: { list.currentIndex=itemId; listselector.value=itemValue; listselector.changed() }
- }
- }
- }
-CommonHighlight { id: listHighlight}
+ onClicked: { list.currentIndex=itemId; listselector.value=itemName; listselector.changed() }
+ }
+ }
+ }
+ CommonHighlight { id: listHighlight}
+
ListSelector {
- id:vehicleList; text: "Current vehicle profile"; itemId: navit.getAttrList("vehicle"); onChanged: {navit.setObjectByName("vehicle",vehicleList.value) }
+ id:vehicleList; text: "Current vehicle profile"; itemId: navit.itemId; onChanged: {navit.setObjectByName("vehicle",vehicleList.value) }
anchors.top: parent.top; anchors.topMargin: gui.height/16; anchors.leftMargin: gui.width/32
anchors.left: parent.left; width: page.width/2;height: page.height/2
}
+
ButtonIcon {
- id: btnVehicle; text: "Vehicle options"; icon: "gui_vehicle.svg"; onClicked: Navit.load("PageSettingsVehicleOptions.qml");
+ id: btnVehicle; text: navit.getAttr("vehicle"); icon: "gui_vehicle.svg"; onClicked: Navit.load("PageSettingsVehicleOptions.qml");
anchors.verticalCenter: vehicleList.verticalCenter; anchors.leftMargin: gui.width/32
anchors.left: vehicleList.right;
}
diff --git a/navit/gui/qml/skins/navit/ToggleSwitch.qml b/navit/gui/qml/skins/navit/ToggleSwitch.qml
index 28220621..b1b26246 100644
--- a/navit/gui/qml/skins/navit/ToggleSwitch.qml
+++ b/navit/gui/qml/skins/navit/ToggleSwitch.qml
@@ -1,72 +1,72 @@
import Qt 4.7
-
- Item {
- id: toggleswitch
- width: background.width + label.width + gui.width/24; height: background.height
-
- property string stOn: "false"
- property string text: "Toggle switch"
- signal changed
-
- function toggle() {
- if (toggleswitch.state == "on")
- toggleswitch.state = "off";
- else toggleswitch.state = "on";
- }
-
- function startup () {
- if (toggleswitch.stOn == "1" )
- toggleswitch.stOn = "true";
- else if (toggleswitch.stOn == "0" )
- toggleswitch.stOn = "false";
- if (toggleswitch.stOn == "true")
- toggleswitch.state = "on";
- else
- toggleswitch.state = "off";
- }
-
- Component.onCompleted: startup();
-
- Text {
- id: label; text: toggleswitch.text; color: "White"; font.pointSize: gui.height/32;
- anchors.left: background.right; anchors.leftMargin: gui.width/24;
- anchors.verticalCenter: background.verticalCenter
- }
-
-
- Image {
- id: background; source: "background.svg"
- MouseArea { anchors.fill: parent; onClicked: toggle() }
- height: gui.height/7.5; width: height*2.4;
- }
-
- Image {
- id: knob; source: "knob.svg"; x: 1; y: 2
- height: gui.height/8; width: gui.height/8;
-
- MouseArea {
- anchors.fill: parent
- drag.target: knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: background.width-knob.width
- hoverEnabled: false; onReleased: toggle()
- }
- }
-
- states: [
- State {
- name: "on"
- PropertyChanges { target: knob; x: background.width-knob.width }
- PropertyChanges { target: toggleswitch; stOn: "true" }
- StateChangeScript { script: toggleswitch.changed(); }
- },
- State {
- name: "off"
- PropertyChanges { target: knob; x: 1 }
- PropertyChanges { target: toggleswitch; stOn: "false" }
- StateChangeScript { script: toggleswitch.changed(); }
- }
- ]
-
- transitions: Transition {
- NumberAnimation { properties: "x"; easing.type: "InOutQuad"; duration: 200 }
- }
- }
+
+ Item {
+ id: toggleswitch
+ width: background.width + label.width + gui.width/24; height: background.height
+
+ property string stOn: "false"
+ property string text: "Toggle switch"
+ signal changed
+
+ function toggle() {
+ if (toggleswitch.state == "on")
+ toggleswitch.state = "off";
+ else toggleswitch.state = "on";
+ }
+
+ function startup () {
+ if (toggleswitch.stOn == "1" )
+ toggleswitch.stOn = "true";
+ else if (toggleswitch.stOn == "0" )
+ toggleswitch.stOn = "false";
+ if (toggleswitch.stOn == "true")
+ toggleswitch.state = "on";
+ else
+ toggleswitch.state = "off";
+ }
+
+ Component.onCompleted: startup();
+
+ Text {
+ id: label; text: toggleswitch.text; color: "White"; font.pointSize: gui.height/20;
+ anchors.left: background.right; anchors.leftMargin: gui.width/24;
+ anchors.verticalCenter: background.verticalCenter
+ }
+
+
+ Image {
+ id: background; source: "background.svg"
+ MouseArea { anchors.fill: parent; onClicked: toggle() }
+ height: gui.height/6; width: height*2.4;
+ }
+
+ Image {
+ id: knob; source: "knob.svg"; x: 1; y: 2
+ height: gui.height/6; width: gui.height/6;
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: background.width-knob.width
+ hoverEnabled: false; onReleased: toggle()
+ }
+ }
+
+ states: [
+ State {
+ name: "on"
+ PropertyChanges { target: knob; x: background.width-knob.width }
+ PropertyChanges { target: toggleswitch; stOn: "true" }
+ StateChangeScript { script: toggleswitch.changed(); }
+ },
+ State {
+ name: "off"
+ PropertyChanges { target: knob; x: 1 }
+ PropertyChanges { target: toggleswitch; stOn: "false" }
+ StateChangeScript { script: toggleswitch.changed(); }
+ }
+ ]
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: "InOutQuad"; duration: 200 }
+ }
+ }