本文整理汇总了C++中QSharedPointer::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ QSharedPointer::GetId方法的具体用法?C++ QSharedPointer::GetId怎么用?C++ QSharedPointer::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSharedPointer
的用法示例。
在下文中一共展示了QSharedPointer::GetId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QStandardItem
QList<QStandardItem *> CFrmUserList::NewItemRoster(QSharedPointer<CUserInfo> info)
{
//呢称条目
QStandardItem* pItem = new QStandardItem(info->GetShowName()
+ info->GetSubscriptionTypeStr(info->GetSubScriptionType()));
pItem->setData(info->GetId(), USERLIST_ITEM_ROLE_JID);
pItem->setData(PROPERTIES_ROSTER, USERLIST_ITEM_ROLE_PROPERTIES);
//改变item背景颜色
//pItem->setData(CGlobal::Instance()->GetRosterStatusColor(info->GetStatus()), Qt::BackgroundRole);
// pItem->setBackground(QBrush(CGlobal::Instance()->GetRosterStatusColor(info->GetStatus())));
pItem->setEditable(false);
QString szText;
szText = info->GetShowName()
#ifdef DEBUG
+ "[" + CGlobal::Instance()->GetRosterStatusText(info->GetStatus()) + "]"
#endif
+ info->GetSubscriptionTypeStr(info->GetSubScriptionType())
;
pItem->setData(szText, Qt::DisplayRole); //改变item文本,或者直接用 pItem->setText(szText);
#ifdef DEBUG
pItem->setToolTip(info->GetId());
#endif
//改变item图标
pItem->setData(QIcon(CGlobal::Instance()->GetRosterStatusIcon(info->GetStatus())), Qt::DecorationRole);
//消息条目
QStandardItem* pMessageCountItem = new QStandardItem("");
pMessageCountItem->setData(info->GetId(), USERLIST_ITEM_ROLE_JID);
pMessageCountItem->setData(PROPERTIES_UNREAD_MESSAGE_COUNT, USERLIST_ITEM_ROLE_PROPERTIES);
pMessageCountItem->setEditable(false);//禁止双击编辑
QList<QStandardItem *> lstItems;
lstItems << pItem << pMessageCountItem;
return lstItems;
}
示例2: QDialog
CDlgUservCard::CDlgUservCard(QSharedPointer<CUserInfo> user, bool bModify, QWidget *parent) :
QDialog(parent),
ui(new Ui::CDlgUservCard),
m_UserInfo(user),
m_bModify(bModify)
{
Init();
m_szJid = user->GetId();
bool check = connect(GET_CLIENT.data(),
SIGNAL(sigUpdateRosterUserInfo(QString,QSharedPointer<CUser>)),
SLOT(slotUpdateRoster(QString, QSharedPointer<CUser>)));
Q_ASSERT(check);
GET_CLIENT->RequestUserInfoRoster(m_szJid);
}
示例3: ItemUpdateRoster
int CFrmUserList::ItemUpdateRoster(const QString &szId)
{
QSharedPointer<CUser> roster = GLOBAL_USER->GetUserInfoRoster(szId);
if(roster.isNull())
{
LOG_MODEL_ERROR("FrmUserList", "Dn't the roster:%s", qPrintable(szId));
return -1;
}
QSharedPointer<CUserInfo> info = roster->GetInfo();
QModelIndexList lstIndexs = m_pModel->match(m_pModel->index(0, 0),
USERLIST_ITEM_ROLE_JID,
info->GetId(),
-1,
Qt::MatchStartsWith | Qt::MatchWrap | Qt::MatchRecursive | Qt::MatchCaseSensitive);
if(lstIndexs.isEmpty())
{
int nRet = 0;
nRet = ItemInsertRoster(szId);
if(nRet)
{
LOG_MODEL_ERROR("FrmUserList", "Insert roster %s fail", qPrintable(szId));
return nRet;
}
LOG_MODEL_DEBUG("FrmUserList", "Insert roster %s", qPrintable(szId));
lstIndexs = m_pModel->match(m_pModel->index(0, 0),
USERLIST_ITEM_ROLE_JID,
info->GetId(),
-1,
Qt::MatchStartsWith | Qt::MatchWrap | Qt::MatchRecursive | Qt::MatchCaseSensitive);
}
QModelIndex index;
foreach(index, lstIndexs)
{
LOG_MODEL_DEBUG("FrmUserList", "index:row:%d;column:%d;id:%s", index.row(), index.column(), qPrintable(info->GetId()));
QStandardItem* pItem = m_pModel->itemFromIndex(index);
if(!pItem) continue;
if(pItem->data(USERLIST_ITEM_ROLE_PROPERTIES) == PROPERTIES_ROSTER)
{
//pItem->setData(roster->GetBareJid(), USERLIST_ITEM_ROLE_JID);
//pItem->setData(PROPERTIES_ROSTER, USERLIST_ITEM_ROLE_PROPERTIES);
//改变item背景颜色
//pItem->setData(CGlobal::Instance()->GetRosterStatusColor(info->GetStatus()), Qt::BackgroundRole);
//pItem->setBackground(QBrush(CGlobal::Instance()->GetRosterStatusColor(info->GetStatus())));
// if(CGlobal::Instance()->GetRosterShowType() == CGlobal::E_ROSTER_SHOW_NICK)
// pItem->setEditable(true);
// else
// pItem->setEditable(false);//禁止双击编辑
QString szText;
szText = info->GetShowName()
#ifdef DEBUG
+ "[" + CGlobal::Instance()->GetRosterStatusText(info->GetStatus()) + "]"
#endif
+ info->GetSubscriptionTypeStr(info->GetSubScriptionType())
;
pItem->setData(szText, Qt::DisplayRole); //改变item文本
#ifdef DEBUG
pItem->setToolTip(info->GetId());
#endif
//改变item图标
QPixmap pmp;
MainWindow::ComposeAvatarStatus(info, pmp);
pItem->setData(pmp.scaled(RABBITIM_ICON_SIZE, RABBITIM_ICON_SIZE), Qt::DecorationRole);
}
if(NULL == pItem || NULL == pItem->parent()) continue;
QStandardItem* pItemUnReadMessageCount = pItem->parent()->child(index.row(), index.column() + 1);
if(pItemUnReadMessageCount->data(USERLIST_ITEM_ROLE_PROPERTIES) == PROPERTIES_UNREAD_MESSAGE_COUNT)
{
//设置未读消息数
int nCount = roster->GetMessage()->GetUnReadCount();
if(nCount)
pItemUnReadMessageCount->setText(QString::number(nCount));
else
pItemUnReadMessageCount->setText(QString(""));
pItemUnReadMessageCount->setData(CGlobal::Instance()->GetUnreadMessageCountColor(), Qt::TextColorRole);
//pItemUnReadMessageCount->setData(roster->GetBareJid(), USERLIST_ITEM_ROLE_JID);
//pItemUnReadMessageCount->setData(PROPERTIES_UNREAD_MESSAGE_COUNT, USERLIST_ITEM_ROLE_PROPERTIES);
//pItemUnReadMessageCount->setEditable(false);//禁止双击编辑
}
}
示例4: ProcessRoster
int CFrmUserList::ProcessRoster(QSharedPointer<CUserInfo> roster, void *para)
{
int nRet = 0;
nRet = ItemUpdateRoster(roster->GetId());
return nRet;
}