~ubuntu-branches/ubuntu/utopic/gramps/utopic

« back to all changes in this revision

Viewing changes to src/gen/lib/event.py

  • Committer: Package Import Robot
  • Author(s): James A. Treacy
  • Date: 2012-05-22 17:18:36 UTC
  • mfrom: (39.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20120522171836-35fi62lp4w7jnrd7
Tags: 3.4.0-1
* New upstream version
* Updated desktop file. Closes: #667472

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#
4
4
# Copyright (C) 2000-2007  Donald N. Allingham
5
5
# Copyright (C) 2010       Michiel D. Nauta
 
6
# Copyright (C) 2011       Tim G L Lyons
6
7
#
7
8
# This program is free software; you can redistribute it and/or modify
8
9
# it under the terms of the GNU General Public License as published by
19
20
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21
#
21
22
 
22
 
# $Id: event.py 16825 2011-03-15 21:52:08Z m_d_n $
 
23
# $Id: event.py 19261 2012-04-07 11:26:45Z m_d_n $
23
24
 
24
25
"""
25
26
Event object for GRAMPS.
27
28
 
28
29
#-------------------------------------------------------------------------
29
30
#
 
31
# standard python modules
 
32
#
 
33
#-------------------------------------------------------------------------
 
34
import logging
 
35
LOG = logging.getLogger(".citation")
 
36
 
 
37
#-------------------------------------------------------------------------
 
38
#
30
39
# GRAMPS modules
31
40
#
32
41
#-------------------------------------------------------------------------
33
42
from gen.lib.primaryobj import PrimaryObject
34
 
from gen.lib.srcbase import SourceBase
 
43
from gen.lib.citationbase import CitationBase
35
44
from gen.lib.notebase import NoteBase
36
45
from gen.lib.mediabase import MediaBase
37
46
from gen.lib.attrbase import AttributeBase
44
53
# Event class
45
54
#
46
55
#-------------------------------------------------------------------------
47
 
class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
 
56
class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
48
57
            DateBase, PlaceBase, PrimaryObject):
49
58
    """
50
59
    The Event record is used to store information about some type of
67
76
        """
68
77
 
69
78
        PrimaryObject.__init__(self, source)
70
 
        SourceBase.__init__(self, source)
 
79
        CitationBase.__init__(self, source)
71
80
        NoteBase.__init__(self, source)
72
81
        MediaBase.__init__(self, source)
73
82
        AttributeBase.__init__(self)
102
111
        return (self.handle, self.gramps_id, self.__type.serialize(),
103
112
                DateBase.serialize(self, no_text_date),
104
113
                self.__description, self.place, 
105
 
                SourceBase.serialize(self),
 
114
                CitationBase.serialize(self),
106
115
                NoteBase.serialize(self),
107
116
                MediaBase.serialize(self),
108
117
                AttributeBase.serialize(self),
119
128
        """
120
129
        (self.handle, self.gramps_id, the_type, date,
121
130
         self.__description, self.place, 
122
 
         source_list, note_list, media_list, attribute_list,
 
131
         citation_list, note_list, media_list, attribute_list,
123
132
         self.change, self.private) = data
124
133
 
125
134
        self.__type = EventType()
127
136
        DateBase.unserialize(self, date)
128
137
        MediaBase.unserialize(self, media_list)
129
138
        AttributeBase.unserialize(self, attribute_list)
130
 
        SourceBase.unserialize(self, source_list)
 
139
        CitationBase.unserialize(self, citation_list)
131
140
        NoteBase.unserialize(self, note_list)
 
141
        return self
132
142
 
133
143
    def _has_handle_reference(self, classname, handle):
134
144
        """
189
199
        :returns: Returns the list of child objects that may carry textual data.
190
200
        :rtype: list
191
201
        """
192
 
        return self.media_list + self.source_list + self.attribute_list
 
202
        return self.media_list + self.attribute_list
193
203
 
194
 
    def get_sourcref_child_list(self):
 
204
    def get_citation_child_list(self):
195
205
        """
196
 
        Return the list of child secondary objects that may refer sources.
 
206
        Return the list of child secondary objects that may refer citations.
197
207
 
198
208
        :returns: Returns the list of child secondary child objects that may 
199
 
                refer sources.
 
209
                refer citations.
200
210
        :rtype: list
201
211
        """
202
212
        return self.media_list + self.attribute_list
209
219
                refer notes.
210
220
        :rtype: list
211
221
        """
212
 
        return self.media_list + self.attribute_list + self.source_list
 
222
        return self.media_list + self.attribute_list
213
223
 
214
224
    def get_referenced_handles(self):
215
225
        """
219
229
        :returns: List of (classname, handle) tuples for referenced objects.
220
230
        :rtype: list
221
231
        """
222
 
        ret = self.get_referenced_note_handles()
 
232
        ret = self.get_referenced_note_handles() + \
 
233
                self.get_referenced_citation_handles()
223
234
        if self.place:
224
235
            ret.append(('Place', self.place))
225
236
        return ret
232
243
        :returns: Returns the list of objects referencing primary objects.
233
244
        :rtype: list
234
245
        """
235
 
        return self.get_sourcref_child_list() + self.source_list
 
246
        return self.get_citation_child_list()
236
247
 
237
248
    def is_empty(self):
238
249
        """
265
276
           self.__description != other.__description \
266
277
           or self.private != other.private or \
267
278
           (not self.get_date_object().is_equal(other.get_date_object())) or \
268
 
           len(self.get_source_references()) != len(other.get_source_references()):
 
279
           len(self.get_citation_list()) != \
 
280
                len(other.get_citation_list()):
269
281
            return False
270
282
 
271
283
        index = 0
272
 
        olist = other.get_source_references()
273
 
        for a in self.get_source_references():
274
 
            if not a.is_equal(olist[index]):
 
284
        olist = other.get_citation_list()
 
285
        for a in self.get_citation_list():
 
286
            # see comment in srefs_are_equal in gen/plug/report/_bibliography.py
 
287
            if a != olist[index]:
275
288
                return False
276
289
            index += 1
277
290
 
289
302
        self._merge_privacy(acquisition)
290
303
        self._merge_attribute_list(acquisition)
291
304
        self._merge_note_list(acquisition)
292
 
        self._merge_source_reference_list(acquisition)
 
305
        self._merge_citation_list(acquisition)
293
306
        self._merge_media_list(acquisition)
294
307
 
295
308
    def set_type(self, the_type):