本文整理汇总了C++中IEvent::ChatLogUpdateTextBlock方法的典型用法代码示例。如果您正苦于以下问题:C++ IEvent::ChatLogUpdateTextBlock方法的具体用法?C++ IEvent::ChatLogUpdateTextBlock怎么用?C++ IEvent::ChatLogUpdateTextBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEvent
的用法示例。
在下文中一共展示了IEvent::ChatLogUpdateTextBlock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: oCursor
//.........这里部分代码省略.........
QDateTime dtl = QDateTime::fromMSecsSinceEpoch(pEvent->m_tsEventID).toLocalTime();
QDate date = dtl.date(); // Strip the time of the day
m_tsMidnightNext = QDateTime(date).toMSecsSinceEpoch() + d_ts_cDays; // I am sure there is a more elegant way to strip the time from a date, however at the moment I don't have time to investigate a better solution (and this code works)
QTextBlockFormat oFormatBlock;
oFormatBlock.setAlignment(Qt::AlignHCenter);
oFormatBlock.setBackground(c_brushSilver);
oCursor.setBlockFormat(oFormatBlock);
QTextCharFormat oFormatChar; // = oCursor.charFormat();
oFormatChar.setFontWeight(QFont::Bold);
//oFormatChar.setFontItalic(true);
//oCursor.setCharFormat(oFormatChar);
oCursor.insertText(date.toString("dddd MMMM d, yyyy"), oFormatChar);
oCursor.AppendBlockBlank();
}
oTextBlockEvent = oCursor.block(); // Get the current block under the cursor
Endorse(oTextBlockEvent.userData() == NULL);
if (pEvent->m_uFlagsEvent & IEvent::FE_kfReplacing)
{
MessageLog_AppendTextFormatSev(eSeverityComment, "Attempting to replace Event ID $t\n", pEvent->m_tsEventID);
QTextBlock oTextBlockUpdate;
QTextBlock oTextBlockTemp = document()->lastBlock();
IEvent * pEventOld = pEvent;
const EEventClass eEventClassUpdater = pEvent->Event_FIsEventTypeSent() ? CEventUpdaterSent::c_eEventClass : CEventUpdaterReceived::c_eEventClass; // Which updater to search for
// The event is replacing an older event. This code is a bit complex because the Chat Log may not display all events and therefore we need to find the most recent block displaying the most recent event.
IEvent ** ppEventStop;
IEvent ** ppEventFirst = pEvent->m_pVaultParent_NZ->m_arraypaEvents.PrgpGetEventsStop(OUT &ppEventStop);
IEvent ** ppEventCompare = ppEventStop; // Search the array from the end, as the event to search is likely to be a recent one
while (ppEventFirst < ppEventCompare)
{
// Find the updater which should be right before the replacing event
IEvent * pEventTemp = *--ppEventCompare;
TryAgain:
if (pEventTemp == pEventOld && ppEventFirst < ppEventCompare)
{
CEventUpdaterSent * pEventUpdater = (CEventUpdaterSent *)*--ppEventCompare; // Get the updater which is just before the event
if (pEventUpdater->EGetEventClass() != eEventClassUpdater)
{
MessageLog_AppendTextFormatSev(eSeverityErrorWarning, "\t Missing Updater for Event ID $t ({tL}); instead found class '$U' with Event ID $t.\n", pEventTemp->m_tsEventID, pEventTemp->m_tsEventID, pEventUpdater->EGetEventClass(), pEventUpdater->m_tsEventID);
pEvent->m_uFlagsEvent &= ~IEvent::FE_kfReplacing; // Remove the bit to avoid displaying the error again and again
pEvent->m_pVaultParent_NZ->SetModified(); // Save the change
continue;
}
const TIMESTAMP tsEventIdOld = pEventUpdater->m_tsEventIdOld;
MessageLog_AppendTextFormatSev(eSeverityNoise, "\t [$i] Found updater: $t -> $t\n", ppEventCompare - ppEventFirst, pEventUpdater->m_tsEventIdNew, tsEventIdOld);
// Now, search for the block containing the replacement event
while (oTextBlockTemp.isValid())
{
OTextBlockUserDataEvent * pUserData = (OTextBlockUserDataEvent *)oTextBlockTemp.userData();
if (pUserData != NULL)
{
TIMESTAMP_DELTA dtsEvent = (pUserData->m_pEvent->m_tsEventID - tsEventIdOld);
MessageLog_AppendTextFormatCo(d_coPurple, "Comparing block Event ID $t with $t: dtsEvent = $T\n", pUserData->m_pEvent->m_tsEventID, tsEventIdOld, dtsEvent);
if (dtsEvent <= 0)
{
if (dtsEvent == 0)
{
MessageLog_AppendTextFormatSev(eSeverityNoise, "\t Found matching textblock for replacement: Event ID $t -> $t\n", pEventOld->m_tsEventID, tsEventIdOld);
oTextBlockUpdate = oTextBlockTemp;
}
break;
}
}
oTextBlockTemp = oTextBlockTemp.previous();
} // while
// Keep searching in case there are chained updated events
while (ppEventFirst < ppEventCompare)
{
pEventTemp = *--ppEventCompare;
if (pEventTemp->m_tsEventID == tsEventIdOld)
{
MessageLog_AppendTextFormatSev(eSeverityNoise, "\t [$i] Found chained replacement: Event ID $t -> $t\n", ppEventCompare - ppEventFirst, pEvent->m_tsEventID, tsEventIdOld);
pEventTemp->m_uFlagsEvent |= IEvent::FE_kfReplaced;
pEventOld = pEventTemp;
goto TryAgain;
}
} // while
} // if
} // while
if (oTextBlockUpdate.isValid())
{
MessageLog_AppendTextFormatSev(eSeverityNoise, "\t Event ID $t is updating its old Event ID $t\n", pEvent->m_tsEventID, pEventOld->m_tsEventID);
OCursorSelectBlock oCursorEventOld(oTextBlockUpdate);
pEvent->ChatLogUpdateTextBlock(INOUT &oCursorEventOld);
continue;
}
MessageLog_AppendTextFormatSev(eSeverityErrorWarning, "Event ID $t is replacing another event which cannot be found\n", pEvent->m_tsEventID);
} // if (replacing)
oTextBlockEvent.setUserData(PA_CHILD new OTextBlockUserDataEvent(pEvent)); // Assign an event for each text block
pEvent->ChatLogUpdateTextBlock(INOUT &oCursor);
if ((pEvent->m_uFlagsEvent & IEvent::FE_kfEventHidden) == 0)
oCursor.AppendBlockBlank(); // If the event is visible, then add a new text block (otherwise it will reuse the same old block)
else
oTextBlockEvent.setUserData(NULL); // Since we are reusing the same block, delete its userdata so we may assing another OTextBlockUserDataEvent
} // while
m_oTextBlockComposing = oCursor.block();
ChatLog_ChatStateTextAppend(INOUT oCursor);
Widget_ScrollToEnd(INOUT this);
} // ChatLog_EventsDisplay()