Esempio n. 1
0
    def handleNewObject(self, args):
        reminderDateTime = None
        recurrence = None
        priority = 0

        if self.version < 2:
            subject, taskId, description, startDate, dueDate, completionDate = args
            categories = None
        elif self.version < 5:
            subject, taskId, description, startDate, dueDate, completionDate, categories = args
            categories = [self.categoryMap[catId] for catId in categories]
        else:
            (subject, taskId, description, startDate, dueDate, completionDate,
             reminderDateTime, priority, hasRecurrence, recPeriod, recRepeat,
             recSameWeekday, categories) = args
            categories = [self.categoryMap[catId] for catId in categories]

            if hasRecurrence:
                recurrence = Recurrence(unit={
                    0: 'daily',
                    1: 'weekly',
                    2: 'monthly',
                    3: 'yearly'
                }[recPeriod],
                                        amount=recRepeat,
                                        sameWeekday=recSameWeekday)

        if self.version < 5:
            startDateTime = DateTime(
                startDate.year, startDate.month, startDate.day,
                self.disp().settings.getint(
                    'view',
                    'efforthourstart')) if startDate != Date() else DateTime()
            dueDateTime = DateTime(
                dueDate.year, dueDate.month, dueDate.day,
                self.disp().settings.getint(
                    'view',
                    'efforthourend')) if dueDate != Date() else DateTime()
            completionDateTime = DateTime(
                completionDate.year, completionDate.month, completionDate.day
            ) if completionDate != Date() else DateTime()
        else:
            startDateTime = startDate
            dueDateTime = dueDate
            completionDateTime = completionDate

        try:
            task = self.taskMap[taskId]
        except KeyError:
            if self.version >= 5:
                self.pack('s', '')
        else:
            self.disp().log(_('Modify task %s'), task.id())
            self.disp().window.modifyIPhoneTask(task, subject, description,
                                                startDateTime, dueDateTime,
                                                completionDateTime,
                                                reminderDateTime, recurrence,
                                                priority, categories)
            if self.version >= 5:
                self.pack('s', task.id())
Esempio n. 2
0
class TwoWayNewTasksState4(BaseState):
    def init(self):
        super(TwoWayNewTasksState4, self).init('ssddfz[s]', self.newTasksCount)

    def handleNewObject(self, (subject, description, startDate, dueDate,
                               completionDateTime, parentId, categories)):
        parent = self.taskMap[parentId] if parentId and self.taskMap.has_key(
            parentId) else None

        if self.version < 5:
            startDateTime = DateTime() if startDate == Date() else DateTime(
                year=startDate.year,
                month=startDate.month,
                day=startDate.day,
                hour=self.disp().settings.getint('view', 'efforthourstart'))

            dueDateTime = DateTime() if dueDate == Date() else DateTime(
                year=dueDate.year,
                month=dueDate.month,
                day=dueDate.day,
                hour=self.disp().settings.getint('view', 'efforthourend'))

        task = Task(subject=subject,
                    description=description,
                    startDateTime=startDateTime,
                    dueDateTime=dueDateTime,
                    completionDateTime=completionDateTime,
                    parent=parent)

        self.disp().window.addIPhoneTask(task, [self.categoryMap[catId] for catId in categories \
                                                    if self.categoryMap.has_key(catId)])
        self.disp().log(_('New task %s'), task.id())

        self.taskMap[task.id()] = task
        self.pack('s', task.id())
Esempio n. 3
0
    def pack(self, value):
        if isinstance(value, DateTime):
            value = Date(value.year, value.month, value.day)

        value = None if value == Date() else value.isoformat()
        return super(DateItem, self).pack(value)
Esempio n. 4
0
    def pack(self, value):
        if isinstance(value, DateTime):
            value = Date(value.year, value.month, value.day)

        value = None if value == Date() else value.isoformat()
        return super(DateItem, self).pack(value)
Esempio n. 5
0
    def feed(self, data):
        super(DateItem, self).feed(data)

        if self.state == 2:
            self.value = Date() if self.value is None else parseDate(
                self.value)