Ejemplo n.º 1
0
# -*- coding:utf-8 -*-
Ejemplo n.º 2
0
	def onControl(self, control):
		# Change the selected control info
		self.change_selection(control)
		
		ctrl_data = self.control_to_data[control.getId()]
		
		if ctrl_data != None and type(ctrl_data) is utils.Data:
			# View Type selection
			if ctrl_data.type == utils.CONTROL_TYPE_VIEW:
				self.view = ctrl_data.value
				self.reload()
			
			
			# Enable/Disable calendar
			if ctrl_data.type == utils.CONTROL_TYPE_CALENDAR:
				cal_name=str(self.calCon.calendar_control_to_calendar_name[control.getId()].encode('utf-8'))
				utils.addon.setSetting(cal_name, str(control.isSelected()))
				self.reload()
				
			# Week View Before
			elif ctrl_data.type == utils.CONTROL_TYPE_BEFORE_NAVIGATION:
				if ctrl_data.value == utils.CONTROL_VALUE_NAVIGATE_PREVIOS:
					if self.before > 1:
						self.before = self.before - 1
				if ctrl_data.value == utils.CONTROL_VALUE_NAVIGATE_NEXT:
					self.before = self.before + 1
				self.newDateSelected(self.date_center)
			
			# Week View After
			elif ctrl_data.type == utils.CONTROL_TYPE_AFTER_NAVIGATION:
				if ctrl_data.value == utils.CONTROL_VALUE_NAVIGATE_PREVIOS:
					if self.after > 1:
						self.after = self.after - 1
				if ctrl_data.value == utils.CONTROL_VALUE_NAVIGATE_NEXT:
					self.after = self.after + 1
				self.newDateSelected(self.date_center)
				
			# Navigate Month
			elif ctrl_data.type == utils.CONTROL_TYPE_MONTH_NAVIGATION:
				if ctrl_data.value == utils.CONTROL_VALUE_NAVIGATE_PREVIOS:
					self.newDateSelected(self.date_center + relativedelta.relativedelta(months=-1))
				if ctrl_data.value == utils.CONTROL_VALUE_NAVIGATE_NEXT:
					self.newDateSelected(self.date_center + relativedelta.relativedelta(months=1))				
			
			# Navigate Year
			elif ctrl_data.type == utils.CONTROL_TYPE_YEAR_NAVIGATION:
				if ctrl_data.value == utils.CONTROL_VALUE_NAVIGATE_PREVIOS:
					self.newDateSelected(self.date_center + relativedelta.relativedelta(years=-1))
				if ctrl_data.value == utils.CONTROL_VALUE_NAVIGATE_NEXT:
					self.newDateSelected(self.date_center + relativedelta.relativedelta(years=1))
			
			# Navigate Today
			elif ctrl_data.type == utils.CONTROL_TYPE_TODAY_NAVIGATION:
				self.newDateSelected(ctrl_data.value)
				
			# Navigat GOTO
			elif ctrl_data.type == utils.CONTROL_TYPE_GOTO:
				dialog=dayselection.DaySelectionDialog(self.date_center)
				dialog.doModal()
				if dialog.selection_date != None:
					self.newDateSelected(dialog.selection_date)
				
				del dialog
				dialog = None
			
			# Edit existing event
			elif ctrl_data.type == utils.CONTROL_TYPE_EVENT:
				dialog=task.TaskDialog(ctrl_data.value, self.calCon, False)
				dialog.doModal()
				self.newDateSelected(utils.formatDateTime(dialog.event,'start').date())
				del dialog
				dialog = None
			
			# Add event to a given slot
			elif ctrl_data.type == utils.CONTROL_TYPE_TASK_SLOT:
				_s = str(ctrl_data.value.isoformat())
				_e = str((ctrl_data.value + relativedelta.relativedelta(hours=1)).isoformat())
				new_event = self.calCon.createNewEventBody(_s, _e)
				dialog=task.TaskDialog(new_event, self.calCon, True)
				dialog.doModal()
				self.newDateSelected(utils.formatDateTime(dialog.event,'start').date())
				del dialog
				dialog = None
			
			# Month selected - change view 
			elif ctrl_data.type == utils.CONTROL_TYPE_MONTH:
				self.view = utils.VIEW_TYPE_MONTH		
				self.newDateSelected(ctrl_data.value)
			
			# Day selected - change view 
			elif ctrl_data.type == utils.CONTROL_TYPE_DATE:
				self.view = utils.VIEW_TYPE_DAY
				self.newDateSelected(ctrl_data.value)
Ejemplo n.º 3
0
# -*- coding:utf-8 -*-
Ejemplo n.º 4
0
# -*- coding:utf-8 -*-
Ejemplo n.º 5
0
	def onControl(self, control):
		# Change the selected control info
		self.change_selection(control)
		
		value = self.control_to_data[control.getId()]
		
		ctrl_data = self.control_to_data[control.getId()]
		if ctrl_data != None and type(ctrl_data) is utils.Data:
			if ctrl_data.type == utils.CONTROL_TYPE_EVENT_SUMMARY:
				self.event['summary'] = utils.getKeyboardResults(control.getLabel(), 'Task Summary')
				control.setLabel(self.event['summary'])
				
			if ctrl_data.type == utils.CONTROL_TYPE_EVENT_DESCRIPTION:
				self.event['description'] = utils.getKeyboardResults(control.getLabel(), 'Task Description')
				control.setLabel(self.event['description'])
				
			if ctrl_data.type == utils.CONTROL_TYPE_TIMEZONE:
				dialog = timezoneselection.TimezoneDialog(utils.addon.getSetting('timezone'))
				dialog.doModal()
				if dialog.selected != None:
					self.event['start']['timeZone'] = dialog.selected
					self.event['end']['timeZone'] = dialog.selected
					control.setLabel(dialog.selected)
				
			if  ctrl_data.type == utils.CONTROL_TYPE_EVENT_LOCATION:
				self.event['location'] = utils.getKeyboardResults(control.getLabel(), 'Task Location')
				control.setLabel(self.event['location'])
				
			if value.type =='start_day':
				dialog = dayselection.DaySelectionDialog(utils.formatDateTime(self.event, 'start'))
				dialog.doModal()
		
				control.setLabel(str(dialog.selection_date))
				self.event['start']['dateTime']= utils.formatDateTime_get_iso(dialog.selection_date)
				
			if value.type =='end_day':
				dialog = dayselection.DaySelectionDialog(utils.formatDateTime(self.event, 'end'))
				dialog.doModal()
				
				control.setLabel(str(dialog.selection_date))
				self.event['end']['dateTime']= utils.formatDateTime_get_iso(dialog.selection_date)
			
			if ctrl_data.type == utils.CONTROL_TYPE_ACTION:
				if ctrl_data.value == utils.CONTROL_VALUE_ACTION_DELETE:
					self.calCon.deleteEvent(self.event)
					self.close()
					
				if ctrl_data.value == utils.CONTROL_VALUE_ACTION_OK:
					print str(self.event)
					if 'timeZone' in self.event['start'] and self.event['start']['timeZone'] in pytz.all_timezones and self.event['end']['timeZone'] in pytz.all_timezones:
						if self.is_new:
							self.calCon.createEvent(self.event)
						else:
							self.calCon.updateEvent(self.event)
						
						self.close()
					
					else:
						utils.message("You must select time zone from the list of timezones")
					
				if ctrl_data.value == utils.CONTROL_VALUE_ACTION_CANCEL:
					self.close()
					
			if value.type == "action" and value.value == "cancel":
				self.close()