class TagRowView(KListView): def __init__(self, app, parent, clientid): KListView.__init__(self, parent) self.app = app self.manager = ClientManager(self.app) self.clientid = clientid self.addColumn('tag') self.addColumn('value') self.setRootIsDecorated(True) self.connect(self, SIGNAL('rightButtonClicked()'), self.popupmymenu) self.refreshlistView() def refreshlistView(self): self.clear() tags = self.manager.getTags(self.clientid) for k, v in tags.items(): KListViewItem(self, k, v) def popupmymenu(self): print 'popupmymenu, right click worked' def rightButtonClicked(self, item, *args): print args print item print 'rightButtonClicked'
class ClientInfoDoc(BaseDocument): def __init__(self, app): BaseDocument.__init__(self, app) self.manager = ClientManager(self.app) self.body.setAttribute('text', '#000000') self.body.setAttribute('background', 'Time-For-Lunch-2.jpg') def setID(self, clientid): cdata = self.manager.getClientInfo(clientid) cdata['addresses'].set_refobject('address', AddressRecord) self.current = clientid self.clear_body() #make header #self.header = ClientHeaderElement(cdata['client']) self.header = ClientTitleElement(cdata['client']) self.body.appendChild(self.header) #make main table self.mtable = BaseElement('table') self.mtable.appendChild(BaseElement('tr')) self.body.appendChild(self.mtable) #append contacts header conheader = ClientSectionHeader(self.current, 'contact', 'Contacts:') self.mtable.firstChild.appendChild(TextElement('td', conheader)) self.contacts = ContactDoc(self.app) self.mtable.firstChild.appendChild(TextElement('td', self.contacts)) #append locations header row = BaseElement('tr') locheader = ClientSectionHeader(self.current, 'location', 'Locations:') row.appendChild(TextElement('td', locheader)) self.locations = LocationDoc(self.app) self.mtable.appendChild(row) row.appendChild(TextElement('td', self.locations)) #insert the contacts, locations and tickets self.contacts.set_records(cdata['contacts'], action=None) self.locations.set_records(cdata['locations'], action=None) for node in self.contacts.records.values(): node.setAttribute('bgcolor', 'DarkSeaGreen3') for node in self.locations.records.values(): node.setAttribute('bgcolor', 'DarkSeaGreen3') self.records = cdata #append tag data #check for tag data tags = self.manager.getTags(clientid) row = BaseElement('tr') tagdoc = ClientTagTableElement(clientid, tags) row.appendChild(tagdoc) self.mtable.appendChild(row) newtrouble = Anchor('new.trouble.%s' % clientid, 'new trouble') self.body.appendChild(newtrouble)