Commit 555fcc34 authored by Lorenz Meier's avatar Lorenz Meier

Clean UAS text handling

parent 696f9e32
...@@ -55,6 +55,8 @@ bool UASMessage::severityIsError() ...@@ -55,6 +55,8 @@ bool UASMessage::severityIsError()
UASMessageHandler::UASMessageHandler(QGCApplication* app) UASMessageHandler::UASMessageHandler(QGCApplication* app)
: QGCTool(app) : QGCTool(app)
, _activeUAS(NULL) , _activeUAS(NULL)
, _activeComponent(-1)
, _multiComp(false)
, _errorCount(0) , _errorCount(0)
, _errorCountTotal(0) , _errorCountTotal(0)
, _warningCount(0) , _warningCount(0)
...@@ -127,6 +129,14 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString ...@@ -127,6 +129,14 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
_mutex.lock(); _mutex.lock();
if (_activeComponent < 0) {
_activeComponent = compId;
}
if (compId != _activeComponent) {
_multiComp = true;
}
// So first determine the styling based on the severity. // So first determine the styling based on the severity.
QString style; QString style;
switch (severity) switch (severity)
...@@ -186,14 +196,22 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString ...@@ -186,14 +196,22 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
// Finally preppend the properly-styled text with a timestamp. // Finally preppend the properly-styled text with a timestamp.
QString dateString = QDateTime::currentDateTime().toString("hh:mm:ss.zzz"); QString dateString = QDateTime::currentDateTime().toString("hh:mm:ss.zzz");
UASMessage* message = new UASMessage(compId, severity, text); UASMessage* message = new UASMessage(compId, severity, text);
message->_setFormatedText(QString("<p style=\"color:#e0e0f0\">[%2 - COMP:%3]<font style=\"%1\">%4 %5</font></p>").arg(style).arg(dateString).arg(compId).arg(severityText).arg(text)); QString compString("");
_messages.append(message); if (_multiComp) {
int count = _messages.count(); compString = QString(" COMP:%1").arg(compId);
}
message->_setFormatedText(QString("<font style=\"%1\">[%2%3]%4 %5</font></p>").arg(style).arg(dateString).arg(compString).arg(severityText).arg(text));
if (message->severityIsError()) { if (message->severityIsError()) {
_latestError = severityText + " " + text; _latestError = severityText + " " + text;
} }
_mutex.unlock(); _mutex.unlock();
emit textMessageReceived(message); emit textMessageReceived(message);
_messages.append(message);
int count = _messages.count();
emit textMessageCountChanged(count); emit textMessageCountChanged(count);
if (_showErrorsInToolbar && message->severityIsError()) { if (_showErrorsInToolbar && message->severityIsError()) {
......
...@@ -158,6 +158,8 @@ private slots: ...@@ -158,6 +158,8 @@ private slots:
private: private:
UASInterface* _activeUAS; UASInterface* _activeUAS;
int _activeComponent;
bool _multiComp;
QVector<UASMessage*> _messages; QVector<UASMessage*> _messages;
QMutex _mutex; QMutex _mutex;
int _errorCount; int _errorCount;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment