Add source icon to editor dialogs

Implements #11372.
This commit is contained in:
prismatisch 2019-10-01 15:10:25 +02:00 committed by Nick Hall
parent 557c1c724a
commit 990d4ed1b2
16 changed files with 57 additions and 39 deletions

View File

@ -135,6 +135,15 @@ class CitationBase:
"""
return self.citation_list
def has_citations(self):
"""
Return True if citations exist for this object.
:returns: Returns whether citations exist for this object.
:rtype: bool
"""
return bool(self.get_citation_list())
def get_all_citation_lists(self):
"""
Return the list of :class:`~.citation.Citation` handles associated with

View File

@ -54,7 +54,7 @@ class AddrEmbedList(EmbeddedList):
Derives from the EmbeddedList class.
"""
_HANDLE_COL = 9
_HANDLE_COL = 10
_DND_TYPE = DdTargets.ADDRESS
_MSG = {
@ -76,7 +76,8 @@ class AddrEmbedList(EmbeddedList):
(_('Country'), 5, 75, TEXT_COL, -1, None),
(_("Postal"), 6, 75, TEXT_COL, -1, None),
(_("Phone"), 7, 150, TEXT_COL, -1, None),
(_('Private'), 8, 30, ICON_COL, -1, 'gramps-lock')
(_('Source'), 8, 30, ICON_COL, -1, 'gramps-source'),
(_('Private'), 9, 30, ICON_COL, -1, 'gramps-lock'),
]
def __init__(self, dbstate, uistate, track, data):
@ -100,7 +101,7 @@ class AddrEmbedList(EmbeddedList):
"""
Return the column order of the columns in the display tab.
"""
return ((1,8), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7))
return ((1, 8), (1, 9), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7))
def add_button_clicked(self, obj):
"""

View File

@ -50,7 +50,8 @@ class AddressModel(Gtk.ListStore):
"""
AddressModel derives from the ListStore, defining te items in the list
"""
Gtk.ListStore.__init__(self, str, str, str, str, str, str, str, str, bool, object)
Gtk.ListStore.__init__(self, str, str, str, str, str, str, str, str,
bool, bool, object)
self.db = dbase
for obj in obj_list:
self.append(row=[
@ -62,6 +63,7 @@ class AddressModel(Gtk.ListStore):
obj.country,
obj.postal,
obj.phone,
obj.has_citations(),
obj.get_privacy(),
obj,
])

View File

@ -45,7 +45,7 @@ from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
#-------------------------------------------------------------------------
class AttrEmbedList(EmbeddedList):
_HANDLE_COL = 3
_HANDLE_COL = 4
_DND_TYPE = DdTargets.ATTRIBUTE
_MSG = {
@ -61,7 +61,8 @@ class AttrEmbedList(EmbeddedList):
_column_names = [
(_('Type'), 0, 250, TEXT_COL, -1, None),
(_('Value'), 1, 200, TEXT_COL, -1, None),
(_('Private'), 2, 30, ICON_COL, -1, 'gramps-lock')
(_('Source'), 2, 30, ICON_COL, -1, 'gramps-source'),
(_('Private'), 3, 30, ICON_COL, -1, 'gramps-lock'),
]
def __init__(self, dbstate, uistate, track, data):
@ -89,7 +90,7 @@ class AttrEmbedList(EmbeddedList):
return self.data
def column_order(self):
return ((1, 2), (1, 0), (1, 1))
return ((1, 2), (1, 3), (1, 0), (1, 1))
def add_button_clicked(self, obj):
pname = ''

View File

@ -24,7 +24,6 @@
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps classes
@ -40,12 +39,13 @@ from gi.repository import Gtk
class AttrModel(Gtk.ListStore):
def __init__(self, attr_list, db):
Gtk.ListStore.__init__(self, str, str, bool, object)
Gtk.ListStore.__init__(self, str, str, bool, bool, object)
self.db = db
for attr in attr_list:
self.append(row=[
str(attr.get_type()),
attr.get_value(),
attr.has_citations(),
attr.get_privacy(),
attr,
])

View File

@ -47,7 +47,7 @@ class ChildModel(Gtk.ListStore):
def __init__(self, child_ref_list, db):
Gtk.ListStore.__init__(self, int, str, str, str, str, str,
str, str, str, str, str, str, str, bool, object)
str, str, str, str, str, str, str, bool, bool, object)
self.db = db
for index, child_ref in enumerate(child_ref_list):
child = db.get_person_from_handle(child_ref.ref)
@ -66,6 +66,7 @@ class ChildModel(Gtk.ListStore):
name_displayer.sort_string(child.primary_name),
self.column_birth_sort(child),
self.column_death_sort(child),
child_ref.has_citations(),
child_ref.get_privacy(),
child_ref
])

View File

@ -87,7 +87,8 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
None,
(_('Age'), EventRefModel.COL_SORTAGE[0], 60, TEXT_COL, -1, None),
None,
(_('Private'), EventRefModel.COL_PRIVATE[0], 30, ICON_COL, -1, 'gramps-lock')
(_('Private'), EventRefModel.COL_PRIVATE[0], 30, ICON_COL, -1, 'gramps-lock'),
(_('Source'), EventRefModel.COL_HAS_SOURCE[0], 30, ICON_COL, -1, 'gramps-source'),
]
def __init__(self, dbstate, uistate, track, obj, build_model=EventRefModel, **kwargs):
@ -196,6 +197,7 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
(1, 3), # date
(1, 4), # place
(1, 6), # main participants
(1, 13), # has source
(1, 12), # private
(1, 5), # role
(1, 2), # gramps id

View File

@ -84,10 +84,11 @@ class EventRefModel(Gtk.TreeStore):
COL_AGE = (10, str)
COL_SORTAGE = (11, str)
COL_PRIVATE = (12, bool)
COL_HAS_SOURCE = (13, bool)
COLS = (COL_DESCR, COL_TYPE, COL_GID, COL_DATE, COL_PLACE, COL_ROLE,
COL_PARTIC, COL_SORTDATE, COL_EVENTREF, COL_FONTWEIGHT, COL_AGE,
COL_SORTAGE, COL_PRIVATE)
COL_SORTAGE, COL_PRIVATE, COL_HAS_SOURCE)
def __init__(self, event_list, db, groups, **kwargs):
"""
@ -114,7 +115,7 @@ class EventRefModel(Gtk.TreeStore):
name = self.namegroup(index, len(group))
spouse = self.groups[index][2]
return [spouse, name, '', '', '', '', '', '', (index, None),
WEIGHT_BOLD, '', '', None]
WEIGHT_BOLD, '', '', None, None]
def namegroup(self, groupindex, length):
return self._GROUPSTRING % {'groupname': self.groups[groupindex][1],
@ -134,6 +135,7 @@ class EventRefModel(Gtk.TreeStore):
self.column_age(event),
self.column_sort_age(event),
eventref.get_privacy(),
event.has_citations(),
]
def colweight(self, index):

View File

@ -42,7 +42,7 @@ from gramps.gen.lib import LdsOrd
#-------------------------------------------------------------------------
class FamilyLdsEmbedList(LdsEmbedList):
_HANDLE_COL = 6
_HANDLE_COL = 7
# _DND_TYPE = DdTargets.ADDRESS
#index = column in model. Value =
@ -52,8 +52,9 @@ class FamilyLdsEmbedList(LdsEmbedList):
(_('Date'), 1, 150, MARKUP_COL, -1, None),
(_('Status'), 3, 75, TEXT_COL, -1, None),
(_('Temple'), 2, 200, TEXT_COL, -1, None),
(_('Place'), 3, 100, TEXT_COL, -1, None),
(_('Private'), 5, 30, ICON_COL, -1, 'gramps-lock')
(_('Place'), 4, 100, TEXT_COL, -1, None),
(_('Source'), 5, 30, ICON_COL, -1, 'gramps-source'),
(_('Private'), 6, 30, ICON_COL, -1, 'gramps-lock'),
]
def __init__(self, dbstate, uistate, track, data):

View File

@ -44,7 +44,7 @@ from .embeddedlist import EmbeddedList, TEXT_COL, MARKUP_COL, ICON_COL
#-------------------------------------------------------------------------
class LdsEmbedList(EmbeddedList):
_HANDLE_COL = 6
_HANDLE_COL = 7
# _DND_TYPE = DdTargets.ADDRESS
_MSG = {
@ -62,8 +62,9 @@ class LdsEmbedList(EmbeddedList):
(_('Date'), 1, 150, MARKUP_COL, -1, None),
(_('Status'), 3, 75, TEXT_COL, -1, None),
(_('Temple'), 2, 200, TEXT_COL, -1, None),
(_('Place'), 3, 100, TEXT_COL, -1, None),
(_('Private'), 5, 30, ICON_COL, -1, 'gramps-lock')
(_('Place'), 4, 100, TEXT_COL, -1, None),
(_('Source'), 5, 30, ICON_COL, -1, 'gramps-source'),
(_('Private'), 6, 30, ICON_COL, -1, 'gramps-lock'),
]
def __init__(self, dbstate, uistate, track, data):
@ -82,7 +83,7 @@ class LdsEmbedList(EmbeddedList):
return self.data
def column_order(self):
return ((1, 5), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4))
return ((1, 5), (1, 6), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4))
def add_button_clicked(self, obj):
try:

View File

@ -47,10 +47,10 @@ from gramps.gen.utils.lds import TEMPLES
#-------------------------------------------------------------------------
class LdsModel(Gtk.ListStore):
_HANDLE_COL = 5
_HANDLE_COL = 6
def __init__(self, lds_list, db):
Gtk.ListStore.__init__(self, str, str, str, str, str, bool, object)
Gtk.ListStore.__init__(self, str, str, str, str, str, bool, bool, object)
for lds_ord in lds_list:
self.append(row=[
@ -59,6 +59,7 @@ class LdsModel(Gtk.ListStore):
lds_ord.status2str(),
TEMPLES.name(lds_ord.get_temple()),
place_displayer.display_event(db, lds_ord),
lds_ord.has_citations(),
lds_ord.get_privacy(),
lds_ord,
])

View File

@ -75,7 +75,7 @@ class NameEmbedList(GroupEmbeddedList):
None,
None,
(_('Group As'), NameModel.COL_GROUPAS[0],100, TEXT_COL, -1, None),
(_('Source'), NameModel.COL_HASSOURCE[0],60, TEXT_COL, -1, None),
(_('Source'), NameModel.COL_HASSOURCE[0],30, ICON_COL, -1, "gramps-source"),
(_('Notes Preview'), NameModel.COL_NOTEPREVIEW[0], 250, TEXT_COL, -1, None),
(_('Private'), NameModel.COL_PRIVATE[0], 30, ICON_COL, -1, 'gramps-lock')
]
@ -114,7 +114,7 @@ class NameEmbedList(GroupEmbeddedList):
The columns to show as a tuple of tuples containing
tuples (show/noshow, model column)
"""
return ((1, 0), (1, 7), (1, 1), (1, 4), (1, 5), (1, 6))
return ((1, 0), (1, 5), (1, 7), (1, 1), (1, 4), (1, 6))
def get_popup_menu_items(self):
if self._tmpgroup == self._WORKGROUP:

View File

@ -70,7 +70,7 @@ class NameModel(Gtk.TreeStore):
COL_DATA = (2, object)
COL_FONTWEIGHT = (3, int)
COL_GROUPAS = (4, str)
COL_HASSOURCE = (5, str)
COL_HASSOURCE = (5, bool)
COL_NOTEPREVIEW = (6, str)
COL_PRIVATE = (7, bool)
@ -109,7 +109,7 @@ class NameModel(Gtk.TreeStore):
(index, name),
self.colweight(index),
name.get_group_as(),
self.hassource(name),
name.has_citations(),
self.notepreview(name),
name.get_privacy(),
]
@ -134,11 +134,6 @@ class NameModel(Gtk.TreeStore):
self.insert(self.get_iter(self.DEFINDEX), 0,
row=self.row(self.DEFINDEX, defname))
def hassource(self, name):
if len(name.get_citation_list()):
return YES
return NO
def notepreview(self, name):
nlist = name.get_note_list()
if nlist:

View File

@ -48,7 +48,7 @@ from ...dbguielement import DbGUIElement
#-------------------------------------------------------------------------
class PersonRefEmbedList(DbGUIElement, EmbeddedList):
_HANDLE_COL = 4
_HANDLE_COL = 5
_DND_TYPE = DdTargets.PERSONREF
_DND_EXTRA = DdTargets.PERSON_LINK
@ -66,7 +66,8 @@ class PersonRefEmbedList(DbGUIElement, EmbeddedList):
(_('Name'), 0, 250, TEXT_COL, -1, None),
(_('ID'), 1, 100, TEXT_COL, -1, None),
(_('Association'), 2, 100, TEXT_COL, -1, None),
(_('Private'), 3, 30, ICON_COL, -1, 'gramps-lock')
(_('Source'), 3, 30, ICON_COL, -1, 'gramps-source'),
(_('Private'), 4, 30, ICON_COL, -1, 'gramps-lock')
]
def __init__(self, dbstate, uistate, track, data):
@ -129,7 +130,7 @@ class PersonRefEmbedList(DbGUIElement, EmbeddedList):
return self.data
def column_order(self):
return ((1,3), (1, 0), (1, 1), (1, 2))
return ((1, 3), (1, 4), (1, 0), (1, 1), (1, 2))
def add_button_clicked(self, obj):
from .. import EditPersonRef

View File

@ -40,13 +40,13 @@ from gramps.gen.display.name import displayer as name_displayer
class PersonRefModel(Gtk.ListStore):
def __init__(self, obj_list, db):
Gtk.ListStore.__init__(self, str, str, str, bool, object)
Gtk.ListStore.__init__(self, str, str, str, bool, bool, object)
self.db = db
for obj in obj_list:
p = self.db.get_person_from_handle(obj.ref)
if p:
data = [name_displayer.display(p), p.gramps_id, obj.rel,
obj.get_privacy(), obj]
obj.has_citations(), obj.get_privacy(), obj]
else:
data = ['unknown','unknown', obj.rel, obj.get_privacy(), obj]
self.append(row=data)

View File

@ -105,7 +105,7 @@ class ChildEmbedList(DbGUIElement, EmbeddedList):
is contained here instead of in displaytabs.
"""
_HANDLE_COL = 14
_HANDLE_COL = 15
_DND_TYPE = DdTargets.CHILDREF
_DND_EXTRA = DdTargets.PERSON_LINK
@ -133,7 +133,8 @@ class ChildEmbedList(DbGUIElement, EmbeddedList):
None,
None,
None,
(_('Private'), 13, 30, ICON_COL, -1, 'gramps-lock')
(_('Source'), 13, 30, ICON_COL, -1, 'gramps-source'),
(_('Private'), 14, 30, ICON_COL, -1, 'gramps-lock'),
]
def __init__(self, dbstate, uistate, track, family):
@ -216,7 +217,7 @@ class ChildEmbedList(DbGUIElement, EmbeddedList):
return prefs
def column_order(self):
return [(1, 13), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),
return [(1, 13), (1, 14), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),
(0, 8), (0, 9)]
def add_button_clicked(self, obj=None):