Пример #1
0
    def groupUpdated(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.toHtmlString()) + "</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())
Пример #2
0
    def group_added(self, group):
        pi = self._model.invisibleRootItem()

        # Adding Group Item

        groupItem = QStandardItem()
        gname = StringView()
        gname = group.name
        self._model.item(groupItem.row(), 0).setText('<b>'+QString.fromUtf8(gname.toHtmlString())+'</b>')
        self._model.item(groupItem.row(), 1).setText(QString.fromUtf8(str(group.uid)))
        pi.appendRow(groupItem)

        for contact in group.contacts:
            contactItem = QStandardItem()
            cname = StringView()
            cname = contact.name
            self._model.item(contactItem.row(), 0).setText(QString.fromUtf8(cname.toHtmlString()))
            self._model.item(contactItem.row(), 1).setText(QString.fromUtf8(str(contact.uid)))

            groupItem.appendRow(contactItem)

            self._contactDict[contact.uid] = contact
Пример #3
0
    def groupAdded(self, group):
        pi = self._model.invisibleRootItem()

        # Adding Group Item

        groupItem = QStandardItem()
        gname = StringView()
        gname = group.name
        self._model.item(groupItem.row(), 0).setText('<b>'+QString.fromUtf8(gname.toHtmlString())+'</b>')
        self._model.item(groupItem.row(), 1).setText(QString.fromUtf8(str(group.uid)))
        pi.appendRow(groupItem)

        for contact in group.contacts:
            contactItem = QStandardItem()
            cname = StringView()
            cname = contact.name
            self._model.item(contactItem.row(), 0).setText(QString.fromUtf8(cname.toHtmlString()))
            self._model.item(contactItem.row(), 1).setText(QString.fromUtf8(str(contact.uid)))

            groupItem.appendRow(contactItem)

            self._contactDict[contact.uid] = contact
Пример #4
0
    def contactUpdated(self, contact):

        citem = self.__search_by_id(contact.uid)
        if citem is None:
            return

        gitem = citem.parent()
        if gitem is None:
            return

        dp = Image(self._parent._theme_manager, contact.dp)
        dp = dp.to_size(28, 28)
        # icon = Image(self._parent._theme_manager, contact.icon)

        gitem.child(self._model.indexFromItem(citem).row(), 0).setData(QVariant(dp), Qt.DecorationRole)
        # gitem.child(self._model.indexFromItem(citem).row(), 0).setData(QVariant(icon), Qt.DecorationRole)

        gitem.child(self._model.indexFromItem(citem).row(), 3).setData(QVariant(contact), Qt.DisplayRole)
        cname = StringView()
        cname = contact.name
        gitem.child(self._model.indexFromItem(citem).row(), 0).setText(QString.fromUtf8(cname.toHtmlString()))
Пример #5
0
    def groupUpdated(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.toHtmlString())+'</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())