Never unselect the album tree if the search text is a valid album tag.
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 19 Aug 2004 20:39:52 +0000 (20:39 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 19 Aug 2004 20:39:52 +0000 (20:39 +0000)
src/gkofoto/gkofoto/mainwindow.py
src/gkofoto/gkofoto/objectcollectionfactory.py

index e9c08ac..bd91f73 100644 (file)
@@ -97,14 +97,13 @@ class MainWindow(gtk.Window):
         self.__query = query
         self.__sourceEntry.set_text(query)
         useFilter = self.__isFilterEnabledCheckbox.get_active()
-        filterText = self.__filterEntry.get_text().decode("utf-8")
         self.__filterEntry.set_sensitive(useFilter)
-        if useFilter and len(filterText) > 0:
-            queryWithFilter = "(%s) and (%s)" % (query, filterText)
+        if useFilter:
+            filterText = self.__filterEntry.get_text().decode("utf-8")
         else:
-            queryWithFilter = query
+            filterText = ""
         self.__setObjectCollection(
-            self.__factory.getObjectCollection(queryWithFilter))
+            self.__factory.getObjectCollection(query, filterText))
 
     def reload(self):
         self.__albums.loadAlbumTree()
index a1808a0..8dafd97 100644 (file)
@@ -15,7 +15,7 @@ class ObjectCollectionFactory:
         self.__searchResult = SearchResult()
         self.__albumMembers = AlbumMembers()
 
-    def getObjectCollection(self, query):
+    def getObjectCollection(self, query, filterText=""):
         env.debug("Object collection factory loading query: " + query);
         self.__clear()
         validAlbumTag = False
@@ -26,12 +26,17 @@ class ObjectCollectionFactory:
             except BadAlbumTagError:
                 pass
         try:
-            if validAlbumTag:
+            if validAlbumTag and not filterText:
                 self.__albumMembers.loadAlbum(env.shelf.getAlbum(query[1:]))
                 return self.__albumMembers
             else:
-                self.__searchResult.loadQuery(query)
-                env.mainwindow.unselectAlbumTree()
+                if filterText:
+                    queryWithFilter = "(%s) and (%s)" % (query, filterText)
+                else:
+                    queryWithFilter = query
+                self.__searchResult.loadQuery(queryWithFilter)
+                if not validAlbumTag:
+                    env.mainwindow.unselectAlbumTree()
                 return self.__searchResult
         except AlbumDoesNotExistError, tag:
             errorText = "No such album tag: \"%s\"." % tag