2007-06-06 Alex Roitman <shura@gramps-project.org>

* src/DisplayState.py (DisplayState.__signals__): Port fixes from
	2.2 tree. 
	* src/FilterEditor/_EditFilter.py: Port fixes from 2.2 tree.
	* src/FilterEditor/_FilterEditor.py: Port fixes from 2.2 tree.
	* data/grampsxml.rng: Port fixes from 2.2 tree.
	* data/grampsxml.dtd: Port fixes from 2.2 tree.
	* src/GrampsDb/_GrampsDbWriteXML.py (_xml_version): Bump up version.



svn: r8536
This commit is contained in:
Alex Roitman 2007-06-07 05:06:14 +00:00
parent b7c0109e5e
commit 6bf09da13d
7 changed files with 103 additions and 14 deletions

View File

@ -1,5 +1,13 @@
2007-06-06 Alex Roitman <shura@gramps-project.org>
* src/DisplayState.py (DisplayState.__signals__): Port fixes from
2.2 tree.
* src/FilterEditor/_EditFilter.py: Port fixes from 2.2 tree.
* src/FilterEditor/_FilterEditor.py: Port fixes from 2.2 tree.
* data/grampsxml.rng: Port fixes from 2.2 tree.
* data/grampsxml.dtd: Port fixes from 2.2 tree.
* src/GrampsDb/_GrampsDbWriteXML.py (_xml_version): Bump up version.
2007-06-03 Don Allingham <don@gramps-project.org> 2007-06-03 Don Allingham <don@gramps-project.org>
* src/GrampsDb/_GrampsBSDDB.py: fix __ issue
* src/GrampsDb/_GrampsCursor.py: added * src/GrampsDb/_GrampsCursor.py: added
* src/Simple/__init__.py: add * src/Simple/__init__.py: add

View File

@ -24,15 +24,15 @@
--> -->
<!-- <!--
This is the Document Type Definition file for v1.1.4 This is the Document Type Definition file for v1.2.0
of the GRAMPS XML genealogy data format. of the GRAMPS XML genealogy data format.
Please use the following formal public identifier to identify it: Please use the following formal public identifier to identify it:
"-//GRAMPS//DTD GRAMPS XML V1.1.4//EN" "-//GRAMPS//DTD GRAMPS XML V1.2.0//EN"
For example: For example:
<!DOCTYPE database PUBLIC "-//GRAMPS//DTD GRAMPS XML V1.1.4//EN" <!DOCTYPE database PUBLIC "-//GRAMPS//DTD GRAMPS XML V1.2.0//EN"
"http://gramps-project.org/xml/1.1.4/grampsxml.dtd" "http://gramps-project.org/xml/1.2.0/grampsxml.dtd"
[...]> [...]>
--> -->
@ -55,7 +55,7 @@ DATABASE
<!ELEMENT database (header, name-formats?, events?, people?, families?, <!ELEMENT database (header, name-formats?, events?, people?, families?,
sources?, places?, objects?, repositories?, notes?, sources?, places?, objects?, repositories?, notes?,
bookmark?)> bookmark?)>
<!ATTLIST database xmlns CDATA #FIXED "http://gramps-project.org/xml/1.1.4/"> <!ATTLIST database xmlns CDATA #FIXED "http://gramps-project.org/xml/1.2.0/">
<!-- ************************************************************ <!-- ************************************************************
HEADER HEADER
@ -110,7 +110,7 @@ GENDER has values of M, F, or U.
--> -->
<!ELEMENT gender (#PCDATA)> <!ELEMENT gender (#PCDATA)>
<!ELEMENT name (first?,last?,suffix?,patronymic?,title?, <!ELEMENT name (first?,call?last?,suffix?,patronymic?,title?,
(daterange|dateval|datestr)?,noteref*,sourceref*)> (daterange|dateval|datestr)?,noteref*,sourceref*)>
<!ATTLIST name <!ATTLIST name
alt (0|1) #IMPLIED alt (0|1) #IMPLIED
@ -121,6 +121,7 @@ GENDER has values of M, F, or U.
> >
<!ELEMENT first (#PCDATA)> <!ELEMENT first (#PCDATA)>
<!ELEMENT call (#PCDATA)>
<!ELEMENT last (#PCDATA)> <!ELEMENT last (#PCDATA)>
<!ATTLIST last <!ATTLIST last
prefix CDATA #IMPLIED prefix CDATA #IMPLIED
@ -371,6 +372,7 @@ SHARED ELEMENTS
<!ELEMENT sourceref (spage?,noteref*,stext?,(daterange|dateval|datestr)?)> <!ELEMENT sourceref (spage?,noteref*,stext?,(daterange|dateval|datestr)?)>
<!ATTLIST sourceref <!ATTLIST sourceref
hlink IDREF #REQUIRED hlink IDREF #REQUIRED
priv (0|1) #IMPLIED
conf CDATA #IMPLIED conf CDATA #IMPLIED
> >
@ -433,6 +435,7 @@ SHARED ELEMENTS
<!ELEMENT lds_ord ((daterange|dateval|datestr)?,temple?,place?,status?, <!ELEMENT lds_ord ((daterange|dateval|datestr)?,temple?,place?,status?,
sealed_to?,noteref*,sourceref*)> sealed_to?,noteref*,sourceref*)>
<!ATTLIST lds_ord <!ATTLIST lds_ord
priv (0|1) #IMPLIED
type CDATA #REQUIRED type CDATA #REQUIRED
> >

View File

@ -31,7 +31,7 @@
<grammar <grammar
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
ns="http://gramps-project.org/xml/1.1.4/" ns="http://gramps-project.org/xml/1.2.0/"
xmlns="http://relaxng.org/ns/structure/1.0"> xmlns="http://relaxng.org/ns/structure/1.0">
<start><element name="database"> <start><element name="database">
@ -214,6 +214,7 @@
<optional><attribute name="sort"><text/></attribute></optional> <optional><attribute name="sort"><text/></attribute></optional>
<optional><attribute name="display"><text/></attribute></optional> <optional><attribute name="display"><text/></attribute></optional>
<optional><element name="first"><text/></element></optional> <optional><element name="first"><text/></element></optional>
<optional><element name="call"><text/></element></optional>
<optional><element name="last"> <optional><element name="last">
<text/> <text/>
<optional><attribute name="prefix"><text/></attribute></optional> <optional><attribute name="prefix"><text/></attribute></optional>
@ -469,6 +470,9 @@
<define name="sourceref-content"> <define name="sourceref-content">
<attribute name="hlink"><data type="IDREF"/></attribute> <attribute name="hlink"><data type="IDREF"/></attribute>
<optional><attribute name="priv">
<ref name="priv-content"/>
</attribute></optional>
<optional><attribute name="conf"><text/></attribute></optional> <optional><attribute name="conf"><text/></attribute></optional>
<optional><element name="spage"><text/></element></optional> <optional><element name="spage"><text/></element></optional>
<zeroOrMore><element name="noteref"> <zeroOrMore><element name="noteref">
@ -552,6 +556,9 @@
</define> </define>
<define name="lds-content"> <define name="lds-content">
<optional><attribute name="priv">
<ref name="priv-content"/>
</attribute></optional>
<attribute name="type"><text/></attribute> <attribute name="type"><text/></attribute>
<optional><ref name="date-content"/></optional> <optional><ref name="date-content"/></optional>
<optional><element name="temple"> <optional><element name="temple">

View File

@ -257,6 +257,7 @@ class DisplayState(GrampsDb.GrampsDBCallback):
__signals__ = { __signals__ = {
'filters-changed' : (str, ), 'filters-changed' : (str, ),
'filter-name-changed' : (str,unicode,unicode),
'nameformat-changed' : None, 'nameformat-changed' : None,
'plugins-reloaded' : (list, list), 'plugins-reloaded' : (list, list),
} }

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2006 Donald N. Allingham # Copyright (C) 2000-2007 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# $Id: _FilterEditor.py 6840 2006-06-01 22:37:13Z dallingham $ # $Id$
""" """
Custom Filter Editor tool. Custom Filter Editor tool.
@ -127,7 +127,12 @@ class EditFilter(ManagedWindow.ManagedWindow):
def filter_name_changed(self,obj): def filter_name_changed(self,obj):
name = unicode(self.fname.get_text()) name = unicode(self.fname.get_text())
self.ok_btn.set_sensitive(len(name) != 0) # Make sure that the name is not empty
# and not in the list of existing filters (excluding this one)
names = [filt.get_name()
for filt in self.filterdb.get_filters(self.space)
if filt != self.filter]
self.ok_btn.set_sensitive((len(name) != 0) and (name not in names))
def select_row(self,obj): def select_row(self,obj):
store,node = self.rlist.get_selected() store,node = self.rlist.get_selected()
@ -147,6 +152,9 @@ class EditFilter(ManagedWindow.ManagedWindow):
n = unicode(self.fname.get_text()).strip() n = unicode(self.fname.get_text()).strip()
if n == '': if n == '':
return return
if n != self.filter.get_name():
self.uistate.emit('filter-name-changed',
(self.space,unicode(self.filter.get_name()),n))
self.filter.set_name(n) self.filter.set_name(n)
self.filter.set_comment(unicode(self.comment.get_text()).strip()) self.filter.set_comment(unicode(self.comment.get_text()).strip())
for f in self.filterdb.get_filters(self.space)[:]: for f in self.filterdb.get_filters(self.space)[:]:

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2006 Donald N. Allingham # Copyright (C) 2000-2007 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -56,8 +56,10 @@ import GrampsDisplay
import const import const
from Filters import GenericFilterFactory, FilterList, \ from Filters import GenericFilterFactory, FilterList, \
reload_custom_filters, reload_system_filters reload_custom_filters, reload_system_filters
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
import ListModel import ListModel
import ManagedWindow import ManagedWindow
from QuestionDialog import QuestionDialog
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -100,6 +102,8 @@ class FilterEditor(ManagedWindow.ManagedWindow):
self.connect_button('close', self.close) self.connect_button('close', self.close)
self.connect_button('add', self.add_new_filter) self.connect_button('add', self.add_new_filter)
self.uistate.connect('filter-name-changed',self.clean_after_rename)
self.clist = ListModel.ListModel( self.clist = ListModel.ListModel(
self.filter_list, self.filter_list,
[(_('Filter'),0,150),(_('Comment'),1,150)], [(_('Filter'),0,150),(_('Comment'),1,150)],
@ -181,9 +185,43 @@ class FilterEditor(ManagedWindow.ManagedWindow):
store,node = self.clist.get_selected() store,node = self.clist.get_selected()
if node: if node:
gfilter = self.clist.get_object(node) gfilter = self.clist.get_object(node)
self.filterdb.get_filters(self.space).remove(gfilter) name = gfilter.get_name()
if self.check_recursive_filters(self.space,name):
QuestionDialog( _('Delete Filter?'),
_('This filter is currently being used '
'as the base for other filters. Deleting'
'this filter will result in removing all '
'other filters that depend on it.'),
_('Delete Filter'),
self._do_delete_selected_filter,
self.window)
else:
self._do_delete_selected_filter()
def _do_delete_selected_filter(self):
store,node = self.clist.get_selected()
if node:
gfilter = self.clist.get_object(node)
self._do_delete_filter(self.space,gfilter)
self.draw_filters() self.draw_filters()
def _do_delete_filter(self,space,gfilter):
"""
This method recursively calls itself to delete all dependent filters
before removing this filter. Otherwise when A is 'matches B'
and C is 'matches D' the removal of A leads to two broken filter
being left behind.
"""
filters = self.filterdb.get_filters(space)
name = gfilter.get_name()
for the_filter in filters:
for rule in the_filter.get_rules():
values = rule.values()
if issubclass(rule.__class__,MatchesFilterBase) \
and (name in values):
self._do_delete_filter(space,the_filter)
filters.remove(gfilter)
def get_all_handles(self): def get_all_handles(self):
if self.space == 'Person': if self.space == 'Person':
return self.db.get_person_handles(sort_handles=False) return self.db.get_person_handles(sort_handles=False)
@ -201,3 +239,27 @@ class FilterEditor(ManagedWindow.ManagedWindow):
return self.db.get_repository_handles() return self.db.get_repository_handles()
elif self.space == 'Note': elif self.space == 'Note':
return self.db.get_note_handles() return self.db.get_note_handles()
def clean_after_rename(self,space,old_name,new_name):
if old_name == "":
return
if old_name == new_name:
return
for the_filter in self.filterdb.get_filters(space):
for rule in the_filter.get_rules():
values = rule.values()
if issubclass(rule.__class__,MatchesFilterBase) \
and (old_name in values):
ind = values.index(old_name)
values[ind] = new_name
def check_recursive_filters(self,space,name):
for the_filter in self.filterdb.get_filters(space):
for rule in the_filter.get_rules():
values = rule.values()
if issubclass(rule.__class__,MatchesFilterBase) \
and (name in values):
return True
return False

View File

@ -72,7 +72,7 @@ except:
_gzip_ok = 0 _gzip_ok = 0
_xml_version = "1.1.4" _xml_version = "1.2.0"
# table for skipping control chars from XML # table for skipping control chars from XML
strip_dict = dict.fromkeys(range(9)+range(12,20)) strip_dict = dict.fromkeys(range(9)+range(12,20))