GEPS 011: Tagging - Extended to Family, Note and Media objects
svn: r16025
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2001-2006 Donald N. Allingham
|
||||
# Copyright (C) 2010 Nick Hall
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -69,7 +70,8 @@ class FamilyView(ListView):
|
||||
COL_MOTHER = 2
|
||||
COL_REL = 3
|
||||
COL_MARDATE = 4
|
||||
COL_CHAN = 5
|
||||
COL_TAGS = 5
|
||||
COL_CHAN = 6
|
||||
# name of the columns
|
||||
COLUMN_NAMES = [
|
||||
_('ID'),
|
||||
@@ -77,6 +79,7 @@ class FamilyView(ListView):
|
||||
_('Mother'),
|
||||
_('Relationship'),
|
||||
_('Marriage Date'),
|
||||
_('Tags'),
|
||||
_('Last Changed'),
|
||||
]
|
||||
#default setting with visible columns, order of the col, and their size
|
||||
@@ -84,8 +87,8 @@ class FamilyView(ListView):
|
||||
('columns.visible', [COL_ID, COL_FATHER, COL_MOTHER, COL_REL,
|
||||
COL_MARDATE]),
|
||||
('columns.rank', [COL_ID, COL_FATHER, COL_MOTHER, COL_REL,
|
||||
COL_MARDATE, COL_CHAN]),
|
||||
('columns.size', [75, 200, 200, 100, 100, 100])
|
||||
COL_MARDATE, COL_TAGS, COL_CHAN]),
|
||||
('columns.size', [75, 200, 200, 100, 100, 100, 100])
|
||||
)
|
||||
|
||||
ADD_MSG = _("Add a new family")
|
||||
@@ -101,6 +104,7 @@ class FamilyView(ListView):
|
||||
'family-update' : self.row_update,
|
||||
'family-delete' : self.row_delete,
|
||||
'family-rebuild' : self.object_build,
|
||||
'tag-update' : self.tag_updated
|
||||
}
|
||||
|
||||
ListView.__init__(
|
||||
@@ -199,6 +203,20 @@ class FamilyView(ListView):
|
||||
])
|
||||
self._add_action_group(self.all_action)
|
||||
|
||||
def set_active(self):
|
||||
"""
|
||||
Called when the page is displayed.
|
||||
"""
|
||||
ListView.set_active(self)
|
||||
self.uistate.viewmanager.tags.tag_enable()
|
||||
|
||||
def set_inactive(self):
|
||||
"""
|
||||
Called when the page is no longer displayed.
|
||||
"""
|
||||
ListView.set_inactive(self)
|
||||
self.uistate.viewmanager.tags.tag_disable()
|
||||
|
||||
def get_bookmarks(self):
|
||||
return self.dbstate.db.get_family_bookmarks()
|
||||
|
||||
@@ -270,3 +288,23 @@ class FamilyView(ListView):
|
||||
Indicate that the drag type is a FAMILY_LINK
|
||||
"""
|
||||
return DdTargets.FAMILY_LINK
|
||||
|
||||
def tag_updated(self, handle_list):
|
||||
"""
|
||||
Update tagged rows when a tag color changes.
|
||||
"""
|
||||
all_links = set([])
|
||||
for tag_handle in handle_list:
|
||||
links = set([link[1] for link in
|
||||
self.dbstate.db.find_backlink_handles(tag_handle,
|
||||
include_classes='Family')])
|
||||
all_links = all_links.union(links)
|
||||
self.row_update(list(all_links))
|
||||
|
||||
def add_tag(self, transaction, family_handle, tag_handle):
|
||||
"""
|
||||
Add the given tag to the given family.
|
||||
"""
|
||||
family = self.dbstate.db.get_family_from_handle(family_handle)
|
||||
family.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_family(family, transaction)
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#
|
||||
# Copyright (C) 2001-2006 Donald N. Allingham
|
||||
# Copyright (C) 2008 Gary Burton
|
||||
# Copyright (C) 2010 Nick Hall
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -82,24 +83,26 @@ class MediaView(ListView):
|
||||
COL_ID = 1
|
||||
COL_TYPE = 2
|
||||
COL_PATH = 3
|
||||
COL_CHAN = 4
|
||||
COL_DATE = 5
|
||||
COL_DATE = 4
|
||||
COL_TAGS = 5
|
||||
COL_CHAN = 6
|
||||
#name of the columns
|
||||
COLUMN_NAMES = [
|
||||
_('Title'),
|
||||
_('ID'),
|
||||
_('Type'),
|
||||
_('Path'),
|
||||
_('Last Changed'),
|
||||
_('Date'),
|
||||
_('Tags'),
|
||||
_('Last Changed'),
|
||||
]
|
||||
# default setting with visible columns, order of the col, and their size
|
||||
CONFIGSETTINGS = (
|
||||
('columns.visible', [COL_TITLE, COL_ID, COL_TYPE, COL_PATH,
|
||||
COL_DATE]),
|
||||
('columns.rank', [COL_TITLE, COL_ID, COL_TYPE, COL_PATH,
|
||||
COL_DATE, COL_CHAN]),
|
||||
('columns.size', [200, 75, 100, 200, 150, 150])
|
||||
COL_DATE, COL_TAGS, COL_CHAN]),
|
||||
('columns.size', [200, 75, 100, 200, 150, 100, 150])
|
||||
)
|
||||
|
||||
ADD_MSG = _("Add a new media object")
|
||||
@@ -117,6 +120,7 @@ class MediaView(ListView):
|
||||
'media-update' : self.row_update,
|
||||
'media-delete' : self.row_delete,
|
||||
'media-rebuild' : self.object_build,
|
||||
'tag-update' : self.tag_updated
|
||||
}
|
||||
|
||||
ListView.__init__(
|
||||
@@ -236,6 +240,20 @@ class MediaView(ListView):
|
||||
self._add_action('QuickReport', None, _("Quick View"), None, None, None)
|
||||
self._add_action('Dummy', None, ' ', None, None, self.dummy_report)
|
||||
|
||||
def set_active(self):
|
||||
"""
|
||||
Called when the page is displayed.
|
||||
"""
|
||||
ListView.set_active(self)
|
||||
self.uistate.viewmanager.tags.tag_enable()
|
||||
|
||||
def set_inactive(self):
|
||||
"""
|
||||
Called when the page is no longer displayed.
|
||||
"""
|
||||
ListView.set_inactive(self)
|
||||
self.uistate.viewmanager.tags.tag_disable()
|
||||
|
||||
def view_media(self, obj):
|
||||
"""
|
||||
Launch external viewers for the selected objects.
|
||||
@@ -451,3 +469,23 @@ class MediaView(ListView):
|
||||
return obj.get_handle()
|
||||
else:
|
||||
return None
|
||||
|
||||
def tag_updated(self, handle_list):
|
||||
"""
|
||||
Update tagged rows when a tag color changes.
|
||||
"""
|
||||
all_links = set([])
|
||||
for tag_handle in handle_list:
|
||||
links = set([link[1] for link in
|
||||
self.dbstate.db.find_backlink_handles(tag_handle,
|
||||
include_classes='MediaObject')])
|
||||
all_links = all_links.union(links)
|
||||
self.row_update(list(all_links))
|
||||
|
||||
def add_tag(self, transaction, media_handle, tag_handle):
|
||||
"""
|
||||
Add the given tag to the given media object.
|
||||
"""
|
||||
media = self.dbstate.db.get_object_from_handle(media_handle)
|
||||
media.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_media_object(media, transaction)
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#
|
||||
# Copyright (C) 2001-2006 Donald N. Allingham
|
||||
# Copyright (C) 2008 Gary Burton
|
||||
# Copyright (C) 2010 Nick Hall
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -69,21 +70,20 @@ class NoteView(ListView):
|
||||
COL_PREVIEW = 0
|
||||
COL_ID = 1
|
||||
COL_TYPE = 2
|
||||
COL_MARKER = 3
|
||||
COL_TAGS = 3
|
||||
COL_CHAN = 4
|
||||
|
||||
COLUMN_NAMES = [
|
||||
_('Preview'),
|
||||
_('ID'),
|
||||
_('Type'),
|
||||
_('Marker'),
|
||||
_('Tags'),
|
||||
_('Last Changed')
|
||||
]
|
||||
# default setting with visible columns, order of the col, and their size
|
||||
CONFIGSETTINGS = (
|
||||
('columns.visible', [COL_PREVIEW, COL_ID, COL_TYPE, COL_MARKER]),
|
||||
('columns.rank', [COL_PREVIEW, COL_ID, COL_TYPE, COL_MARKER,
|
||||
COL_CHAN]),
|
||||
('columns.visible', [COL_PREVIEW, COL_ID, COL_TYPE]),
|
||||
('columns.rank', [COL_PREVIEW, COL_ID, COL_TYPE, COL_TAGS, COL_CHAN]),
|
||||
('columns.size', [350, 75, 100, 100, 100]))
|
||||
|
||||
ADD_MSG = _("Add a new note")
|
||||
@@ -99,6 +99,7 @@ class NoteView(ListView):
|
||||
'note-update' : self.row_update,
|
||||
'note-delete' : self.row_delete,
|
||||
'note-rebuild' : self.object_build,
|
||||
'tag-update' : self.tag_updated
|
||||
}
|
||||
|
||||
ListView.__init__(
|
||||
@@ -213,6 +214,20 @@ class NoteView(ListView):
|
||||
self._add_action('QuickReport', None, _("Quick View"), None, None, None)
|
||||
self._add_action('Dummy', None, ' ', None, None, self.dummy_report)
|
||||
|
||||
def set_active(self):
|
||||
"""
|
||||
Called when the page is displayed.
|
||||
"""
|
||||
ListView.set_active(self)
|
||||
self.uistate.viewmanager.tags.tag_enable()
|
||||
|
||||
def set_inactive(self):
|
||||
"""
|
||||
Called when the page is no longer displayed.
|
||||
"""
|
||||
ListView.set_inactive(self)
|
||||
self.uistate.viewmanager.tags.tag_disable()
|
||||
|
||||
def get_handle_from_gramps_id(self, gid):
|
||||
obj = self.dbstate.db.get_note_from_gramps_id(gid)
|
||||
if obj:
|
||||
@@ -259,3 +274,23 @@ class NoteView(ListView):
|
||||
else:
|
||||
import Merge
|
||||
Merge.MergeNotes(self.dbstate, self.uistate, mlist[0], mlist[1])
|
||||
|
||||
def tag_updated(self, handle_list):
|
||||
"""
|
||||
Update tagged rows when a tag color changes.
|
||||
"""
|
||||
all_links = set([])
|
||||
for tag_handle in handle_list:
|
||||
links = set([link[1] for link in
|
||||
self.dbstate.db.find_backlink_handles(tag_handle,
|
||||
include_classes='Note')])
|
||||
all_links = all_links.union(links)
|
||||
self.row_update(list(all_links))
|
||||
|
||||
def add_tag(self, transaction, note_handle, tag_handle):
|
||||
"""
|
||||
Add the given tag to the given note.
|
||||
"""
|
||||
note = self.dbstate.db.get_note_from_handle(note_handle)
|
||||
note.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_note(note, transaction)
|
||||
|
Reference in New Issue
Block a user