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.wxgui.framework import Controller 20 21 22 FORWARD = 0 23 BACKWARD = 1 24 BOTH = 2 25 262882 8330 if event_duplicator is None: 31 self.event_duplicator = EventDuplicator() 32 else: 33 self.event_duplicator = event_duplicator 34 self.event = event 35 self._set_default_values()36 4042 self.view.SetCount(1) 43 self.view.SetFrequency(1) 44 self.view.SetDirection(FORWARD) 45 self.view.SelectMovePeriodFnAtIndex(0)4648 missing_dates_count, periods = self._repeat_period( 49 self.event.time_period 50 ) 51 self.event_duplicator.duplicate(self.event, periods) 52 if missing_dates_count > 0: 53 self.view.HandleDateErrors(missing_dates_count)5456 missing_dates_count = 0 57 periods = [] 58 for index in self._calculate_indicies(): 59 new_period = self.view.GetMovePeriodFn()( 60 period, 61 index * self.view.GetFrequency() 62 ) 63 if new_period is None: 64 missing_dates_count += 1 65 else: 66 periods.append(new_period) 67 return (missing_dates_count, periods)6870 direction = self.view.GetDirection() 71 repetitions = self.view.GetCount() 72 if direction == FORWARD: 73 return range(1, repetitions + 1) 74 elif direction == BACKWARD: 75 return range(-repetitions, 0) 76 elif direction == BOTH: 77 indicies = list(range(-repetitions, repetitions + 1)) 78 indicies.remove(0) 79 return indicies 80 else: 81 raise Exception("Invalid direction.")85 89 9310895 duplicate = event.duplicate() 96 duplicate.time_period = period 97 duplicate.container = event.container 98 duplicate.save() 99 if event.is_container(): 100 delta = period.get_start_time() - event.get_start_time() 101 for subevent in event.subevents: 102 duplicate_subevent = subevent.duplicate() 103 duplicate_subevent.time_period = subevent.time_period.move_delta(delta) 104 # It is important to set time period before container, because 105 # otherwise the strategy might move events unexpectedly. 106 duplicate_subevent.container = duplicate 107 duplicate_subevent.save()
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Jun 26 01:55:29 2020 | http://epydoc.sourceforge.net |