diff --git a/src/blackgui/components/statusmessageform.cpp b/src/blackgui/components/statusmessageform.cpp index 1a91a2de0..bd0c93ec6 100644 --- a/src/blackgui/components/statusmessageform.cpp +++ b/src/blackgui/components/statusmessageform.cpp @@ -7,7 +7,7 @@ */ #include "blackgui/components/statusmessageform.h" -#include "blackmisc/logcategories.h" +#include "blackmisc/logpattern.h" #include "ui_statusmessageform.h" #include @@ -41,7 +41,7 @@ namespace BlackGui { ui->te_Message->setPlainText(message.getMessage()); ui->lbl_SeverityIcon->setPixmap(CIcon(message.toIcon())); - const QString hrc(message.getHumanReadablePattern()); + const QString hrc(CLogPattern::humanReadableNamesFrom(message).join(", ")); if (hrc.isEmpty()) { ui->le_Categories->setText(message.getCategories().toQString()); diff --git a/src/blackgui/components/statusmessageformsmall.cpp b/src/blackgui/components/statusmessageformsmall.cpp index c8de2fea6..0cce842a7 100644 --- a/src/blackgui/components/statusmessageformsmall.cpp +++ b/src/blackgui/components/statusmessageformsmall.cpp @@ -7,6 +7,7 @@ */ #include "blackgui/components/statusmessageformsmall.h" +#include "blackmisc/logpattern.h" #include "ui_statusmessageformsmall.h" #include @@ -39,7 +40,7 @@ namespace BlackGui { ui->te_Message->setPlainText(message.getMessage()); ui->lbl_SeverityIcon->setPixmap(CIcon(message.toIcon())); - ui->le_Categories->setText(message.getHumanOrTechnicalCategoriesAsString()); + ui->le_Categories->setText(CLogPattern::humanOrTechnicalCategoriesFrom(message).join(", ")); ui->le_Severity->setText(message.getSeverityAsString()); ui->le_Timestamp->setText(message.getFormattedUtcTimestampYmdhms()); } diff --git a/src/blackgui/models/statusmessagefilter.cpp b/src/blackgui/models/statusmessagefilter.cpp index 1614a544c..2cfbbedc0 100644 --- a/src/blackgui/models/statusmessagefilter.cpp +++ b/src/blackgui/models/statusmessagefilter.cpp @@ -40,7 +40,7 @@ namespace BlackGui if (!this->m_category.isEmpty()) { - if (!this->stringMatchesFilterExpression(msg.getHumanOrTechnicalCategoriesAsString(), this->m_category)) { continue; } + if (!this->stringMatchesFilterExpression(CLogPattern::humanOrTechnicalCategoriesFrom(msg).join(", "), this->m_category)) { continue; } } outContainer.push_back(msg); diff --git a/src/blackgui/models/statusmessagelistmodel.cpp b/src/blackgui/models/statusmessagelistmodel.cpp index 4afc3c40f..e9c825fc8 100644 --- a/src/blackgui/models/statusmessagelistmodel.cpp +++ b/src/blackgui/models/statusmessagelistmodel.cpp @@ -89,7 +89,7 @@ namespace BlackGui col.setSortPropertyIndex(CStatusMessage::IndexSeverityAsString); m_columns.addColumn(col); m_columns.addColumn(CColumn::standardString("message", CStatusMessage::IndexMessage)); - m_columns.addColumn(CColumn::standardString("category", CStatusMessage::IndexCategoryHumanReadableOrTechnicalAsString)); + m_columns.addColumn(CColumn::standardString("category", CStatusMessage::IndexCategoriesAsString)); } break; case SimplifiedWithOrder: diff --git a/src/blackmisc/logpattern.cpp b/src/blackmisc/logpattern.cpp index 8da41608c..4783824f7 100644 --- a/src/blackmisc/logpattern.cpp +++ b/src/blackmisc/logpattern.cpp @@ -71,6 +71,23 @@ namespace BlackMisc return names; } + QStringList CLogPattern::humanReadableNamesFrom(const CStatusMessage &message) + { + QStringList patternNames; + for (const QString &name : CLogPattern::allHumanReadableNames()) + { + if (CLogPattern::fromHumanReadableName(name).match(message)) { patternNames.push_back(name); } + } + return patternNames; + } + + QStringList CLogPattern::humanOrTechnicalCategoriesFrom(const CStatusMessage &message) + { + if (message.getCategories().isEmpty()) { return {}; } + QStringList c(humanReadableNamesFrom(message).join(", ")); + return c.isEmpty() ? message.getCategories().toQStringList() : c; + } + const CLogPattern &CLogPattern::fromHumanReadableName(const QString &name) { static const CLogPattern empty {}; diff --git a/src/blackmisc/logpattern.h b/src/blackmisc/logpattern.h index 8bfff6b41..316c0c385 100644 --- a/src/blackmisc/logpattern.h +++ b/src/blackmisc/logpattern.h @@ -58,6 +58,12 @@ namespace BlackMisc //! Return a predefined CLogPattern corresponding to the given human-readable name. static const CLogPattern &fromHumanReadableName(const QString &name); + //! Human readable categories of message. + static QStringList humanReadableNamesFrom(const CStatusMessage &message); + + //! Human or machine readable categories of message. + static QStringList humanOrTechnicalCategoriesFrom(const CStatusMessage &message); + //! Default constructed CLogPattern will match any message. CLogPattern(); diff --git a/src/blackmisc/statusmessage.cpp b/src/blackmisc/statusmessage.cpp index 02ba03694..cb7c24c36 100644 --- a/src/blackmisc/statusmessage.cpp +++ b/src/blackmisc/statusmessage.cpp @@ -9,7 +9,6 @@ #include "blackmisc/statusmessage.h" #include "blackmisc/propertyindexref.h" #include "blackmisc/iconlist.h" -#include "blackmisc/logpattern.h" #include "blackmisc/comparefunctions.h" #include "blackmisc/stringutils.h" #include "blackmisc/verify.h" @@ -196,29 +195,6 @@ namespace BlackMisc return m_categories.toQString(); } - QString CStatusMessage::getHumanReadablePattern() const - { - const QStringList patternNames(getHumanReadablePatterns()); - return patternNames.isEmpty() ? QString() : patternNames.join(", "); - } - - QStringList CStatusMessage::getHumanReadablePatterns() const - { - QStringList patternNames; - for (const QString &name : CLogPattern::allHumanReadableNames()) - { - if (CLogPattern::fromHumanReadableName(name).match(*this)) { patternNames.push_back(name); } - } - return patternNames; - } - - QString CStatusMessage::getHumanOrTechnicalCategoriesAsString() const - { - if (m_categories.isEmpty()) { return {}; } - const QString c(getHumanReadablePattern()); - return c.isEmpty() ? this->getCategoriesAsString() : c; - } - bool CStatusMessage::clampSeverity(CStatusMessage::StatusSeverity severity) { if (this->getSeverity() <= severity) { return false; } @@ -430,8 +406,6 @@ namespace BlackMisc case IndexSeverityAsString: return QVariant::fromValue(this->getSeverityAsString()); case IndexSeverityAsIcon: return QVariant::fromValue(this->getSeverityAsIcon()); case IndexCategoriesAsString: return QVariant::fromValue(m_categories.toQString()); - case IndexCategoriesHumanReadableAsString: return QVariant::fromValue(this->getHumanReadablePattern()); - case IndexCategoryHumanReadableOrTechnicalAsString: return QVariant::fromValue(this->getHumanOrTechnicalCategoriesAsString()); case IndexMessageAsHtml: return QVariant::fromValue(this->toHtml(false, true)); default: return CValueObject::propertyByIndex(index); } @@ -469,8 +443,6 @@ namespace BlackMisc case IndexSeverityAsIcon: case IndexSeverity: return Compare::compare(this->getSeverity(), compareValue.getSeverity()); case IndexCategoriesAsString: return this->getCategoriesAsString().compare(compareValue.getCategoriesAsString()); - case IndexCategoriesHumanReadableAsString: return this->getHumanReadablePattern().compare(compareValue.getHumanReadablePattern()); - case IndexCategoryHumanReadableOrTechnicalAsString: return this->getHumanOrTechnicalCategoriesAsString().compare(compareValue.getHumanOrTechnicalCategoriesAsString()); default: break; } return CValueObject::comparePropertyByIndex(index, compareValue); diff --git a/src/blackmisc/statusmessage.h b/src/blackmisc/statusmessage.h index b90bc7696..5548a9e85 100644 --- a/src/blackmisc/statusmessage.h +++ b/src/blackmisc/statusmessage.h @@ -307,8 +307,6 @@ namespace BlackMisc enum ColumnIndex { IndexCategoriesAsString = CPropertyIndexRef::GlobalIndexCStatusMessage, - IndexCategoriesHumanReadableAsString, - IndexCategoryHumanReadableOrTechnicalAsString, IndexSeverity, IndexSeverityAsString, IndexSeverityAsIcon, @@ -380,12 +378,6 @@ namespace BlackMisc //! Message categories as string QString getCategoriesAsString() const; - //! Human readable category - QString getHumanReadablePattern() const; - - //! All human readable categories - QStringList getHumanReadablePatterns() const; - //! The human or technical categories QString getHumanOrTechnicalCategoriesAsString() const;