[gnome-documents] selections, query: Different collections for Books and Documents



commit e037d81c69c587083d89ac743e2175f23ed39f47
Author: Alessandro Bono <shadow openaliasbox org>
Date:   Wed Oct 14 13:26:03 2015 +0200

    selections, query: Different collections for Books and Documents
    
    Restore separate collections for Books and Documents, and fix the
    queries accordingly.
    
    This reverts 5e9d776ae276cb660104bb19d8d4743c5f2f6747
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749900

 src/query.js      |   12 ++++++++++--
 src/selections.js |    9 ++++++++-
 2 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/query.js b/src/query.js
index 48b89f7..f1dd34b 100644
--- a/src/query.js
+++ b/src/query.js
@@ -48,7 +48,8 @@ const QueryFlags = {
     SEARCH: 1 << 3
 };
 
-const LOCAL_COLLECTIONS_IDENTIFIER = 'gd:collection:local:';
+const LOCAL_BOOKS_COLLECTIONS_IDENTIFIER = 'gb:collection:local:';
+const LOCAL_DOCUMENTS_COLLECTIONS_IDENTIFIER = 'gd:collection:local:';
 
 const QueryBuilder = new Lang.Class({
     Name: 'QueryBuilder',
@@ -219,11 +220,18 @@ const QueryBuilder = new Lang.Class({
     },
 
     buildCreateCollectionQuery: function(name) {
+        let application = Gio.Application.get_default();
+        let collectionsIdentifier;
+        if (application.isBooks)
+            collectionsIdentifier = LOCAL_BOOKS_COLLECTIONS_IDENTIFIER;
+        else
+            collectionsIdentifier = LOCAL_DOCUMENTS_COLLECTIONS_IDENTIFIER;
+
         let time = GdPrivate.iso8601_from_timestamp(GLib.get_real_time() / GLib.USEC_PER_SEC);
         let sparql = ('INSERT { _:res a nfo:DataContainer ; a nie:DataObject ; ' +
                       'nie:contentLastModified \"' + time + '\" ; ' +
                       'nie:title \"' + name + '\" ; ' +
-                      'nao:identifier \"' + LOCAL_COLLECTIONS_IDENTIFIER + name + '\" }');
+                      'nao:identifier \"' + collectionsIdentifier + name + '\" }');
 
         return this._createQuery(sparql);
     },
diff --git a/src/selections.js b/src/selections.js
index 22c1856..9ff72be 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -160,6 +160,13 @@ const FetchCollectionStateForSelectionJob = new Lang.Class({
                     hidden = true;
             }
 
+            let application = Gio.Application.get_default();
+            let collectionsIdentifier;
+            if (application.isBooks)
+                collectionsIdentifier = Query.LOCAL_BOOKS_COLLECTIONS_IDENTIFIER;
+            else
+                collectionsIdentifier = Query.LOCAL_DOCUMENTS_COLLECTIONS_IDENTIFIER;
+
             for (let itemIdx in this._collectionsForItems) {
                 let item = Application.documentManager.getItemById(itemIdx);
                 let collectionsForItem = this._collectionsForItems[itemIdx];
@@ -171,7 +178,7 @@ const FetchCollectionStateForSelectionJob = new Lang.Class({
                     notFound = true;
 
                 if ((item.resourceUrn != collection.resourceUrn) &&
-                    (collection.identifier.indexOf(Query.LOCAL_COLLECTIONS_IDENTIFIER) == -1)) {
+                    (collection.identifier.indexOf(collectionsIdentifier) == -1)) {
                     hidden = true;
                 }
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]