2007-04-01 Don Allingham <don@gramps-project.org>

* src/DataViews/_PedigreeView.py: display matches in statusbar
	* src/DataViews/_PersonView.py: display matches in statusbar
	* src/DataViews/_RelationView.py: display matches in statusbar
	* src/DisplayState.py: display matches in statusbar
	* src/DisplayModels/_BaseModel.py: display matches in statusbar
	* src/DisplayModels/_PeopleModel.py: display matches in statusbar
	* src/GrampsDbUtils/_GedcomParse.py: display matches in statusbar
	* src/PageView.py: display matches in statusbar
	* src/Filters/_SearchBar.py: display matches in statusbar
	* src/DbManager.py: fix default file name



svn: r8346
This commit is contained in:
Don Allingham 2007-04-01 22:37:10 +00:00
parent a5732076d6
commit 30ce0c5291
13 changed files with 119 additions and 34 deletions

View File

@ -1,3 +1,15 @@
2007-04-01 Don Allingham <don@gramps-project.org>
* src/DataViews/_PedigreeView.py: display matches in statusbar
* src/DataViews/_PersonView.py: display matches in statusbar
* src/DataViews/_RelationView.py: display matches in statusbar
* src/DisplayState.py: display matches in statusbar
* src/DisplayModels/_BaseModel.py: display matches in statusbar
* src/DisplayModels/_PeopleModel.py: display matches in statusbar
* src/GrampsDbUtils/_GedcomParse.py: display matches in statusbar
* src/PageView.py: display matches in statusbar
* src/Filters/_SearchBar.py: display matches in statusbar
* src/DbManager.py: fix default file name
2007-04-01 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/GrampsWidgets.py (Statusbar._set_packing): Reverse packing style.

View File

@ -468,6 +468,9 @@ class PedigreeView(PageView.PersonNavView):
self.show_marriage_data = 0 # Hide marriage data by default
self.format_helper = FormattingHelper( self.dbstate)
def change_page(self):
self.uistate.clear_filter_results()
def init_parent_signals_cb(self, widget, event):
# required to properly bootstrap the signal handlers.
# This handler is connected by build_widget. After the outside ViewManager

View File

@ -111,6 +111,9 @@ class PersonView(PageView.PersonNavView):
PageView.PersonNavView.change_page(self)
self.edit_action.set_visible(True)
self.edit_action.set_sensitive(not self.dbstate.db.readonly)
self.uistate.show_filter_results(self.dbstate,
self.model.displayed,
self.model.total)
def set_active(self):
PageView.PersonNavView.set_active(self)
@ -535,6 +538,9 @@ class PersonView(PageView.PersonNavView):
self.dbstate.change_active_person(active)
self._goto()
self.dirty = False
self.uistate.show_filter_results(self.dbstate,
self.model.displayed,
self.model.total)
else:
self.dirty = True

View File

@ -204,6 +204,9 @@ class RelationshipView(PageView.PersonNavView):
pass
else:
self.change_person(None)
def change_page(self):
self.uistate.clear_filter_results()
def get_stock(self):
"""

View File

@ -59,7 +59,12 @@ import gtk.glade
import QuestionDialog
DEFAULT_DIR = os.path.expanduser("~/grampsdb")
#-------------------------------------------------------------------------
#
# constants
#
#-------------------------------------------------------------------------
DEFAULT_DIR = os.path.expanduser("~/.gramps/grampsdb")
DEFAULT_TITLE = _("Family Tree")
NAME_FILE = "name.txt"
META_NAME = "meta_data.db"
@ -71,9 +76,16 @@ DATE_COL = 3
OPEN_COL = 5
class DbManager:
"""
Database Manager. Opens a database manager window that allows users to
create, rename, delete and open databases.
"""
def __init__(self, dbstate, parent=None):
"""
Creates the top level window from the glade description, and extracts
the GTK widgets that are needed.
"""
self.glade = gtk.glade.XML(const.gladeFile, "dbmanager", "gramps")
self.top = self.glade.get_widget('dbmanager')
if parent:
@ -100,6 +112,9 @@ class DbManager:
self.populate()
def connect_signals(self):
"""
Connects the signals to the buttons on the interface.
"""
self.remove.connect('clicked', self.remove_db)
self.new.connect('clicked', self.new_db)
self.rename.connect('clicked', self.rename_db)
@ -249,10 +264,12 @@ class DbManager:
os.mkdir(new_path)
path_name = os.path.join(new_path, NAME_FILE)
name_list = [ name[0] for name in self.current_names ]
i = 1
while True:
title = "%s %d" % (DEFAULT_TITLE, i)
if title not in self.current_names:
if title not in name_list:
break
i += 1
@ -266,7 +283,3 @@ class DbManager:
path = self.model.get_path(node)
self.dblist.set_cursor(path, focus_column=self.column, start_editing=True)
if __name__ == "__main__":
a = DbManager()
a.run()

View File

@ -153,6 +153,9 @@ class BaseModel(gtk.GenericTreeModel):
self.sort_col = scol
self.skip = skip
self.total = 0
self.displayed = 0
self.node_map = NodeMap()
if search:
@ -205,9 +208,11 @@ class BaseModel(gtk.GenericTreeModel):
self.sort_data = []
data = cursor.next()
self.total = 0
while data:
key = locale.strxfrm(self.sort_func(data[1]))
self.sort_data.append((key,data[0]))
self.total += 1
data = cursor.next()
cursor.close()
@ -216,6 +221,7 @@ class BaseModel(gtk.GenericTreeModel):
return [ x[1] for x in self.sort_data ]
def _rebuild_search(self,ignore=None):
self.total = 0
if self.db.is_open():
if self.search and self.search.text:
dlist = [h for h in self.sort_keys()\
@ -224,11 +230,14 @@ class BaseModel(gtk.GenericTreeModel):
else:
dlist = [h for h in self.sort_keys() \
if h not in self.skip and h != ignore]
self.displayed = len(dlist)
self.node_map.set_path_map(dlist)
else:
self.displayed = 0
self.node_map.clear_map()
def _rebuild_filter(self, ignore=None):
self.total = 0
if self.db.is_open():
if self.search:
dlist = self.search.apply(self.db,
@ -238,8 +247,10 @@ class BaseModel(gtk.GenericTreeModel):
dlist = [ k for k in self.sort_keys() \
if k != ignore ]
self.displayed = len(dlist)
self.node_map.set_path_map(dlist)
else:
self.displayed = 0
self.node_map.clear_map()
def add_row_by_handle(self,handle):

View File

@ -273,6 +273,9 @@ class PeopleModel(gtk.GenericTreeModel):
self.mapper = NodeTreeMap()
self.total = 0
self.displayed = 0
if filter_info and filter_info != (1, (0, u'', False)):
if filter_info[0] == PeopleModel.GENERIC:
data_filter = filter_info[1]
@ -325,15 +328,19 @@ class PeopleModel(gtk.GenericTreeModel):
cursor = self.db.get_person_cursor()
node = cursor.first()
self.total = 0
self.displayed = 0
while node:
#for node in self.db.get_person_cursor_iter():
self.total += 1
handle, d = node
if not (handle in skip or (dfilter and not dfilter.match(handle))):
name_data = d[PeopleModel._NAME_COL]
group_name = ngn(self.db, name_data)
sorted_name = nsn(name_data)
self.displayed += 1
self.mapper.assign_sort_name(handle, sorted_name, group_name)
node = cursor.next()
cursor.close()
@ -343,11 +350,17 @@ class PeopleModel(gtk.GenericTreeModel):
ngn = NameDisplay.displayer.name_grouping_data
nsn = NameDisplay.displayer.raw_sorted_name
plist = self.db.get_person_handles()
self.total = len(plist)
if dfilter:
handle_list = dfilter.apply(self.db, self.db.get_person_handles())
else:
handle_list = self.db.get_person_handles()
self.displayed = len(handle_list)
self.mapper.clear_sort_names()
status = LongOpStatus(msg="Loading People",
@ -378,6 +391,9 @@ class PeopleModel(gtk.GenericTreeModel):
self.lru_bdate = LRU(_CACHE_SIZE)
self.lru_ddate = LRU(_CACHE_SIZE)
self.total = 0
self.displayed = 0
if dfilter:
self.dfilter = dfilter

View File

@ -275,6 +275,7 @@ class DisplayState(GrampsDb.GrampsDBCallback):
self.gwm = ManagedWindow.GrampsWindowManager(uimanager)
self.widget = None
self.warnbtn = warnbtn
self.last_bar = self.status.insert(min_width=150)
formatter = logging.Formatter('%(levelname)s %(name)s: %(message)s')
self.rh = WarnHandler(capacity=400,button=warnbtn)
@ -337,6 +338,15 @@ class DisplayState(GrampsDb.GrampsDBCallback):
self.status_text(text)
gobject.timeout_add(5000,self.modify_statusbar,dbstate)
def show_filter_results(self, dbstate, matched, total):
text = _("%d/%d matched") % (matched, total)
self.status.pop(1, self.last_bar)
self.status.push(1, text, self.last_bar)
def clear_filter_results(self):
self.status.pop(1, self.last_bar)
self.status.push(1, '', self.last_bar)
def modify_statusbar(self,dbstate,active=None):
self.status.pop(self.status_id)
if dbstate.active == None:

View File

@ -136,7 +136,7 @@ class SearchBar:
inv = self.filter_model.get_value(node,2)
return (index, text, inv)
def apply_filter(self,current_model=None):
def apply_filter(self, current_model=None):
self.apply_text = unicode(self.filter_text.get_text())
self.filter_button.set_sensitive(False)
self.uistate.status_text(_('Updating display...'))

View File

@ -115,6 +115,7 @@ from BasicUtils import NameDisplay, UpdateCallback
import Utils
import Mime
import LdsUtils
import Utils
from _GedcomInfo import *
from _GedcomTokens import *
@ -2562,7 +2563,7 @@ class GedcomParser(UpdateCallback):
self.__parse_level(sub_state, self.event_parse_tbl, self.__undefined)
family_event_name(event, state.family)
family_event_name(event, state.family, self.dbase)
self.dbase.commit_event(event, self.trans)
event_ref.ref = event.handle
state.family.add_event_ref(event_ref)
@ -2606,7 +2607,7 @@ class GedcomParser(UpdateCallback):
else:
state.family.type.set(RelLib.FamilyRelType.MARRIED)
family_event_name(event, state.family)
family_event_name(event, state.family, self.dbase)
self.dbase.commit_event(event, self.trans)
event_ref.ref = event.handle
@ -4406,8 +4407,11 @@ class GedcomParser(UpdateCallback):
event_ref = RelLib.EventRef()
event.set_gramps_id(self.emapper.find_next())
event.set_type(event_type)
if description and description != 'Y':
event.set_description(description)
else:
person_event_name(event, state.person)
self.dbase.add_event(event, self.trans)
sub_state = GedcomUtils.CurrentState()
@ -4430,6 +4434,9 @@ class GedcomParser(UpdateCallback):
event.set_type(event_type)
if description and description != 'Y':
event.set_description(description)
else:
family_event_name(event, state.family, self.dbase)
self.dbase.add_event(event, self.trans)
sub_state = GedcomUtils.CurrentState()
@ -4440,7 +4447,7 @@ class GedcomParser(UpdateCallback):
self.__parse_level(sub_state, event_map, self.__undefined)
family_event_name(event, state.family)
family_event_name(event, state.family, self.dbase)
self.dbase.commit_event(event, self.trans)
event_ref.set_reference_handle(event.handle)
@ -4482,22 +4489,20 @@ class GedcomParser(UpdateCallback):
#
#-------------------------------------------------------------------------
def person_event_name(event, person):
if event.get_type().is_custom():
if not event.get_description():
text = EVENT_PERSON_STR % {
'event_name' : str(event.get_type()),
'person' : NameDisplay.displayer.display(person),
}
event.set_description(text)
if not event.get_description():
text = EVENT_PERSON_STR % {
'event_name' : str(event.get_type()),
'person' : NameDisplay.displayer.display(person),
}
event.set_description(text)
def family_event_name(event, family):
if event.get_type().is_custom():
if not event.get_description():
text = EVENT_FAMILY_STR % {
'event_name' : str(event.get_type()),
'family' : "<TBD>",
}
event.set_description(text)
def family_event_name(event, family, dbase):
if not event.get_description():
text = EVENT_FAMILY_STR % {
'event_name' : str(event.get_type()),
'family' : Utils.family_name(family, dbase),
}
event.set_description(text)
def encode_filename(name):
enc = sys.getfilesystemencoding()

View File

@ -161,7 +161,7 @@ class PageView:
self.additional_action_groups.append(group)
def change_page(self):
pass
self.uistate.clear_filter_results()
def edit(self,obj):
pass
@ -564,7 +564,8 @@ class ListView(BookMarkView):
self.vbox.set_border_width(4)
self.vbox.set_spacing(4)
self.search_bar = SearchBar(self.dbstate,self.uistate, self.build_tree)
self.search_bar = SearchBar(self.dbstate,self.uistate,
self.search_build_tree)
filter_box = self.search_bar.build()
self.list = gtk.TreeView()
@ -604,6 +605,9 @@ class ListView(BookMarkView):
else:
return self.vbox
def search_build_tree(self):
self.build_tree()
def row_changed(self,obj):
"""Called with a row is changed. Check the selected objects from
the person_tree to get the IDs of the selected objects. Set the
@ -733,6 +737,9 @@ class ListView(BookMarkView):
self.dirty = False
else:
self.dirty = True
self.uistate.show_filter_results(self.dbstate,
self.model.displayed,
self.model.total)
def filter_toggle_action(self,obj):
if obj.get_active():

View File

@ -151,8 +151,9 @@ def wasHistory_broken():
#
#-------------------------------------------------------------------------
def family_name(family,db,noname=_("unknown")):
def family_name(family, db, noname=_("unknown")):
"""Builds a name for the family from the parents names"""
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
father = db.get_person_from_handle(father_handle)
@ -171,7 +172,7 @@ def family_name(family,db,noname=_("unknown")):
name = noname
return name
def family_upper_name(family,db):
def family_upper_name(family, db):
"""Builds a name for the family from the parents names"""
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
@ -187,7 +188,6 @@ def family_upper_name(family,db):
name = mother.get_primary_name().get_upper_name()
return name
#-------------------------------------------------------------------------
#
#

View File

@ -1070,7 +1070,6 @@ class ViewManager:
self.state.db.enable_signals()
self.state.signal_change()
print filename
Config.set(Config.RECENT_FILE, filename)
self.relationship = self.RelClass(self.state.db)