diff --git a/src/blackmisc/statusmessagelist.cpp b/src/blackmisc/statusmessagelist.cpp
index 63d76f55f..cef97467e 100644
--- a/src/blackmisc/statusmessagelist.cpp
+++ b/src/blackmisc/statusmessagelist.cpp
@@ -163,6 +163,41 @@ namespace BlackMisc
return newMsg;
}
+ QString CStatusMessageList::toHtml(const CPropertyIndexList &indexes) const
+ {
+ if (indexes.isEmpty() || this->isEmpty()) { return ""; }
+ QString html;
+ for (const CStatusMessage &statusMessage : *this)
+ {
+ QString rowHtml;
+ for (const CPropertyIndex index : indexes)
+ {
+ rowHtml += "
" + statusMessage.propertyByIndex(index).toQString(true) + " | ";
+ }
+
+ rowHtml = "" + rowHtml + "
";
+ const QString severityClass = statusMessage.getSeverityAsString();
+ html += rowHtml.arg(severityClass);
+ }
+ return "";
+ }
+
+ const QString htmlStyleSheetImpl()
+ {
+ QString style;
+ style += "." + CStatusMessage::severityToString(CStatusMessage::SeverityDebug) + " { color: lightgreen; } ";
+ style += "." + CStatusMessage::severityToString(CStatusMessage::SeverityInfo) + " { color: lightgreen; } ";
+ style += "." + CStatusMessage::severityToString(CStatusMessage::SeverityWarning) + " { color: yellow; } ";
+ style += "." + CStatusMessage::severityToString(CStatusMessage::SeverityError) + " { color: red; }";
+ return style; // "";
+ }
+
+ const QString &CStatusMessageList::htmlStyleSheet()
+ {
+ static const QString style(htmlStyleSheetImpl());
+ return style;
+ }
+
CStatusMessageList CStatusMessageList::fromDatabaseJson(const QJsonArray &array)
{
CStatusMessageList messages;
diff --git a/src/blackmisc/statusmessagelist.h b/src/blackmisc/statusmessagelist.h
index 67adcd607..059546483 100644
--- a/src/blackmisc/statusmessagelist.h
+++ b/src/blackmisc/statusmessagelist.h
@@ -100,6 +100,12 @@ namespace BlackMisc
//! Merge into a single message
CStatusMessage toSingleMessage() const;
+ //! Specialized version to convert to HTML
+ QString toHtml(const CPropertyIndexList &indexes) const;
+
+ //! Default style sheet which can be used with CStatusMessageList::toHtml
+ static const QString &htmlStyleSheet();
+
//! From our database JSON format
static CStatusMessageList fromDatabaseJson(const QJsonArray &array);
};