def _createSelectionFile(self, tasks, TaskFileClass): selectionFile = TaskFileClass() selectionFile.tasks().extend(tasks) allCategories = set() for task in tasks: allCategories.update(task.categories()) selectionFile.categories().extend(allCategories) return selectionFile
def __init__(self, parent, task, categories, *args, **kwargs): super(CategoriesPage, self).__init__(parent, task, *args, **kwargs) self.__categories = category.CategorySorter(categories) categoriesBox = widgets.BoxWithBoxSizer(self, label=_('Categories')) self._treeCtrl = widgets.CheckTreeCtrl(categoriesBox, lambda index: self.getCategoryWithIndex(index).subject(), lambda *args: None, lambda index, expanded=False: -1, lambda index: customtree.TreeItemAttr(), self.getChildrenCount, lambda index: 'Undetermined', lambda index: self.getCategoryWithIndex(index) in task.categories(), lambda *args: None, lambda *args: None, lambda *args: None, lambda *args: None) self._treeCtrl.expandAllItems() categoriesBox.add(self._treeCtrl, proportion=1, flag=wx.EXPAND|wx.ALL) categoriesBox.fit() self.add(categoriesBox) self.fit()
def edit(self, tasks=None, edits=None): tasks = tasks or [] editcommand = command.EditTaskCommand(self.taskList, tasks) for task in tasks: task.setSubject('New subject') task.setDescription('New description') task.setBudget(date.TimeDelta(hours=1)) task.setCompletionDate() att = attachment.FileAttachment('attachment') if att in task.attachments(): task.removeAttachments(att) else: task.addAttachments(att) if self.category in task.categories(): task.removeCategory(self.category) else: task.addCategory(self.category) for edit in edits or []: edit() editcommand.do()
def do_command(self): super(EditTaskCommand, self).do_command() self.newCategories = [task.categories() for task in self.items] self.updateCategories(self.oldCategories, self.newCategories)
def __init__(self, *args, **kwargs): super(EditTaskCommand, self).__init__(*args, **kwargs) self.oldCategories = [task.categories() for task in self.items]