Пример #1
0
 def __init__(self, parent, task, *args, **kwargs):
     super(BudgetPage, self).__init__(parent, task, *args, **kwargs)
     # Boxes:
     budgetBox = widgets.BoxWithFlexGridSizer(self, label=_('Budget'), cols=3)
     revenueBox = widgets.BoxWithFlexGridSizer(self, label=_('Revenue'), cols=3)
     # Editable entries:
     self._budgetEntry = TimeDeltaEntry(budgetBox, task.budget())
     self._hourlyFeeEntry = AmountEntry(revenueBox, task.hourlyFee())
     self._fixedFeeEntry = AmountEntry(revenueBox, task.fixedFee())
     # Readonly entries:
     if task.children():
         recursiveBudget = render.budget(task.budget(recursive=True))
         recursiveTimeSpent = render.timeSpent(task.timeSpent(recursive=True))
         recursiveBudgetLeft = render.budget(task.budgetLeft(recursive=True))
         recursiveFixedFee = render.amount(task.fixedFee(recursive=True))
         recursiveRevenue = render.amount(task.revenue(recursive=True))
     else:
         recursiveBudget = recursiveTimeSpent = recursiveBudgetLeft = \
         recursiveFixedFee = recursiveRevenue = ''
     # Fill the boxes:
     self.addHeaders(budgetBox)
     for entry in [_('Budget'), self._budgetEntry, recursiveBudget,
                   _('Time spent'), render.budget(task.timeSpent()), recursiveTimeSpent,
                   _('Budget left'), render.budget(task.budgetLeft()), recursiveBudgetLeft]:
         budgetBox.add(entry, flag=wx.ALIGN_RIGHT)
     
     self.addHeaders(revenueBox)
     for entry in [_('Hourly fee'), self._hourlyFeeEntry, '',
                   _('Fixed fee'), self._fixedFeeEntry, recursiveFixedFee,
                   _('Revenue'), render.amount(task.revenue()), recursiveRevenue]:
         revenueBox.add(entry, flag=wx.ALIGN_RIGHT)
     for box in budgetBox, revenueBox:
         box.fit()
         self.add(box, proportion=0, flag=wx.EXPAND|wx.ALL, border=5)
     self.fit()
Пример #2
0
 def _addTaskRecursively(self, task, parentItem=None):
     ''' Add a task to the ComboTreeBox and then recursively add its
         subtasks. '''
     item = self._comboTreeBox.Append(task.subject(), parent=parentItem, 
                                      clientData=task)
     for child in task.children():
         self._addTaskRecursively(child, item)
Пример #3
0
    def read(self):
        # Determine where are attachments.
        path, name = os.path.split(os.path.abspath(self.__fd.name))
        name, ext = os.path.splitext(name)
        attdir = os.path.normpath(os.path.join(path, name + '_attachments'))
        attachment.MailAttachment.attdir = attdir

        domDocument = xml.dom.minidom.parse(self.__fd)
        self.__tskversion = self.__parseTskVersionNumber(domDocument)
        tasks = self.__parseTaskNodes(domDocument.documentElement.childNodes)
        categorizables = tasks[:]
        for task in tasks:
            categorizables.extend(task.children(recursive=True))
        if self.__tskversion <= 15:
            notes = []
        else:
            notes = self.__parseNoteNodes(domDocument.documentElement.childNodes)
        categorizables.extend(notes)
        for note in notes:
            categorizables.extend(note.children(recursive=True))
        categorizablesById = dict([(categorizable.id(), categorizable) for \
                                   categorizable in categorizables])
        if self.__tskversion <= 13:
            categories = self.__parseCategoryNodesFromTaskNodes(domDocument, 
                                                                categorizablesById)
        else:
            categories = self.__parseCategoryNodes( \
                domDocument.documentElement.childNodes, categorizablesById)

        return tasks, categories, notes
Пример #4
0
    def read(self):
        domDocument = xml.dom.minidom.parse(self.__fd)
        self.__tskversion = self.__parseTskVersionNumber(domDocument)
        tasks = self.__parseTaskNodes(domDocument.documentElement.childNodes)
        categorizables = tasks[:]
        for task in tasks:
            categorizables.extend(task.children(recursive=True))
        if self.__tskversion <= 15:
            notes = []
        else:
            notes = self.__parseNoteNodes(domDocument.documentElement.childNodes)
        categorizables.extend(notes)
        for note in notes:
            categorizables.extend(note.children(recursive=True))
        categorizablesById = dict([(categorizable.id(), categorizable) for \
                                   categorizable in categorizables])
        if self.__tskversion <= 13:
            categories = self.__parseCategoryNodesFromTaskNodes(domDocument, 
                                                                categorizablesById)
        else:
            categories = self.__parseCategoryNodes( \
                domDocument.documentElement.childNodes, categorizablesById)

        guid = self.__findGUIDNode(domDocument.documentElement.childNodes)
        syncMLConfig = self.__parseSyncMLNode(domDocument.documentElement.childNodes, guid)

        return tasks, categories, notes, syncMLConfig, guid
Пример #5
0
    def __init__(self, parent, task, *args, **kwargs):
        super(DatesPage, self).__init__(parent, task, *args, **kwargs)
        datesBox = widgets.BoxWithFlexGridSizer(self, label=_("Dates"), cols=3)
        self.addHeaders(datesBox)
        for label, taskMethodName in [
            (_("Start date"), "startDate"),
            (_("Due date"), "dueDate"),
            (_("Completion date"), "completionDate"),
        ]:
            datesBox.add(label)
            taskMethod = getattr(task, taskMethodName)
            entry = DateEntry(datesBox, taskMethod(), callback=self.onDateChanged)
            setattr(self, "_%sEntry" % taskMethodName, entry)
            datesBox.add(entry)
            if task.children():
                recursiveEntry = DateEntry(datesBox, taskMethod(recursive=True), readonly=True)
            else:
                recursiveEntry = (0, 0)
            datesBox.add(recursiveEntry)

        reminderBox = widgets.BoxWithFlexGridSizer(self, label=_("Reminder"), cols=2)
        reminderBox.add(_("Reminder"))
        self._reminderDateTimeEntry = widgets.DateTimeCtrl(reminderBox, task.reminder())
        # If the users has not set a reminder, make sure that the default
        # date time in the reminder entry is a reasonable suggestion:
        if self._reminderDateTimeEntry.GetValue() == date.DateTime.max:
            self.suggestReminder()
        reminderBox.add(self._reminderDateTimeEntry)

        recurrenceBox = widgets.BoxWithFlexGridSizer(self, label=_("Recurrence"), cols=2)
        recurrenceBox.add(_("Recurrence"))
        self._recurrenceEntry = wx.Choice(recurrenceBox, choices=[_("None"), _("Daily"), _("Weekly"), _("Monthly")])
        self._recurrenceEntry.Bind(wx.EVT_CHOICE, self.onRecurrenceChanged)
        recurrenceBox.add(self._recurrenceEntry)
        recurrenceBox.add(_("Maximum number of recurrences"))
        panel = wx.Panel(recurrenceBox)
        panelSizer = wx.BoxSizer(wx.HORIZONTAL)
        self._maxRecurrenceCheckBox = wx.CheckBox(panel)
        self._maxRecurrenceCheckBox.Bind(wx.EVT_CHECKBOX, self.onMaxRecurrenceChecked)
        panelSizer.Add(self._maxRecurrenceCheckBox, flag=wx.ALIGN_CENTER_VERTICAL)
        panelSizer.Add((3, -1))
        self._maxRecurrenceCountEntry = wx.SpinCtrl(
            panel, size=(50, -1), value=str(task.maxRecurrenceCount()), style=wx.SP_ARROW_KEYS
        )
        # Can't use sys.maxint because Python and wxPython disagree on what the
        # maximum integer is on Suse 10.0 x86_64. Using sys.maxint will cause
        # an Overflow exception, so we use a constant:
        maxint = 2147483647
        self._maxRecurrenceCountEntry.SetRange(1, maxint)
        self.setRecurrence(task.recurrence())
        panelSizer.Add(self._maxRecurrenceCountEntry)
        panel.SetSizerAndFit(panelSizer)
        recurrenceBox.add(panel)

        for box in datesBox, reminderBox, recurrenceBox:
            box.fit()
            self.add(box, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
        self.fit()
Пример #6
0
 def addMenuItemForTask(self, task, menu):
     uiCommand = uicommand.EffortStartForTask(task=task, taskList=self.tasks)
     uiCommand.appendToMenu(menu, self._window)
     activeChildren = [child for child in task.children() if child.active()]
     if activeChildren:
         activeChildren.sort(key=lambda task: task.subject())
         subMenu = wx.Menu()
         for child in activeChildren:
             self.addMenuItemForTask(child, subMenu)
         menu.AppendSubMenu(subMenu, _('%s (subtasks)')%task.subject())
Пример #7
0
 def addPrerequisitesAndDependencies(tasks):            
     for task in tasks:
         dummyPrerequisites = task.prerequisites()
         prerequisites = set()
         for dummyPrerequisite in dummyPrerequisites:
             prerequisites.add(tasksById[dummyPrerequisite.id])
         task.setPrerequisites(prerequisites)
         for prerequisite in prerequisites:
             prerequisite.addDependencies([task])
         addPrerequisitesAndDependencies(task.children())
Пример #8
0
 def addMenuItemForTask(self, task, menu):  # pylint: disable=W0621
     uiCommand = uicommand.EffortStartForTask(task=task, taskList=self.tasks)
     uiCommand.addToMenu(menu, self._window)
     trackableChildren = [child for child in task.children() if \
                          child in self.tasks and not child.completed()]
     if trackableChildren:
         trackableChildren.sort(key=lambda child: child.subject())
         subMenu = Menu(self._window)
         for child in trackableChildren:
             self.addMenuItemForTask(child, subMenu)
         menu.AppendSubMenu(subMenu, _('%s (subtasks)') % task.subject())
Пример #9
0
 def addMenuItemForTask(self, task, menu):  # pylint: disable=W0621
     uiCommand = uicommand.EffortStartForTask(task=task, taskList=self.tasks)
     uiCommand.addToMenu(menu, self._window)
     trackableChildren = [child for child in task.children() if \
                          child in self.tasks and not child.completed()]
     if trackableChildren:
         trackableChildren.sort(key=lambda child: child.subject())
         subMenu = Menu(self._window)
         for child in trackableChildren:
             self.addMenuItemForTask(child, subMenu)
         menu.AppendSubMenu(subMenu, _('%s (subtasks)') % task.subject())
Пример #10
0
 def addMenuItemForTask(self, task, menu):  # pylint: disable-msg=W0621
     uiCommand = uicommand.EffortStartForTask(task=task,
                                              taskList=self.tasks)
     uiCommand.addToMenu(menu, self._window)
     activeChildren = [child for child in task.children() if \
                       child in self.tasks and child.active()]
     if activeChildren:
         activeChildren.sort(key=lambda task: task.subject())
         subMenu = wx.Menu()
         for child in activeChildren:
             self.addMenuItemForTask(child, subMenu)
         menu.AppendSubMenu(subMenu, _('%s (subtasks)') % task.subject())
Пример #11
0
 def addDatesBox(self, task):
     datesBox = widgets.BoxWithFlexGridSizer(self, label=_('Dates'), cols=3)
     self.addHeaders(datesBox)
     for label, taskMethodName in [(_('Start date'), 'startDate'),
                                   (_('Due date'), 'dueDate'),
                                   (_('Completion date'), 'completionDate')]:
         datesBox.add(label)
         taskMethod = getattr(task, taskMethodName)
         dateEntry = entry.DateEntry(datesBox, taskMethod(),
                                     callback=self.onDateChanged)
         setattr(self, '_%sEntry'%taskMethodName, dateEntry)
         datesBox.add(dateEntry)
         if task.children():
             recursiveDateEntry = entry.DateEntry(datesBox,
                 taskMethod(recursive=True), readonly=True)
         else:
             recursiveDateEntry = (0, 0)
         datesBox.add(recursiveDateEntry)
     return datesBox
Пример #12
0
 def addPrerequisitesAndDependencies(tasks, event):
     for task in tasks:
         if task.isDeleted():
             # Don't restore prerequisites and dependencies for deleted
             # tasks
             task.setPrerequisites([], event=event)
             continue
         dummyPrerequisites = task.prerequisites()
         prerequisites = set()
         for dummyPrerequisite in dummyPrerequisites:
             try:
                 prerequisites.add(tasksById[dummyPrerequisite.id])
             except KeyError:
                 # Release 1.2.11 and older have a bug where tasks can
                 # have prerequisites listed that don't exist anymore
                 pass
         task.setPrerequisites(prerequisites, event=event)
         for prerequisite in prerequisites:
             prerequisite.addDependencies([task], event=event)
         addPrerequisitesAndDependencies(task.children(), event)
Пример #13
0
 def collectIds(tasks):
     for task in tasks:
         tasksById[task.id()] = task
         collectIds(task.children())
Пример #14
0
 def children(self, task):
     return [child for child in task.children() if child in self.presentation()]
Пример #15
0
 def collectIds(tasks):
     for task in tasks:
         tasksById[task.id()] = task
         collectIds(task.children())