Пример #1
0
    def group_updated(self, group):
        if (group.uid == 0): group.uid = '0'
        if group.uid not in self.groups: return
        
        gitem = self.__search_by_id(group.uid)
        self._model.item(self._model.indexFromItem(gitem).row(), 3).setData(QVariant(group), Qt.DisplayRole)
        gname = StringView()
        gname = group.name
        self._model.item((self._model.indexFromItem(gitem)).row(), 0).setText('<b>'+QString.fromUtf8(gname.to_HTML_string())+'</b>')

        try:
            cuids = self.contacts[group.uid]
        except:
            cuids = []
        self.contacts[group.uid] = group.contact_ids.copy()

        for cid in group.contact_ids:
            if cid not in cuids:
                gitem = self.__search_by_id(group.uid)
                gitem.appendRow([QStandardItem(cid), QStandardItem(cid), QStandardItem("contact"), QStandardItem()])

        # Remove unused contacts
        for cid in cuids:
            if cid not in self.contacts[group.uid]:
                citem = self.__search_by_id(cid)
                self._model.removeRow((self._model.indexFromItem(citem)).row())