Ref T566, UI allow to enable/full matching log messages

This commit is contained in:
Klaus Basan
2019-04-08 03:08:54 +02:00
committed by Mat Sutcliffe
parent 0d2e6dd997
commit 5e32064d21
3 changed files with 49 additions and 22 deletions

View File

@@ -17,6 +17,7 @@
using namespace BlackCore; using namespace BlackCore;
using namespace BlackCore::Context; using namespace BlackCore::Context;
using namespace BlackMisc::Simulation;
namespace BlackGui namespace BlackGui
{ {
@@ -27,14 +28,15 @@ namespace BlackGui
ui(new Ui::CModelMatcherLogEnable) ui(new Ui::CModelMatcherLogEnable)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->cb_LogReverseLookup, &QCheckBox::toggled, this, &CModelMatcherLogEnable::enabledCheckboxChanged); connect(ui->cb_LogReverseLookup, &QCheckBox::toggled, this, &CModelMatcherLogEnable::enabledCheckboxChanged, Qt::QueuedConnection);
connect(ui->cb_LogMatchingMessages, &QCheckBox::toggled, this, &CModelMatcherLogEnable::enabledCheckboxChanged); 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()) if (this->hasContexts())
{ {
connect(sGui->getIContextSimulator(), &IContextSimulator::changedLogOrDebugSettings, this, &CModelMatcherLogEnable::valuesChanged, Qt::QueuedConnection); connect(sGui->getIContextSimulator(), &IContextSimulator::changedLogOrDebugSettings, this, &CModelMatcherLogEnable::valuesChanged, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::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); connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CModelMatcherLogEnable::connectionStatusChanged, Qt::QueuedConnection);
} }
QPointer<CModelMatcherLogEnable> myself(this); QPointer<CModelMatcherLogEnable> myself(this);
@@ -62,13 +64,28 @@ namespace BlackGui
{ {
if (!this->hasContexts()) { return; } if (!this->hasContexts()) { return; }
const QObject *sender = QObject::sender(); const QObject *sender = QObject::sender();
if (sender == ui->cb_LogReverseLookup)
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)
{ {
sGui->getIContextNetwork()->enableReverseLookupMessages(enabled); ReverseLookupLogging revLog = RevLogDisabled;
if (reverse && simplified) { revLog = RevLogEnabledSimplified; }
else if (reverse) { revLog = RevLogEnabled; }
sGui->getIContextNetwork()->enableReverseLookupMessages(revLog);
} }
else if (sender == ui->cb_LogMatchingMessages)
if (sender == ui->cb_LogMatchingMessages || sender == ui->cb_LogDetailed)
{ {
sGui->getIContextSimulator()->enableMatchingMessages(enabled); MatchingLog matchingLog = MatchingLogNothing;
if (matching && simplified) { matchingLog = MatchingLogSimplified; }
else if (matching) { matchingLog = MatchingLogAll; }
sGui->getIContextSimulator()->enableMatchingMessages(matchingLog);
} }
} }
@@ -77,17 +94,17 @@ namespace BlackGui
if (this->hasContexts()) if (this->hasContexts())
{ {
// avoid signal roundtrips // avoid signal roundtrips
bool c = sGui->getIContextNetwork()->isReverseLookupMessagesEnabled(); const ReverseLookupLogging revLog = sGui->getIContextNetwork()->isReverseLookupMessagesEnabled();
if (c != ui->cb_LogReverseLookup->isChecked()) const bool revLogEnabled = revLog.testFlag(RevLogEnabled);
{ if (revLogEnabled != ui->cb_LogReverseLookup->isChecked()) { ui->cb_LogReverseLookup->setChecked(revLogEnabled); }
ui->cb_LogReverseLookup->setChecked(c);
}
c = sGui->getIContextSimulator()->isMatchingMessagesEnabled(); const MatchingLog matchingLog = sGui->getIContextSimulator()->isMatchingMessagesEnabled();
if (c != ui->cb_LogMatchingMessages->isChecked()) const bool matchingLogEnabled = matchingLog > 0;
{ if (matchingLogEnabled != ui->cb_LogMatchingMessages->isChecked()) { ui->cb_LogMatchingMessages->setChecked(matchingLogEnabled); }
ui->cb_LogMatchingMessages->setChecked(c);
} const bool simplified = revLog.testFlag(RevLogSimplifiedInfo) || matchingLog == MatchingLogSimplified;
const bool detailed = !simplified;
if (detailed != ui->cb_LogDetailed->isChecked()) { ui->cb_LogDetailed->setChecked(detailed); }
} }
} }

View File

@@ -30,7 +30,7 @@ namespace BlackGui
explicit CModelMatcherLogEnable(QWidget *parent = nullptr); explicit CModelMatcherLogEnable(QWidget *parent = nullptr);
//! Destructor //! Destructor
virtual ~CModelMatcherLogEnable(); virtual ~CModelMatcherLogEnable() override;
//! Reverse lookup enabled? //! Reverse lookup enabled?
bool isReverseLookupLogEnabled() const; bool isReverseLookupLogEnabled() const;

View File

@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>276</width> <width>287</width>
<height>20</height> <height>20</height>
</rect> </rect>
</property> </property>
@@ -45,7 +45,7 @@
<string>enable logging of reverse lookup messages</string> <string>enable logging of reverse lookup messages</string>
</property> </property>
<property name="text"> <property name="text">
<string>rev. lookup msgs.</string> <string>rev. lookup</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -55,7 +55,17 @@
<string>enable matching messages</string> <string>enable matching messages</string>
</property> </property>
<property name="text"> <property name="text">
<string>matching msgs.</string> <string>matching</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_LogDetailed">
<property name="toolTip">
<string>a simplified matching log (faster) or a detailed log (slower)</string>
</property>
<property name="text">
<string>detailed</string>
</property> </property>
</widget> </widget>
</item> </item>