* src/DisplayModels.py: use dirty flag to only draw when requested

* src/PageView.py: use dirty flag to only draw when requested
* src/PeopleView.py: use dirty flag to only draw when requested
* src/PeopleModel.py: provide simple caching
* src/ViewManager.py: control dirty flags


svn: r5803
This commit is contained in:
Don Allingham 2006-01-20 05:33:38 +00:00
parent 8c439b364e
commit c5fc889410
7 changed files with 92 additions and 26 deletions

View File

@ -1,3 +1,10 @@
2006-01-19 Don Allingham <don@gramps-project.org>
* src/DisplayModels.py: use dirty flag to only draw when requested
* src/PageView.py: use dirty flag to only draw when requested
* src/PeopleView.py: use dirty flag to only draw when requested
* src/PeopleModel.py: provide simple caching
* src/ViewManager.py: control dirty flags
2006-01-19 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/ObjectSelector/_PersonFilterFrame.py, src/ObjectSelector/_PersonFrame.py
src/ObjectSelector/_PersonTreeFrame.py: filters in Person view just about work.

View File

@ -71,6 +71,8 @@ class BaseModel(gtk.GenericTreeModel):
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING,tooltip_column=None):
gtk.GenericTreeModel.__init__(self)
self.prev_handle = None
self.prev_data = None
self.set_property("leak_references",False)
self.db = db
self.sort_func = self.smap[scol]
@ -161,7 +163,10 @@ class BaseModel(gtk.GenericTreeModel):
def on_get_value(self,node,col):
try:
return self.fmap[col](self.map(str(node)))
if node != self.prev_handle:
self.prev_data = self.map(str(node))
self.prev_handle = node
return self.fmap[col](self.prev_data)
except:
return u''

View File

@ -2652,7 +2652,7 @@ class FilterWidget:
def get_filter( self):
print "get_filter"
print self.DataFilter.flist[0]
#print self.DataFilter.flist[0]
return self.DataFilter
def inverted( self):

View File

@ -47,6 +47,20 @@ class PageView:
self.ui = '<ui></ui>'
self.dbstate.connect('no-database',self.disable_action_group)
self.dbstate.connect('database-changed',self.enable_action_group)
self.dirty = True
self.active = False
def set_active(self):
self.active = True
if self.dirty:
print self,"set active dirty"
self.build_tree()
def set_inactive(self):
self.active = False
def build_tree(self):
pass
def navigation_type(self):
return NAVIGATION_NONE
@ -405,13 +419,17 @@ class ListView(PageView):
index += 1
def build_tree(self):
self.model = self.make_model(self.dbstate.db,self.sort_col)
self.list.set_model(self.model)
self.selection = self.list.get_selection()
if self.active:
self.model = self.make_model(self.dbstate.db,self.sort_col)
self.list.set_model(self.model)
self.selection = self.list.get_selection()
if self.model.tooltip_column != None:
self.tooltips = TreeTips.TreeTips(self.list,
self.model.tooltip_column,True)
if self.model.tooltip_column != None:
self.tooltips = TreeTips.TreeTips(self.list,
self.model.tooltip_column,True)
self.dirty = False
else:
self.dirty = True
def change_db(self,db):
for sig in self.signal_map:
@ -419,19 +437,35 @@ class ListView(PageView):
self.model = self.make_model(self.dbstate.db,0)
self.list.set_model(self.model)
self.build_columns()
self.build_tree()
if self.active:
self.build_tree()
else:
print self,"change_db dirty"
self.dirty = True
def row_add(self,handle_list):
for handle in handle_list:
self.model.add_row_by_handle(handle)
if self.active:
for handle in handle_list:
self.model.add_row_by_handle(handle)
else:
print self,"row add dirty"
self.dirty = True
def row_update(self,handle_list):
for handle in handle_list:
self.model.update_row_by_handle(handle)
if self.active:
for handle in handle_list:
self.model.update_row_by_handle(handle)
else:
print self,"row update dirty"
self.dirty = True
def row_delete(self,handle_list):
for handle in handle_list:
self.model.delete_row_by_handle(handle)
if self.active:
for handle in handle_list:
self.model.delete_row_by_handle(handle)
else:
print self,"row delete dirty"
self.dirty = True
def define_actions(self):
"""

View File

@ -112,6 +112,8 @@ class PeopleModel(gtk.GenericTreeModel):
self.sortnames = {}
self.marker_color_column = 11
self.tooltip_column = 12
self.prev_handle = None
self.prev_data = None
self.rebuild_data(data_filter)
def rebuild_data(self,data_filter=None,skip=None):
@ -236,7 +238,10 @@ class PeopleModel(gtk.GenericTreeModel):
# return values for 'data' row, calling a function
# according to column_defs table
try:
return COLUMN_DEFS[col][COLUMN_DEF_LIST](self,self.db.get_raw_person_data(str(node)),node)
if node != self.prev_handle:
self.prev_data = self.db.get_raw_person_data(str(node))
self.prev_handle = node
return COLUMN_DEFS[col][COLUMN_DEF_LIST](self,self.prev_data,node)
except:
print "".join(traceback.format_exception(*sys.exc_info()))
return u'error'

View File

@ -231,6 +231,12 @@ class PersonView(PageView.PersonNavView):
self.generic_filter_widget.apply_filter()
def goto_active_person(self,obj=None):
import time
t = time.time()
self.goto_active_person_2(None)
print time.time() - t
def goto_active_person_2(self,obj=None):
"""
Callback (and usable function) that selects the active person
in the display tree.
@ -319,14 +325,17 @@ class PersonView(PageView.PersonNavView):
Creates a new PeopleModel instance. Essentially creates a complete
rebuild of the data.
"""
self.model = PeopleModel.PeopleModel(
self.dbstate.db, self.generic_filter_widget.get_filter(), self.generic_filter_widget.inverted())
self.tree.set_model(self.model)
if self.model.tooltip_column != None:
self.tooltips = TreeTips.TreeTips(self.tree,self.model.tooltip_column,True)
self.build_columns()
if self.active:
self.model = PeopleModel.PeopleModel(
self.dbstate.db, self.generic_filter_widget.get_filter(), self.generic_filter_widget.inverted())
self.tree.set_model(self.model)
if self.model.tooltip_column != None:
self.tooltips = TreeTips.TreeTips(self.tree,self.model.tooltip_column,True)
self.build_columns()
self.dirty = False
else:
self.dirty = True
def filter_toggle(self,obj):
if obj.get_active():

View File

@ -466,21 +466,27 @@ class ViewManager:
index += 1
self.bbox.pack_start(button,False)
self.active_page = self.pages[0]
self.active_page.set_active()
def change_page(self,obj,page,num=-1):
if num == -1:
num = self.notebook.get_current_page()
if self.state.open == True:
for mergeid in self.merge_ids:
self.uimanager.remove_ui(mergeid)
if self.active_page:
self.active_page.set_inactive()
groups = self.active_page.get_actions()
for grp in groups:
self.uimanager.remove_action_group(grp)
if len(self.pages) > 0:
self.active_page = self.pages[num]
self.active_page.set_active()
old_nav = self.navigation_type[self.prev_nav]
if old_nav[0] != None: