Fix Place Tree view when using enclosed by sidebar filter (#764)
the filter was incorrectly using a standard place cursor instead of the tree cursor. Fixes #10948
This commit is contained in:
parent
be98b673df
commit
d65ad470d6
@ -124,6 +124,9 @@ class GenericFilter:
|
|||||||
def get_cursor(self, db):
|
def get_cursor(self, db):
|
||||||
return db.get_person_cursor()
|
return db.get_person_cursor()
|
||||||
|
|
||||||
|
def get_tree_cursor(self, db):
|
||||||
|
return db.get_person_cursor()
|
||||||
|
|
||||||
def make_obj(self):
|
def make_obj(self):
|
||||||
return Person()
|
return Person()
|
||||||
|
|
||||||
@ -133,13 +136,15 @@ class GenericFilter:
|
|||||||
def get_number(self, db):
|
def get_number(self, db):
|
||||||
return db.get_number_of_people()
|
return db.get_number_of_people()
|
||||||
|
|
||||||
def check_func(self, db, id_list, task, user=None, tupleind=None):
|
def check_func(self, db, id_list, task, user=None, tupleind=None,
|
||||||
|
tree=False):
|
||||||
final_list = []
|
final_list = []
|
||||||
if user:
|
if user:
|
||||||
user.begin_progress(_('Filter'), _('Applying ...'),
|
user.begin_progress(_('Filter'), _('Applying ...'),
|
||||||
self.get_number(db))
|
self.get_number(db))
|
||||||
if id_list is None:
|
if id_list is None:
|
||||||
with self.get_cursor(db) as cursor:
|
with (self.get_tree_cursor(db) if tree else
|
||||||
|
self.get_cursor(db)) as cursor:
|
||||||
for handle, data in cursor:
|
for handle, data in cursor:
|
||||||
person = self.make_obj()
|
person = self.make_obj()
|
||||||
person.unserialize(data)
|
person.unserialize(data)
|
||||||
@ -162,14 +167,15 @@ class GenericFilter:
|
|||||||
user.end_progress()
|
user.end_progress()
|
||||||
return final_list
|
return final_list
|
||||||
|
|
||||||
def check_and(self, db, id_list, user=None, tupleind=None):
|
def check_and(self, db, id_list, user=None, tupleind=None, tree=False):
|
||||||
final_list = []
|
final_list = []
|
||||||
flist = self.flist
|
flist = self.flist
|
||||||
if user:
|
if user:
|
||||||
user.begin_progress(_('Filter'), _('Applying ...'),
|
user.begin_progress(_('Filter'), _('Applying ...'),
|
||||||
self.get_number(db))
|
self.get_number(db))
|
||||||
if id_list is None:
|
if id_list is None:
|
||||||
with self.get_cursor(db) as cursor:
|
with (self.get_tree_cursor(db) if tree else
|
||||||
|
self.get_cursor(db)) as cursor:
|
||||||
for handle, data in cursor:
|
for handle, data in cursor:
|
||||||
person = self.make_obj()
|
person = self.make_obj()
|
||||||
person.unserialize(data)
|
person.unserialize(data)
|
||||||
@ -194,14 +200,17 @@ class GenericFilter:
|
|||||||
user.end_progress()
|
user.end_progress()
|
||||||
return final_list
|
return final_list
|
||||||
|
|
||||||
def check_or(self, db, id_list, user=None, tupleind=None):
|
def check_or(self, db, id_list, user=None, tupleind=None, tree=False):
|
||||||
return self.check_func(db, id_list, self.or_test, user, tupleind)
|
return self.check_func(db, id_list, self.or_test, user, tupleind,
|
||||||
|
tree=False)
|
||||||
|
|
||||||
def check_one(self, db, id_list, user=None, tupleind=None):
|
def check_one(self, db, id_list, user=None, tupleind=None, tree=False):
|
||||||
return self.check_func(db, id_list, self.one_test, user, tupleind)
|
return self.check_func(db, id_list, self.one_test, user, tupleind,
|
||||||
|
tree=False)
|
||||||
|
|
||||||
def check_xor(self, db, id_list, user=None, tupleind=None):
|
def check_xor(self, db, id_list, user=None, tupleind=None, tree=False):
|
||||||
return self.check_func(db, id_list, self.xor_test, user, tupleind)
|
return self.check_func(db, id_list, self.xor_test, user, tupleind,
|
||||||
|
tree=False)
|
||||||
|
|
||||||
def xor_test(self, db, person):
|
def xor_test(self, db, person):
|
||||||
test = False
|
test = False
|
||||||
@ -231,7 +240,7 @@ class GenericFilter:
|
|||||||
def check(self, db, handle):
|
def check(self, db, handle):
|
||||||
return self.get_check_func()(db, [handle])
|
return self.get_check_func()(db, [handle])
|
||||||
|
|
||||||
def apply(self, db, id_list=None, tupleind=None, user=None):
|
def apply(self, db, id_list=None, tupleind=None, user=None, tree=False):
|
||||||
"""
|
"""
|
||||||
Apply the filter using db.
|
Apply the filter using db.
|
||||||
If id_list given, the handles in id_list are used. If not given
|
If id_list given, the handles in id_list are used. If not given
|
||||||
@ -251,7 +260,7 @@ class GenericFilter:
|
|||||||
m = self.get_check_func()
|
m = self.get_check_func()
|
||||||
for rule in self.flist:
|
for rule in self.flist:
|
||||||
rule.requestprepare(db, user)
|
rule.requestprepare(db, user)
|
||||||
res = m(db, id_list, user, tupleind)
|
res = m(db, id_list, user, tupleind, tree)
|
||||||
for rule in self.flist:
|
for rule in self.flist:
|
||||||
rule.requestreset()
|
rule.requestreset()
|
||||||
return res
|
return res
|
||||||
@ -315,6 +324,9 @@ class GenericCitationFilter(GenericFilter):
|
|||||||
def get_cursor(self, db):
|
def get_cursor(self, db):
|
||||||
return db.get_citation_cursor()
|
return db.get_citation_cursor()
|
||||||
|
|
||||||
|
def get_tree_cursor(self, db):
|
||||||
|
return db.get_citation_cursor()
|
||||||
|
|
||||||
def make_obj(self):
|
def make_obj(self):
|
||||||
return Citation()
|
return Citation()
|
||||||
|
|
||||||
@ -332,6 +344,9 @@ class GenericPlaceFilter(GenericFilter):
|
|||||||
def get_cursor(self, db):
|
def get_cursor(self, db):
|
||||||
return db.get_place_cursor()
|
return db.get_place_cursor()
|
||||||
|
|
||||||
|
def get_tree_cursor(self, db):
|
||||||
|
return db.get_place_tree_cursor()
|
||||||
|
|
||||||
def make_obj(self):
|
def make_obj(self):
|
||||||
return Place()
|
return Place()
|
||||||
|
|
||||||
|
@ -584,7 +584,7 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
|
|||||||
self.__total += items
|
self.__total += items
|
||||||
assert not skip
|
assert not skip
|
||||||
if dfilter:
|
if dfilter:
|
||||||
for handle in dfilter.apply(self.db,
|
for handle in dfilter.apply(self.db, tree=True,
|
||||||
user=User(parent=self.uistate.window)):
|
user=User(parent=self.uistate.window)):
|
||||||
status_ppl.heartbeat()
|
status_ppl.heartbeat()
|
||||||
data = data_map(handle)
|
data = data_map(handle)
|
||||||
|
Loading…
Reference in New Issue
Block a user