* src/GenericFilter.py (HasTextMatchingSubstringOf, HasTextMatchingRegexpOf): Search media objects in full text search.
* src/RelLib.py: Add GRAMPS ID to get_text_data_list so this field is usable in full text search; Dont crash if get_text_data_list contains None values instead of empty strings. * src/EditPerson.py: Dont crash with "note only" media object. svn: r4593
This commit is contained in:
parent
9a1dece0db
commit
8e7e8155f7
@ -3,6 +3,13 @@
|
||||
not the filterMatch; (HasEvent,HasFamilyEvent): Dont crash in filter
|
||||
editor.
|
||||
|
||||
* src/GenericFilter.py (HasTextMatchingSubstringOf, HasTextMatchingRegexpOf):
|
||||
Search media objects in full text search.
|
||||
* src/RelLib.py: Add GRAMPS ID to get_text_data_list so this field is
|
||||
usable in full text search; Dont crash if get_text_data_list contains
|
||||
None values instead of empty strings.
|
||||
* src/EditPerson.py: Dont crash with "note only" media object.
|
||||
|
||||
2005-05-13 Don Allingham <don@gramps-project.org>
|
||||
* src/plugins/ScratchPad.py: fix GdkAtom index problem with pygtk2.4
|
||||
|
||||
|
@ -1971,7 +1971,8 @@ class EditPerson:
|
||||
object_handle = ph.get_reference_handle()
|
||||
obj = self.db.get_object_from_handle(object_handle)
|
||||
if self.load_obj != obj.get_path():
|
||||
if obj.get_mime_type()[0:5] == "image":
|
||||
mime_type = obj.get_mime_type()
|
||||
if mime_type and mime_type.startswith("image"):
|
||||
self.load_photo(obj.get_path())
|
||||
else:
|
||||
self.load_photo(None)
|
||||
|
@ -1894,6 +1894,7 @@ class HasTextMatchingSubstringOf(Rule):
|
||||
self.source_map = {}
|
||||
self.family_map = {}
|
||||
self.place_map = {}
|
||||
self.media_map = {}
|
||||
try:
|
||||
if int(self.list[1]):
|
||||
self.case_sensitive = True
|
||||
@ -1916,6 +1917,7 @@ class HasTextMatchingSubstringOf(Rule):
|
||||
self.source_map = {}
|
||||
self.family_map = {}
|
||||
self.place_map = {}
|
||||
self.media_map = {}
|
||||
|
||||
def name(self):
|
||||
return 'Has text matching substring of'
|
||||
@ -1938,6 +1940,9 @@ class HasTextMatchingSubstringOf(Rule):
|
||||
for family_handle in p.get_family_handle_list(): # match families
|
||||
if self.search_family(family_handle):
|
||||
return 1
|
||||
for media_ref in p.get_media_list(): # match Media object
|
||||
if self.search_media(media_ref.get_reference_handle()):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def search_family(self,family_handle):
|
||||
@ -1954,6 +1959,9 @@ class HasTextMatchingSubstringOf(Rule):
|
||||
if self.search_event(event_handle):
|
||||
match = 1
|
||||
break
|
||||
for media_ref in family.get_media_list(): # match Media object
|
||||
if self.search_media(media_ref.get_reference_handle()):
|
||||
return 1
|
||||
self.family_map[family_handle] = match
|
||||
return self.family_map[family_handle]
|
||||
|
||||
@ -1971,6 +1979,9 @@ class HasTextMatchingSubstringOf(Rule):
|
||||
if place_handle:
|
||||
if self.search_place(place_handle):
|
||||
match = 1
|
||||
for media_ref in event.get_media_list(): # match Media object
|
||||
if self.search_media(media_ref.get_reference_handle()):
|
||||
return 1
|
||||
self.event_map[event_handle] = match
|
||||
return self.event_map[event_handle]
|
||||
|
||||
@ -1983,6 +1994,15 @@ class HasTextMatchingSubstringOf(Rule):
|
||||
self.place_map[place_handle] = self.match_object(place)
|
||||
return self.place_map[place_handle]
|
||||
|
||||
def search_media(self,media_handle):
|
||||
if not media_handle:
|
||||
return 0
|
||||
# search inside the place and cache the result
|
||||
if not media_handle in self.media_map:
|
||||
media = self.db.get_object_from_handle(media_handle)
|
||||
self.media_map[media_handle] = self.match_object(media)
|
||||
return self.media_map[media_handle]
|
||||
|
||||
def cache_sources(self):
|
||||
# search all sources and match all referents of a matching source
|
||||
for source_handle in self.db.get_source_handles():
|
||||
@ -1999,6 +2019,8 @@ class HasTextMatchingSubstringOf(Rule):
|
||||
self.event_map[handle] = 1
|
||||
for handle in place_list:
|
||||
self.place_map[handle] = 1
|
||||
for handle in media_list:
|
||||
self.media_map[handle] = 1
|
||||
|
||||
def match_object(self,obj):
|
||||
if not obj:
|
||||
@ -2022,6 +2044,7 @@ class HasTextMatchingRegexpOf(HasTextMatchingSubstringOf):
|
||||
self.source_map = {}
|
||||
self.family_map = {}
|
||||
self.place_map = {}
|
||||
self.media_map = {}
|
||||
self.case_sensitive = False
|
||||
self.regexp_match = True
|
||||
self.cache_sources()
|
||||
|
@ -96,6 +96,8 @@ class BaseObject:
|
||||
# Run through its own items
|
||||
patern_upper = pattern.upper()
|
||||
for item in self.get_text_data_list():
|
||||
if not item:
|
||||
continue
|
||||
if case_sensitive:
|
||||
if item.find(pattern) != -1:
|
||||
return True
|
||||
@ -127,7 +129,7 @@ class BaseObject:
|
||||
else:
|
||||
pattern_obj = re.compile(pattern,re.IGNORECASE)
|
||||
for item in self.get_text_data_list():
|
||||
if pattern_obj.match(item):
|
||||
if item and pattern_obj.match(item):
|
||||
return True
|
||||
|
||||
# Run through child objects
|
||||
@ -1038,7 +1040,7 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
|
||||
@return: Returns the list of all textual attributes of the object.
|
||||
@rtype: list
|
||||
"""
|
||||
return [self.nickname]
|
||||
return [self.nickname,self.gramps_id]
|
||||
|
||||
def get_text_data_child_list(self):
|
||||
"""
|
||||
@ -1768,6 +1770,15 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
|
||||
if self.lds_seal and self.lds_seal.place == old_handle:
|
||||
self.lds_seal.place = new_handle
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
||||
@return: Returns the list of all textual attributes of the object.
|
||||
@rtype: list
|
||||
"""
|
||||
return [self.gramps_id]
|
||||
|
||||
def get_text_data_child_list(self):
|
||||
"""
|
||||
Returns the list of child objects that may carry textual data.
|
||||
@ -2119,7 +2130,7 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase):
|
||||
@return: Returns the list of all textual attributes of the object.
|
||||
@rtype: list
|
||||
"""
|
||||
return [self.description,self.name,self.cause,self.get_date()]
|
||||
return [self.description,self.name,self.cause,self.get_date(),self.gramps_id]
|
||||
|
||||
def get_text_data_child_list(self):
|
||||
"""
|
||||
@ -2394,7 +2405,7 @@ class Place(PrimaryObject,SourceNote,MediaBase):
|
||||
@return: Returns the list of all textual attributes of the object.
|
||||
@rtype: list
|
||||
"""
|
||||
return [self.long,self.lat,self.title]
|
||||
return [self.long,self.lat,self.title,self.gramps_id]
|
||||
|
||||
def get_text_data_child_list(self):
|
||||
"""
|
||||
@ -2653,7 +2664,7 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
|
||||
@return: Returns the list of all textual attributes of the object.
|
||||
@rtype: list
|
||||
"""
|
||||
return [self.path,self.mime,self.desc,self.get_date()]
|
||||
return [self.path,self.mime,self.desc,self.get_date(),self.gramps_id]
|
||||
|
||||
def get_text_data_child_list(self):
|
||||
"""
|
||||
@ -2757,7 +2768,7 @@ class Source(PrimaryObject,MediaBase,NoteBase):
|
||||
@return: Returns the list of all textual attributes of the object.
|
||||
@rtype: list
|
||||
"""
|
||||
return [self.title,self.author,self.pubinfo,self.abbrev]
|
||||
return [self.title,self.author,self.pubinfo,self.abbrev,self.gramps_id]
|
||||
|
||||
def get_text_data_child_list(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user