[gnome-maps/wip/routing2: 8/11] Add a Route query model
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/routing2: 8/11] Add a Route query model
- Date: Mon, 28 Apr 2014 17:13:28 +0000 (UTC)
commit 831064407dfe2f36d9e1cac195f09da2c7a76f62
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date: Tue Apr 22 04:38:50 2014 +0200
Add a Route query model
This will represent the route query state in the app.
https://bugzilla.gnome.org/show_bug.cgi?id=728695
src/route.js | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
---
diff --git a/src/route.js b/src/route.js
index ef31b8c..3c7687a 100644
--- a/src/route.js
+++ b/src/route.js
@@ -20,11 +20,21 @@
* Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
*/
+const GeoCode = imports.gi.GeocodeGlib;
+const GObject = imports.gi.GObject;
+
const Lang = imports.lang;
const Champlain = imports.gi.Champlain;
const Utils = imports.utils;
+const Transportation = {
+ CAR: 0,
+ BIKE: 1,
+ PEDESTRIAN: 2,
+ TRANSIT: 3
+};
+
const TurnPointType = {
END: -3,
VIA: -2,
@@ -40,6 +50,65 @@ const TurnPointType = {
ROUNDABOUT: 8
};
+const Query = new Lang.Class({
+ Name: 'Query',
+ Extends: GObject.Object,
+ Properties: {
+ 'from': GObject.ParamSpec.object('from',
+ '',
+ '',
+ GObject.ParamFlags.READABLE |
+ GObject.ParamFlags.WRITABLE,
+ GeoCode.Place),
+ 'to': GObject.ParamSpec.object('to',
+ '',
+ '',
+ GObject.ParamFlags.READABLE |
+ GObject.ParamFlags.WRITABLE,
+ GeoCode.Place),
+ 'transportation': GObject.ParamSpec.int('transportation',
+ '',
+ '',
+ GObject.ParamFlags.READABLE |
+ GObject.ParamFlags.WRITABLE,
+ Transportation.CAR, Transportation.TRANSIT,
+ Transportation.CAR)
+ },
+
+ _init: function(args) {
+ this.parent(args);
+ this._changeSignalId = this.connect('notify', this.emit.bind(this, 'change'));
+ this.reset();
+ },
+
+ reset: function() {
+ this.setMany({ from: null,
+ to: null,
+ transportation: Transportation.CAR });
+ },
+
+ setMany: function(obj) {
+ this.disconnect(this._changeSignalId);
+
+ if(obj.hasOwnProperty("from"))
+ this.from = obj.from;
+ if(obj.hasOwnProperty("to"))
+ this.to = obj.to;
+ if(obj.hasOwnProperty("transportation"))
+ this.transportation = obj.transportation;
+
+ this._changeSignalId = this.connect('notify', this.emit.bind(this, 'change'));
+ this.emit('change');
+ },
+
+ toString: function() {
+ return "From: " + this.from +
+ "\nTo: " + this.to +
+ "\nTransportation" + this.transportation;
+ }
+});
+Utils.addSignalMethods(Query.prototype);
+
const Route = new Lang.Class({
Name: 'Route',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]