def pubContacts(self, event): s = domaindata.get_action_summary() txt = "Do you really want to %s %d, %s %d and %s %d contacts, and add %d update %d and delete %d groups?" % ( ACTION.ADD, s[ACTION.ADD], ACTION.UPDATE, s[ACTION.UPDATE], ACTION.DELETE, s[ACTION.DELETE], s[GRP.ADD], s[GRP.UPDATE], s[GRP.DELETE] ) dlg = self.app.displayDialog(wx.MessageDialog, txt, 'Question?', wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: logging.debug("Publish changes") dlg.Destroy() dlg = self.app.inProgressDialog("Publish changes made to contacts...") try: domaindata.publish_changes() dlg.Destroy() except BaseException, e: dlg.Destroy() self.alert(str(e), title="Publish Error") observer.send_message(pmsg.DATA_UPLOADED) # do it anyway because of possible partial upload
def delContact(self, msg): logging.debug("Controller: Delete contact %s" % str(msg)) for row in msg.data: if row >= 0: logging.debug("Mark row %d as deleted" % row) domaindata.del_contact_from_row(row) observer.send_message(pmsg.CONTACT_DELETED)
def onDelete(self, event): if self.idx >= 0: name = self.gnc.GetValue().strip() try: self.pg.delete(name) self.glc.DeleteItem(self.idx) except Exception, e: observer.send_message(pmsg.ALERT, data=str(e)) self.clearForm()
def onAddOrUpdate(self, event): name = self.gnc.GetValue().strip() if len(name) == 0: return if self.idx < 0: try: self.pg.add(name) self.appendGroup( name, TYPE_TXT_PRI) except Exception, e: observer.send_message(pmsg.ALERT, data=str(e)) self.clearForm()
def downloadGroups(self): try: dlg = self.app.inProgressDialog("Download groups...") domaindata.download_groups() observer.send_message(pmsg.GROUPS_DOWNLOADED) dlg.Destroy() except Exception, e: dlg.Destroy() self.alert(str(e), title="Download Error") return False
def downloadContacts(self): try: dlg = self.app.inProgressDialog("Download contacts...") domaindata.download_contacts() observer.send_message(pmsg.DATA_DOWNLOADED) dlg.Destroy() # contacts downloaded except Exception, e: dlg.Destroy() self.alert(str(e), title="Download Error") return False
def cancel_search(): # just for consitency it is done here observer.send_message(pmsg.UNHIDE_ROWS)
def do_search(sf): # sf: search filter as string global _domainContacts if _domainContacts: cidx = _domainContacts.getSearchHits(sf) observer.send_message(pmsg.HIDE_ROWS, data=cidx)
def __delitionDone__(self, e): d={'id':e.id.text, 'name':e.title.text} observer.send_message(pmsg.GROUP_DELETION_DONE, data=d)
def resetSearch(self, evt): self.search.Clear() observer.send_message(pmsg.CANCEL_SEARCH)
def onSearch(self, evt): s = self.search.GetValue() if len(s) > 0: observer.send_message(pmsg.SEARCH, data=s) else: observer.send_message(pmsg.CANCEL_SEARCH, data=s)
def publishEvent(self, event): """Depending on the id the event with the appropriate message will be published. """ if event.GetId() == self.ADD_ID: observer.send_message(pmsg.ADD_CONTACT, event) elif event.GetId() == self.DEL_ID: observer.send_message(pmsg.DEL_CONTACT, data=self.grid.getActiveRows()) elif event.GetId() == self.GRP_ID: observer.send_message(pmsg.MAN_GROUPS, event) elif event.GetId() == self.PUB_ID: observer.send_message(pmsg.PUB_CONTACT, event) elif event.GetId() == self.GET_ID: observer.send_message(pmsg.PUB_CONTACT, event) elif event.GetId() == self.EXIT_ID: observer.send_message(pmsg.EXIT_APP, event)
def publishChanges(self): for g in self.groups: if g.flag: observer.send_message(g.flag, data=g) g.clearFlag() log.debug("Published %s %s" % (str(g.flag), g.current))
def addContact(self, event): logging.debug("Controller: Add contact") domaindata.add_contact() observer.send_message(pmsg.CONTACT_ADDED)