Package Gnumed :: Package timelinelib :: Package wxgui :: Package dialogs :: Package duplicateevent :: Module view
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.wxgui.dialogs.duplicateevent.view

  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  import wx 
 20   
 21  from timelinelib.db.utils import safe_locking 
 22  from timelinelib.wxgui.dialogs.duplicateevent.controller import DuplicateEventDialogController 
 23  from timelinelib.wxgui.framework import Dialog 
 24  from timelinelib.wxgui.utils import display_error_message 
 25  import timelinelib.wxgui.utils as gui_utils 
 26   
 27   
28 -class DuplicateEventDialog(Dialog):
29 30 """ 31 <BoxSizerVertical> 32 33 <BoxSizerHorizontal border="ALL" > 34 <StaticText 35 label="$(nbr_of_duplicates_text)" 36 align="ALIGN_CENTER_VERTICAL" 37 /> 38 <Spacer /> 39 <SpinCtrl 40 name="sc_nbr_of_duplicates" 41 align="ALIGN_CENTER_VERTICAL" 42 /> 43 </BoxSizerHorizontal> 44 45 <RadioBox 46 label="$(period_text)" 47 name="rb_periods" 48 choices="$(period_choices)" 49 border="LEFT|RIGHT|BOTTOM" 50 /> 51 52 <BoxSizerHorizontal border="LEFT|RIGHT|BOTTOM" > 53 <StaticText 54 label="$(frequency_text)" 55 align="ALIGN_CENTER_VERTICAL" 56 /> 57 <Spacer /> 58 <SpinCtrl 59 name="sc_frequency" 60 align="ALIGN_CENTER_VERTICAL" 61 /> 62 </BoxSizerHorizontal> 63 64 <RadioBox 65 label="$(direction_text)" 66 name="rb_direction" 67 choices="$(direction_choices)" 68 border="LEFT|RIGHT|BOTTOM" 69 /> 70 71 <DialogButtonsOkCancelSizer 72 border="LEFT|RIGHT|BOTTOM" 73 event_EVT_BUTTON__ID_OK="on_ok" 74 /> 75 76 </BoxSizerVertical> 77 """ 78
79 - def __init__(self, parent, db, event):
80 self. move_period_config = db.get_time_type().get_duplicate_functions() 81 period_list = [label for (label, fn) in self.move_period_config] 82 Dialog.__init__(self, DuplicateEventDialogController, parent, { 83 "nbr_of_duplicates_text": _("Number of duplicates:"), 84 "period_text": _("Period"), 85 "direction_text": _("Direction"), 86 "period_choices": period_list, 87 "frequency_text": _("Frequency:"), 88 "direction_choices": [_("Forward"), _("Backward"), _("Both")], 89 }, title=_("Duplicate Event")) 90 self.controller.on_init(event) 91 self.sc_nbr_of_duplicates.SetSelection(-1, -1)
92
93 - def SetCount(self, count):
94 self.sc_nbr_of_duplicates.SetValue(count)
95
96 - def GetCount(self):
97 return self.sc_nbr_of_duplicates.GetValue()
98
99 - def SetFrequency(self, frequency):
100 self.sc_frequency.SetValue(frequency)
101
102 - def GetFrequency(self):
103 return self.sc_frequency.GetValue()
104
105 - def SetDirection(self, direction):
106 self.rb_direction.SetSelection(direction)
107
108 - def GetDirection(self):
109 return self.rb_direction.GetSelection()
110
111 - def SelectMovePeriodFnAtIndex(self, index):
112 self.rb_periods.SetSelection(index)
113
114 - def GetMovePeriodFn(self):
115 move_period_fns = [fn for (_, fn) in self.move_period_config] 116 return move_period_fns[self.rb_periods.GetSelection()]
117
118 - def Close(self):
119 self.EndModal(wx.ID_OK)
120
121 - def HandleDateErrors(self, error_count):
122 display_error_message( 123 _("%d Events not duplicated due to missing dates.") 124 % error_count)
125
126 - def SetWaitCursor(self):
127 gui_utils.set_wait_cursor(self)
128
129 - def SetDefaultCursor(self):
130 gui_utils.set_default_cursor(self)
131 132
133 -def open_duplicate_event_dialog_for_event(edit_controller, parent, db, event):
134 def create_dialog(): 135 return DuplicateEventDialog(parent, db, event)
136 137 def edit_function(): 138 dialog = create_dialog() 139 dialog.ShowModal() 140 dialog.Destroy() 141 safe_locking(edit_controller, edit_function) 142