From f08d35b1697a8711d306b4cbc558ea3e966d3863 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 15 May 2006 04:14:03 +0000 Subject: [PATCH] * src/DataViews/_RepositoryView.py: column fixes * src/DataViews/_SourceView.py: column fixes * src/DataViews/_EventView.py: column fixes * src/DataViews/_FamilyList.py: column fixes * src/DataViews/_PlaceView.py: column fixes * src/DataViews/_PersonView.py: column fixes * src/DisplayModels.py: column/sort fixes * src/PageView.py: column/sort fixes svn: r6664 --- gramps2/ChangeLog | 8 +++ gramps2/src/DataViews/_EventView.py | 3 - gramps2/src/DataViews/_FamilyList.py | 3 - gramps2/src/DataViews/_PersonView.py | 8 ++- gramps2/src/DataViews/_PlaceView.py | 3 - gramps2/src/DataViews/_RepositoryView.py | 3 - gramps2/src/DataViews/_SourceView.py | 3 - gramps2/src/DisplayModels.py | 83 +++++++++++++++++------- gramps2/src/PageView.py | 7 +- 9 files changed, 77 insertions(+), 44 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 691cd10a7..dec2ac706 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -8,6 +8,14 @@ * src/plugins/FamilyGroup.py: Fix for Event and EventType changes. 2006-05-14 Don Allingham + * src/DataViews/_RepositoryView.py: column fixes + * src/DataViews/_SourceView.py: column fixes + * src/DataViews/_EventView.py: column fixes + * src/DataViews/_FamilyList.py: column fixes + * src/DataViews/_PlaceView.py: column fixes + * src/DataViews/_PersonView.py: column fixes + * src/DisplayModels.py: column/sort fixes + * src/PageView.py: column/sort fixes * src/DateHandler/__init__.py: import DateParser and DateDisplay * src/DataViews/_PersonView.py: default gender filter to "any" * configure.in: bump up to 2.1.2 diff --git a/gramps2/src/DataViews/_EventView.py b/gramps2/src/DataViews/_EventView.py index 3cb785acb..eaf8a4ef3 100644 --- a/gramps2/src/DataViews/_EventView.py +++ b/gramps2/src/DataViews/_EventView.py @@ -102,9 +102,6 @@ class EventView(PageView.ListView): def ui_definition(self): return ''' - - - diff --git a/gramps2/src/DataViews/_FamilyList.py b/gramps2/src/DataViews/_FamilyList.py index 4d94e7663..224064238 100644 --- a/gramps2/src/DataViews/_FamilyList.py +++ b/gramps2/src/DataViews/_FamilyList.py @@ -115,9 +115,6 @@ class FamilyListView(PageView.ListView): - - - diff --git a/gramps2/src/DataViews/_PersonView.py b/gramps2/src/DataViews/_PersonView.py index 433bcdce4..e5483a19b 100644 --- a/gramps2/src/DataViews/_PersonView.py +++ b/gramps2/src/DataViews/_PersonView.py @@ -307,7 +307,13 @@ class PersonView(PageView.PersonNavView): return table def clear_clicked(self,obj): - print "clear" + self.filter_name.set_text('') + self.filter_id.set_text('') + self.filter_birth.set_text('') + self.filter_death.get_text('') + self.filter_note.get_text('') + self.filter_gender.set_active(0) + self.event_menu.child.set_text('') def filter_clicked(self, obj): name = self.filter_name.get_text().strip() diff --git a/gramps2/src/DataViews/_PlaceView.py b/gramps2/src/DataViews/_PlaceView.py index a5d821099..71a97e252 100644 --- a/gramps2/src/DataViews/_PlaceView.py +++ b/gramps2/src/DataViews/_PlaceView.py @@ -121,9 +121,6 @@ class PlaceView(PageView.ListView): def ui_definition(self): return ''' - - - diff --git a/gramps2/src/DataViews/_RepositoryView.py b/gramps2/src/DataViews/_RepositoryView.py index 726b2befc..e78662eb7 100644 --- a/gramps2/src/DataViews/_RepositoryView.py +++ b/gramps2/src/DataViews/_RepositoryView.py @@ -127,9 +127,6 @@ class RepositoryView(PageView.ListView): def ui_definition(self): return ''' - - - diff --git a/gramps2/src/DataViews/_SourceView.py b/gramps2/src/DataViews/_SourceView.py index 3f7c18366..1012a3314 100644 --- a/gramps2/src/DataViews/_SourceView.py +++ b/gramps2/src/DataViews/_SourceView.py @@ -119,9 +119,6 @@ class SourceView(PageView.ListView): def ui_definition(self): return ''' - - - diff --git a/gramps2/src/DisplayModels.py b/gramps2/src/DisplayModels.py index d2df87cde..68529f50b 100644 --- a/gramps2/src/DisplayModels.py +++ b/gramps2/src/DisplayModels.py @@ -93,15 +93,15 @@ class BaseModel(gtk.GenericTreeModel): def set_sort_column(self,col): self.sort_func = self.smap[col] - #print self.sort_func def sort_keys(self): cursor = self.gen_cursor() sarray = [] data = cursor.next() - + while data: - sarray.append((locale.strxfrm(self.sort_func(data[1])),data[0])) + key = locale.strxfrm(self.sort_func(data[1])) + sarray.append((key,data[0])) data = cursor.next() cursor.close() @@ -277,7 +277,7 @@ class SourceModel(BaseModel): GrampsLocale.codeset) def sort_change(self,data): - return time.localtime(data[8]) + return "%012x" % data[8] def column_tooltip(self,data): if const.use_tips: @@ -387,7 +387,7 @@ class PlaceModel(BaseModel): return u'' def sort_change(self,data): - return time.localtime(data[11]) + return "%012x" % data[11] def column_change(self,data): return unicode(time.strftime('%x %X',time.localtime(data[11])), @@ -396,8 +396,9 @@ class PlaceModel(BaseModel): def column_tooltip(self,data): if const.use_tips: try: - t = ToolTips.TipFromFunction(self.db, lambda: - self.db.get_place_from_handle(data[0])) + t = ToolTips.TipFromFunction( + self.db, lambda: + self.db.get_place_from_handle(data[0])) except: log.error("Failed to create tooltip.", exc_info=True) return t @@ -476,7 +477,7 @@ class FamilyModel(BaseModel): return unicode(data[1]) def sort_change(self,data): - return time.localtime(data[13]) + return "%012x" % data[13] def column_change(self,data): return unicode(time.strftime('%x %X',time.localtime(data[13])), @@ -553,14 +554,16 @@ class MediaModel(BaseModel): def column_date(self,data): if data[9]: - return unicode(DateHandler.displayer.display(data[9])) + date = RelLib.Date() + date.unserialize(data[9]) + return unicode(DateHandler.displayer.display(date)) return u'' def column_handle(self,data): return unicode(data[0]) def sort_change(self,data): - return time.localtime(data[8]) + return "%012x" % data[8] def column_change(self,data): return unicode(time.strftime('%x %X',time.localtime(data[8])), @@ -645,8 +648,7 @@ class EventModel(BaseModel): return unicode(data[0]) def sort_change(self,data): - #print time.localtime(data[10]) - return time.localtime(data[10]) + return "%012x" % data[10] def column_change(self,data): return unicode(time.strftime('%x %X',time.localtime(data[10])), @@ -724,14 +726,21 @@ class RepositoryModel(BaseModel): def column_city(self,data): try: - return data[4].get_city() + if data[4]: + addr = RelLib.Address() + addr.unserialize(data[4][0]) + return addr.get_city() + else: + return u'' except: return u'' def column_street(self,data): try: if data[5]: - return data[5][0].get_street() + addr = RelLib.Address() + addr.unserialize(data[5][0]) + return addr.get_street() else: return u'' except: @@ -740,7 +749,9 @@ class RepositoryModel(BaseModel): def column_county(self,data): try: if data[5]: - return data[5][0].get_county() + addr = RelLib.Address() + addr.unserialize(data[5][0]) + return addr.get_county() else: return u'' except: @@ -749,7 +760,9 @@ class RepositoryModel(BaseModel): def column_state(self,data): try: if data[5]: - return data[5][0].get_state() + addr = RelLib.Address() + addr.unserialize(data[5][0]) + return addr.get_state() else: return u'' except: @@ -758,7 +771,9 @@ class RepositoryModel(BaseModel): def column_country(self,data): try: if data[5]: - return data[5][0].get_country() + addr = RelLib.Address() + addr.unserialize(data[5][0]) + return addr.get_country() else: return u'' except: @@ -767,7 +782,9 @@ class RepositoryModel(BaseModel): def column_postal_code(self,data): try: if data[5]: - return data[5][0].get_postal_code() + addr = RelLib.Address() + addr.unserialize(data[5][0]) + return addr.get_postal_code() else: return u'' except: @@ -776,24 +793,40 @@ class RepositoryModel(BaseModel): def column_phone(self,data): try: if data[5]: - return data[5][0].get_phone() + addr = RelLib.Address() + addr.unserialize(data[5][0]) + return addr.get_phone() else: return u'' except: return u'' def column_email(self,data): - return unicode(data[5]) + if data[6]: + for i in data[6]: + url = RelLib.Url() + url.unserialize(i) + if url.get_type() == RelLib.UrlType.EMAIL: + return unicode(url.path) + return u'' def column_search_url(self,data): - return unicode(data[6]) + if data[6]: + for i in data[6]: + url = RelLib.Url() + url.unserialize(i) + if url.get_type() == RelLib.UrlType.WEB_SEARCH: + return unicode(url.path) + return u'' def column_home_url(self,data): if data[6]: - urllist = data[6] - return unicode(urllist[0].path) - else: - return u"" + for i in data[6]: + url = RelLib.Url() + url.unserialize(i) + if url.get_type() == RelLib.UrlType.WEB_HOME: + return unicode(url.path) + return u"" def column_tooltip(self,data): return "" diff --git a/gramps2/src/PageView.py b/gramps2/src/PageView.py index b7af6c556..9b12326c0 100644 --- a/gramps2/src/PageView.py +++ b/gramps2/src/PageView.py @@ -568,6 +568,7 @@ class ListView(BookMarkView): order = gtk.SORT_ASCENDING else: order = gtk.SORT_DESCENDING + self.sort_col = data handle = self.first_selected() @@ -575,9 +576,10 @@ class ListView(BookMarkView): search = EMPTY_SEARCH else: search = self.search_bar.get_value() - + self.model = self.make_model(self.dbstate.db, self.sort_col, order, search=search) + self.list.set_model(self.model) colmap = self.column_order() @@ -586,9 +588,8 @@ class ListView(BookMarkView): self.selection.select_path(path) self.list.scroll_to_cell(path,None,1,0.5,0) for i in xrange(len(self.columns)): - self.columns[i].set_sort_indicator(i==colmap[data][1]) + self.columns[i].set_sort_indicator(i==self.sort_col) self.columns[self.sort_col].set_sort_order(order) -# print self.sort_col, order, colmap def build_columns(self): for column in self.columns: