mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 19:25:49 +08:00
refs #702, CStatusMessageList toHTML
This commit is contained in:
@@ -163,6 +163,41 @@ namespace BlackMisc
|
|||||||
return newMsg;
|
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 += "<td>" + statusMessage.propertyByIndex(index).toQString(true) + "</td>";
|
||||||
|
}
|
||||||
|
|
||||||
|
rowHtml = "<tr class=\"%1\">" + rowHtml + "</tr>";
|
||||||
|
const QString severityClass = statusMessage.getSeverityAsString();
|
||||||
|
html += rowHtml.arg(severityClass);
|
||||||
|
}
|
||||||
|
return "<table>" + html + "</table>";
|
||||||
|
}
|
||||||
|
|
||||||
|
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; // "<style type=\"text/css\">" + style + "</style>";
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &CStatusMessageList::htmlStyleSheet()
|
||||||
|
{
|
||||||
|
static const QString style(htmlStyleSheetImpl());
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
CStatusMessageList CStatusMessageList::fromDatabaseJson(const QJsonArray &array)
|
CStatusMessageList CStatusMessageList::fromDatabaseJson(const QJsonArray &array)
|
||||||
{
|
{
|
||||||
CStatusMessageList messages;
|
CStatusMessageList messages;
|
||||||
|
|||||||
@@ -100,6 +100,12 @@ namespace BlackMisc
|
|||||||
//! Merge into a single message
|
//! Merge into a single message
|
||||||
CStatusMessage toSingleMessage() const;
|
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
|
//! From our database JSON format
|
||||||
static CStatusMessageList fromDatabaseJson(const QJsonArray &array);
|
static CStatusMessageList fromDatabaseJson(const QJsonArray &array);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user