From 12e9764fddbe665d56fe697dc423fce1879695b3 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sun, 16 Aug 2015 17:19:59 -0400 Subject: [PATCH] Cut in half the time to load treeviews: people tree, place, and citation tree views --- gramps/gui/views/treemodels/treebasemodel.py | 45 +++++--------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/gramps/gui/views/treemodels/treebasemodel.py b/gramps/gui/views/treemodels/treebasemodel.py index ef960bc49..9e8bd6df8 100644 --- a/gramps/gui/views/treemodels/treebasemodel.py +++ b/gramps/gui/views/treemodels/treebasemodel.py @@ -583,49 +583,24 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel): status = progressdlg.LongOpStatus(msg=_("Building View"), total_steps=3, interval=1) pmon.add_op(status) - status_ppl = progressdlg.LongOpStatus(msg=_("Obtaining all rows"), + status_ppl = progressdlg.LongOpStatus(msg=_("Loading items..."), total_steps=items, interval=items//10) pmon.add_op(status_ppl) self.__total += items - def beat(key): - status_ppl.heartbeat() - # for python3 this returns a byte object, so conversion needed - if not isinstance(key, str): - key = key.decode('utf-8') - return key - with gen_cursor() as cursor: - handle_list = [beat(key) for key, data in cursor] + for handle, data in cursor: + if not isinstance(handle, str): + handle = handle.decode('utf-8') + status_ppl.heartbeat() + if not handle in skip: + if not dfilter or dfilter.apply(self.db, [handle]): + add_func(handle, data) + self.__displayed += 1 status_ppl.end() - status.heartbeat() - - if dfilter: - _LOG.debug("rebuild filter %s" % dfilter) - _LOG.debug(" list before filter %s" % handle_list) - status_filter = progressdlg.LongOpStatus(msg=_("Applying filter"), - total_steps=items, interval=items//10) - pmon.add_op(status_filter) - handle_list = dfilter.apply(self.db, handle_list, - cb_progress=status_filter.heartbeat) - _LOG.debug(" list after filter %s" % handle_list) - status_filter.end() - status.heartbeat() - - todisplay = len(handle_list) - status_col = progressdlg.LongOpStatus(msg=_("Constructing column data"), - total_steps=todisplay, interval=todisplay//10) - pmon.add_op(status_col) - for handle in handle_list: - status_col.heartbeat() - data = data_map(handle) - if not handle in skip: - add_func(handle, data) - self.__displayed += 1 - status_col.end() status.end() - + def add_node(self, parent, child, sortkey, handle, add_parent=True, secondary=False): """