* src/RelLib.py: add sorting by source title, remove dependency on string

module
* src/PlaceView.py: do an initial sort, don't rely on "click" function
* src/SourceView.py: do an initial sort, don't rely on "click" function


svn: r2565
This commit is contained in:
Don Allingham 2003-12-29 18:37:44 +00:00
parent 79b7134b55
commit a75928f974
3 changed files with 19 additions and 17 deletions

View File

@ -85,7 +85,6 @@ class PlaceView:
column.set_min_width(title[2]) column.set_min_width(title[2])
self.list.append_column(column) self.list.append_column(column)
self.list.set_search_column(0)
self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
@ -94,7 +93,6 @@ class PlaceView:
gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_STRING) gobject.TYPE_STRING)
self.list.set_model(self.model) self.list.set_model(self.model)
self.list.get_column(0).clicked()
self.selection = self.list.get_selection() self.selection = self.list.get_selection()
self.list.connect('button-press-event',self.button_press) self.list.connect('button-press-event',self.button_press)
self.topWindow = self.glade.get_widget("gramps") self.topWindow = self.glade.get_widget("gramps")
@ -117,7 +115,7 @@ class PlaceView:
gobject.TYPE_STRING) gobject.TYPE_STRING)
self.id2col = {} self.id2col = {}
for key in self.db.getPlaceKeys(): for key in self.db.sortPlaceKeys():
val = self.db.getPlaceDisplay(key) val = self.db.getPlaceDisplay(key)
iter = self.model.append() iter = self.model.append()
@ -129,7 +127,6 @@ class PlaceView:
12, val[12] 12, val[12]
) )
self.list.set_model(self.model) self.list.set_model(self.model)
self.list.get_column(0).clicked()
def goto(self,id): def goto(self,id):
self.selection.unselect_all() self.selection.unselect_all()

View File

@ -31,7 +31,6 @@ __version__ = "$Revision$"
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from re import compile from re import compile
from string import strip, upper
import os import os
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -446,21 +445,21 @@ class Researcher:
def set(self,name,addr,city,state,country,postal,phone,email): def set(self,name,addr,city,state,country,postal,phone,email):
"""sets the information about the database owner""" """sets the information about the database owner"""
if name: if name:
self.name = strip(name) self.name = name.strip()
if addr: if addr:
self.addr = strip(addr) self.addr = addr.strip()
if city: if city:
self.city = strip(city) self.city = city.strip()
if state: if state:
self.state = strip(state) self.state = state.strip()
if country: if country:
self.country = strip(country) self.country = country.strip()
if postal: if postal:
self.postal = strip(postal) self.postal = postal.strip()
if phone: if phone:
self.phone = strip(phone) self.phone = phone.strip()
if email: if email:
self.email = strip(email) self.email = email.strip()
class Location: class Location:
"""Provides information about a place, including city, county, state, """Provides information about a place, including city, county, state,
@ -1897,8 +1896,7 @@ class Source:
self.abbrev = "" self.abbrev = ""
def getDisplayInfo(self): def getDisplayInfo(self):
return [self.title,self.id,self.author,upper(self.title), return [self.title,self.id,self.author,self.title.upper(),self.author.upper()]
upper(self.author)]
def setId(self,newId): def setId(self,newId):
"""sets the gramps' ID for the Source instance""" """sets the gramps' ID for the Source instance"""
@ -2738,6 +2736,15 @@ class GrampsDB:
def getSourceKeys(self): def getSourceKeys(self):
return self.sourceTable.keys() return self.sourceTable.keys()
def sortbysource(self,f,s):
return cmp(self.sourceTable[f][3],self.placTable[s][3])
def sortSourceKeys(self):
keys = self.sourceTable.keys()
if type(keys) == type([]):
keys.sort(self.sortbyplace)
return keys
def getSourceDisplay(self,key): def getSourceDisplay(self,key):
return self.sourceTable[key] return self.sourceTable[key]

View File

@ -89,7 +89,6 @@ class SourceView:
gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_STRING) gobject.TYPE_STRING)
self.list.set_model(self.model) self.list.set_model(self.model)
self.list.get_column(0).clicked()
self.topWindow = self.glade.get_widget("gramps") self.topWindow = self.glade.get_widget("gramps")
def change_db(self,db): def change_db(self,db):
@ -117,7 +116,6 @@ class SourceView:
3, val[3], 4, val[4]) 3, val[3], 4, val[4])
self.list.connect('button-press-event',self.button_press) self.list.connect('button-press-event',self.button_press)
self.list.set_model(self.model) self.list.set_model(self.model)
self.list.get_column(0).clicked()
def button_press(self,obj,event): def button_press(self,obj,event):
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: