* Updated signal handlers to deal with citation tree model and secondary nodes
* Fix for citation selector. svn: r18171
This commit is contained in:
parent
c474e5e638
commit
21e402fc6f
@ -68,10 +68,10 @@ class SelectCitation(BaseSelector):
|
||||
]
|
||||
|
||||
def get_from_handle_func(self):
|
||||
return self.db.get_citation_from_handle
|
||||
|
||||
def get_from_handle_func2(self):
|
||||
return self.db.get_source_from_handle
|
||||
|
||||
def get_from_handle_func2(self):
|
||||
return self.db.get_citation_from_handle
|
||||
|
||||
def get_handle_column(self):
|
||||
return 11
|
||||
return 8
|
||||
|
@ -112,6 +112,9 @@ class CitationBaseModel(object):
|
||||
def citation_sort_change(self, data):
|
||||
return "%012x" % data[COLUMN_CHANGE]
|
||||
|
||||
def citation_source(self, data):
|
||||
return data[COLUMN_SOURCE]
|
||||
|
||||
def citation_src_title(self, data):
|
||||
source_handle = data[COLUMN_SOURCE]
|
||||
try:
|
||||
|
@ -21,7 +21,7 @@
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
CitationBaseModel, CitationListModel and CitationTreeModel classes for GRAMPS.
|
||||
CitationListModel class for GRAMPS.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -168,9 +168,6 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel):
|
||||
citation_page = citation.get_page()
|
||||
self.add_node(handle, citation_handle, citation_page,
|
||||
citation_handle, secondary=True)
|
||||
|
||||
|
||||
|
||||
# try:
|
||||
# source_handle = data[COLUMN_SOURCE]
|
||||
# except:
|
||||
@ -190,6 +187,14 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel):
|
||||
# unicode(data[COLUMN_PAGE]),
|
||||
# exc_info=True)
|
||||
|
||||
def add_secondary_row(self, handle, data):
|
||||
"""
|
||||
Add a secondary node to the node map for a citation.
|
||||
"""
|
||||
# parameters are parent, child, sortkey, handle
|
||||
self.add_node(self.citation_source(data), handle,
|
||||
self.citation_page(data), handle, secondary=True)
|
||||
|
||||
def on_get_n_columns(self):
|
||||
return len(self.fmap)+1
|
||||
|
||||
|
@ -680,7 +680,10 @@ class TreeBaseModel(gtk.GenericTreeModel):
|
||||
(self.search and self.search.match(handle, self.db)):
|
||||
#row needs to be added to the model
|
||||
data = self.map(handle)
|
||||
self.add_row(handle, data)
|
||||
if data:
|
||||
self.add_row(handle, data)
|
||||
else:
|
||||
self.add_secondary_row(handle, self.map2(handle))
|
||||
|
||||
_LOG.debug(self.__class__.__name__ + ' add_row_by_handle ' +
|
||||
str(time.clock() - cput) + ' sec')
|
||||
|
@ -73,18 +73,8 @@ class BaseCitationView(ListView):
|
||||
# The configuration parameters have been moved to CitationTreeView and
|
||||
# CitationListView, because they differ for the two different views.
|
||||
|
||||
def __init__(self, pdata, dbstate, uistate, title, model, nav_group=0):
|
||||
|
||||
signal_map = {
|
||||
'citation-add' : self.row_add,
|
||||
'citation-update' : self.row_update,
|
||||
'citation-delete' : self.row_delete,
|
||||
'citation-rebuild' : self.object_build,
|
||||
'source-add' : self.row_add,
|
||||
'source-update' : self.row_update,
|
||||
'source-delete' : self.row_delete,
|
||||
'source-rebuild' : self.object_build,
|
||||
}
|
||||
def __init__(self, pdata, dbstate, uistate, title, model, signal_map,
|
||||
nav_group=0):
|
||||
|
||||
ListView.__init__(
|
||||
self, title, pdata, dbstate, uistate,
|
||||
@ -430,7 +420,7 @@ class BaseCitationView(ListView):
|
||||
"""
|
||||
Define the default gramplets for the sidebar and bottombar.
|
||||
"""
|
||||
return (("Source Filter",),
|
||||
return (("Citation Filter",),
|
||||
("Citation Gallery",
|
||||
"Citation Notes",
|
||||
"Citation Backlinks"))
|
||||
|
@ -50,9 +50,12 @@ from gen.ggettext import gettext as _
|
||||
class CitationListView(BaseCitationView):
|
||||
"""
|
||||
A list view of citations.
|
||||
|
||||
The citation list view only shows the citations (it does not show
|
||||
sources as separate list entries).
|
||||
"""
|
||||
# The data items here have to correspond, in order, to the items in
|
||||
# src/giu.views/treemodels/citationlistmodel.py
|
||||
# src/giu.views/treemodels/citationlismodel.py
|
||||
COL_TITLE_PAGE = 0
|
||||
COL_ID = 1
|
||||
COL_DATE = 2
|
||||
@ -99,7 +102,16 @@ class CitationListView(BaseCitationView):
|
||||
QR_CATEGORY = CATEGORY_QR_SOURCE
|
||||
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
|
||||
signal_map = {
|
||||
'citation-add' : self.row_add,
|
||||
'citation-update' : self.row_update,
|
||||
'citation-delete' : self.row_delete,
|
||||
'citation-rebuild' : self.object_build,
|
||||
}
|
||||
|
||||
BaseCitationView.__init__(self, pdata, dbstate, uistate,
|
||||
_('Citation View'), CitationListModel,
|
||||
signal_map,
|
||||
nav_group=nav_group)
|
||||
|
||||
|
@ -98,8 +98,20 @@ class CitationTreeView(BaseCitationView):
|
||||
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
|
||||
signal_map = {
|
||||
'citation-add' : self.row_add,
|
||||
'citation-update' : self.row_update,
|
||||
'citation-delete' : self.row_delete,
|
||||
'citation-rebuild' : self.object_build,
|
||||
'source-add' : self.row_add,
|
||||
'source-update' : self.row_update,
|
||||
'source-delete' : self.row_delete,
|
||||
'source-rebuild' : self.object_build,
|
||||
}
|
||||
|
||||
BaseCitationView.__init__(self, pdata, dbstate, uistate,
|
||||
_('Citation Tree View'), CitationTreeModel,
|
||||
signal_map,
|
||||
nav_group=nav_group)
|
||||
|
||||
def type_list(self):
|
||||
|
Loading…
Reference in New Issue
Block a user