Use nested namespaces (C++17 feature)

This commit is contained in:
Mat Sutcliffe
2021-09-15 21:44:54 +01:00
parent 3f2e5b0b69
commit 57d32da826
1345 changed files with 146075 additions and 150376 deletions

View File

@@ -20,113 +20,110 @@ using namespace BlackCore::Context;
using namespace BlackMisc::Network;
using namespace BlackMisc::Simulation;
namespace BlackGui
namespace BlackGui::Components
{
namespace Components
CModelMatcherLogEnable::CModelMatcherLogEnable(QWidget *parent) :
QFrame(parent),
ui(new Ui::CModelMatcherLogEnable)
{
CModelMatcherLogEnable::CModelMatcherLogEnable(QWidget *parent) :
QFrame(parent),
ui(new Ui::CModelMatcherLogEnable)
ui->setupUi(this);
connect(ui->cb_LogReverseLookup, &QCheckBox::toggled, this, &CModelMatcherLogEnable::enabledCheckboxChanged, Qt::QueuedConnection);
connect(ui->cb_LogMatchingMessages, &QCheckBox::toggled, this, &CModelMatcherLogEnable::enabledCheckboxChanged, Qt::QueuedConnection);
connect(ui->cb_LogDetailed, &QCheckBox::toggled, this, &CModelMatcherLogEnable::enabledCheckboxChanged, Qt::QueuedConnection);
if (this->hasContexts())
{
ui->setupUi(this);
connect(ui->cb_LogReverseLookup, &QCheckBox::toggled, this, &CModelMatcherLogEnable::enabledCheckboxChanged, Qt::QueuedConnection);
connect(ui->cb_LogMatchingMessages, &QCheckBox::toggled, this, &CModelMatcherLogEnable::enabledCheckboxChanged, Qt::QueuedConnection);
connect(ui->cb_LogDetailed, &QCheckBox::toggled, this, &CModelMatcherLogEnable::enabledCheckboxChanged, Qt::QueuedConnection);
if (this->hasContexts())
{
connect(sGui->getIContextSimulator(), &IContextSimulator::changedLogOrDebugSettings, this, &CModelMatcherLogEnable::valuesChanged, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::changedLogOrDebugSettings, this, &CModelMatcherLogEnable::valuesChanged, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CModelMatcherLogEnable::connectionStatusChanged, Qt::QueuedConnection);
}
QPointer<CModelMatcherLogEnable> myself(this);
QTimer::singleShot(5000, this, [ = ]
{
if (!myself) { return; }
this->initGui();
});
connect(sGui->getIContextSimulator(), &IContextSimulator::changedLogOrDebugSettings, this, &CModelMatcherLogEnable::valuesChanged, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::changedLogOrDebugSettings, this, &CModelMatcherLogEnable::valuesChanged, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CModelMatcherLogEnable::connectionStatusChanged, Qt::QueuedConnection);
}
CModelMatcherLogEnable::~CModelMatcherLogEnable()
{ }
bool CModelMatcherLogEnable::isReverseLookupLogEnabled() const
QPointer<CModelMatcherLogEnable> myself(this);
QTimer::singleShot(5000, this, [ = ]
{
return ui->cb_LogReverseLookup->isChecked();
if (!myself) { return; }
this->initGui();
});
}
CModelMatcherLogEnable::~CModelMatcherLogEnable()
{ }
bool CModelMatcherLogEnable::isReverseLookupLogEnabled() const
{
return ui->cb_LogReverseLookup->isChecked();
}
bool CModelMatcherLogEnable::isMatchingLogEnabled() const
{
return ui->cb_LogMatchingMessages->isChecked();
}
void CModelMatcherLogEnable::enabledCheckboxChanged(bool enabled)
{
if (!this->hasContexts()) { return; }
const QObject *sender = QObject::sender();
const bool detailed = (sender == ui->cb_LogDetailed) ? enabled : ui->cb_LogDetailed->isChecked();
const bool reverse = (sender == ui->cb_LogReverseLookup) ? enabled : ui->cb_LogReverseLookup->isChecked();
const bool matching = (sender == ui->cb_LogMatchingMessages) ? enabled : ui->cb_LogMatchingMessages->isChecked();
const bool simplified = !detailed;
if (sender == ui->cb_LogReverseLookup || sender == ui->cb_LogDetailed)
{
ReverseLookupLogging revLog = RevLogDisabled;
if (reverse && simplified) { revLog = RevLogEnabledSimplified; }
else if (reverse) { revLog = RevLogEnabled; }
sGui->getIContextNetwork()->enableReverseLookupMessages(revLog);
}
bool CModelMatcherLogEnable::isMatchingLogEnabled() const
if (sender == ui->cb_LogMatchingMessages || sender == ui->cb_LogDetailed)
{
return ui->cb_LogMatchingMessages->isChecked();
}
MatchingLog matchingLog = MatchingLogNothing;
if (matching && simplified) { matchingLog = MatchingLogSimplified; }
else if (matching) { matchingLog = MatchingLogAll; }
void CModelMatcherLogEnable::enabledCheckboxChanged(bool enabled)
sGui->getIContextSimulator()->enableMatchingMessages(matchingLog);
}
}
void CModelMatcherLogEnable::initGui()
{
if (this->hasContexts())
{
if (!this->hasContexts()) { return; }
const QObject *sender = QObject::sender();
// avoid signal roundtrips
const ReverseLookupLogging revLog = sGui->getIContextNetwork()->isReverseLookupMessagesEnabled();
const bool revLogEnabled = revLog.testFlag(RevLogEnabled);
if (revLogEnabled != ui->cb_LogReverseLookup->isChecked()) { ui->cb_LogReverseLookup->setChecked(revLogEnabled); }
const bool detailed = (sender == ui->cb_LogDetailed) ? enabled : ui->cb_LogDetailed->isChecked();
const bool reverse = (sender == ui->cb_LogReverseLookup) ? enabled : ui->cb_LogReverseLookup->isChecked();
const bool matching = (sender == ui->cb_LogMatchingMessages) ? enabled : ui->cb_LogMatchingMessages->isChecked();
const bool simplified = !detailed;
const MatchingLog matchingLog = sGui->getIContextSimulator()->isMatchingMessagesEnabled();
const bool matchingLogEnabled = matchingLog > 0;
if (matchingLogEnabled != ui->cb_LogMatchingMessages->isChecked()) { ui->cb_LogMatchingMessages->setChecked(matchingLogEnabled); }
if (sender == ui->cb_LogReverseLookup || sender == ui->cb_LogDetailed)
{
ReverseLookupLogging revLog = RevLogDisabled;
if (reverse && simplified) { revLog = RevLogEnabledSimplified; }
else if (reverse) { revLog = RevLogEnabled; }
sGui->getIContextNetwork()->enableReverseLookupMessages(revLog);
}
if (sender == ui->cb_LogMatchingMessages || sender == ui->cb_LogDetailed)
{
MatchingLog matchingLog = MatchingLogNothing;
if (matching && simplified) { matchingLog = MatchingLogSimplified; }
else if (matching) { matchingLog = MatchingLogAll; }
sGui->getIContextSimulator()->enableMatchingMessages(matchingLog);
}
const bool simplified = revLog.testFlag(RevLogSimplifiedInfo) || matchingLog == MatchingLogSimplified;
const bool detailed = !simplified;
if (detailed != ui->cb_LogDetailed->isChecked()) { ui->cb_LogDetailed->setChecked(detailed); }
}
}
void CModelMatcherLogEnable::initGui()
{
if (this->hasContexts())
{
// avoid signal roundtrips
const ReverseLookupLogging revLog = sGui->getIContextNetwork()->isReverseLookupMessagesEnabled();
const bool revLogEnabled = revLog.testFlag(RevLogEnabled);
if (revLogEnabled != ui->cb_LogReverseLookup->isChecked()) { ui->cb_LogReverseLookup->setChecked(revLogEnabled); }
bool CModelMatcherLogEnable::hasContexts() const
{
if (!sGui || sGui->isShuttingDown()) { return false; }
return sGui->getIContextSimulator() && sGui->getIContextNetwork();
}
const MatchingLog matchingLog = sGui->getIContextSimulator()->isMatchingMessagesEnabled();
const bool matchingLogEnabled = matchingLog > 0;
if (matchingLogEnabled != ui->cb_LogMatchingMessages->isChecked()) { ui->cb_LogMatchingMessages->setChecked(matchingLogEnabled); }
void CModelMatcherLogEnable::valuesChanged()
{
this->initGui();
}
const bool simplified = revLog.testFlag(RevLogSimplifiedInfo) || matchingLog == MatchingLogSimplified;
const bool detailed = !simplified;
if (detailed != ui->cb_LogDetailed->isChecked()) { ui->cb_LogDetailed->setChecked(detailed); }
}
}
bool CModelMatcherLogEnable::hasContexts() const
{
if (!sGui || sGui->isShuttingDown()) { return false; }
return sGui->getIContextSimulator() && sGui->getIContextNetwork();
}
void CModelMatcherLogEnable::valuesChanged()
void CModelMatcherLogEnable::connectionStatusChanged(const CConnectionStatus &from, const CConnectionStatus &to)
{
Q_UNUSED(from);
if (to.isConnected() || to.isDisconnected())
{
this->initGui();
}
void CModelMatcherLogEnable::connectionStatusChanged(const CConnectionStatus &from, const CConnectionStatus &to)
{
Q_UNUSED(from);
if (to.isConnected() || to.isDisconnected())
{
this->initGui();
}
}
} // ns
}
} // ns