[hamster-applet] kind of sorted out the mess with dates and such
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet] kind of sorted out the mess with dates and such
- Date: Tue, 13 Jul 2010 15:09:20 +0000 (UTC)
commit 4bece451d50704fdf2cd52711c36ab0ea84743a1
Author: Toms Bauģis <toms baugis gmail com>
Date: Tue Jul 13 15:00:56 2010 +0100
kind of sorted out the mess with dates and such
src/hamster/overview_activities.py | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/hamster/overview_activities.py b/src/hamster/overview_activities.py
index 20ada8b..3b93191 100644
--- a/src/hamster/overview_activities.py
+++ b/src/hamster/overview_activities.py
@@ -38,6 +38,7 @@ import datetime as dt
import calendar
import time
from hamster.i18n import C_
+from collections import defaultdict
@@ -70,21 +71,26 @@ class OverviewBox(gtk.VBox):
def fill_facts_tree(self):
- #create list of all required dates
- dates = [(self.start_date + dt.timedelta(i), [])
- for i in range((self.end_date - self.start_date).days + 1)]
+ # detach model to trigger selection memory and speeding up
+ self.fact_tree.detach_model()
+ self.fact_tree.clear()
+
+
+ dates = defaultdict(list)
+
+ print self.end_date, self.start_date
+
+ # fill blanks
+ for i in range((self.end_date - self.start_date).days + 1):
+ dates[self.start_date + dt.timedelta(i)] = []
#update with facts for the day
for date, facts in groupby(self.facts, lambda fact: fact["date"]):
- dates[dates.index((date, []))] = (date, list(facts))
-
+ dates[date] = list(facts)
- # detach model to trigger selection memory and speeding up
- self.fact_tree.detach_model()
- self.fact_tree.clear()
# push facts in tree
- for date, facts in dates:
+ for date, facts in sorted(dates.items(), key=lambda t: t[0]):
fact_date = date.strftime(C_("overview list", "%A, %b %d"))
self.fact_tree.add_group(fact_date, date, facts)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]