Upgraded Source and Citation reference Quick Views to work with citations (actually, for citationtreeview, this is a source_or_citation reference, to avoid having to change the way listview calls the pop up menu items).

Also minimal changes to SimpleAccess and SimpleTable to support these references views.

svn: r18447
This commit is contained in:
Tim G L Lyons
2011-11-15 12:08:43 +00:00
parent a73075f881
commit 4a69d45fe6
10 changed files with 61 additions and 8 deletions

View File

@ -57,7 +57,8 @@ from gui.pluginmanager import GuiPluginManager
from gen.plug import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, CATEGORY_QR_MEDIA, from gen.plug import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, CATEGORY_QR_MEDIA,
CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_MISC, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_MISC,
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY,
CATEGORY_QR_NOTE) CATEGORY_QR_NOTE, CATEGORY_QR_CITATION,
CATEGORY_QR_SOURCE_OR_CITATION)
def flatten(L): def flatten(L):
""" """
@ -119,7 +120,8 @@ def create_quickreport_menu(category,dbstate,uistate, handle) :
It collects the reports of the requested category, which must be one of It collects the reports of the requested category, which must be one of
CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY,
CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_MEDIA, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_MEDIA,
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY,
CATEGORY_QR_CITATION, CATEGORY_QR_SOURCE_OR_CITATION
It constructs the ui string of the quick report menu, and it's actions It constructs the ui string of the quick report menu, and it's actions
The action callback function is constructed, using the dbstate and the The action callback function is constructed, using the dbstate and the
handle as input method. handle as input method.
@ -166,7 +168,8 @@ def get_quick_report_list(qv_category=None):
Returns a list of PluginData of quick views of category qv_category Returns a list of PluginData of quick views of category qv_category
CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT,
CATEGORY_QR_SOURCE, CATEGORY_QR_MISC, CATEGORY_QR_PLACE, CATEGORY_QR_SOURCE, CATEGORY_QR_MISC, CATEGORY_QR_PLACE,
CATEGORY_QR_REPOSITORY, CATEGORY_QR_MEDIA or None for all CATEGORY_QR_REPOSITORY, CATEGORY_QR_MEDIA,
CATEGORY_QR_CITATION, CATEGORY_QR_SOURCE_OR_CITATION or None for all
""" """
names = [] names = []
pmgr = GuiPluginManager.get_instance() pmgr = GuiPluginManager.get_instance()
@ -254,6 +257,17 @@ def run_report(dbstate, uistate, category, handle, pdata, container=None,
obj = dbstate.db.get_event_from_handle(handle) obj = dbstate.db.get_event_from_handle(handle)
elif category == CATEGORY_QR_SOURCE : elif category == CATEGORY_QR_SOURCE :
obj = dbstate.db.get_source_from_handle(handle) obj = dbstate.db.get_source_from_handle(handle)
elif category == CATEGORY_QR_CITATION :
obj = dbstate.db.get_citation_from_handle(handle)
elif category == CATEGORY_QR_SOURCE_OR_CITATION :
source = dbstate.db.get_source_from_handle(handle)
citation = dbstate.db.get_citation_from_handle(handle)
if (not source and not citation) or (source and citation):
raise ValueError("selection must be either source or citation")
if citation:
obj = citation
else:
obj = source
elif category == CATEGORY_QR_PLACE : elif category == CATEGORY_QR_PLACE :
obj = dbstate.db.get_place_from_handle(handle) obj = dbstate.db.get_place_from_handle(handle)
elif category == CATEGORY_QR_MEDIA : elif category == CATEGORY_QR_MEDIA :

View File

@ -849,6 +849,20 @@ class SimpleAccess(object):
return source.get_title() return source.get_title()
return u'' return u''
def page(self, citation):
"""
Return the page of the citation.
@param citation: Source object
@type citation: L{gen.lib.Citation}
@return: title of the citation
@rtype: unicode
"""
assert(isinstance(citation, (gen.lib.Citation, NoneType)))
if citation:
return citation.get_page()
return u''
def author(self, source): def author(self, source):
""" """
Return the author of the source. Return the author of the source.
@ -952,6 +966,8 @@ class SimpleAccess(object):
return obj.desc return obj.desc
elif isinstance(obj, gen.lib.Source): elif isinstance(obj, gen.lib.Source):
return self.title(obj) return self.title(obj)
elif isinstance(obj, gen.lib.Citation):
return self.page(obj)
elif isinstance(obj, gen.lib.Place): elif isinstance(obj, gen.lib.Place):
return place_name(self.dbase, obj.handle) return place_name(self.dbase, obj.handle)
elif isinstance(obj, gen.lib.Repository): elif isinstance(obj, gen.lib.Repository):

View File

@ -352,6 +352,10 @@ class SimpleTable(object):
retval.append(self.access.describe(item)) retval.append(self.access.describe(item))
if (self.__link_col == col or link is None): if (self.__link_col == col or link is None):
link = ('Source', item.handle) link = ('Source', item.handle)
elif isinstance(item, gen.lib.Citation):
retval.append(self.access.describe(item))
if (self.__link_col == col or link is None):
link = ('Citation', item.handle)
elif isinstance(item, gen.lib.Event): elif isinstance(item, gen.lib.Event):
retval.append(self.access.describe(item)) retval.append(self.access.describe(item))
if (self.__link_col == col or link is None): if (self.__link_col == col or link is None):

View File

@ -33,6 +33,7 @@ from _pluginreg import (PluginData, PluginRegister, REPORT, TOOL,
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE, CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE,
CATEGORY_QR_DATE, PTYPE_STR, CATEGORY_QR_MEDIA, CATEGORY_QR_DATE, PTYPE_STR, CATEGORY_QR_MEDIA,
CATEGORY_QR_CITATION, CATEGORY_QR_SOURCE_OR_CITATION,
START, END, make_environment, START, END, make_environment,
) )
from _manager import BasePluginManager from _manager import BasePluginManager
@ -54,4 +55,5 @@ __all__ = [ "docbackend", "docgen", "menu", Plugin, PluginData,
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE, CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE,
CATEGORY_QR_DATE, PTYPE_STR, CATEGORY_QR_MEDIA, CATEGORY_QR_DATE, PTYPE_STR, CATEGORY_QR_MEDIA,
CATEGORY_QR_CITATION, CATEGORY_QR_SOURCE_OR_CITATION,
START, END, make_environment] START, END, make_environment]

View File

@ -116,6 +116,8 @@ CATEGORY_QR_REPOSITORY = 5
CATEGORY_QR_NOTE = 6 CATEGORY_QR_NOTE = 6
CATEGORY_QR_DATE = 7 CATEGORY_QR_DATE = 7
CATEGORY_QR_MEDIA = 8 CATEGORY_QR_MEDIA = 8
CATEGORY_QR_CITATION = 9
CATEGORY_QR_SOURCE_OR_CITATION = 10
# Modes for generating reports # Modes for generating reports
REPORT_MODE_GUI = 1 # Standalone report using GUI REPORT_MODE_GUI = 1 # Standalone report using GUI
@ -1009,6 +1011,8 @@ def make_environment(**kwargs):
'CATEGORY_QR_FAMILY': CATEGORY_QR_FAMILY, 'CATEGORY_QR_FAMILY': CATEGORY_QR_FAMILY,
'CATEGORY_QR_EVENT': CATEGORY_QR_EVENT, 'CATEGORY_QR_EVENT': CATEGORY_QR_EVENT,
'CATEGORY_QR_SOURCE': CATEGORY_QR_SOURCE, 'CATEGORY_QR_SOURCE': CATEGORY_QR_SOURCE,
'CATEGORY_QR_CITATION': CATEGORY_QR_CITATION,
'CATEGORY_QR_SOURCE_OR_CITATION': CATEGORY_QR_SOURCE_OR_CITATION,
'CATEGORY_QR_PLACE': CATEGORY_QR_PLACE, 'CATEGORY_QR_PLACE': CATEGORY_QR_PLACE,
'CATEGORY_QR_MEDIA': CATEGORY_QR_MEDIA, 'CATEGORY_QR_MEDIA': CATEGORY_QR_MEDIA,
'CATEGORY_QR_REPOSITORY': CATEGORY_QR_REPOSITORY, 'CATEGORY_QR_REPOSITORY': CATEGORY_QR_REPOSITORY,

View File

@ -36,7 +36,8 @@ from QuickReports import run_quick_report_by_name, get_quick_report_list
from gen.plug import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, from gen.plug import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY,
CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_NOTE, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_NOTE,
CATEGORY_QR_MISC, CATEGORY_QR_PLACE, CATEGORY_QR_MEDIA, CATEGORY_QR_MISC, CATEGORY_QR_PLACE, CATEGORY_QR_MEDIA,
CATEGORY_QR_REPOSITORY) CATEGORY_QR_REPOSITORY, CATEGORY_QR_CITATION,
CATEGORY_QR_SOURCE_OR_CITATION)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -52,6 +53,7 @@ class QuickViewGramplet(Gramplet):
self.connect_signal('Event', self._active_changed) self.connect_signal('Event', self._active_changed)
self.connect_signal('Place', self._active_changed) self.connect_signal('Place', self._active_changed)
self.connect_signal('Source', self._active_changed) self.connect_signal('Source', self._active_changed)
self.connect_signal('Citation', self._active_changed)
self.connect_signal('Repository', self._active_changed) self.connect_signal('Repository', self._active_changed)
self.connect_signal('Media', self._active_changed) self.connect_signal('Media', self._active_changed)
self.connect_signal('Note', self._active_changed) self.connect_signal('Note', self._active_changed)
@ -108,6 +110,7 @@ class QuickViewGramplet(Gramplet):
("Place", _("Place")), ("Place", _("Place")),
("Repository", _("Repository")), ("Repository", _("Repository")),
("Source", _("Source")), ("Source", _("Source")),
("Citation", _("Citation")),
]: ]:
type_list.add_item(item[0], item[1]) type_list.add_item(item[0], item[1])
# Add particular lists: # Add particular lists:
@ -129,6 +132,8 @@ class QuickViewGramplet(Gramplet):
"Family": CATEGORY_QR_FAMILY, "Family": CATEGORY_QR_FAMILY,
"Event": CATEGORY_QR_EVENT, "Event": CATEGORY_QR_EVENT,
"Source": CATEGORY_QR_SOURCE, "Source": CATEGORY_QR_SOURCE,
"Citation": CATEGORY_QR_CITATION,
"Source or Citation": CATEGORY_QR_SOURCE_OR_CITATION,
"Place": CATEGORY_QR_PLACE, "Place": CATEGORY_QR_PLACE,
"Media": CATEGORY_QR_MEDIA, "Media": CATEGORY_QR_MEDIA,
"Note": CATEGORY_QR_NOTE, "Note": CATEGORY_QR_NOTE,

View File

@ -41,6 +41,8 @@ def get_ref(db, objclass, handle):
ref = db.get_event_from_handle(handle) ref = db.get_event_from_handle(handle)
elif objclass == 'Source': elif objclass == 'Source':
ref = db.get_source_from_handle(handle) ref = db.get_source_from_handle(handle)
elif objclass == 'Citation':
ref = db.get_citation_from_handle(handle)
elif objclass == 'Place': elif objclass == 'Place':
ref = db.get_place_from_handle(handle) ref = db.get_place_from_handle(handle)
elif objclass == 'Note': elif objclass == 'Note':
@ -83,6 +85,9 @@ run_person = lambda db, doc, obj: run(db, doc, obj, 'person', _("Person"))
run_family = lambda db, doc, obj: run(db, doc, obj, 'family', _("Family")) run_family = lambda db, doc, obj: run(db, doc, obj, 'family', _("Family"))
run_event = lambda db, doc, obj: run(db, doc, obj, 'event', _("Event")) run_event = lambda db, doc, obj: run(db, doc, obj, 'event', _("Event"))
run_source = lambda db, doc, obj: run(db, doc, obj, 'source', _("Source")) run_source = lambda db, doc, obj: run(db, doc, obj, 'source', _("Source"))
run_citation = lambda db, doc, obj: run(db, doc, obj, 'citation', _("Citation"))
run_source_or_citation = lambda db, doc, obj: run(db, doc, obj,
'source or citation', _("Source or Citation"))
run_place = lambda db, doc, obj: run(db, doc, obj, 'place', _("Place")) run_place = lambda db, doc, obj: run(db, doc, obj, 'place', _("Place"))
run_media = lambda db, doc, obj: run(db, doc, obj, 'media', _("Media")) run_media = lambda db, doc, obj: run(db, doc, obj, 'media', _("Media"))
run_note = lambda db, doc, obj: run(db, doc, obj, 'note', _("Note")) run_note = lambda db, doc, obj: run(db, doc, obj, 'note', _("Note"))

View File

@ -202,6 +202,9 @@ refitems = [(CATEGORY_QR_PERSON, 'person', _("Person")),
(CATEGORY_QR_PLACE, 'place', _("Place")), (CATEGORY_QR_PLACE, 'place', _("Place")),
(CATEGORY_QR_MEDIA, 'media', _("Media")), (CATEGORY_QR_MEDIA, 'media', _("Media")),
(CATEGORY_QR_NOTE, 'note', _("Note")), (CATEGORY_QR_NOTE, 'note', _("Note")),
(CATEGORY_QR_CITATION, 'citation', _("Citation")),
(CATEGORY_QR_SOURCE_OR_CITATION, 'source or citation',
_("Source or Citation"))
] ]
for (category, item, trans) in refitems: for (category, item, trans) in refitems:

View File

@ -46,7 +46,7 @@ import gtk
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gui.views.treemodels.citationlistmodel import CitationListModel from gui.views.treemodels.citationlistmodel import CitationListModel
from gen.plug import CATEGORY_QR_SOURCE from gen.plug import CATEGORY_QR_CITATION
import gen.lib import gen.lib
from gui.views.listview import ListView from gui.views.listview import ListView
import Utils import Utils
@ -120,7 +120,7 @@ class CitationListView(ListView):
DEL_MSG = _("Delete the selected citation") DEL_MSG = _("Delete the selected citation")
MERGE_MSG = _("Merge the selected citations") MERGE_MSG = _("Merge the selected citations")
FILTER_TYPE = "Citation" FILTER_TYPE = "Citation"
QR_CATEGORY = CATEGORY_QR_SOURCE QR_CATEGORY = CATEGORY_QR_CITATION
def __init__(self, pdata, dbstate, uistate, nav_group=0): def __init__(self, pdata, dbstate, uistate, nav_group=0):

View File

@ -47,7 +47,7 @@ import gtk
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gui.views.listview import LISTTREE from gui.views.listview import LISTTREE
from gui.views.treemodels.citationtreemodel import CitationTreeModel from gui.views.treemodels.citationtreemodel import CitationTreeModel
from gen.plug import CATEGORY_QR_SOURCE from gen.plug import CATEGORY_QR_SOURCE_OR_CITATION
import gen.lib import gen.lib
from gui.views.listview import ListView from gui.views.listview import ListView
import Utils import Utils
@ -112,7 +112,7 @@ class CitationTreeView(ListView):
DEL_MSG = _("Delete the selected citation or source") DEL_MSG = _("Delete the selected citation or source")
MERGE_MSG = _("Merge the selected citations or selected sources") MERGE_MSG = _("Merge the selected citations or selected sources")
FILTER_TYPE = "Citation" FILTER_TYPE = "Citation"
QR_CATEGORY = CATEGORY_QR_SOURCE QR_CATEGORY = CATEGORY_QR_SOURCE_OR_CITATION
def __init__(self, pdata, dbstate, uistate, nav_group=0): def __init__(self, pdata, dbstate, uistate, nav_group=0):