2006-05-26 Don Allingham <don@gramps-project.org>

* src/DataViews/_RelationView.py: build skip list for SelectFamily so that
	* a person cannot be his own parent
	* src/Editors/_EditFamily.py: don't allow a person to be his own parent
	* src/Selectors/_BaseSelector.py: Add skipping of handles
	* src/DisplayModels/_BaseModel.py: Add skipping of handles
	* src/DisplayModels/_MediaModel.py: Add skipping of handles
	* src/DisplayModels/_RepositoryModel.py: Add skipping of handles
	* src/DisplayModels/_SourceModel.py: Add skipping of handles
	* src/DisplayModels/_EventModel.py: Add skipping of handles
	* src/DisplayModels/_FamilyModel.py: Add skipping of handles
	* src/DisplayModels/_PlaceModel.py: Add skipping of handles



svn: r6790
This commit is contained in:
Don Allingham 2006-05-26 20:48:40 +00:00
parent a32ed5e6bb
commit 8ec6242dd7
11 changed files with 112 additions and 22 deletions

View File

@ -1,3 +1,16 @@
2006-05-26 Don Allingham <don@gramps-project.org>
* src/DataViews/_RelationView.py: build skip list for SelectFamily so that
* a person cannot be his own parent
* src/Editors/_EditFamily.py: don't allow a person to be his own parent
* src/Selectors/_BaseSelector.py: Add skipping of handles
* src/DisplayModels/_BaseModel.py: Add skipping of handles
* src/DisplayModels/_MediaModel.py: Add skipping of handles
* src/DisplayModels/_RepositoryModel.py: Add skipping of handles
* src/DisplayModels/_SourceModel.py: Add skipping of handles
* src/DisplayModels/_EventModel.py: Add skipping of handles
* src/DisplayModels/_FamilyModel.py: Add skipping of handles
* src/DisplayModels/_PlaceModel.py: Add skipping of handles
2006-05-25 Don Allingham <don@gramps-project.org>
* src/DisplayTabs/_NoteTab.py (NoteTab.flow_changed): save flow status
in Note

View File

@ -801,7 +801,11 @@ class RelationshipView(PageView.PersonNavView):
from Selectors import selector_factory
SelectFamily = selector_factory('Family')
dialog = SelectFamily(self.dbstate, self.uistate)
phandle = self.dbstate.get_active_person().handle
person = self.dbstate.db.get_person_from_handle(phandle)
skip = set(person.get_family_handle_list())
dialog = SelectFamily(self.dbstate, self.uistate, skip=skip)
family = dialog.run()
if family:

View File

@ -25,7 +25,11 @@
#
#-------------------------------------------------------------------------
import locale
try:
set()
except:
from sets import Set as set
#-------------------------------------------------------------------------
#
# GNOME/GTK modules
@ -48,7 +52,7 @@ from Filters import SearchFilter
class BaseModel(gtk.GenericTreeModel):
def __init__(self, db, scol=0, order=gtk.SORT_ASCENDING,
tooltip_column=None, search=None):
tooltip_column=None, search=None, skip=set()):
gtk.GenericTreeModel.__init__(self)
self.prev_handle = None
self.prev_data = None
@ -56,7 +60,8 @@ class BaseModel(gtk.GenericTreeModel):
self.db = db
self.sort_func = self.smap[scol]
self.sort_col = scol
self.skip = skip
if search:
col = search[0]
text = search[1]
@ -95,14 +100,15 @@ class BaseModel(gtk.GenericTreeModel):
if self.db.is_open():
if self.search:
self.datalist = [h for h in self.sort_keys()\
if self.search.match(h)]
if self.search.match(h) and h not in self.skip]
else:
self.datalist = self.sort_keys()
self.datalist = [h for h in self.sort_keys() if h not in self.skip]
i = 0
self.indexlist = {}
for key in self.datalist:
self.indexlist[key] = i
i += 1
if key not in self.skip:
self.indexlist[key] = i
i += 1
else:
self.datalist = []
self.indexlist = {}

View File

@ -27,6 +27,10 @@
import time
import logging
log = logging.getLogger(".")
try:
set()
except:
from sets import Set as set
#-------------------------------------------------------------------------
#
@ -54,7 +58,8 @@ from _BaseModel import BaseModel
#-------------------------------------------------------------------------
class EventModel(BaseModel):
def __init__(self, db, scol=0, order=gtk.SORT_ASCENDING, search=None):
def __init__(self, db, scol=0, order=gtk.SORT_ASCENDING, search=None,
skip=set()):
self.gen_cursor = db.get_event_cursor
self.map = db.get_raw_event_data
@ -81,7 +86,7 @@ class EventModel(BaseModel):
self.column_tooltip,
]
BaseModel.__init__(self, db, scol, order, tooltip_column=8,
search=search)
search=search, skip=skip)
def on_get_n_columns(self):
return len(self.fmap)+1

View File

@ -28,6 +28,11 @@ import time
import logging
log = logging.getLogger(".")
try:
set()
except:
from sets import Set as set
#-------------------------------------------------------------------------
#
# GNOME/GTK modules
@ -55,7 +60,8 @@ from _BaseModel import BaseModel
#-------------------------------------------------------------------------
class FamilyModel(BaseModel):
def __init__(self, db, scol=0, order=gtk.SORT_ASCENDING, search=None):
def __init__(self, db, scol=0, order=gtk.SORT_ASCENDING, search=None,
skip=set()):
self.gen_cursor = db.get_family_cursor
self.map = db.get_raw_family_data
self.fmap = [
@ -77,7 +83,7 @@ class FamilyModel(BaseModel):
self.column_tooltip
]
BaseModel.__init__(self, db, scol, order, tooltip_column=6,
search=search)
search=search, skip=skip)
def on_get_n_columns(self):
return len(self.fmap)+1

View File

@ -29,6 +29,11 @@ from gettext import gettext as _
import logging
log = logging.getLogger(".")
try:
set()
except:
from sets import Set as set
#-------------------------------------------------------------------------
#
# GNOME/GTK modules
@ -55,7 +60,8 @@ from _BaseModel import BaseModel
#-------------------------------------------------------------------------
class MediaModel(BaseModel):
def __init__(self, db, scol=0, order=gtk.SORT_ASCENDING, search=None):
def __init__(self, db, scol=0, order=gtk.SORT_ASCENDING, search=None,
skip=set()):
self.gen_cursor = db.get_media_cursor
self.map = db.get_raw_object_data
@ -79,7 +85,7 @@ class MediaModel(BaseModel):
self.column_handle,
]
BaseModel.__init__(self, db, scol, order, tooltip_column=7,
search=search)
search=search, skip=skip)
def on_get_n_columns(self):
return len(self.fmap)+1

View File

@ -28,6 +28,11 @@ import time
import logging
log = logging.getLogger(".")
try:
set()
except:
from sets import Set as set
#-------------------------------------------------------------------------
#
# GNOME/GTK modules
@ -52,7 +57,8 @@ from _BaseModel import BaseModel
#-------------------------------------------------------------------------
class PlaceModel(BaseModel):
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING,search=None):
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING,search=None,
skip=set()):
self.gen_cursor = db.get_place_cursor
self.map = db.get_raw_place_data
self.fmap = [
@ -85,7 +91,7 @@ class PlaceModel(BaseModel):
self.column_handle,
]
BaseModel.__init__(self, db, scol, order, tooltip_column=12,
search=search)
search=search, skip=skip)
def on_get_n_columns(self):
return len(self.fmap)+1

View File

@ -28,6 +28,11 @@ import time
import logging
log = logging.getLogger(".")
try:
set()
except:
from sets import Set as set
#-------------------------------------------------------------------------
#
# GNOME/GTK modules
@ -53,7 +58,8 @@ from _BaseModel import BaseModel
#-------------------------------------------------------------------------
class RepositoryModel(BaseModel):
def __init__(self, db, scol=0, order=gtk.SORT_ASCENDING, search=None):
def __init__(self, db, scol=0, order=gtk.SORT_ASCENDING, search=None,
skip=set()):
self.gen_cursor = db.get_repository_cursor
self.get_handles = db.get_repository_handles
self.map = db.get_raw_repository_data
@ -91,7 +97,7 @@ class RepositoryModel(BaseModel):
]
BaseModel.__init__(self, db, scol, order, tooltip_column=12,
search=search)
search=search, skip=skip)
def on_get_n_columns(self):
return len(self.fmap)+1

View File

@ -28,6 +28,11 @@ import time
import logging
log = logging.getLogger(".")
try:
set()
except:
from sets import Set as set
#-------------------------------------------------------------------------
#
# GNOME/GTK modules
@ -52,7 +57,8 @@ from _BaseModel import BaseModel
#-------------------------------------------------------------------------
class SourceModel(BaseModel):
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING,search=None):
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING,search=None,
skip=set()):
self.map = db.get_raw_source_data
self.gen_cursor = db.get_source_cursor
self.fmap = [
@ -73,7 +79,8 @@ class SourceModel(BaseModel):
self.column_pubinfo,
self.sort_change,
]
BaseModel.__init__(self,db,scol,order,tooltip_column=7,search=search)
BaseModel.__init__(self,db,scol,order,tooltip_column=7,search=search,
skip=skip)
def on_get_n_columns(self):
return len(self.fmap)+1

View File

@ -734,6 +734,32 @@ class EditFamily(EditPrimary):
else:
original = None
# do some basic checks
child_list = [ ref.ref for ref in self.obj.get_child_ref_list() ]
if self.obj.get_father_handle() in child_list:
from QuestionDialog import ErrorDialog
father = db.get_person_from_handle(self.obj.get_father_handle())
name = "%s [%s]" % (NameDisplay.displayer.display(father),
father.gramps_id)
ErrorDialog(_("A father cannot be his own child"),
_("%s is listed as both the father and child of "
"of the family.") % name)
return
elif self.obj.get_mother_handle() in child_list:
from QuestionDialog import ErrorDialog
mother = db.get_person_from_handle(self.obj.get_mother_handle())
name = "%s [%s]" % (NameDisplay.displayer.display(mother),
mother.gramps_id)
ErrorDialog(_("A mother cannot be her own child"),
_("%s is listed as both the mother and child of "
"of the family.") % name)
return
if not original and not self.object_is_empty():
trans = self.db.transaction_begin()

View File

@ -20,6 +20,11 @@
# $Id$
try:
set()
except:
from sets import Set as set
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
@ -48,7 +53,7 @@ class BaseSelector(ManagedWindow.ManagedWindow):
MARKUP = 1
IMAGE = 2
def __init__(self, dbstate, uistate, track=[], filter=None, skip=[]):
def __init__(self, dbstate, uistate, track=[], filter=None, skip=set()):
self.title = self.get_window_title()
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
@ -64,7 +69,7 @@ class BaseSelector(ManagedWindow.ManagedWindow):
self.set_window(window,title_label,self.title)
self.model = self.get_model_class()(self.db)
self.model = self.get_model_class()(self.db,skip=skip)
self.selection = self.tree.get_selection()
self.tree.set_model(self.model)