[hamster-applet] sped up treeview a little by detaching model on bigger operations and then reattaching again
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet] sped up treeview a little by detaching model on bigger operations and then reattaching again
- Date: Sun, 20 Dec 2009 14:53:41 +0000 (UTC)
commit dbd09d84fb6b4d29e1be5ed150c5470650ce53a4
Author: Toms Bauģis <toms baugis gmail com>
Date: Sat Dec 19 21:06:55 2009 +0000
sped up treeview a little by detaching model on bigger operations and then reattaching again
hamster/stats_overview.py | 2 ++
hamster/widgets/facttree.py | 20 ++++++++++++--------
2 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/hamster/stats_overview.py b/hamster/stats_overview.py
index b2ac047..b8ef178 100644
--- a/hamster/stats_overview.py
+++ b/hamster/stats_overview.py
@@ -77,6 +77,7 @@ class OverviewBox(gtk.VBox):
def fill_facts_tree(self, facts):
facts = facts or runtime.storage.get_facts(self.start_date, self.end_date)
+ self.fact_tree.detach_model()
self.fact_tree.clear()
@@ -94,6 +95,7 @@ class OverviewBox(gtk.VBox):
self.fact_tree.add_group(fact_date, facts)
+ self.fact_tree.attach_model()
def search(self, start_date, end_date, facts):
self.start_date = start_date
diff --git a/hamster/widgets/facttree.py b/hamster/widgets/facttree.py
index 5db381a..d395717 100644
--- a/hamster/widgets/facttree.py
+++ b/hamster/widgets/facttree.py
@@ -83,8 +83,9 @@ class FactTree(gtk.TreeView):
self.set_headers_visible(False)
self.set_show_expanders(False)
+ self.store_model = gtk.TreeStore(int, str, str, str, str, str, gobject.TYPE_PYOBJECT)
#id, caption, duration, date (invisible), description, category
- self.set_model(gtk.TreeStore(int, str, str, str, str, str, gobject.TYPE_PYOBJECT))
+ self.set_model(self.store_model)
# name
@@ -122,11 +123,7 @@ class FactTree(gtk.TreeView):
self.show()
def clear(self):
- self.model.clear()
-
- @property
- def model(self):
- return self.get_model()
+ self.store_model.clear()
def add_fact(self, fact, parent = None):
duration = stuff.duration_minutes(fact["delta"]) / 60
@@ -137,7 +134,7 @@ class FactTree(gtk.TreeView):
else:
fact_time = fact["start_time"].strftime("%H:%M ")
- self.model.append(parent, [fact["id"],
+ self.store_model.append(parent, [fact["id"],
"%s %s" % (fact_time, fact["name"]),
stuff.format_duration(fact["delta"]),
fact["start_time"].strftime('%Y-%m-%d'),
@@ -149,7 +146,7 @@ class FactTree(gtk.TreeView):
total = sum([stuff.duration_minutes(fact["delta"]) for fact in facts])
# adds group of facts with the given label
- group_row = self.model.append(None,
+ group_row = self.store_model.append(None,
[-1,
group_label,
stuff.format_duration(total),
@@ -162,6 +159,13 @@ class FactTree(gtk.TreeView):
self.add_fact(fact, group_row)
self.expand_all()
+
+ def detach_model(self):
+ self.set_model()
+
+ def attach_model(self):
+ self.set_model(self.store_model)
+ self.expand_all()
def get_selected_fact(self):
selection = self.get_selection()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]