Enabled Quickviews on all list views; enabled References Quickview for all views
svn: r13947
This commit is contained in:
parent
fa1413c640
commit
205b3beadd
@ -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_PLACE, CATEGORY_QR_REPOSITORY)
|
||||
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE)
|
||||
from gui.pluginmanager import GuiPluginManager
|
||||
|
||||
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
|
||||
It collects the reports of the requested category, which must be one of
|
||||
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
|
||||
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
|
||||
@ -112,7 +112,7 @@ def get_quick_report_list(qv_category=None):
|
||||
Returns a list of PluginData of quick views of category qv_category
|
||||
CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT,
|
||||
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 = []
|
||||
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)
|
||||
elif category == CATEGORY_QR_PLACE :
|
||||
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 :
|
||||
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:
|
||||
obj = handle
|
||||
else:
|
||||
|
@ -29,7 +29,7 @@ from _pluginreg import (PluginData, PluginRegister, REPORT, TOOL,
|
||||
TOOL_UTILS, CATEGORY_QR_MISC, CATEGORY_QR_PERSON,
|
||||
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
|
||||
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE,
|
||||
CATEGORY_QR_DATE, PTYPE_STR,
|
||||
CATEGORY_QR_DATE, PTYPE_STR, CATEGORY_QR_MEDIA,
|
||||
START, END
|
||||
)
|
||||
from _manager import BasePluginManager
|
||||
@ -48,5 +48,5 @@ __all__ = [ "docbackend", "docgen", "menu", Plugin, PluginData,
|
||||
TOOL_UTILS, CATEGORY_QR_MISC, CATEGORY_QR_PERSON,
|
||||
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
|
||||
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE,
|
||||
CATEGORY_QR_DATE, PTYPE_STR,
|
||||
CATEGORY_QR_DATE, PTYPE_STR, CATEGORY_QR_MEDIA,
|
||||
START, END]
|
||||
|
@ -112,6 +112,7 @@ CATEGORY_QR_PLACE = 4
|
||||
CATEGORY_QR_REPOSITORY = 5
|
||||
CATEGORY_QR_NOTE = 6
|
||||
CATEGORY_QR_DATE = 7
|
||||
CATEGORY_QR_MEDIA = 8
|
||||
|
||||
# Modes for generating reports
|
||||
REPORT_MODE_GUI = 1 # Standalone report using GUI
|
||||
@ -855,6 +856,7 @@ class PluginRegister(object):
|
||||
'CATEGORY_QR_EVENT': CATEGORY_QR_EVENT,
|
||||
'CATEGORY_QR_SOURCE': CATEGORY_QR_SOURCE,
|
||||
'CATEGORY_QR_PLACE': CATEGORY_QR_PLACE,
|
||||
'CATEGORY_QR_MEDIA': CATEGORY_QR_MEDIA,
|
||||
'CATEGORY_QR_REPOSITORY': CATEGORY_QR_REPOSITORY,
|
||||
'CATEGORY_QR_NOTE': CATEGORY_QR_NOTE,
|
||||
'CATEGORY_QR_DATE': CATEGORY_QR_DATE,
|
||||
|
@ -54,6 +54,7 @@ from gui.pluginmanager import GuiPluginManager
|
||||
from DdTargets import DdTargets
|
||||
from gui.editors import EditPlace, DeletePlaceQuery
|
||||
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")
|
||||
DEL_MSG = _("Delete the selected place")
|
||||
FILTER_TYPE = "Place"
|
||||
QR_CATEGORY = CATEGORY_QR_PLACE
|
||||
|
||||
def __init__(self, dbstate, uistate, title, model):
|
||||
|
||||
@ -143,6 +145,8 @@ class PlaceBaseView(ListView):
|
||||
"Service (OpenstreetMap, Google Maps, ...)"))
|
||||
self._add_action('FilterEdit', None, _('Place 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):
|
||||
"""
|
||||
@ -317,9 +321,20 @@ class PlaceBaseView(ListView):
|
||||
<menuitem action="Edit"/>
|
||||
<menuitem action="Remove"/>
|
||||
<menuitem action="GotoMap"/>
|
||||
<separator/>
|
||||
<menu name="QuickReport" action="QuickReport">
|
||||
<menuitem action="Dummy"/>
|
||||
</menu>
|
||||
</popup>
|
||||
</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):
|
||||
try:
|
||||
EditPlace(self.dbstate, self.uistate, [], gen.lib.Place())
|
||||
|
@ -35,7 +35,7 @@ from TransUtils import sgettext as _
|
||||
from QuickReports import run_quick_report_by_name, get_quick_report_list
|
||||
from gen.plug import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY,
|
||||
CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
|
||||
CATEGORY_QR_MISC, CATEGORY_QR_PLACE,
|
||||
CATEGORY_QR_MISC, CATEGORY_QR_PLACE, CATEGORY_QR_MEDIA,
|
||||
CATEGORY_QR_REPOSITORY)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@ -62,23 +62,33 @@ class QuickViewGramplet(Gramplet):
|
||||
container=self.gui.textview)
|
||||
else:
|
||||
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
|
||||
quick_type == CATEGORY_QR_FAMILY):
|
||||
active_list = item.selected_handles()
|
||||
active_list += item.selected_handles()
|
||||
elif (item.get_title() == _("Events") and
|
||||
quick_type == CATEGORY_QR_EVENT):
|
||||
active_list = item.selected_handles()
|
||||
active_list += item.selected_handles()
|
||||
elif (item.get_title() == _("Sources") and
|
||||
quick_type == CATEGORY_QR_SOURCE):
|
||||
active_list = item.selected_handles()
|
||||
active_list += item.selected_handles()
|
||||
elif (item.get_title() == _("Places") and
|
||||
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
|
||||
quick_type == CATEGORY_QR_REPOSITORY):
|
||||
active_list = item.selected_handles()
|
||||
if len(active_list) > 0:
|
||||
active_list += item.selected_handles()
|
||||
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,
|
||||
self.gui.uistate,
|
||||
quick_view,
|
||||
@ -91,11 +101,12 @@ class QuickViewGramplet(Gramplet):
|
||||
type_list = EnumeratedListOption(_("View Type"), CATEGORY_QR_PERSON)
|
||||
for item in [(CATEGORY_QR_PERSON, _("Person")),
|
||||
#TODO: add these once they have active change signals
|
||||
#(CATEGORY_QR_FAMILY, _("Family")),
|
||||
#(CATEGORY_QR_EVENT, _("Event")),
|
||||
#(CATEGORY_QR_SOURCE, _("Source")),
|
||||
#(CATEGORY_QR_PLACE, _("Place")),
|
||||
#(CATEGORY_QR_REPOSITORY, _("Repository")),
|
||||
(CATEGORY_QR_EVENT, _("Event")),
|
||||
(CATEGORY_QR_FAMILY, _("Family")),
|
||||
(CATEGORY_QR_MEDIA, _("Media")),
|
||||
(CATEGORY_QR_PLACE, _("Place")),
|
||||
(CATEGORY_QR_REPOSITORY, _("Repository")),
|
||||
(CATEGORY_QR_SOURCE, _("Source")),
|
||||
]:
|
||||
type_list.add_item(item[0], item[1])
|
||||
# Add particular lists:
|
||||
|
@ -43,6 +43,10 @@ def get_ref(db, objclass, handle):
|
||||
ref = db.get_source_from_handle(handle)
|
||||
elif objclass == 'Place':
|
||||
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:
|
||||
ref = objclass
|
||||
return ref
|
||||
@ -61,7 +65,6 @@ def run(database, document, object, item, trans):
|
||||
sdoc.title(_("References for this %s") % trans)
|
||||
sdoc.paragraph("\n")
|
||||
stab.columns(_("Type"), _("Reference"))
|
||||
|
||||
for (objclass, handle) in database.find_backlink_handles(object.handle):
|
||||
ref = get_ref(database, objclass, handle)
|
||||
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_source = lambda db, doc, obj: run(db, doc, obj, 'source', _("Source"))
|
||||
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"))
|
||||
|
@ -191,6 +191,8 @@ refitems = [(CATEGORY_QR_PERSON, 'person', _("Person")),
|
||||
(CATEGORY_QR_EVENT, 'event', _("Event")),
|
||||
(CATEGORY_QR_SOURCE, 'source', _("Source")),
|
||||
(CATEGORY_QR_PLACE, 'place', _("Place")),
|
||||
(CATEGORY_QR_MEDIA, 'media', _("Media")),
|
||||
(CATEGORY_QR_NOTE, 'note', _("Note")),
|
||||
]
|
||||
|
||||
for (category, item, trans) in refitems:
|
||||
|
@ -60,7 +60,7 @@ from gui.editors import EditMedia, DeleteMediaQuery
|
||||
import Errors
|
||||
from Filters.SideBar import MediaSidebarFilter
|
||||
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")
|
||||
DEL_MSG = _("Delete the selected media object")
|
||||
FILTER_TYPE = 'MediaObject'
|
||||
QR_CATEGORY = CATEGORY_QR_MEDIA
|
||||
|
||||
_DND_TYPE = DdTargets.URI_LIST
|
||||
|
||||
@ -226,6 +227,9 @@ class MediaView(ListView):
|
||||
tip=_("Open the folder containing the media file"),
|
||||
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):
|
||||
"""
|
||||
Launch external viewers for the selected objects.
|
||||
@ -372,9 +376,20 @@ class MediaView(ListView):
|
||||
<menuitem action="Add"/>
|
||||
<menuitem action="Edit"/>
|
||||
<menuitem action="Remove"/>
|
||||
<separator/>
|
||||
<menu name="QuickReport" action="QuickReport">
|
||||
<menuitem action="Dummy"/>
|
||||
</menu>
|
||||
</popup>
|
||||
</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):
|
||||
"""Add a new media object to the media list"""
|
||||
try:
|
||||
|
@ -55,6 +55,7 @@ from gen.lib import Note
|
||||
from DdTargets import DdTargets
|
||||
from Filters.SideBar import NoteSidebarFilter
|
||||
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")
|
||||
DEL_MSG = _("Delete the selected note")
|
||||
FILTER_TYPE = "Note"
|
||||
QR_CATEGORY = CATEGORY_QR_NOTE
|
||||
|
||||
def __init__(self, dbstate, uistate):
|
||||
|
||||
@ -165,15 +167,28 @@ class NoteView(ListView):
|
||||
<menuitem action="Add"/>
|
||||
<menuitem action="Edit"/>
|
||||
<menuitem action="Remove"/>
|
||||
<separator/>
|
||||
<menu name="QuickReport" action="QuickReport">
|
||||
<menuitem action="Dummy"/>
|
||||
</menu>
|
||||
</popup>
|
||||
</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):
|
||||
ListView.define_actions(self)
|
||||
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
|
||||
_('_Column Editor'), callback=self._column_editor)
|
||||
self._add_action('FilterEdit', None, _('Note 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):
|
||||
obj = self.dbstate.db.get_note_from_gramps_id(gid)
|
||||
|
@ -47,6 +47,7 @@ from DdTargets import DdTargets
|
||||
from QuestionDialog import ErrorDialog
|
||||
from gui.editors import EditSource, DeleteSrcQuery
|
||||
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")
|
||||
DEL_MSG = _("Delete the selected source")
|
||||
FILTER_TYPE = "Source"
|
||||
QR_CATEGORY = CATEGORY_QR_SOURCE
|
||||
|
||||
def __init__(self, dbstate, uistate):
|
||||
|
||||
@ -119,6 +121,8 @@ class SourceView(ListView):
|
||||
callback=self.fast_merge)
|
||||
self._add_action('FilterEdit', None, _('Source 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):
|
||||
import ColumnOrder
|
||||
@ -174,9 +178,20 @@ class SourceView(ListView):
|
||||
<menuitem action="Add"/>
|
||||
<menuitem action="Edit"/>
|
||||
<menuitem action="Remove"/>
|
||||
<separator/>
|
||||
<menu name="QuickReport" action="QuickReport">
|
||||
<menuitem action="Dummy"/>
|
||||
</menu>
|
||||
</popup>
|
||||
</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):
|
||||
EditSource(self.dbstate, self.uistate, [], gen.lib.Source())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user