diff --git a/src/blackgui/components/aircraftpartshistory.cpp b/src/blackgui/components/aircraftpartshistory.cpp index e0b14f06c..f8eef8873 100644 --- a/src/blackgui/components/aircraftpartshistory.cpp +++ b/src/blackgui/components/aircraftpartshistory.cpp @@ -17,6 +17,7 @@ #include "blackgui/guiapplication.h" #include "blackgui/uppercasevalidator.h" #include +#include #include using namespace BlackMisc; @@ -106,7 +107,6 @@ namespace BlackGui { if (!this->hasContexts()) { return; } if (isBeingModified) { return; } - static const CPropertyIndexList properties({ CStatusMessage::IndexUtcTimestampFormattedHms, CStatusMessage::IndexMessage }); const CCallsign cs(ui->le_Callsign->text().trimmed().toUpper()); if (cs.isEmpty()) { return; } const auto currentAircraftParts = sGui->getIContextNetwork()->getRemoteAircraftParts(cs, -1).frontOrDefault(); @@ -115,37 +115,37 @@ namespace BlackGui QString html; if (currentAircraftParts == CAircraftParts() && aircraftPartsHistory.isEmpty()) { - html = cs.toQString() + QString(" does not support aircraft parts or nothing received yet."); + html = cs.toQString() % QLatin1Literal(" does not support aircraft parts or nothing received yet."); } else { - QString s; - s += "lights on:"; - s += "
"; - s += "    "; - s += currentAircraftParts.getLights().toQString(); - s += "
"; - s += "gear down: "; - s += BlackMisc::boolToYesNo(currentAircraftParts.isGearDown()); - s += "
"; - s += "flaps pct: "; - s += QString::number(currentAircraftParts.getFlapsPercent()); - s += "
"; - s += "spoilers out: "; - s += BlackMisc::boolToYesNo(currentAircraftParts.isSpoilersOut()); - s += "
"; - s += "engines on: "; - s += "
"; - s += "    "; - s += currentAircraftParts.getEngines().toQString(); - s += "
"; - s += " on ground: "; - s += BlackMisc::boolToYesNo(currentAircraftParts.isOnGround()); + const QString s = + QLatin1Literal("lights on:") % + QLatin1Literal("
") % + QLatin1Literal("    ") % + currentAircraftParts.getLights().toQString() % + QLatin1Literal("
") % + QLatin1Literal("gear down: ") % + BlackMisc::boolToYesNo(currentAircraftParts.isGearDown()) % + QLatin1Literal("
") % + QLatin1Literal("flaps pct: ") % + QString::number(currentAircraftParts.getFlapsPercent()) % + QLatin1Literal("
") % + QLatin1Literal("spoilers out: ") % + BlackMisc::boolToYesNo(currentAircraftParts.isSpoilersOut()) % + QLatin1Literal("
") % + QLatin1Literal("engines on: ") % + QLatin1Literal("
") % + QLatin1Literal("    ") % + currentAircraftParts.getEngines().toQString() % + QLatin1Literal("
") % + QLatin1Literal(" on ground: ") % + BlackMisc::boolToYesNo(currentAircraftParts.isOnGround()); html += s; if (ui->cb_PartsHistoryEnabled->isChecked()) { - html +="
"; - html += aircraftPartsHistory.toHtml(properties); + html += QLatin1Literal("
") % + aircraftPartsHistory.toHtml(CStatusMessageList::timestampHtmlOutput()); } } diff --git a/src/blackgui/components/aircraftpartshistory.h b/src/blackgui/components/aircraftpartshistory.h index 8d157e9ff..b4f491931 100644 --- a/src/blackgui/components/aircraftpartshistory.h +++ b/src/blackgui/components/aircraftpartshistory.h @@ -35,7 +35,7 @@ namespace BlackGui explicit CAircraftPartsHistory(QWidget *parent = nullptr); //! Destructor - ~CAircraftPartsHistory(); + virtual ~CAircraftPartsHistory(); private: QScopedPointer ui; diff --git a/src/blackgui/components/modelmatcherlogcomponent.cpp b/src/blackgui/components/modelmatcherlogcomponent.cpp index 09e5b7d7b..02b1ed6f9 100644 --- a/src/blackgui/components/modelmatcherlogcomponent.cpp +++ b/src/blackgui/components/modelmatcherlogcomponent.cpp @@ -105,7 +105,6 @@ namespace BlackGui void CModelMatcherLogComponent::ps_callsignEntered() { if (!this->hasContexts()) { return; } - static const CPropertyIndexList properties({ CPropertyIndex::GlobalIndexLineNumber, CStatusMessage::IndexMessage }); const CCallsign cs(ui->le_Callsign->text().trimmed().toUpper()); const CStatusMessageList reverseLookupMessages = sGui->getIContextNetwork()->getReverseLookupMessages(cs); const CStatusMessageList matchingMessages = sGui->getIContextSimulator()->getMatchingMessages(cs); @@ -113,7 +112,7 @@ namespace BlackGui CStatusMessageList allMessages(reverseLookupMessages); allMessages.push_back(matchingMessages); - const QString html = allMessages.toHtml(properties); + const QString html = allMessages.toHtml(); this->m_text.setHtml(html); ui->te_Messages->setDocument(&this->m_text); } diff --git a/src/blackgui/guiapplication.cpp b/src/blackgui/guiapplication.cpp index 390f6232d..4ac97c850 100644 --- a/src/blackgui/guiapplication.cpp +++ b/src/blackgui/guiapplication.cpp @@ -324,7 +324,7 @@ namespace BlackGui const QString path(QDir::toNativeSeparators(CSettingsCache::persistentStore())); if (QDir(path).exists()) { - QDesktopServices::openUrl(QUrl("file:///" + path)); + QDesktopServices::openUrl(QUrl::fromLocalFile(path)); } }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); @@ -353,7 +353,7 @@ namespace BlackGui const QString path(QDir::toNativeSeparators(CDataCache::persistentStore())); if (QDir(path).exists()) { - QDesktopServices::openUrl(QUrl("file:///" + path)); + QDesktopServices::openUrl(QUrl::fromLocalFile(path)); } }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); diff --git a/src/blackmisc/statusmessagelist.cpp b/src/blackmisc/statusmessagelist.cpp index 6ada60cc7..1ab1cbd9d 100644 --- a/src/blackmisc/statusmessagelist.cpp +++ b/src/blackmisc/statusmessagelist.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -178,29 +179,39 @@ namespace BlackMisc QString rowHtml; if (withLineNumbers) { - rowHtml += "" + QString::number(line++) + ""; + rowHtml = QLatin1Literal("") % QString::number(line++) % QLatin1Literal(""); } for (const CPropertyIndex &index : usedIndexes) { - rowHtml += "" + statusMessage.propertyByIndex(index).toQString(true).toHtmlEscaped() + ""; + rowHtml += QLatin1Literal("") % statusMessage.propertyByIndex(index).toQString(true).toHtmlEscaped() % QLatin1Literal(""); } - rowHtml = "" + rowHtml + ""; const QString severityClass = statusMessage.getSeverityAsString(); - html += rowHtml.arg(severityClass); + html += QStringLiteral("%2").arg(severityClass, rowHtml); } - return "" + html + "
"; + return "" % html % "
"; + } + + const CPropertyIndexList &CStatusMessageList::simpleHtmlOutput() + { + static const CPropertyIndexList properties({ CPropertyIndex::GlobalIndexLineNumber, CStatusMessage::IndexMessage }); + return properties; + } + + const CPropertyIndexList &CStatusMessageList::timestampHtmlOutput() + { + static const CPropertyIndexList properties({ CStatusMessage::IndexUtcTimestampFormattedHms, CStatusMessage::IndexMessage }); + return properties; } 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 style = QLatin1Char('.') % CStatusMessage::severityToString(CStatusMessage::SeverityDebug) % QLatin1Literal(" { color: lightgreen; } ") % + QLatin1Char('.') % CStatusMessage::severityToString(CStatusMessage::SeverityInfo) % QLatin1Literal(" { color: lightgreen; } ") % + QLatin1Char('.') % CStatusMessage::severityToString(CStatusMessage::SeverityWarning) % QLatin1Literal(" { color: yellow; } ") % + QLatin1Char('.') % CStatusMessage::severityToString(CStatusMessage::SeverityError) % QLatin1Literal(" { color: red; }"); + return style; } const QString &CStatusMessageList::htmlStyleSheet() diff --git a/src/blackmisc/statusmessagelist.h b/src/blackmisc/statusmessagelist.h index 059546483..5519db9f3 100644 --- a/src/blackmisc/statusmessagelist.h +++ b/src/blackmisc/statusmessagelist.h @@ -101,7 +101,13 @@ namespace BlackMisc CStatusMessage toSingleMessage() const; //! Specialized version to convert to HTML - QString toHtml(const CPropertyIndexList &indexes) const; + QString toHtml(const CPropertyIndexList &indexes = simpleHtmlOutput()) const; + + //! Properties for CStatusMessageList::toHtml + static const CPropertyIndexList &simpleHtmlOutput(); + + //! Properties for CStatusMessageList::toHtml + static const CPropertyIndexList ×tampHtmlOutput(); //! Default style sheet which can be used with CStatusMessageList::toHtml static const QString &htmlStyleSheet();