mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
Issue #77 Break cyclic dependency between CStatusMessage and CLogPattern by moving methods from one to the other
This commit is contained in:
@@ -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 {};
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user