Mercurial > libervia-web
changeset 255:da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
- group and contact lists are sorted
- avoid adding empty group in the "Add group" panel
- allow to show/hide the contact panel from another class
author | souliane <souliane@mailoo.org> |
---|---|
date | Sat, 09 Nov 2013 15:31:39 +0100 |
parents | 28d3315a8003 |
children | 0e7f3944bd27 |
files | browser_side/contact.py browser_side/dialog.py browser_side/panels.py |
diffstat | 3 files changed, 26 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/browser_side/contact.py Sat Nov 09 09:38:17 2013 +0100 +++ b/browser_side/contact.py Sat Nov 09 15:31:39 2013 +0100 @@ -89,7 +89,12 @@ _item = GroupLabel(self._parent.host, group) _item.addMouseListener(self._parent) DOM.setStyleAttribute(_item.getElement(), "cursor", "pointer") - VerticalPanel.add(self, _item) + index = 0 + for group_ in [group.group for group in self.getChildren()]: + if group_ > group: + break + index += 1 + VerticalPanel.insert(self, _item, index) def remove(self, group): for wid in self: @@ -105,15 +110,20 @@ def __init__(self, host): VerticalPanel.__init__(self) self.host = host - self.contacts = set() + self.contacts = [] def add(self, jid, name=None, item_cb=None): if jid in self.contacts: return - self.contacts.add(jid) + index = 0 + for contact_ in self.contacts: + if contact_ > jid: + break + index += 1 + self.contacts.insert(index, jid) _item = ContactLabel(self.host, jid, name) DOM.setStyleAttribute(_item.getElement(), "cursor", "pointer") - VerticalPanel.add(self, _item) + VerticalPanel.insert(self, _item, index) if item_cb is not None: item_cb(_item)
--- a/browser_side/dialog.py Sat Nov 09 09:38:17 2013 +0100 +++ b/browser_side/dialog.py Sat Nov 09 15:31:39 2013 +0100 @@ -298,6 +298,8 @@ def onGroupInput(self, sender): text = sender.getText() + if text == "": + return for group in self.groups: if text == group: Window.alert("The group '%s' already exists." % text)
--- a/browser_side/panels.py Sat Nov 09 09:38:17 2013 +0100 +++ b/browser_side/panels.py Sat Nov 09 15:31:39 2013 +0100 @@ -114,6 +114,10 @@ #self.getCompletionItems().completions.append(key) def removeKey(self, key): + return + # TODO: investigate why AutoCompleteTextBox doesn't work here, + # maybe it can work on a TextBox but no TextArea. Remove addKey + # and removeKey methods if they don't serve anymore. try: self.getCompletionItems().completions.remove(key) except KeyError: @@ -890,9 +894,9 @@ # contacts self._contacts = HorizontalPanel() self._contacts.addStyleName('globalLeftArea') - contacts_switch = Button(u'«', self._contactsSwitch) - contacts_switch.addStyleName('contactsSwitch') - self._contacts.add(contacts_switch) + self.contacts_switch = Button(u'«', self._contactsSwitch) + self.contacts_switch.addStyleName('contactsSwitch') + self._contacts.add(self.contacts_switch) self._contacts.add(self.host.contact_panel) # tabs @@ -916,8 +920,10 @@ self.setWidth("100%") Window.addWindowResizeListener(self) - def _contactsSwitch(self, btn): + def _contactsSwitch(self, btn=None): """ (Un)hide contacts panel """ + if btn is None: + btn = self.contacts_switch cpanel = self.host.contact_panel cpanel.setVisible(not cpanel.getVisible()) btn.setText(u"«" if cpanel.getVisible() else u"»")