Formatting, QStringBuilder

This commit is contained in:
Klaus Basan
2017-01-31 19:46:37 +01:00
committed by Mathew Sutcliffe
parent a61abfcb8b
commit ec23863d53
6 changed files with 59 additions and 43 deletions

View File

@@ -17,6 +17,7 @@
#include "blackgui/guiapplication.h"
#include "blackgui/uppercasevalidator.h"
#include <QCompleter>
#include <QStringBuilder>
#include <QStringListModel>
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 += "<br>";
s += "&nbsp;&nbsp;&nbsp;&nbsp;";
s += currentAircraftParts.getLights().toQString();
s += "<br>";
s += "gear down: ";
s += BlackMisc::boolToYesNo(currentAircraftParts.isGearDown());
s += "<br>";
s += "flaps pct: ";
s += QString::number(currentAircraftParts.getFlapsPercent());
s += "<br>";
s += "spoilers out: ";
s += BlackMisc::boolToYesNo(currentAircraftParts.isSpoilersOut());
s += "<br>";
s += "engines on: ";
s += "<br>";
s += "&nbsp;&nbsp;&nbsp;&nbsp;";
s += currentAircraftParts.getEngines().toQString();
s += "<br>";
s += " on ground: ";
s += BlackMisc::boolToYesNo(currentAircraftParts.isOnGround());
const QString s =
QLatin1Literal("lights on:") %
QLatin1Literal("<br>") %
QLatin1Literal("&nbsp;&nbsp;&nbsp;&nbsp;") %
currentAircraftParts.getLights().toQString() %
QLatin1Literal("<br>") %
QLatin1Literal("gear down: ") %
BlackMisc::boolToYesNo(currentAircraftParts.isGearDown()) %
QLatin1Literal("<br>") %
QLatin1Literal("flaps pct: ") %
QString::number(currentAircraftParts.getFlapsPercent()) %
QLatin1Literal("<br>") %
QLatin1Literal("spoilers out: ") %
BlackMisc::boolToYesNo(currentAircraftParts.isSpoilersOut()) %
QLatin1Literal("<br>") %
QLatin1Literal("engines on: ") %
QLatin1Literal("<br>") %
QLatin1Literal("&nbsp;&nbsp;&nbsp;&nbsp;") %
currentAircraftParts.getEngines().toQString() %
QLatin1Literal("<br>") %
QLatin1Literal(" on ground: ") %
BlackMisc::boolToYesNo(currentAircraftParts.isOnGround());
html += s;
if (ui->cb_PartsHistoryEnabled->isChecked())
{
html +="<hr>";
html += aircraftPartsHistory.toHtml(properties);
html += QLatin1Literal("<hr>") %
aircraftPartsHistory.toHtml(CStatusMessageList::timestampHtmlOutput());
}
}

View File

@@ -35,7 +35,7 @@ namespace BlackGui
explicit CAircraftPartsHistory(QWidget *parent = nullptr);
//! Destructor
~CAircraftPartsHistory();
virtual ~CAircraftPartsHistory();
private:
QScopedPointer<Ui::CAircraftPartsHistory> ui;

View File

@@ -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);
}