summaryrefslogtreecommitdiffstats
path: root/item.py
blob: d1d84271bc9b48b8e9fbca2a7268d7983bcf0e3d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-

class item:
    readOnly = ['id']
    
    def __init__(self, title=None, created=None, priority=None, description=None, completed=None, row=None):
        if title != None:
            self.__dict__['id'] = -1
            self.title = title
            self.created = created
            self.priority = priority
            self.description = description
            self.completed = completed
        else:
            id = row[0]

            row.__delitem__(0)
            apply(self.__init__, row)
            self.__dict__['id'] = id

    def setId(self, id):
        if self.id == -1:
            self.__dict__['id'] = id

    def getId(self):
        return self.id
    
    def getTitle(self):
        return self.title

    def getCreatedAt(self):
        return self.created

    def getPriority(self):
        return self.priority
    
    def getDescription(self):
        return self.description

    def getCompleted(self):
        return self.completed

    def __setattr__(self, name, value):
        if name not in item.readOnly:
            if name not in self.__dict__ or self.__dict__[name] != value:
                self.__dict__[name] = value
            
                if 'observer' in self.__dict__:
                    self.observer.notifyChange(self)