[gnome-maps/wip/jonasdn/storedRoute: 3/13] placeStore: Add storing of favorite route
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/jonasdn/storedRoute: 3/13] placeStore: Add storing of favorite route
- Date: Thu, 12 Feb 2015 20:05:11 +0000 (UTC)
commit fd867a33780ebfd64a699b0446e01436d84dfc9d
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Thu Feb 12 20:41:22 2015 +0100
placeStore: Add storing of favorite route
https://bugzilla.gnome.org/show_bug.cgi?id=744425
src/placeStore.js | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/src/placeStore.js b/src/placeStore.js
index f3be0bf..79c5d89 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -28,6 +28,7 @@ const Lang = imports.lang;
const Application = imports.application;
const ContactPlace = imports.contactPlace;
const Place = imports.place;
+const StoredRoute = imports.storedRoute;
const Utils = imports.utils;
const _PLACES_STORE_FILE = 'maps-places.json';
@@ -39,7 +40,8 @@ const PlaceType = {
ANY: -1,
RECENT: 0,
FAVORITE: 1,
- CONTACT: 2
+ CONTACT: 2,
+ FAVORITE_ROUTE: 3
};
const Columns = {
@@ -129,6 +131,16 @@ const PlaceStore = new Lang.Class({
this._numRecent++;
},
+ _addFavoriteRoute: function(stored) {
+ if (this.exists(stored, PlaceType.FAVORITE_ROUTE))
+ return;
+
+ if (stored.containsCurrentLocation)
+ return;
+
+ this._addPlace(stored, PlaceType.FAVORITE_ROUTE);
+ },
+
load: function() {
if (!GLib.file_test(this.filename, GLib.FileTest.EXISTS))
return;
@@ -146,7 +158,12 @@ const PlaceStore = new Lang.Class({
if (!place.id)
return;
- let p = Place.Place.fromJSON(place);
+ let p;
+ if (type === PlaceType.FAVORITE_ROUTE)
+ p = StoredRoute.StoredRoute.fromJSON(place);
+ else
+ p = Place.Place.fromJSON(place);
+
this._setPlace(this.append(), p, type, added);
if (type === PlaceType.RECENT)
this._numRecent++;
@@ -163,6 +180,8 @@ const PlaceStore = new Lang.Class({
this._addRecent(place, type);
else if (type === PlaceType.CONTACT)
this._addContact(place, type);
+ else if (type === PlaceType.FAVORITE_ROUTE)
+ this._addFavoriteRoute(place);
},
removePlace: function(place, placeType) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]