Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Rickard Lindberg, Roger Lindberg 2 # 3 # This file is part of Timeline. 4 # 5 # Timeline is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # Timeline is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with Timeline. If not, see <http://www.gnu.org/licenses/>. 17 18 19 from timelinelib.canvas.data.base import create_noop_property 20 from timelinelib.canvas.data.event import Event 21 from timelinelib.canvas.data.event import DEFAULT_COLOR 22 from timelinelib.canvas.data.immutable import ImmutableContainer 23 from timelinelib.canvas.data.timeperiod import TimePeriod 24 from timelinelib.features.experimental.experimentalfeatures import EXTENDED_CONTAINER_STRATEGY28120 121 122 create_noop_property(Container, "fuzzy", False) 123 create_noop_property(Container, "locked", False) 124 create_noop_property(Container, "ends_today", False) 125 create_noop_property(Container, "icon", None) 126 create_noop_property(Container, "hyperlink", None) 127 create_noop_property(Container, "alert", None) 128 create_noop_property(Container, "progress", None) 129 create_noop_property(Container, "default_color", DEFAULT_COLOR) 13030 Event.__init__(self, db=db, id_=id_, immutable_value=immutable_value) 31 self._subevents = [] 32 self._is_in_update = False 33 import timelinelib.db.strategies 34 if EXTENDED_CONTAINER_STRATEGY.enabled(): 35 self.strategy = timelinelib.db.strategies.ExtendedContainerStrategy(self) 36 else: 37 self.strategy = timelinelib.db.strategies.DefaultContainerStrategy(self)38 39 @property 42 43 @subevents.setter45 self._subevents = value4648 self._update_category_id() 49 self._update_category_ids() 50 with self._db.transaction("Save container") as t: 51 t.save_container(self._immutable_value, self.ensure_id()) 52 return self5355 with self._db.transaction("Delete container") as t: 56 t.delete_container(self.id) 57 self.id = None5860 if len(self.subevents) == 0: 61 return self._immutable_value.time_period 62 else: 63 return TimePeriod( 64 min([event.get_start_time() for event in self.subevents]), 65 max([event.get_end_time() for event in self.subevents]) 66 )67 71 72 time_period = property(get_time_period, set_time_period) 7375 if len(self.subevents) == 0: 76 return 0 77 else: 78 return min( 79 self.subevents, 80 key=lambda event: event.sort_order 81 ).sort_order82 86 87 sort_order = property(get_sort_order, set_sort_order) 88 92 95 98 101 104106 if self._is_in_update: 107 return 108 try: 109 self._is_in_update = True 110 self.strategy.update(subevent) 111 finally: 112 self._is_in_update = False113 117119 return self.strategy.allow_ends_today_on_subevents()
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Jun 26 01:55:29 2020 | http://epydoc.sourceforge.net |