Cut in half the time to load treeviews: people tree, place, and citation tree views

This commit is contained in:
Doug Blank 2015-08-16 17:19:59 -04:00
parent 9b93a812d3
commit 12e9764fdd

View File

@ -583,47 +583,22 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
status = progressdlg.LongOpStatus(msg=_("Building View"), status = progressdlg.LongOpStatus(msg=_("Building View"),
total_steps=3, interval=1) total_steps=3, interval=1)
pmon.add_op(status) 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) total_steps=items, interval=items//10)
pmon.add_op(status_ppl) pmon.add_op(status_ppl)
self.__total += items 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: with gen_cursor() as cursor:
handle_list = [beat(key) for key, data in cursor] for handle, data in cursor:
status_ppl.end() if not isinstance(handle, str):
status.heartbeat() handle = handle.decode('utf-8')
status_ppl.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: if not handle in skip:
if not dfilter or dfilter.apply(self.db, [handle]):
add_func(handle, data) add_func(handle, data)
self.__displayed += 1 self.__displayed += 1
status_col.end() status_ppl.end()
status.end() status.end()
def add_node(self, parent, child, sortkey, handle, add_parent=True, def add_node(self, parent, child, sortkey, handle, add_parent=True,