本文整理汇总了C++中ToxId::isSelf方法的典型用法代码示例。如果您正苦于以下问题:C++ ToxId::isSelf方法的具体用法?C++ ToxId::isSelf怎么用?C++ ToxId::isSelf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToxId
的用法示例。
在下文中一共展示了ToxId::isSelf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadHistory
void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
{
QDateTime now = historyBaselineDate.addMSecs(-1);
if (since > now)
return;
if (!earliestMessage.isNull())
{
if (earliestMessage < since)
return;
if (earliestMessage < now)
{
now = earliestMessage;
now = now.addMSecs(-1);
}
}
auto msgs = Nexus::getProfile()->getHistory()->getChatHistory(f->getToxId().publicKey, since, now);
ToxId storedPrevId = previousId;
ToxId prevId;
QList<ChatLine::Ptr> historyMessages;
QDate lastDate(1,0,0);
for (const auto &it : msgs)
{
// Show the date every new day
QDateTime msgDateTime = it.timestamp.toLocalTime();
QDate msgDate = msgDateTime.date();
if (msgDate > lastDate)
{
lastDate = msgDate;
historyMessages.append(ChatMessage::createChatInfoMessage(msgDate.toString(Settings::getInstance().getDateFormat()), ChatMessage::INFO, QDateTime()));
}
// Show each messages
ToxId authorId = ToxId(it.sender);
QString authorStr = !it.dispName.isEmpty() ? it.dispName : (authorId.isSelf() ? Core::getInstance()->getUsername() : resolveToxId(authorId));
bool isAction = it.message.startsWith(ACTION_PREFIX, Qt::CaseInsensitive);
bool needSending = !it.isSent && authorId.isSelf();
ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr,
isAction ? it.message.mid(4) : it.message,
isAction ? ChatMessage::ACTION : ChatMessage::NORMAL,
authorId.isSelf(),
needSending ? QDateTime() : msgDateTime);
if (!isAction && (prevId == authorId) && (prevMsgDateTime.secsTo(msgDateTime) < getChatLog()->repNameAfter) )
msg->hideSender();
prevId = authorId;
prevMsgDateTime = msgDateTime;
if (needSending)
{
if (processUndelivered)
{
int rec;
if (!isAction)
rec = Core::getInstance()->sendMessage(f->getFriendID(), msg->toString());
else
rec = Core::getInstance()->sendAction(f->getFriendID(), msg->toString());
getOfflineMsgEngine()->registerReceipt(rec, it.id, msg);
}
}
historyMessages.append(msg);
}
previousId = storedPrevId;
int savedSliderPos = chatWidget->verticalScrollBar()->maximum() - chatWidget->verticalScrollBar()->value();
earliestMessage = since;
chatWidget->insertChatlineOnTop(historyMessages);
savedSliderPos = chatWidget->verticalScrollBar()->maximum() - savedSliderPos;
chatWidget->verticalScrollBar()->setValue(savedSliderPos);
}