1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """
24 NoteBase class for GRAMPS.
25 """
26
27
28
29
30
31
33 """
34 Base class for storing notes.
35
36 Starting in 3.0 branch, the objects may have multiple notes.
37 Internally, this class maintains a list of Note handles,
38 as a note_list attribute of the NoteBase object.
39 """
41 """
42 Create a new NoteBase, copying from source if not None.
43
44 @param source: Object used to initialize the new object
45 @type source: NoteBase
46 """
47
48 if source:
49 self.note_list = [handle for handle in source.note_list]
50 else:
51 self.note_list = []
52
54 """
55 Convert the object to a serialized tuple of data.
56 """
57 return self.note_list
58
60 """
61 Convert a serialized tuple of data to an object.
62 """
63 self.note_list = [handle for handle in data]
64
66 """
67 Add the L{Note} handle to the list of note handles.
68
69 @param handle: L{Note} handle to add the list of notes
70 @type handle: str
71
72 @return: True if handle was added, False if it already was in the list
73 @rtype: bool
74 """
75 if handle in self.note_list:
76 return False
77 else:
78 self.note_list.append(handle)
79 return True
80
82 """
83 Remove the specified handle from the list of note handles, and all
84 secondary child objects.
85
86 @param handle: L{Note} handle to remove from the list of notes
87 @type handle: str
88 """
89 if handle in self.note_list:
90 self.note_list.remove(handle)
91 for item in self.get_note_child_list():
92 item.remove_note(handle)
93
95 """
96 Return the list of child secondary objects that may refer notes.
97
98 All methods which inherit from NoteBase and have other child objects
99 with notes, should return here a list of child objects which are
100 NoteBase
101
102 @return: Returns the list of child secondary child objects that may
103 refer notes.
104 @rtype: list
105 """
106 return []
107
109 """
110 Return the list of L{Note} handles associated with the object.
111
112 @return: The list of L{Note} handles
113 @rtype: list
114 """
115 return self.note_list
116
118 """
119 Assign the passed list to be object's list of L{Note} handles.
120
121 @param note_list: List of L{Note} handles to be set on the object
122 @type note_list: list
123 """
124 self.note_list = note_list
125
127 """
128 Return the list of (classname, handle) tuples for all referenced notes.
129
130 This method should be used to get the L{Note} portion of the list
131 by objects that store note lists.
132
133 @return: List of (classname, handle) tuples for referenced objects.
134 @rtype: list
135 """
136 return [('Note', handle) for handle in self.note_list]
137