comparison browser_side/list_manager.py @ 256:0e7f3944bd27

browser_side: added contact group manager based on ListManager
author souliane <souliane@mailoo.org>
date Sat, 09 Nov 2013 09:39:45 +0100
parents 28d3315a8003
children d3c734669577
comparison
equal deleted inserted replaced
255:da0487f0a2e7 256:0e7f3944bd27
84 offsets["x_first"] = offsets["x"] 84 offsets["x_first"] = offsets["x"]
85 self.offsets.update(offsets) 85 self.offsets.update(offsets)
86 86
87 self.style = { 87 self.style = {
88 "keyItem": "recipientTypeItem", 88 "keyItem": "recipientTypeItem",
89 "popupMenuItem": "recipientTypeItem",
89 "buttonCell": "recipientButtonCell", 90 "buttonCell": "recipientButtonCell",
90 "dragoverPanel": "dragover-recipientPanel", 91 "dragoverPanel": "dragover-recipientPanel",
91 "keyPanel": "recipientPanel", 92 "keyPanel": "recipientPanel",
92 "textBox": "recipientTextBox", 93 "textBox": "recipientTextBox",
93 "removeButton": "recipientRemoveButton", 94 "removeButton": "recipientRemoveButton",
108 self._addChild(self.__keys_dict[key], title_format) 109 self._addChild(self.__keys_dict[key], title_format)
109 110
110 def _addChild(self, entry, title_format): 111 def _addChild(self, entry, title_format):
111 """Add a button and FlowPanel for the corresponding map entry.""" 112 """Add a button and FlowPanel for the corresponding map entry."""
112 button = Button(title_format % entry["title"]) 113 button = Button(title_format % entry["title"])
113 button.addStyleName(self.style["keyItem"]) 114 button.setStyleName(self.style["keyItem"])
114 if hasattr(entry, "desc"): 115 if hasattr(entry, "desc"):
115 button.setTitle(entry["desc"]) 116 button.setTitle(entry["desc"])
116 if not "optional" in entry: 117 if not "optional" in entry:
117 entry["optional"] = False 118 entry["optional"] = False
118 button.setVisible(not entry["optional"]) 119 button.setVisible(not entry["optional"])
209 """Used to drag and drop the contacts from one panel to another.""" 210 """Used to drag and drop the contacts from one panel to another."""
210 return self._target_drop_cell 211 return self._target_drop_cell
211 212
212 def registerPopupMenuPanel(self, entries, hide, callback): 213 def registerPopupMenuPanel(self, entries, hide, callback):
213 "Register a popup menu panel that will be bound to all contact keys elements." 214 "Register a popup menu panel that will be bound to all contact keys elements."
214 self.popup_menu = panels.PopupMenuPanel(entries=entries, hide=hide, callback=callback, item_style="recipientTypeItem") 215 self.popup_menu = panels.PopupMenuPanel(entries=entries, hide=hide, callback=callback, item_style=self.style["popupMenuItem"])
215 216
216 217
217 class DragAutoCompleteTextBox(AutoCompleteTextBox, DragWidget, MouseHandler): 218 class DragAutoCompleteTextBox(AutoCompleteTextBox, DragWidget, MouseHandler):
218 """A draggable AutoCompleteTextBox which is used for representing a contact. 219 """A draggable AutoCompleteTextBox which is used for representing a contact.
219 This class is NOT generic because of the onDragEnd method which call methods 220 This class is NOT generic because of the onDragEnd method which call methods
425 self.__remove_cbs = [] 426 self.__remove_cbs = []
426 427
427 def setContacts(self, tab): 428 def setContacts(self, tab):
428 """Set the contacts.""" 429 """Set the contacts."""
429 self.emptyContacts() 430 self.emptyContacts()
431 if isinstance(tab, set):
432 tab = list(tab)
433 tab.sort()
430 for contact in tab: 434 for contact in tab:
431 self.addContact(contact, resetLastTextBox=False) 435 self.addContact(contact, resetLastTextBox=False)
432 self.__resetLastTextBox() 436 self.__resetLastTextBox()
433 437
434 def getContacts(self): 438 def getContacts(self):