Fixes for database update signal handling for treemodel as used for the citation tree
- corrected handing of setting of the handle of a node to 'None' for a non-leaf (heading) node - only insert the citation leaf node if it is not already present. svn: r18220
This commit is contained in:
parent
a906c98439
commit
afefdb09a7
@ -162,6 +162,7 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel):
|
|||||||
for j in i:
|
for j in i:
|
||||||
source_handle_list.append(j)
|
source_handle_list.append(j)
|
||||||
for citation_handle in source_handle_list:
|
for citation_handle in source_handle_list:
|
||||||
|
if self.get_node(citation_handle) is None:
|
||||||
# # add as node: parent, child, sortkey, handle; parent and child are
|
# # add as node: parent, child, sortkey, handle; parent and child are
|
||||||
# # nodes in the treebasemodel, and will be used as iters
|
# # nodes in the treebasemodel, and will be used as iters
|
||||||
citation = self.db.get_citation_from_handle(citation_handle)
|
citation = self.db.get_citation_from_handle(citation_handle)
|
||||||
|
@ -99,7 +99,7 @@ class Node(object):
|
|||||||
"""
|
"""
|
||||||
Assign the handle of a Gramps object to this node.
|
Assign the handle of a Gramps object to this node.
|
||||||
"""
|
"""
|
||||||
if not self.handle:
|
if not self.handle or handle == None:
|
||||||
self.handle = handle
|
self.handle = handle
|
||||||
self.secondary = secondary
|
self.secondary = secondary
|
||||||
else:
|
else:
|
||||||
@ -609,6 +609,7 @@ class TreeBaseModel(gtk.GenericTreeModel):
|
|||||||
Remove a node from the map.
|
Remove a node from the map.
|
||||||
"""
|
"""
|
||||||
if node.children:
|
if node.children:
|
||||||
|
del self.handle2node[node.handle]
|
||||||
node.set_handle(None)
|
node.set_handle(None)
|
||||||
self.__displayed -= 1
|
self.__displayed -= 1
|
||||||
self.__total -= 1
|
self.__total -= 1
|
||||||
@ -687,6 +688,8 @@ class TreeBaseModel(gtk.GenericTreeModel):
|
|||||||
|
|
||||||
_LOG.debug(self.__class__.__name__ + ' add_row_by_handle ' +
|
_LOG.debug(self.__class__.__name__ + ' add_row_by_handle ' +
|
||||||
str(time.clock() - cput) + ' sec')
|
str(time.clock() - cput) + ' sec')
|
||||||
|
_LOG.debug("displayed %d / total: %d" %
|
||||||
|
(self.__displayed, self.__total))
|
||||||
|
|
||||||
def delete_row_by_handle(self, handle):
|
def delete_row_by_handle(self, handle):
|
||||||
"""
|
"""
|
||||||
@ -715,6 +718,8 @@ class TreeBaseModel(gtk.GenericTreeModel):
|
|||||||
|
|
||||||
_LOG.debug(self.__class__.__name__ + ' delete_row_by_handle ' +
|
_LOG.debug(self.__class__.__name__ + ' delete_row_by_handle ' +
|
||||||
str(time.clock() - cput) + ' sec')
|
str(time.clock() - cput) + ' sec')
|
||||||
|
_LOG.debug("displayed %d / total: %d" %
|
||||||
|
(self.__displayed, self.__total))
|
||||||
|
|
||||||
def update_row_by_handle(self, handle):
|
def update_row_by_handle(self, handle):
|
||||||
"""
|
"""
|
||||||
|
@ -31,6 +31,7 @@ A view showing all the Sources with child Citations
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import logging
|
import logging
|
||||||
LOG = logging.getLogger(".citation")
|
LOG = logging.getLogger(".citation")
|
||||||
|
_LOG = logging.getLogger('.gui.citationtreeview')
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -116,14 +117,14 @@ class CitationTreeView(ListView):
|
|||||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||||
|
|
||||||
signal_map = {
|
signal_map = {
|
||||||
'citation-add' : self.row_add,
|
'citation-add' : self._citation_row_add,
|
||||||
'citation-update' : self.row_update,
|
'citation-update' : self._citation_row_update,
|
||||||
'citation-delete' : self.row_delete,
|
'citation-delete' : self._citation_row_delete,
|
||||||
'citation-rebuild' : self.object_build,
|
'citation-rebuild' : self._citation_object_build,
|
||||||
'source-add' : self.row_add,
|
'source-add' : self._source_row_add,
|
||||||
'source-update' : self.row_update,
|
'source-update' : self._source_row_update,
|
||||||
'source-delete' : self.row_delete,
|
'source-delete' : self._source_row_delete,
|
||||||
'source-rebuild' : self.object_build,
|
'source-rebuild' : self._source_object_build,
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView.__init__(
|
ListView.__init__(
|
||||||
@ -142,6 +143,52 @@ class CitationTreeView(ListView):
|
|||||||
|
|
||||||
self.additional_uis.append(self.additional_ui())
|
self.additional_uis.append(self.additional_ui())
|
||||||
|
|
||||||
|
def _print_handles(self, text, handle_list):
|
||||||
|
for handle in handle_list:
|
||||||
|
source = self.dbstate.db.get_source_from_handle(handle)
|
||||||
|
citation = self.dbstate.db.get_citation_from_handle(handle)
|
||||||
|
_LOG.debug("\n\n\n")
|
||||||
|
if source:
|
||||||
|
_LOG.debug("---- %s -- source %s" %
|
||||||
|
(text, source.get_title()))
|
||||||
|
elif citation:
|
||||||
|
_LOG.debug("---- %s -- citation %s" %
|
||||||
|
(text, citation.get_page()))
|
||||||
|
else:
|
||||||
|
_LOG.debug("---- %s -- handle %s" % (text, handle))
|
||||||
|
|
||||||
|
def _citation_row_add(self, handle_list):
|
||||||
|
self._print_handles("citation row add", handle_list)
|
||||||
|
self.row_add(handle_list)
|
||||||
|
|
||||||
|
def _citation_row_update(self, handle_list):
|
||||||
|
self._print_handles("citation row update", handle_list)
|
||||||
|
self.row_update(handle_list)
|
||||||
|
|
||||||
|
def _citation_row_delete(self, handle_list):
|
||||||
|
self._print_handles("citation row delete", handle_list)
|
||||||
|
self.row_delete(handle_list)
|
||||||
|
|
||||||
|
def _citation_object_build(self, *args):
|
||||||
|
_LOG.debug("citation object build")
|
||||||
|
self.object_build(*args)
|
||||||
|
|
||||||
|
def _source_row_add(self, handle_list):
|
||||||
|
self._print_handles("source row add", handle_list)
|
||||||
|
self.row_add(handle_list)
|
||||||
|
|
||||||
|
def _source_row_update(self, handle_list):
|
||||||
|
self._print_handles("source row update", handle_list)
|
||||||
|
self.row_update(handle_list)
|
||||||
|
|
||||||
|
def _source_row_delete(self, handle_list):
|
||||||
|
self._print_handles("source row delete", handle_list)
|
||||||
|
self.row_delete(handle_list)
|
||||||
|
|
||||||
|
def _source_object_build(self, *args):
|
||||||
|
_LOG.debug("source object build")
|
||||||
|
self.object_build(*args)
|
||||||
|
|
||||||
def navigation_type(self):
|
def navigation_type(self):
|
||||||
return 'Citation'
|
return 'Citation'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user