Exemplo n.º 1
0
class ClientTagEditorWin(SimpleWindow):
    def __init__(self, app, parent, clientid):
        SimpleWindow.__init__(self, app, parent, 'ContactEditor')
        self.app = app
        self.manager = ClientManager(self.app)
        self.clientid = clientid
        self.fields =  ['tag', 'value']
        self.dialogs = {}
        self.mainView = TagRowView(self.app, self, clientid)
        self.setCentralWidget(self.mainView)
        self.setCaption('ClientTagEditor')
        self.resize(300, 500)
        self.show()
        
    def initActions(self):
        collection = self.actionCollection()
        self.newAction = KStdAction.openNew(self.slotNewTag, collection)
        self.editAction = KStdAction.replace(self.slotEditTag, collection)
        self.quitAction = KStdAction.quit(self.close, collection)
        
    def initMenus(self):
        mainMenu = KPopupMenu(self)
        self.newAction.plug(mainMenu)
        self.editAction.plug(mainMenu)
        self.quitAction.plug(mainMenu)
        self.menuBar().insertItem('&Main', mainMenu)
        self.menuBar().insertItem('&Help', self.helpMenu(''))

    def initToolbar(self):
        toolbar = self.toolBar()
        self.newAction.plug(toolbar)
        self.editAction.plug(toolbar)
        self.quitAction.plug(toolbar)
        
    def slotNewTag(self):
        dlg = SimpleRecordDialog(self, ['tag', 'value'])
        dlg.connect(dlg, SIGNAL('okClicked()'), self.insertTag)
        dlg.connect(dlg, PYSIGNAL('updated()'), self.mainView.refreshlistView)
        self.dialogs['new-tag'] = dlg

    def slotEditTag(self):
        print 'slotEditTag'
    def insertTag(self):
        dlg = self.dialogs['new-tag']
        data = dlg.getRecordData()
        print 'data', data
        #data['clientid'] = self.clientid
        self.manager.appendTag(self.clientid, data['tag'], data['value'])
        #self.manager.updateContact(contactid, data)
        dlg.emit(PYSIGNAL('updated()'), ())
        dlg.close()
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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'
Exemplo n.º 4
0
 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()
Exemplo n.º 5
0
 def __init__(self, parent, app, *args):
     BaseManagerWidget.__init__(self, parent, app, ClientView, 'ClientManager')
     self.cfg = self.app.cfg
     self.cfg.setGroup('client-gui')
     size = self.cfg.readEntry('mainwinsize')
     w, h = [int(x.strip()) for x in str(size).split(',')]
     #self.resize(QSize(w, h))
     self.dialogs  = {}
     self.manager = ClientManager(self.app)
     self.initToolbar()
     self.resize(800, 600)
Exemplo n.º 6
0
class ClientView(ViewBrowser):
    def __init__(self, app, parent):
        doc = ClientInfoDoc(app)
        ViewBrowser.__init__(self, app, parent, ClientInfoDoc)
        self.dialogs = {}
        self.manager = ClientManager(self.app)
        self.resize(800, 600)
        
    def setSource(self, url):
        action, context, id = str(url).split('.')
        if context == 'contact':
            if action == 'new':
                dlg = ContactDialog(self, self.db)
                dlg.connect(dlg, SIGNAL('okClicked()'), self.insertContact)
                dlg.clientid = self.doc.current
                self.dialogs['new-contact'] = dlg
        elif context == 'location':
            if action == 'new':
                dlg = LocationDialog(self, self.db)
                dlg.connect(dlg, SIGNAL('okClicked()'), self.insertLocation)
                dlg.clientid = self.doc.current
                self.dialogs['new-location'] = dlg
        else:
            KMessageBox.error(self, 'bad call %s' % url)

    def set_client(self, clientid):
        clause = Eq('clientid', clientid)
        self.doc.setID(clientid)
        self.setText(self.doc.toxml())
        
    def insertContact(self):
        dlg = self.dialogs['new-contact']
        data = dict([(k,v.text()) for k,v in dlg.grid.entries.items()])
        contactid = self.manager.insertContact(dlg.clientid, dlg.addressid, data)
        self.set_client(dlg.clientid)

    def insertLocation(self):
        dlg = self.dialogs['new-location']
        data = dict([(k,v.text()) for k,v in dlg.grid.entries.items()])
        locationid = self.manager.insertLocation(dlg.clientid, dlg.addressid, data)
        self.set_client(dlg.clientid)
Exemplo n.º 7
0
 def __init__(self, app, parent, clientid):
     SimpleWindow.__init__(self, app, parent, 'ContactEditor')
     self.app = app
     self.manager = ClientManager(self.app)
     self.clientid = clientid
     self.fields =  ['tag', 'value']
     self.dialogs = {}
     self.mainView = TagRowView(self.app, self, clientid)
     self.setCentralWidget(self.mainView)
     self.setCaption('ClientTagEditor')
     self.resize(300, 500)
     self.show()
Exemplo n.º 8
0
class LocationView(RecordView):
    def __init__(self, app, parent, records):
        RecordView.__init__(self, app, parent, records, LocationDoc,
                            'edit')
        self.manager = ClientManager(self.app)
        
    def setSource(self, url):
        action, context, id = str(url).split('.')
        dlg = EditLocationDialog(self.app, self, self.doc.records[int(id)].record)
        dlg.connect(dlg, SIGNAL('okClicked()'), self.updateRecord)
        self.dialogs['edit-location'] = dlg

    def updateRecord(self):
        dlg = self.dialogs['edit-location']
        data = dlg.getRecordData()
        locationid = dlg.record.locationid
        data['addressid'] = dlg.addressid
        print 'updateRecord', locationid
        self.manager.updateLocation(locationid, data)
        self.parent().emit(PYSIGNAL('updated()'), ())
        self.parent().close()
Exemplo n.º 9
0
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)
        self.current = clientid
        self.clear_body()
        #make header
        self.header = ClientHeaderElement(cdata['client'])
        self.body.appendChild(self.header)
        #append contacts header
        conheader = ClientSectionHeader(self.current, 'contact', 'Contacts:')
        self.body.appendChild(conheader)
        self.contacts = ContactTableElement()
        self.body.appendChild(self.contacts)
        #append locations header
        locheader = ClientSectionHeader(self.current, 'location', 'Locations:')
        self.body.appendChild(locheader)
        self.locations = LocationTableElement()
        self.body.appendChild(self.locations)
        #insert the contacts, locations and tickets
        self.appendLocations(cdata)
        self.appendContacts(cdata)

    def _appendRows(self, rows, element, addresses):
        for row in rows:
            row.addressid = AddressLink(self.db, addresses[row.addressid])
            element.appendRowElement(element, row)
            
    def _appendRowsOrig(self, ids, fields, table, idcol, element):
        if len(ids):
            clause = In(idcol, ids)
            for row in self.db.mcursor.select(fields=fields, table=table, clause=clause):
                row.addressid = AddressLink(self.db, row.addressid)
                element.appendRowElement(element, row)
            
    def appendLocations(self, data):
        self._appendRows(data['locations'], self.locations, data['addresses'])

    def appendContacts(self, data):
        self._appendRows(data['contacts'], self.contacts, data['addresses'])
Exemplo n.º 10
0
 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')
Exemplo n.º 11
0
 def __init__(self, app, parent, records):
     RecordView.__init__(self, app, parent, records, LocationDoc,
                         'edit')
     self.manager = ClientManager(self.app)
Exemplo n.º 12
0
 def __init__(self, app, parent):
     doc = ClientInfoDoc(app)
     ViewBrowser.__init__(self, app, parent, ClientInfoDoc)
     self.dialogs = {}
     self.manager = ClientManager(self.app)
     self.resize(800, 600)
Exemplo n.º 13
0
class ClientManagerWidget(BaseManagerWidget):
    def __init__(self, parent, app, *args):
        BaseManagerWidget.__init__(self, parent, app, ClientView, 'ClientManager')
        self.cfg = self.app.cfg
        self.cfg.setGroup('client-gui')
        size = self.cfg.readEntry('mainwinsize')
        w, h = [int(x.strip()) for x in str(size).split(',')]
        #self.resize(QSize(w, h))
        self.dialogs  = {}
        self.manager = ClientManager(self.app)
        self.initToolbar()
        self.resize(800, 600)

    def initActions(self):
        collection = self.actionCollection()
        self.newAction = KStdAction.openNew(self.slotNew, collection)
        self.quitAction = KStdAction.quit(self.app.quit, collection)
        self.editaddressAction = EditAddresses(self.slotEditAddresses, collection)
        self.configureAction = ConfigureKonsultant(self.slotConfigure, collection)
        self.manageTicketsAction = ManageTickets(self.slotManageTickets, collection)
        print self.editaddressAction

    def initMenus(self):
        mainMenu = KPopupMenu(self)
        self.newAction.plug(mainMenu)
        self.manageTicketsAction.plug(mainMenu)
        self.editaddressAction.plug(mainMenu)
        self.quitAction.plug(mainMenu)
        self.configureAction.plug(mainMenu)
        self.menuBar().insertItem('&Main', mainMenu)
        self.menuBar().insertItem('&Help', self.helpMenu(''))
        
    def initlistView(self):
        self.listView.addColumn('client')
        self.listView.setRootIsDecorated(True)
        self.refreshlistView()
        
    def initToolbar(self):
        toolbar = self.toolBar()
        actions = [self.newAction, self.manageTicketsAction,
                   self.editaddressAction, self.quitAction]
        for action in actions:
            action.plug(toolbar)
        
    def refreshlistView(self):
        self.listView.clear()
        clients = KListViewItem(self.listView, 'clients')
        rows = self.db.mcursor.select(fields=['clientid', 'client'], table='clients')
        for row in rows:
            c = KListViewItem(clients, row['client'])
            c.clientid = row.clientid

    def slotConfigure(self):
        ConfigureDialog(self)
    
    def slotNew(self):
        dlg = ClientDialog(self, self.db)
        dlg.connect(dlg, SIGNAL('okClicked()'), self.insertClientok)
        self.dialogs['new-client'] = dlg
        
    def slotEditAddresses(self):
        AddressSelector(self, self.app)

    def testAction(self, action):
        KMessageBox.error(self, QString('<html>action <b>%s</b> not ready</html>' % action))

    def selectionChanged(self):
        current = self.listView.currentItem()
        if hasattr(current, 'clientid'):
            self.setClientView(current.clientid)
        else:
            self.view.setText('<b>clients</b>')


    def insertClientok(self):
        dlg = self.dialogs['new-client']
        data = dict([(k,v.text()) for k,v in dlg.grid.entries.items()])
        clientid = self.manager.insertClient(str(dlg.grid.entries['client'].text()))
        self.setClientView(clientid)
        self.refreshlistView()
    def setClientView(self, clientid):
        self.view.set_client(clientid)


    def slotManageTickets(self):
        TicketManagerWidget(self, self.app, self.db)