def __init__(self, task, taskList, effortList, settings, *args, **kwargs): kwargs['title'] = kwargs.get('title', meta.name + ' ' + _('Reminder')) super(ReminderDialog, self).__init__(*args, **kwargs) self.SetIcon(wx.ArtProvider_GetIcon('taskcoach', wx.ART_FRAME_ICON, (16,16))) self.task = task self.taskList = taskList self.effortList = effortList self.settings = settings patterns.Publisher().registerObserver(self.onTaskRemoved, eventType=self.taskList.removeItemEventType(), eventSource=self.taskList) patterns.Publisher().registerObserver(self.onTaskCompletionDateChanged, eventType='task.completionDateTime', eventSource=task) patterns.Publisher().registerObserver(self.onTrackingStartedOrStopped, eventType=task.trackStartEventType(), eventSource=task) patterns.Publisher().registerObserver(self.onTrackingStartedOrStopped, eventType=task.trackStopEventType(), eventSource=task) self.openTaskAfterClose = self.ignoreSnoozeOption = False pane = self.GetContentsPane() pane.SetSizerType("form") wx.StaticText(pane, label=_('Task') + ':') panel = wx.Panel(pane) sizer = wx.BoxSizer(wx.HORIZONTAL) self.openTask = wx.Button(panel, label=self.task.subject(recursive=True)) self.openTask.Bind(wx.EVT_BUTTON, self.onOpenTask) sizer.Add(self.openTask) if self.settings.getboolean('feature', 'effort'): self.startTracking = wx.BitmapButton(panel) self.setTrackingIcon() self.startTracking.Bind(wx.EVT_BUTTON, self.onStartOrStopTracking) sizer.Add(self.startTracking) panel.SetSizerAndFit(sizer) for label in _('Reminder date/time') + ':', \ render.dateTime(self.task.reminder()), _('Snooze') + ':': wx.StaticText(pane, label=label) self.snoozeOptions = wx.ComboBox(pane) snoozeTimesUserWantsToSee = [0] + self.settings.getlist('view', 'snoozetimes') lastSnoozeTime = self.settings.getint('view', 'defaultsnoozetime') selectionIndex = 1 # Use the 1st non-zero option if we don't find the last snooze time for minutes, label in date.snoozeChoices: if minutes in snoozeTimesUserWantsToSee: self.snoozeOptions.Append(label, date.TimeDelta(minutes=minutes)) if minutes == lastSnoozeTime: selectionIndex = self.snoozeOptions.Count - 1 self.snoozeOptions.SetSelection(min(selectionIndex, self.snoozeOptions.Count - 1)) buttonSizer = self.CreateStdDialogButtonSizer(wx.OK) self.markCompleted = wx.Button(self, label=_('Mark task completed')) self.markCompleted.Bind(wx.EVT_BUTTON, self.onMarkTaskCompleted) if self.task.completed(): self.markCompleted.Disable() buttonSizer.Add(self.markCompleted) self.SetButtonSizer(buttonSizer) self.Bind(wx.EVT_CLOSE, self.onClose) self.Bind(wx.EVT_BUTTON, self.onOK, id=self.GetAffirmativeId()) self.Fit() self.RequestUserAttention()
def assertRenderedDateTime(self, expectedDateTime, *dateTimeArgs): renderedDateTime = render.dateTime(date.DateTime(*dateTimeArgs)) if expectedDateTime: renderedParts = renderedDateTime.split(' ') if len(renderedParts) > 1: renderedDate, renderedTime = renderedParts expectedDate, expectedTime = expectedDateTime.split(' ') self.assertEqual(expectedTime, renderedTime) else: expectedDate, renderedDate = expectedDateTime, renderedDateTime self.assertEqual(expectedDate, renderedDate) else: self.assertEqual(expectedDateTime, renderedDateTime)
def __init__(self, task, taskList, settings, *args, **kwargs): kwargs['title'] = kwargs.get('title', meta.name + ' ' + _('Reminder')) super(ReminderDialog, self).__init__(*args, **kwargs) self.SetIcon( wx.ArtProvider_GetIcon('taskcoach', wx.ART_FRAME_ICON, (16, 16))) self.task = task self.taskList = taskList self.settings = settings patterns.Publisher().registerObserver( self.onTaskRemoved, eventType=self.taskList.removeItemEventType(), eventSource=self.taskList) patterns.Publisher().registerObserver( self.onTaskCompletionDateChanged, eventType='task.completionDateTime', eventSource=self.task) self.openTaskAfterClose = self.ignoreSnoozeOption = False pane = self.GetContentsPane() pane.SetSizerType("form") wx.StaticText(pane, label=_('Task') + ':') self.openTask = wx.Button(pane, label=self.task.subject(recursive=True)) self.openTask.Bind(wx.EVT_BUTTON, self.onOpenTask) for label in _('Reminder date/time') + ':', \ render.dateTime(self.task.reminder()), _('Snooze') + ':': wx.StaticText(pane, label=label) self.snoozeOptions = wx.ComboBox(pane) snoozeTimesUserWantsToSee = [0] + eval( self.settings.get('view', 'snoozetimes')) for minutes, label in date.snoozeChoices: if minutes in snoozeTimesUserWantsToSee: self.snoozeOptions.Append(label, date.TimeDelta(minutes=minutes)) self.snoozeOptions.SetSelection(0) buttonSizer = self.CreateStdDialogButtonSizer(wx.OK) self.markCompleted = wx.Button(self, label=_('Mark task completed')) self.markCompleted.Bind(wx.EVT_BUTTON, self.onMarkTaskCompleted) if self.task.completed(): self.markCompleted.Disable() buttonSizer.Add(self.markCompleted) self.SetButtonSizer(buttonSizer) self.Bind(wx.EVT_CLOSE, self.onClose) self.Bind(wx.EVT_BUTTON, self.onOK, id=self.GetAffirmativeId()) self.Fit() self.RequestUserAttention()
def __init__(self, task, *args, **kwargs): kwargs['title'] = kwargs.get('title', meta.name + ' ' + _('Reminder')) super(ReminderDialog, self).__init__(*args, **kwargs) self.task = task self.openTaskAfterClose = False pane = self.GetContentsPane() pane.SetSizerType("form") wx.StaticText(pane, label=_('Task') + ':') self.openTask = wx.Button(pane, label=self.task.subject(recursive=True)) self.openTask.Bind(wx.EVT_BUTTON, self.onOpenTask) for label in _('Reminder date/time') + ':', \ render.dateTime(self.task.reminder()), _('Snooze') + ':': wx.StaticText(pane, label=label) self.snoozeOptions = wx.ComboBox(pane) for choice, timeDelta in zip(self.snoozeChoices, self.snoozeTimes): self.snoozeOptions.Append(choice, timeDelta) self.snoozeOptions.SetSelection(0) self.SetButtonSizer(self.CreateStdDialogButtonSizer(wx.OK)) self.Bind(wx.EVT_BUTTON, lambda event: self.Close()) self.Fit()
def __init__(self, task, taskList, settings, *args, **kwargs): kwargs['title'] = kwargs.get('title', meta.name + ' ' + _('Reminder')) super(ReminderDialog, self).__init__(*args, **kwargs) self.SetIcon(wx.ArtProvider_GetIcon('taskcoach', wx.ART_FRAME_ICON, (16,16))) self.task = task self.taskList = taskList self.settings = settings patterns.Publisher().registerObserver(self.onTaskRemoved, eventType=self.taskList.removeItemEventType(), eventSource=self.taskList) patterns.Publisher().registerObserver(self.onTaskCompletionDateChanged, eventType='task.completionDateTime', eventSource=self.task) self.openTaskAfterClose = self.ignoreSnoozeOption = False pane = self.GetContentsPane() pane.SetSizerType("form") wx.StaticText(pane, label=_('Task') + ':') self.openTask = wx.Button(pane, label=self.task.subject(recursive=True)) self.openTask.Bind(wx.EVT_BUTTON, self.onOpenTask) for label in _('Reminder date/time') + ':', \ render.dateTime(self.task.reminder()), _('Snooze') + ':': wx.StaticText(pane, label=label) self.snoozeOptions = wx.ComboBox(pane) snoozeTimesUserWantsToSee = [0] + eval(self.settings.get('view', 'snoozetimes')) for minutes, label in date.snoozeChoices: if minutes in snoozeTimesUserWantsToSee: self.snoozeOptions.Append(label, date.TimeDelta(minutes=minutes)) self.snoozeOptions.SetSelection(0) buttonSizer = self.CreateStdDialogButtonSizer(wx.OK) self.markCompleted = wx.Button(self, label=_('Mark task completed')) self.markCompleted.Bind(wx.EVT_BUTTON, self.onMarkTaskCompleted) if self.task.completed(): self.markCompleted.Disable() buttonSizer.Add(self.markCompleted) self.SetButtonSizer(buttonSizer) self.Bind(wx.EVT_CLOSE, self.onClose) self.Bind(wx.EVT_BUTTON, self.onOK, id=self.GetAffirmativeId()) self.Fit() self.RequestUserAttention()
def renderStartDateTime(task): # The rendering of the start date time doesn't depend on whether the # task is collapsed since the start date time is a parent is always <= # start date times of all children. return render.dateTime(task.startDateTime())
def _createColumns(self): kwargs = dict(renderDescriptionCallback=lambda task: task.description(), resizeCallback=self.onResizeColumn) columns = [widgets.Column('subject', _('Subject'), task.Task.subjectChangedEventType(), 'task.completionDate', 'task.dueDate', 'task.startDate', task.Task.trackStartEventType(), task.Task.trackStopEventType(), sortCallback=uicommand.ViewerSortByCommand(viewer=self, value='subject'), width=self.getColumnWidth('subject'), imageIndexCallback=self.subjectImageIndex, renderCallback=self.renderSubject, **kwargs)] + \ [widgets.Column('description', _('Description'), task.Task.descriptionChangedEventType(), sortCallback=uicommand.ViewerSortByCommand(viewer=self, value='description'), renderCallback=lambda task: task.description(), width=self.getColumnWidth('description'), **kwargs)] + \ [widgets.Column('attachments', '', task.Task.attachmentsChangedEventType(), width=self.getColumnWidth('attachments'), alignment=wx.LIST_FORMAT_LEFT, imageIndexCallback=self.attachmentImageIndex, headerImageIndex=self.imageIndex['attachment'], renderCallback=lambda task: '', **kwargs)] if self.settings.getboolean('feature', 'notes'): columns.append(widgets.Column('notes', '', task.Task.notesChangedEventType(), width=self.getColumnWidth('notes'), alignment=wx.LIST_FORMAT_LEFT, imageIndexCallback=self.noteImageIndex, headerImageIndex=self.imageIndex['note'], renderCallback=lambda task: '', **kwargs)) columns.extend( [widgets.Column('categories', _('Categories'), task.Task.categoryAddedEventType(), task.Task.categoryRemovedEventType(), task.Task.categorySubjectChangedEventType(), sortCallback=uicommand.ViewerSortByCommand(viewer=self, value='categories'), width=self.getColumnWidth('categories'), renderCallback=self.renderCategory, **kwargs)] + \ [widgets.Column('totalCategories', _('Overall categories'), task.Task.totalCategoryAddedEventType(), task.Task.totalCategoryRemovedEventType(), task.Task.totalCategorySubjectChangedEventType(), sortCallback=uicommand.ViewerSortByCommand(viewer=self, value='totalCategories'), renderCallback=lambda task: self.renderCategory(task, recursive=True), width=self.getColumnWidth('totalCategories'), **kwargs)]) effortOn = self.settings.getboolean('feature', 'effort') dependsOnEffortFeature = ['budget', 'totalBudget', 'timeSpent', 'totalTimeSpent', 'budgetLeft', 'totalBudgetLeft', 'hourlyFee', 'fixedFee', 'totalFixedFee', 'revenue', 'totalRevenue'] for name, columnHeader, renderCallback, eventType in [ ('startDate', _('Start date'), lambda task: render.date(task.startDate()), None), ('dueDate', _('Due date'), lambda task: render.date(task.dueDate()), None), ('timeLeft', _('Days left'), lambda task: render.daysLeft(task.timeLeft(), task.completed()), None), ('completionDate', _('Completion date'), lambda task: render.date(task.completionDate()), None), ('recurrence', _('Recurrence'), lambda task: render.recurrence(task.recurrence()), None), ('budget', _('Budget'), lambda task: render.budget(task.budget()), None), ('totalBudget', _('Total budget'), lambda task: render.budget(task.budget(recursive=True)), None), ('timeSpent', _('Time spent'), lambda task: render.timeSpent(task.timeSpent()), None), ('totalTimeSpent', _('Total time spent'), lambda task: render.timeSpent(task.timeSpent(recursive=True)), None), ('budgetLeft', _('Budget left'), lambda task: render.budget(task.budgetLeft()), None), ('totalBudgetLeft', _('Total budget left'), lambda task: render.budget(task.budgetLeft(recursive=True)), None), ('priority', _('Priority'), lambda task: render.priority(task.priority()), None), ('totalPriority', _('Overall priority'), lambda task: render.priority(task.priority(recursive=True)), None), ('hourlyFee', _('Hourly fee'), lambda task: render.amount(task.hourlyFee()), task.Task.hourlyFeeChangedEventType()), ('fixedFee', _('Fixed fee'), lambda task: render.amount(task.fixedFee()), None), ('totalFixedFee', _('Total fixed fee'), lambda task: render.amount(task.fixedFee(recursive=True)), None), ('revenue', _('Revenue'), lambda task: render.amount(task.revenue()), None), ('totalRevenue', _('Total revenue'), lambda task: render.amount(task.revenue(recursive=True)), None), ('reminder', _('Reminder'), lambda task: render.dateTime(task.reminder()), None)]: eventType = eventType or 'task.'+name if (name in dependsOnEffortFeature and effortOn) or name not in dependsOnEffortFeature: columns.append(widgets.Column(name, columnHeader, eventType, sortCallback=uicommand.ViewerSortByCommand(viewer=self, value=name), renderCallback=renderCallback, width=self.getColumnWidth(name), alignment=wx.LIST_FORMAT_RIGHT, **kwargs)) return columns