refs #522, as preparation for mutable in status message

* added the new human readable patterns ( also for #506 )
* adjusted using functions

Meeting:
https://dev.vatsim-germany.org/boards/22/topics/2786?r=2787#message-2787
This commit is contained in:
Klaus Basan
2015-11-25 23:10:57 +01:00
parent a2b413c8e1
commit a4ba45ce75
6 changed files with 24 additions and 26 deletions

View File

@@ -35,7 +35,7 @@ namespace BlackGui
{ {
ui->te_Message->setPlainText(message.getMessage()); ui->te_Message->setPlainText(message.getMessage());
ui->lbl_SeverityIcon->setPixmap(message.toPixmap()); ui->lbl_SeverityIcon->setPixmap(message.toPixmap());
ui->le_Categories->setText(message.getCategories().toQString(true)); ui->le_Categories->setText(message.getHumanReadablePattern());
ui->le_Severity->setText(message.getSeverityAsString()); ui->le_Severity->setText(message.getSeverityAsString());
ui->le_Timestamp->setText(message.getFormattedUtcTimestampYmdhms()); ui->le_Timestamp->setText(message.getFormattedUtcTimestampYmdhms());
} }

View File

@@ -35,7 +35,7 @@ namespace BlackGui
{ {
ui->te_Message->setPlainText(message.getMessage()); ui->te_Message->setPlainText(message.getMessage());
ui->lbl_SeverityIcon->setPixmap(message.toPixmap()); ui->lbl_SeverityIcon->setPixmap(message.toPixmap());
ui->le_Categories->setText(message.getCategories().toQString(true)); ui->le_Categories->setText(message.getHumanReadablePattern());
ui->le_Severity->setText(message.getSeverityAsString()); ui->le_Severity->setText(message.getSeverityAsString());
ui->le_Timestamp->setText(message.getFormattedUtcTimestampYmdhms()); ui->le_Timestamp->setText(message.getFormattedUtcTimestampYmdhms());
} }

View File

@@ -52,7 +52,7 @@ namespace BlackMisc
if (! m_logPattern.match(statusMessage)) { return; } if (! m_logPattern.match(statusMessage)) { return; }
QString finalContent = QDateTime::currentDateTime().toString(QStringLiteral("hh:mm:ss ")); QString finalContent = QDateTime::currentDateTime().toString(QStringLiteral("hh:mm:ss "));
finalContent += statusMessage.getHumanReadableCategory(); finalContent += statusMessage.getHumanReadablePattern();
finalContent += " "; finalContent += " ";
finalContent += statusMessage.getSeverityAsString(); finalContent += statusMessage.getSeverityAsString();
finalContent += ": "; finalContent += ": ";

View File

@@ -72,6 +72,7 @@ namespace BlackMisc
} }
//! All predefined special categories //! All predefined special categories
//! \note Human readable patterns are defined in CLogPattern::allHumanReadablePatterns
static const QList<CLogCategory> &allSpecialCategories() static const QList<CLogCategory> &allSpecialCategories()
{ {
static const QList<CLogCategory> cats static const QList<CLogCategory> cats

View File

@@ -104,39 +104,33 @@ namespace BlackMisc
} }
} }
QString CStatusMessage::getHumanReadableCategory() const QString CStatusMessage::getHumanReadablePattern() const
{ {
//! \todo This should me not hardcoded //! \todo This should me not hardcoded
if (this->m_humanReadableCategory.isEmpty()) if (this->m_humanReadableCategory.isEmpty())
{ {
const QString cat(this->m_categories.toQString().toLower()); QStringList patternNames(getHumanReadablePatterns());
// could als be subject of i18n this->m_humanReadableCategory = patternNames.isEmpty() ?
// from sepcific to unspecific "None" : patternNames.join(", ");
if (cat.isEmpty()) { this->m_humanReadableCategory = "None"; }
else if (cat.contains(CLogCategory::validation().toQString())) { this->m_humanReadableCategory = "Validation"; }
else if (cat.contains("contextaudio")) { this->m_humanReadableCategory = "Audio"; }
else if (cat.contains("contextsimulator")) { this->m_humanReadableCategory = "Simulator"; }
else if (cat.contains("contextnetwork")) { this->m_humanReadableCategory = "Network"; }
else if (cat.contains("vatlib")) { this->m_humanReadableCategory = "VATSIM library"; }
else if (cat.contains("blackmisc")) { this->m_humanReadableCategory = "Library"; }
else if (cat.contains("blackcore")) { this->m_humanReadableCategory = "Core"; }
else if (cat.contains("blackgui")) { this->m_humanReadableCategory = "GUI"; }
else if (cat.contains("blacksound")) { this->m_humanReadableCategory = "GUI"; }
else if (cat.contains("interpolator")) { this->m_humanReadableCategory = "Interpolator"; }
else if (cat.contains("xplane")) { this->m_humanReadableCategory = "XPlane"; }
else if (cat.contains("fsx")) { this->m_humanReadableCategory = "FSX"; }
else if (cat.contains("fs9")) { this->m_humanReadableCategory = "FS9"; }
else if (cat.contains("mapping") || cat.contains("matching")) { this->m_humanReadableCategory = "Model matching"; }
else this->m_humanReadableCategory = "Misc.";
} }
return this->m_humanReadableCategory; return this->m_humanReadableCategory;
} }
QStringList CStatusMessage::getHumanReadablePatterns() const
{
QStringList patternNames;
for (const QString &name : CLogPattern::allHumanReadableNames())
{
if (CLogPattern::fromHumanReadableName(name).match(*this)) { patternNames.push_back(name); }
}
return patternNames;
}
void CStatusMessage::markAsHandledBy(const QObject *object) const void CStatusMessage::markAsHandledBy(const QObject *object) const
{ {
this->m_handledByObjects.push_back(quintptr(object)); this->m_handledByObjects.push_back(quintptr(object));
} }
bool CStatusMessage::wasHandledBy(const QObject *object) const bool CStatusMessage::wasHandledBy(const QObject *object) const
{ {
return this->m_handledByObjects.contains(quintptr(object)); return this->m_handledByObjects.contains(quintptr(object));
@@ -293,7 +287,7 @@ namespace BlackMisc
case IndexCategories: case IndexCategories:
return CVariant::from(this->m_categories.toQString()); return CVariant::from(this->m_categories.toQString());
case IndexCategoryHumanReadable: case IndexCategoryHumanReadable:
return CVariant::from(this->getHumanReadableCategory()); return CVariant::from(this->getHumanReadablePattern());
default: default:
return CValueObject::propertyByIndex(index); return CValueObject::propertyByIndex(index);
} }

View File

@@ -83,7 +83,10 @@ namespace BlackMisc
const CLogCategoryList &getCategories() const { return this->m_categories; } const CLogCategoryList &getCategories() const { return this->m_categories; }
//! Human readable category //! Human readable category
QString getHumanReadableCategory() const; QString getHumanReadablePattern() const;
//! All human readable categories
QStringList getHumanReadablePatterns() const;
//! Message severity //! Message severity
StatusSeverity getSeverity() const { return this->m_severity; } StatusSeverity getSeverity() const { return this->m_severity; }