本文整理汇总了C++中MessageItem::getLineStart方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageItem::getLineStart方法的具体用法?C++ MessageItem::getLineStart怎么用?C++ MessageItem::getLineStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageItem
的用法示例。
在下文中一共展示了MessageItem::getLineStart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addGUIMessage
/*!
Adds the error message.\n
Moves to the most recent error message in the view.
*/
void MessagesWidget::addGUIMessage(MessageItem messageItem)
{
// move the cursor down before adding message.
QTextCursor textCursor = mpMessagesTextBrowser->textCursor();
textCursor.movePosition(QTextCursor::End);
mpMessagesTextBrowser->setTextCursor(textCursor);
// set the CSS class depending on message type
QString messageCSSClass;
switch (messageItem.getErrorType()) {
case StringHandler::Warning:
messageCSSClass = "warning";
break;
case StringHandler::OMError:
messageCSSClass = "error";
break;
case StringHandler::Notification:
default:
messageCSSClass = "notification";
break;
}
QString linkFormat = QString("[%1: %2]: <a href=\"omeditmessagesbrowser:///%3?lineNumber=%4\">%5</a>");
QString errorMessage;
QString message;
if(messageItem.getMessageItemType()== MessageItem::Modelica) {
// if message already have tags then just use it.
if (Qt::mightBeRichText(messageItem.getMessage())) {
message = messageItem.getMessage();
} else {
message = Qt::convertFromPlainText(messageItem.getMessage()).remove("<p>").remove("</p>");
}
} else if(messageItem.getMessageItemType()== MessageItem::TLM) {
message = messageItem.getMessage().remove("<p>");
}
if (messageItem.getFileName().isEmpty()) { // if custom error message
errorMessage = message;
} else if (messageItem.getMessageItemType()== MessageItem::TLM ||
mpMainWindow->getLibraryWidget()->getLibraryTreeModel()->findLibraryTreeItem(messageItem.getFileName())) {
// If the class is only loaded in AST via loadString then create link for the error message.
errorMessage = linkFormat.arg(messageItem.getFileName())
.arg(messageItem.getLocation())
.arg(messageItem.getFileName())
.arg(messageItem.getLineStart())
.arg(message);
} else {
// Find the class name using the file name and line number.
LibraryTreeItem *pLibraryTreeItem;
pLibraryTreeItem = mpMainWindow->getLibraryWidget()->getLibraryTreeModel()->getLibraryTreeItemFromFile(messageItem.getFileName(),
messageItem.getLineStart().toInt());
if (pLibraryTreeItem) {
errorMessage = linkFormat.arg(pLibraryTreeItem->getNameStructure())
.arg(messageItem.getLocation())
.arg(pLibraryTreeItem->getNameStructure())
.arg(messageItem.getLineStart())
.arg(message);
} else {
// otherwise display filename to user where error occurred.
errorMessage = QString("[%1: %2]: %3")
.arg(messageItem.getFileName())
.arg(messageItem.getLocation())
.arg(message);
}
}
QString errorString = QString("<div class=\"%1\">"
"<b>[%2] %3 %4 %5</b><br>"
"%6"
"</div><br>")
.arg(messageCSSClass)
.arg(QString::number(mMessageNumber))
.arg(QTime::currentTime().toString())
.arg(StringHandler::getErrorKindString(messageItem.getErrorKind()))
.arg(StringHandler::getErrorTypeDisplayString(messageItem.getErrorType()))
.arg(errorMessage);
mpMessagesTextBrowser->insertHtml(errorString);
mMessageNumber++;
// move the cursor down after adding message.
textCursor.movePosition(QTextCursor::End);
mpMessagesTextBrowser->setTextCursor(textCursor);
emit MessageAdded();
}