blob: 7dc2944277425eb9b331e4206809ee87327deea7 (
plain) (
tree)
|
|
# -*- coding: utf-8 -*-
class itemList:
def __init__(self, observer):
self.data = []
self.observer = observer
def __len__(self):
return len(self.data)
def __getitem__(self, idx):
return self.data[idx]
def __setitem__(self, idx, item):
self.data[idx] = item
def __delitem__(self, key):
self.date[key].removed = True
self.data.__delitem__(key)
def remove(self, item):
item.removed = True
self.data.remove(item)
def __contians__(self, item):
return (item in self.data)
def append(self, item):
item.observer = self
self.data.append(item)
self.observer.notifyChange(item)
def notifyChange(self, sender):
self.observer.notifyChange(sender)
def __add__(self, item):
self.append(item)
return self
def __iter__(self):
return self.data.__iter__()
|