Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/MAVLink/StatusTextHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ void StatusTextHandler::resetErrorLevelMessages()
}
}

void StatusTextHandler::handleTextMessage(MAV_COMPONENT compId, MAV_SEVERITY severity, const QString &text, const QString &description)
void StatusTextHandler::handleHTMLEscapedTextMessage(MAV_COMPONENT compId, MAV_SEVERITY severity, const QString &text, const QString &description)
{
QString htmlText(text);

(void) htmlText.replace("\n", "<br/>");

// TODO: handle text + description separately in the UI
Expand Down Expand Up @@ -335,7 +336,7 @@ void StatusTextHandler::_chunkedStatusTextCompleted(MAV_COMPONENT compId)

(void) m_chunkedStatusTextInfoMap.remove(compId);

emit textMessageReceived(compId, severity, messageText.toHtmlEscaped(), "");
emit textMessageReceived(compId, severity, messageText, "");
}

void StatusTextHandler::_handleTextMessage(uint32_t newCount, MessageType messageType)
Expand Down
2 changes: 1 addition & 1 deletion src/MAVLink/StatusTextHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class StatusTextHandler : public QObject
~StatusTextHandler();

void mavlinkMessageReceived(const mavlink_message_t &message);
void handleTextMessage(MAV_COMPONENT componentid, MAV_SEVERITY severity, const QString &text, const QString &description);
void handleHTMLEscapedTextMessage(MAV_COMPONENT componentid, MAV_SEVERITY severity, const QString &text, const QString &description);

void clearMessages();
void resetAllMessages();
Expand Down
5 changes: 3 additions & 2 deletions src/Vehicle/Vehicle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ void Vehicle::_handleEvent(uint8_t comp_id, std::unique_ptr<events::parser::Pars
return;
}

m_statusTextHandler->handleTextMessage(static_cast<MAV_COMPONENT>(comp_id), static_cast<MAV_SEVERITY>(severity), text, QString::fromStdString(description));
m_statusTextHandler->handleHTMLEscapedTextMessage(static_cast<MAV_COMPONENT>(comp_id), static_cast<MAV_SEVERITY>(severity), text, QString::fromStdString(description));
}
}
}
Expand Down Expand Up @@ -4047,7 +4047,8 @@ void Vehicle::_textMessageReceived(MAV_COMPONENT componentid, MAV_SEVERITY sever
_say(text);
}

m_statusTextHandler->handleTextMessage(componentid, severity, text.toHtmlEscaped(), description);
emit textMessageReceived(id(), componentid, severity, text, description);
m_statusTextHandler->handleHTMLEscapedTextMessage(componentid, severity, text.toHtmlEscaped(), description);
}

void Vehicle::_errorMessageReceived(QString message)
Expand Down
4 changes: 2 additions & 2 deletions test/MAVLink/StatusTextHandlerTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ void StatusTextHandlerTest::_testHandleTextMessage()
{
StatusTextHandler* statusTextHandler = new StatusTextHandler(this);

statusTextHandler->handleTextMessage(MAV_COMP_ID_USER1, MAV_SEVERITY_INFO, "StatusTextHandlerTestInfo", "This is the StatusTextHandlerTestInfo Test");
statusTextHandler->handleHTMLEscapedTextMessage(MAV_COMP_ID_USER1, MAV_SEVERITY_INFO, "StatusTextHandlerTestInfo", "This is the StatusTextHandlerTestInfo Test");
QString messages = statusTextHandler->formattedMessages();
QVERIFY(!messages.isEmpty());
QVERIFY(messages.contains("StatusTextHandlerTestInfo"));
QCOMPARE(statusTextHandler->getNormalCount(), 1);
QCOMPARE(statusTextHandler->messageCount(), 1);

statusTextHandler->handleTextMessage(MAV_COMP_ID_USER1, MAV_SEVERITY_WARNING, "StatusTextHandlerTestWarning", "This is the StatusTextHandlerTestWarning Test");
statusTextHandler->handleHTMLEscapedTextMessage(MAV_COMP_ID_USER1, MAV_SEVERITY_WARNING, "StatusTextHandlerTestWarning", "This is the StatusTextHandlerTestWarning Test");
messages = statusTextHandler->formattedMessages();
QVERIFY(messages.contains("StatusTextHandlerTestInfo"));
QVERIFY(messages.contains("StatusTextHandlerTestWarning"));
Expand Down
Loading