Enabled Quickviews on all list views; enabled References Quickview for all views

svn: r13947
This commit is contained in:
Doug Blank 2009-12-31 14:59:44 +00:00
parent fa1413c640
commit 205b3beadd
10 changed files with 121 additions and 37 deletions

View File

@ -54,9 +54,9 @@ import gtk
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gen.plug import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, 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)
from gui.pluginmanager import GuiPluginManager from gui.pluginmanager import GuiPluginManager
def create_quickreport_menu(category,dbstate,uistate, handle) : def create_quickreport_menu(category,dbstate,uistate, handle) :
@ -64,7 +64,7 @@ def create_quickreport_menu(category,dbstate,uistate, handle) :
quick_report_list of _PluginMgr.py quick_report_list of _PluginMgr.py
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_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_MEDIA,
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY
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
@ -112,7 +112,7 @@ 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 or None for all CATEGORY_QR_REPOSITORY, CATEGORY_QR_MEDIA or None for all
""" """
names = [] names = []
pmgr = GuiPluginManager.get_instance() pmgr = GuiPluginManager.get_instance()
@ -202,8 +202,12 @@ def run_report(dbstate, uistate, category, handle, pdata, container=None,
obj = dbstate.db.get_source_from_handle(handle) obj = dbstate.db.get_source_from_handle(handle)
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 :
obj = dbstate.db.get_object_from_handle(handle)
elif category == CATEGORY_QR_REPOSITORY : elif category == CATEGORY_QR_REPOSITORY :
obj = dbstate.db.get_repository_from_handle(handle) obj = dbstate.db.get_repository_from_handle(handle)
elif category == CATEGORY_QR_NOTE :
obj = dbstate.db.get_note_from_handle(handle)
elif category == CATEGORY_QR_MISC: elif category == CATEGORY_QR_MISC:
obj = handle obj = handle
else: else:

View File

@ -29,7 +29,7 @@ from _pluginreg import (PluginData, PluginRegister, REPORT, TOOL,
TOOL_UTILS, CATEGORY_QR_MISC, CATEGORY_QR_PERSON, TOOL_UTILS, CATEGORY_QR_MISC, CATEGORY_QR_PERSON,
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_DATE, PTYPE_STR, CATEGORY_QR_MEDIA,
START, END START, END
) )
from _manager import BasePluginManager from _manager import BasePluginManager
@ -48,5 +48,5 @@ __all__ = [ "docbackend", "docgen", "menu", Plugin, PluginData,
TOOL_UTILS, CATEGORY_QR_MISC, CATEGORY_QR_PERSON, TOOL_UTILS, CATEGORY_QR_MISC, CATEGORY_QR_PERSON,
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_DATE, PTYPE_STR, CATEGORY_QR_MEDIA,
START, END] START, END]

View File

@ -112,6 +112,7 @@ CATEGORY_QR_PLACE = 4
CATEGORY_QR_REPOSITORY = 5 CATEGORY_QR_REPOSITORY = 5
CATEGORY_QR_NOTE = 6 CATEGORY_QR_NOTE = 6
CATEGORY_QR_DATE = 7 CATEGORY_QR_DATE = 7
CATEGORY_QR_MEDIA = 8
# Modes for generating reports # Modes for generating reports
REPORT_MODE_GUI = 1 # Standalone report using GUI REPORT_MODE_GUI = 1 # Standalone report using GUI
@ -855,6 +856,7 @@ class PluginRegister(object):
'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_PLACE': CATEGORY_QR_PLACE, 'CATEGORY_QR_PLACE': CATEGORY_QR_PLACE,
'CATEGORY_QR_MEDIA': CATEGORY_QR_MEDIA,
'CATEGORY_QR_REPOSITORY': CATEGORY_QR_REPOSITORY, 'CATEGORY_QR_REPOSITORY': CATEGORY_QR_REPOSITORY,
'CATEGORY_QR_NOTE': CATEGORY_QR_NOTE, 'CATEGORY_QR_NOTE': CATEGORY_QR_NOTE,
'CATEGORY_QR_DATE': CATEGORY_QR_DATE, 'CATEGORY_QR_DATE': CATEGORY_QR_DATE,

View File

@ -54,6 +54,7 @@ from gui.pluginmanager import GuiPluginManager
from DdTargets import DdTargets from DdTargets import DdTargets
from gui.editors import EditPlace, DeletePlaceQuery from gui.editors import EditPlace, DeletePlaceQuery
from Filters.SideBar import PlaceSidebarFilter from Filters.SideBar import PlaceSidebarFilter
from gen.plug import CATEGORY_QR_PLACE
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -89,6 +90,7 @@ class PlaceBaseView(ListView):
EDIT_MSG = _("Edit the selected place") EDIT_MSG = _("Edit the selected place")
DEL_MSG = _("Delete the selected place") DEL_MSG = _("Delete the selected place")
FILTER_TYPE = "Place" FILTER_TYPE = "Place"
QR_CATEGORY = CATEGORY_QR_PLACE
def __init__(self, dbstate, uistate, title, model): def __init__(self, dbstate, uistate, title, model):
@ -143,6 +145,8 @@ class PlaceBaseView(ListView):
"Service (OpenstreetMap, Google Maps, ...)")) "Service (OpenstreetMap, Google Maps, ...)"))
self._add_action('FilterEdit', None, _('Place Filter Editor'), self._add_action('FilterEdit', None, _('Place Filter Editor'),
callback=self.filter_editor) callback=self.filter_editor)
self._add_action('QuickReport', None, _("Quick View"), None, None, None)
self._add_action('Dummy', None, ' ', None, None, self.dummy_report)
def change_page(self): def change_page(self):
""" """
@ -317,9 +321,20 @@ class PlaceBaseView(ListView):
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
<menuitem action="GotoMap"/> <menuitem action="GotoMap"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
</popup> </popup>
</ui>''' </ui>'''
def dummy_report(self, obj):
""" For the xml UI definition of popup to work, the submenu
Quick Report must have an entry in the xml
As this submenu will be dynamically built, we offer a dummy action
"""
pass
def add(self, obj): def add(self, obj):
try: try:
EditPlace(self.dbstate, self.uistate, [], gen.lib.Place()) EditPlace(self.dbstate, self.uistate, [], gen.lib.Place())

View File

@ -35,7 +35,7 @@ from TransUtils import sgettext as _
from QuickReports import run_quick_report_by_name, get_quick_report_list 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_EVENT, CATEGORY_QR_SOURCE,
CATEGORY_QR_MISC, CATEGORY_QR_PLACE, CATEGORY_QR_MISC, CATEGORY_QR_PLACE, CATEGORY_QR_MEDIA,
CATEGORY_QR_REPOSITORY) CATEGORY_QR_REPOSITORY)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -62,23 +62,33 @@ class QuickViewGramplet(Gramplet):
container=self.gui.textview) container=self.gui.textview)
else: else:
active_list = [] active_list = []
for item in self.gui.uistate.viewmanager.pages: for pages in self.gui.uistate.viewmanager.pages:
for item in pages:
if (item.get_title() == _("Families") and if (item.get_title() == _("Families") and
quick_type == CATEGORY_QR_FAMILY): quick_type == CATEGORY_QR_FAMILY):
active_list = item.selected_handles() active_list += item.selected_handles()
elif (item.get_title() == _("Events") and elif (item.get_title() == _("Events") and
quick_type == CATEGORY_QR_EVENT): quick_type == CATEGORY_QR_EVENT):
active_list = item.selected_handles() active_list += item.selected_handles()
elif (item.get_title() == _("Sources") and elif (item.get_title() == _("Sources") and
quick_type == CATEGORY_QR_SOURCE): quick_type == CATEGORY_QR_SOURCE):
active_list = item.selected_handles() active_list += item.selected_handles()
elif (item.get_title() == _("Places") and elif (item.get_title() == _("Places") and
quick_type == CATEGORY_QR_PLACE): quick_type == CATEGORY_QR_PLACE):
active_list = item.selected_handles() active_list += item.selected_handles()
elif (item.get_title() == _("Media") and
quick_type == CATEGORY_QR_MEDIA):
active_list += item.selected_handles()
elif (item.get_title() == _("Repositories") and elif (item.get_title() == _("Repositories") and
quick_type == CATEGORY_QR_REPOSITORY): quick_type == CATEGORY_QR_REPOSITORY):
active_list = item.selected_handles() active_list += item.selected_handles()
if len(active_list) > 0: if len(active_list) > 1:
for active in active_list:
run_quick_report_by_name(self.gui.dbstate,
self.gui.uistate,
quick_view,
active)
elif len(active_list) == 1:
run_quick_report_by_name(self.gui.dbstate, run_quick_report_by_name(self.gui.dbstate,
self.gui.uistate, self.gui.uistate,
quick_view, quick_view,
@ -91,11 +101,12 @@ class QuickViewGramplet(Gramplet):
type_list = EnumeratedListOption(_("View Type"), CATEGORY_QR_PERSON) type_list = EnumeratedListOption(_("View Type"), CATEGORY_QR_PERSON)
for item in [(CATEGORY_QR_PERSON, _("Person")), for item in [(CATEGORY_QR_PERSON, _("Person")),
#TODO: add these once they have active change signals #TODO: add these once they have active change signals
#(CATEGORY_QR_FAMILY, _("Family")), (CATEGORY_QR_EVENT, _("Event")),
#(CATEGORY_QR_EVENT, _("Event")), (CATEGORY_QR_FAMILY, _("Family")),
#(CATEGORY_QR_SOURCE, _("Source")), (CATEGORY_QR_MEDIA, _("Media")),
#(CATEGORY_QR_PLACE, _("Place")), (CATEGORY_QR_PLACE, _("Place")),
#(CATEGORY_QR_REPOSITORY, _("Repository")), (CATEGORY_QR_REPOSITORY, _("Repository")),
(CATEGORY_QR_SOURCE, _("Source")),
]: ]:
type_list.add_item(item[0], item[1]) type_list.add_item(item[0], item[1])
# Add particular lists: # Add particular lists:

View File

@ -43,6 +43,10 @@ def get_ref(db, objclass, handle):
ref = db.get_source_from_handle(handle) ref = db.get_source_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':
ref = db.get_note_from_handle(handle)
elif objclass in ['MediaObject', 'Media']:
ref = db.get_object_from_handle(handle)
else: else:
ref = objclass ref = objclass
return ref return ref
@ -61,7 +65,6 @@ def run(database, document, object, item, trans):
sdoc.title(_("References for this %s") % trans) sdoc.title(_("References for this %s") % trans)
sdoc.paragraph("\n") sdoc.paragraph("\n")
stab.columns(_("Type"), _("Reference")) stab.columns(_("Type"), _("Reference"))
for (objclass, handle) in database.find_backlink_handles(object.handle): for (objclass, handle) in database.find_backlink_handles(object.handle):
ref = get_ref(database, objclass, handle) ref = get_ref(database, objclass, handle)
stab.row(_(objclass), ref) # translation are explicit (above) stab.row(_(objclass), ref) # translation are explicit (above)
@ -79,3 +82,5 @@ 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_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_note = lambda db, doc, obj: run(db, doc, obj, 'note', _("Note"))

View File

@ -191,6 +191,8 @@ refitems = [(CATEGORY_QR_PERSON, 'person', _("Person")),
(CATEGORY_QR_EVENT, 'event', _("Event")), (CATEGORY_QR_EVENT, 'event', _("Event")),
(CATEGORY_QR_SOURCE, 'source', _("Source")), (CATEGORY_QR_SOURCE, 'source', _("Source")),
(CATEGORY_QR_PLACE, 'place', _("Place")), (CATEGORY_QR_PLACE, 'place', _("Place")),
(CATEGORY_QR_MEDIA, 'media', _("Media")),
(CATEGORY_QR_NOTE, 'note', _("Note")),
] ]
for (category, item, trans) in refitems: for (category, item, trans) in refitems:

View File

@ -60,7 +60,7 @@ from gui.editors import EditMedia, DeleteMediaQuery
import Errors import Errors
from Filters.SideBar import MediaSidebarFilter from Filters.SideBar import MediaSidebarFilter
from DdTargets import DdTargets from DdTargets import DdTargets
from gen.plug import CATEGORY_QR_MEDIA
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -89,6 +89,7 @@ class MediaView(ListView):
EDIT_MSG = _("Edit the selected media object") EDIT_MSG = _("Edit the selected media object")
DEL_MSG = _("Delete the selected media object") DEL_MSG = _("Delete the selected media object")
FILTER_TYPE = 'MediaObject' FILTER_TYPE = 'MediaObject'
QR_CATEGORY = CATEGORY_QR_MEDIA
_DND_TYPE = DdTargets.URI_LIST _DND_TYPE = DdTargets.URI_LIST
@ -226,6 +227,9 @@ class MediaView(ListView):
tip=_("Open the folder containing the media file"), tip=_("Open the folder containing the media file"),
callback=self.open_containing_folder) callback=self.open_containing_folder)
self._add_action('QuickReport', None, _("Quick View"), None, None, None)
self._add_action('Dummy', None, ' ', None, None, self.dummy_report)
def view_media(self, obj): def view_media(self, obj):
""" """
Launch external viewers for the selected objects. Launch external viewers for the selected objects.
@ -372,9 +376,20 @@ class MediaView(ListView):
<menuitem action="Add"/> <menuitem action="Add"/>
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
</popup> </popup>
</ui>''' </ui>'''
def dummy_report(self, obj):
""" For the xml UI definition of popup to work, the submenu
Quick Report must have an entry in the xml
As this submenu will be dynamically built, we offer a dummy action
"""
pass
def add(self, obj): def add(self, obj):
"""Add a new media object to the media list""" """Add a new media object to the media list"""
try: try:

View File

@ -55,6 +55,7 @@ from gen.lib import Note
from DdTargets import DdTargets from DdTargets import DdTargets
from Filters.SideBar import NoteSidebarFilter from Filters.SideBar import NoteSidebarFilter
from gui.editors import EditNote, DeleteNoteQuery from gui.editors import EditNote, DeleteNoteQuery
from gen.plug import CATEGORY_QR_NOTE
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -74,6 +75,7 @@ class NoteView(ListView):
EDIT_MSG = _("Edit the selected note") EDIT_MSG = _("Edit the selected note")
DEL_MSG = _("Delete the selected note") DEL_MSG = _("Delete the selected note")
FILTER_TYPE = "Note" FILTER_TYPE = "Note"
QR_CATEGORY = CATEGORY_QR_NOTE
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate):
@ -165,15 +167,28 @@ class NoteView(ListView):
<menuitem action="Add"/> <menuitem action="Add"/>
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
</popup> </popup>
</ui>''' </ui>'''
def dummy_report(self, obj):
""" For the xml UI definition of popup to work, the submenu
Quick Report must have an entry in the xml
As this submenu will be dynamically built, we offer a dummy action
"""
pass
def define_actions(self): def define_actions(self):
ListView.define_actions(self) ListView.define_actions(self)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES, self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor) _('_Column Editor'), callback=self._column_editor)
self._add_action('FilterEdit', None, _('Note Filter Editor'), self._add_action('FilterEdit', None, _('Note Filter Editor'),
callback=self.filter_editor,) callback=self.filter_editor,)
self._add_action('QuickReport', None, _("Quick View"), None, None, None)
self._add_action('Dummy', None, ' ', None, None, self.dummy_report)
def get_handle_from_gramps_id(self, gid): def get_handle_from_gramps_id(self, gid):
obj = self.dbstate.db.get_note_from_gramps_id(gid) obj = self.dbstate.db.get_note_from_gramps_id(gid)

View File

@ -47,6 +47,7 @@ from DdTargets import DdTargets
from QuestionDialog import ErrorDialog from QuestionDialog import ErrorDialog
from gui.editors import EditSource, DeleteSrcQuery from gui.editors import EditSource, DeleteSrcQuery
from Filters.SideBar import SourceSidebarFilter from Filters.SideBar import SourceSidebarFilter
from gen.plug import CATEGORY_QR_SOURCE
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -76,6 +77,7 @@ class SourceView(ListView):
EDIT_MSG = _("Edit the selected source") EDIT_MSG = _("Edit the selected source")
DEL_MSG = _("Delete the selected source") DEL_MSG = _("Delete the selected source")
FILTER_TYPE = "Source" FILTER_TYPE = "Source"
QR_CATEGORY = CATEGORY_QR_SOURCE
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate):
@ -119,6 +121,8 @@ class SourceView(ListView):
callback=self.fast_merge) callback=self.fast_merge)
self._add_action('FilterEdit', None, _('Source Filter Editor'), self._add_action('FilterEdit', None, _('Source Filter Editor'),
callback=self.filter_editor,) callback=self.filter_editor,)
self._add_action('QuickReport', None, _("Quick View"), None, None, None)
self._add_action('Dummy', None, ' ', None, None, self.dummy_report)
def _column_editor(self, obj): def _column_editor(self, obj):
import ColumnOrder import ColumnOrder
@ -174,9 +178,20 @@ class SourceView(ListView):
<menuitem action="Add"/> <menuitem action="Add"/>
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
<separator/>
<menu name="QuickReport" action="QuickReport">
<menuitem action="Dummy"/>
</menu>
</popup> </popup>
</ui>''' </ui>'''
def dummy_report(self, obj):
""" For the xml UI definition of popup to work, the submenu
Quick Report must have an entry in the xml
As this submenu will be dynamically built, we offer a dummy action
"""
pass
def add(self, obj): def add(self, obj):
EditSource(self.dbstate, self.uistate, [], gen.lib.Source()) EditSource(self.dbstate, self.uistate, [], gen.lib.Source())