示例#1
0
void ChatControler::onListChanged(int flag, std::vector<std::shared_ptr<service::User> > chats)
{
    qDebug() << Q_FUNC_INFO;
    qDebug() <<Q_FUNC_INFO<< "chats szie:" << chats.size();
    Chat_UIList  chatList;
    for(auto i: chats){

        std::shared_ptr<service::Chat> ch = std::dynamic_pointer_cast<service::Chat>(i);
        Chat_UI chatData;
        chatData.name = QString::fromStdString(ch->name);
        qDebug() <<Q_FUNC_INFO<<QString::fromStdString(ch->last_msg);
        if(ch->msg_type==2||ch->msg_type==8){
        chatData.last_msg =  QString::fromStdString(utils::MsgUtils::getText(ch->last_msg));
        }
        else{
        chatData.last_msg = "不支持的消息类型,请在电脑端查看";
        }
        chatData.avatar =  QString::fromStdString(ch->avatar);
        chatData.msg_time = dealTime(ch->msg_time,1);
        chatData.id = QString::number(ch->id);
        qDebug() << Q_FUNC_INFO << "name" << chatData.name<<"id"<<chatData.id<<"unreadcount"<<QString::number(ch->unread_count);
        chatData.chat_type = ch->chat_type;
        chatData.thumb_avatar = QString::fromStdString(ch->thumb_avatar);
        chatData.unread_count=ch->unread_count;
        if(chatData.chat_type == 1){
            chatList.push_back(chatData);
        }
        // qDebug() << Q_FUNC_INFO << "avatar" << chatData.avatar;
        // qDebug() << Q_FUNC_INFO << "thumb_avatar" << ch->thumb_avatar.c_str();
    }
    emit chatListChanged(chatList);

}
void CDoodSessionListManager::onChatListChanged(const Chat_UIList &chats)
{
    qDebug() << Q_FUNC_INFO << "zhangp **** chat size4 = " << chats.size();
    Chat_UI historysession;
    foreach (historysession, chats) {
        if(!sessionListMap.contains(historysession.id)) {
            CDoodSessionListItem *tmpItem = new CDoodSessionListItem(this);
            tmpItem->setId(historysession.id);
            tmpItem->setLastMsg(historysession.last_msg);
            tmpItem->setName(historysession.name);
            tmpItem->setMsgTime(historysession.msg_time);
            tmpItem->setThumbAvatar(historysession.thumb_avatar);
            qDebug() << Q_FUNC_INFO << "chat avatar111:" << historysession.thumb_avatar;
            addItem(tmpItem);
            sessionListMap[historysession.id] = tmpItem;
        }
    }
}
示例#3
0
void LinkDoodService::onChatListChanged(Chat_UIList chats)
{
    qDebug() << Q_FUNC_INFO << "11111111111111111111111chats size3:" << chats.size();
    emit chatListChanged(chats);
}