mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Improve the performance and usability of the raw FSD message display
* Replaced QListView with QPlainTextEdit * Added filter options for packet type and text * Option to globally disable/enable the feature. Default disabled Maniphest Tasks: Ref T240
This commit is contained in:
committed by
Klaus Basan
parent
58d128a9da
commit
b12002caa2
@@ -160,7 +160,8 @@ namespace BlackCore
|
||||
Vat_SetAircraftInfoHandler(m_net.data(), onPilotInfoReceived, this);
|
||||
Vat_SetCustomPilotPacketHandler(m_net.data(), onCustomPacketReceived, this);
|
||||
Vat_SetAircraftConfigHandler(m_net.data(), onAircraftConfigReceived, this);
|
||||
Vat_SetFsdMessageHandler(m_net.data(), onRawFsdMessage, this);
|
||||
|
||||
fsdMessageSettingsChanged();
|
||||
}
|
||||
|
||||
CNetworkVatlib::~CNetworkVatlib()
|
||||
@@ -1036,6 +1037,7 @@ namespace BlackCore
|
||||
|
||||
void CNetworkVatlib::handleRawFsdMessage(const QString &fsdMessage)
|
||||
{
|
||||
if (!m_rawFsdMessagesEnabled) { return; }
|
||||
CRawFsdMessage rawFsdMessage(fsdMessage);
|
||||
if (m_rawFsdMessageLogFile.isOpen())
|
||||
{
|
||||
@@ -1045,11 +1047,25 @@ namespace BlackCore
|
||||
emit rawFsdMessageReceived(rawFsdMessage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CNetworkVatlib::fsdMessageSettingsChanged()
|
||||
{
|
||||
if (!m_net) { return; }
|
||||
if (m_rawFsdMessageLogFile.isOpen()) { m_rawFsdMessageLogFile.close(); }
|
||||
const CRawFsdMessageSettings setting = m_fsdMessageSetting.get();
|
||||
if (!setting.isFileWritingEnabled() || setting.getFileDir().isEmpty()) { return; }
|
||||
|
||||
// Workaround bug in vatlib v0.9.7. Handlers cannot be updated.
|
||||
m_rawFsdMessagesEnabled = setting.areRawFsdMessagesEnabled();
|
||||
/*if (!setting.areRawFsdMessagesEnabled())
|
||||
{
|
||||
Vat_SetFsdMessageHandler(m_net.data(), nullptr, this);
|
||||
return;
|
||||
}*/
|
||||
|
||||
Vat_SetFsdMessageHandler(m_net.data(), CNetworkVatlib::onRawFsdMessage, this);
|
||||
|
||||
if (setting.getFileWriteMode() == CRawFsdMessageSettings::None || setting.getFileDir().isEmpty()) { return; }
|
||||
|
||||
if (setting.getFileWriteMode() == CRawFsdMessageSettings::Truncate)
|
||||
{
|
||||
|
||||
@@ -260,6 +260,7 @@ namespace BlackCore
|
||||
|
||||
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TRawFsdMessageSetting> m_fsdMessageSetting { this, &CNetworkVatlib::fsdMessageSettingsChanged };
|
||||
QFile m_rawFsdMessageLogFile;
|
||||
bool m_rawFsdMessagesEnabled = false;
|
||||
};
|
||||
} //namespace
|
||||
} //namespace
|
||||
|
||||
@@ -79,14 +79,14 @@ namespace BlackCore
|
||||
{ }
|
||||
|
||||
CRawFsdMessageSettings::CRawFsdMessageSettings(bool enabled, const QString &FileDir) :
|
||||
m_fileWritingEnabled(enabled), m_FileDir(FileDir)
|
||||
m_rawFsdMessagesEnabled(enabled), m_FileDir(FileDir)
|
||||
{ }
|
||||
|
||||
QString CRawFsdMessageSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
QString s("CRawFsdMessageSettings");
|
||||
s.append(" enabled: ").append(boolToYesNo(m_fileWritingEnabled));
|
||||
s.append(" enabled: ").append(boolToYesNo(m_rawFsdMessagesEnabled));
|
||||
s.append(" dir: ").append(m_FileDir);
|
||||
return s;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ namespace BlackCore
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexWriteEnabled: return CVariant::fromValue(this->m_fileWritingEnabled);
|
||||
case IndexRawFsdMessagesEnabled: return CVariant::fromValue(this->m_rawFsdMessagesEnabled);
|
||||
case IndexFileDir: return CVariant::fromValue(this->m_FileDir);
|
||||
case IndexFileWriteMode: return CVariant::fromValue(this->m_fileWriteMode);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
@@ -110,7 +110,7 @@ namespace BlackCore
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexWriteEnabled: this->m_fileWritingEnabled = variant.toBool(); break;
|
||||
case IndexRawFsdMessagesEnabled: this->m_rawFsdMessagesEnabled = variant.toBool(); break;
|
||||
case IndexFileDir: this->m_FileDir = variant.toQString(); break;
|
||||
case IndexFileWriteMode: this->m_fileWriteMode = variant.to<FileWriteMode>(); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
|
||||
@@ -174,6 +174,7 @@ namespace BlackCore
|
||||
//! File writing mode
|
||||
enum FileWriteMode
|
||||
{
|
||||
None,
|
||||
Truncate,
|
||||
Append,
|
||||
Timestamped
|
||||
@@ -182,7 +183,7 @@ namespace BlackCore
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexWriteEnabled = BlackMisc::CPropertyIndex::GlobalIndexRawFsdMessageSettings,
|
||||
IndexRawFsdMessagesEnabled = BlackMisc::CPropertyIndex::GlobalIndexRawFsdMessageSettings,
|
||||
IndexFileDir,
|
||||
IndexFileWriteMode
|
||||
};
|
||||
@@ -193,8 +194,8 @@ namespace BlackCore
|
||||
//! Simplified constructor
|
||||
CRawFsdMessageSettings(bool enabled, const QString &fileDir);
|
||||
|
||||
//! Is file writing enabled?
|
||||
bool isFileWritingEnabled() const { return m_fileWritingEnabled; }
|
||||
//! Are raw FSD messages enabled?
|
||||
bool areRawFsdMessagesEnabled() const { return m_rawFsdMessagesEnabled; }
|
||||
|
||||
//! Get file directory
|
||||
QString getFileDir() const { return m_FileDir; }
|
||||
@@ -212,13 +213,13 @@ namespace BlackCore
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
private:
|
||||
bool m_fileWritingEnabled = false;
|
||||
bool m_rawFsdMessagesEnabled = false;
|
||||
QString m_FileDir;
|
||||
FileWriteMode m_fileWriteMode = Truncate;
|
||||
FileWriteMode m_fileWriteMode = None;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CRawFsdMessageSettings,
|
||||
BLACK_METAMEMBER(fileWritingEnabled),
|
||||
BLACK_METAMEMBER(rawFsdMessagesEnabled),
|
||||
BLACK_METAMEMBER(FileDir),
|
||||
BLACK_METAMEMBER(fileWriteMode)
|
||||
);
|
||||
@@ -233,12 +234,12 @@ namespace BlackCore
|
||||
//! \copydoc BlackCore::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("FSD message Logging"); return name; }
|
||||
|
||||
//! \copydoc BlackCore::TSettingTrait::isValid
|
||||
/* //! \copydoc BlackCore::TSettingTrait::isValid
|
||||
static bool isValid(const CRawFsdMessageSettings &setting)
|
||||
{
|
||||
if (setting.isFileWritingEnabled()) { return !setting.getFileDir().isEmpty(); }
|
||||
if (setting.areRawFsdMessagesEnabled()) { return !setting.getFileDir().isEmpty(); }
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
//! \copydoc BlackCore::TSettingTrait::defaultValue
|
||||
static const CRawFsdMessageSettings &defaultValue()
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QDir>
|
||||
#include <QStringList>
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace BlackMisc;
|
||||
@@ -30,37 +31,145 @@ namespace BlackGui
|
||||
QFrame(parent), ui(new Ui::CRawFsdMessagesComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->cb_FileWritingMode->addItem(QApplication::translate("CRawFsdMessagesComponent", "None", nullptr), QVariant::fromValue(CRawFsdMessageSettings::None));
|
||||
ui->cb_FileWritingMode->addItem(QApplication::translate("CRawFsdMessagesComponent", "Truncate", nullptr), QVariant::fromValue(CRawFsdMessageSettings::Truncate));
|
||||
ui->cb_FileWritingMode->addItem(QApplication::translate("CRawFsdMessagesComponent", "Append", nullptr), QVariant::fromValue(CRawFsdMessageSettings::Append));
|
||||
ui->cb_FileWritingMode->addItem(QApplication::translate("CRawFsdMessagesComponent", "Timestamped", nullptr), QVariant::fromValue(CRawFsdMessageSettings::Timestamped));
|
||||
|
||||
QMetaObject::Connection c = sGui->getIContextNetwork()->connectRawFsdMessageSignal(this, std::bind(&CRawFsdMessagesComponent::addFsdMessage, this, std::placeholders::_1));
|
||||
if (!c)
|
||||
{
|
||||
ui->cb_EnableFileWriting->setEnabled(false);
|
||||
ui->lw_RawFsdMessages->addItem(QStringLiteral("Could not connect to raw FSD message."));
|
||||
ui->lw_RawFsdMessages->addItem(QStringLiteral("This is most likely because core is not running in this process."));
|
||||
ui->lw_RawFsdMessages->addItem(QStringLiteral("Open this component again from the process running core."));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_signalConnections.append(c);
|
||||
readSettings();
|
||||
connect(ui->cb_EnableFileWriting, &QCheckBox::toggled, this, &CRawFsdMessagesComponent::changeWritingToFile);
|
||||
connect(ui->pb_SelectFileDir, &QPushButton::clicked, this, &CRawFsdMessagesComponent::selectFileDir);
|
||||
connect(ui->cb_FileWritingMode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CRawFsdMessagesComponent::changeFileWritingMode);
|
||||
}
|
||||
ui->cb_FilterPacketType->addItem("");
|
||||
ui->cb_FilterPacketType->addItems(CRawFsdMessage::getAllPacketTypes());
|
||||
ui->pte_RawFsdMessages->setMaximumBlockCount(m_maxDisplayedMessages);
|
||||
ui->le_MaxDisplayedMessages->setText(QString::number(m_maxDisplayedMessages));
|
||||
|
||||
setupConnections();
|
||||
expandFilters(false);
|
||||
expandWritingToFile(false);
|
||||
}
|
||||
|
||||
CRawFsdMessagesComponent::~CRawFsdMessagesComponent()
|
||||
{ }
|
||||
|
||||
void CRawFsdMessagesComponent::changeWritingToFile(bool enable)
|
||||
void CRawFsdMessagesComponent::setupConnections()
|
||||
{
|
||||
|
||||
connect(ui->le_FilterText, &QLineEdit::returnPressed, this, &CRawFsdMessagesComponent::changeStringFilter);
|
||||
connect(ui->cb_FilterPacketType, &QComboBox::currentTextChanged, this, &CRawFsdMessagesComponent::changePacketTypeFilter);
|
||||
connect(ui->gb_Filter, &QGroupBox::toggled, this, &CRawFsdMessagesComponent::expandFilters);
|
||||
connect(ui->gb_WriteToFile , &QGroupBox::toggled, this, &CRawFsdMessagesComponent::expandWritingToFile);
|
||||
connect(ui->pb_SelectFileDir, &QPushButton::clicked, this, &CRawFsdMessagesComponent::selectFileDir);
|
||||
connect(ui->le_MaxDisplayedMessages, &QLineEdit::returnPressed, this, &CRawFsdMessagesComponent::changeMaxDisplayedMessages);
|
||||
|
||||
QValidator *validator = new QIntValidator(10, 200, this);
|
||||
ui->le_MaxDisplayedMessages->setValidator(validator);
|
||||
|
||||
using namespace std::placeholders;
|
||||
QMetaObject::Connection c = sGui->getIContextNetwork()->connectRawFsdMessageSignal(this, std::bind(&CRawFsdMessagesComponent::addFsdMessage, this, _1));
|
||||
if (!c)
|
||||
{
|
||||
ui->pte_RawFsdMessages->appendPlainText(QStringLiteral("Could not connect to raw FSD message."));
|
||||
ui->pte_RawFsdMessages->appendPlainText(QStringLiteral("This is most likely because core is not running in this process."));
|
||||
ui->pte_RawFsdMessages->appendPlainText(QStringLiteral("Open this component again from the process running core."));
|
||||
return;
|
||||
}
|
||||
m_signalConnections.append(c);
|
||||
|
||||
readSettings();
|
||||
// Connect them after settings are read. Otherwise they get called.
|
||||
connect(ui->cb_FileWritingMode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CRawFsdMessagesComponent::changeFileWritingMode);
|
||||
connect(ui->cb_EnableRawFsdMessages, &QCheckBox::toggled, this, &CRawFsdMessagesComponent::enableRawFsdMessages);
|
||||
}
|
||||
|
||||
void CRawFsdMessagesComponent::enableRawFsdMessages(bool enable)
|
||||
{
|
||||
ui->cb_FilterPacketType->setEnabled(enable);
|
||||
ui->le_FilterText->setEnabled(enable);
|
||||
ui->le_MaxDisplayedMessages->setEnabled(enable);
|
||||
ui->le_FileDir->setEnabled(enable);
|
||||
ui->pb_SelectFileDir->setEnabled(enable);
|
||||
ui->cb_FileWritingMode->setEnabled(enable);
|
||||
m_setting.setProperty(Vatsim::CRawFsdMessageSettings::IndexWriteEnabled, CVariant::fromValue(enable));
|
||||
m_setting.setProperty(Vatsim::CRawFsdMessageSettings::IndexRawFsdMessagesEnabled, CVariant::fromValue(enable));
|
||||
}
|
||||
|
||||
void CRawFsdMessagesComponent::expandFilters(bool expand)
|
||||
{
|
||||
if(expand)
|
||||
{
|
||||
ui->gl_Filters->setHorizontalSpacing(7);
|
||||
ui->gl_Filters->setVerticalSpacing(7);
|
||||
ui->gl_Filters->setContentsMargins(11, 11, 11, 11);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->gl_Filters->setHorizontalSpacing(0);
|
||||
ui->gl_Filters->setVerticalSpacing(0);
|
||||
ui->gl_Filters->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < ui->gl_Filters->count(); idx++)
|
||||
{
|
||||
QLayoutItem * const item = ui->gl_Filters->itemAt(idx);
|
||||
if(item->widget()) { item->widget()->setVisible(expand); }
|
||||
}
|
||||
}
|
||||
|
||||
void CRawFsdMessagesComponent::expandWritingToFile(bool expand)
|
||||
{
|
||||
if(expand)
|
||||
{
|
||||
ui->gl_WriteToFile->setHorizontalSpacing(7);
|
||||
ui->gl_WriteToFile->setVerticalSpacing(7);
|
||||
ui->gl_WriteToFile->setContentsMargins(11, 11, 11, 11);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->gl_WriteToFile->setHorizontalSpacing(0);
|
||||
ui->gl_WriteToFile->setVerticalSpacing(0);
|
||||
ui->gl_WriteToFile->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < ui->gl_WriteToFile->count(); idx++)
|
||||
{
|
||||
QLayoutItem * const item = ui->gl_WriteToFile->itemAt(idx);
|
||||
if(item->widget()) { item->widget()->setVisible(expand); }
|
||||
}
|
||||
}
|
||||
|
||||
void CRawFsdMessagesComponent::changeStringFilter()
|
||||
{
|
||||
m_filterString = ui->le_FilterText->text();
|
||||
filterDisplayedMessages();
|
||||
}
|
||||
|
||||
void CRawFsdMessagesComponent::changePacketTypeFilter(const QString &type)
|
||||
{
|
||||
m_filterPacketType = type;
|
||||
filterDisplayedMessages();
|
||||
}
|
||||
|
||||
void CRawFsdMessagesComponent::changeMaxDisplayedMessages()
|
||||
{
|
||||
int maxDisplayedMessages = 0;
|
||||
bool ok = false;
|
||||
maxDisplayedMessages = ui->le_MaxDisplayedMessages->text().toInt(&ok);
|
||||
if (ok)
|
||||
{
|
||||
m_maxDisplayedMessages = maxDisplayedMessages;
|
||||
filterDisplayedMessages();
|
||||
}
|
||||
}
|
||||
|
||||
void CRawFsdMessagesComponent::filterDisplayedMessages()
|
||||
{
|
||||
CRawFsdMessageList filtered = m_buffer;
|
||||
if (! m_filterString.isEmpty()) { filtered = filtered.findByContainsString(m_filterString); }
|
||||
if (! m_filterPacketType.isEmpty()) { filtered = filtered.findByPacketType(m_filterPacketType); }
|
||||
ui->pte_RawFsdMessages->clear();
|
||||
// Append only the last messages up to maximum display size. Erase everything before.
|
||||
filtered.erase(filtered.begin(), filtered.end() - std::min(filtered.size(), m_maxDisplayedMessages));
|
||||
for (const CRawFsdMessage &rawFsdMessage : filtered)
|
||||
{
|
||||
ui->pte_RawFsdMessages->appendPlainText(rawFsdMessageToString(rawFsdMessage));
|
||||
}
|
||||
}
|
||||
|
||||
void CRawFsdMessagesComponent::selectFileDir()
|
||||
@@ -74,38 +183,39 @@ namespace BlackGui
|
||||
|
||||
void CRawFsdMessagesComponent::changeFileWritingMode()
|
||||
{
|
||||
CRawFsdMessageSettings::FileWriteMode mode = ui->cb_FileWritingMode->currentData().value<CRawFsdMessageSettings::FileWriteMode>();
|
||||
const CRawFsdMessageSettings::FileWriteMode mode = ui->cb_FileWritingMode->currentData().value<CRawFsdMessageSettings::FileWriteMode>();
|
||||
m_setting.setProperty(Vatsim::CRawFsdMessageSettings::IndexFileWriteMode, CVariant::fromValue(mode));
|
||||
}
|
||||
|
||||
void CRawFsdMessagesComponent::setFileWritingModeFromSettings(CRawFsdMessageSettings::FileWriteMode mode)
|
||||
{
|
||||
ui->cb_FileWritingMode->setCurrentIndex(static_cast<int>(mode));
|
||||
}
|
||||
|
||||
void CRawFsdMessagesComponent::addFsdMessage(const CRawFsdMessage &rawFsdMessage)
|
||||
{
|
||||
ui->lw_RawFsdMessages->addItem(rawFsdMessage.toQString());
|
||||
ui->lw_RawFsdMessages->scrollToBottom();
|
||||
if (m_buffer.size() == m_maxDisplayedMessages) { m_buffer.pop_front(); }
|
||||
m_buffer.push_back(rawFsdMessage.getRawMessage());
|
||||
|
||||
while (ui->lw_RawFsdMessages->count() > 100)
|
||||
{
|
||||
QListWidgetItem *item = ui->lw_RawFsdMessages->takeItem(0);
|
||||
delete item;
|
||||
}
|
||||
if (! m_filterPacketType.isEmpty() && ! rawFsdMessage.isPacketType(m_filterPacketType)) { return; }
|
||||
if (! m_filterString.isEmpty() && ! rawFsdMessage.containsString(m_filterString)) { return; }
|
||||
ui->pte_RawFsdMessages->appendPlainText(rawFsdMessageToString(rawFsdMessage));
|
||||
}
|
||||
|
||||
void CRawFsdMessagesComponent::readSettings()
|
||||
{
|
||||
const Vatsim::CRawFsdMessageSettings setting = m_setting.get();
|
||||
ui->le_FileDir->setText(setting.getFileDir());
|
||||
const bool enable = setting.isFileWritingEnabled();
|
||||
ui->cb_EnableFileWriting->setChecked(enable);
|
||||
const bool enable = setting.areRawFsdMessagesEnabled();
|
||||
ui->cb_EnableRawFsdMessages->setChecked(enable);
|
||||
ui->cb_FilterPacketType->setEnabled(enable);
|
||||
ui->le_FilterText->setEnabled(enable);
|
||||
ui->le_MaxDisplayedMessages->setEnabled(enable);
|
||||
ui->le_FileDir->setEnabled(enable);
|
||||
ui->le_FileDir->setText(setting.getFileDir());
|
||||
ui->pb_SelectFileDir->setEnabled(enable);
|
||||
ui->cb_FileWritingMode->setEnabled(enable);
|
||||
const CRawFsdMessageSettings::FileWriteMode mode = setting.getFileWriteMode();
|
||||
ui->cb_FileWritingMode->setCurrentIndex(static_cast<int>(mode));
|
||||
}
|
||||
|
||||
QString CRawFsdMessagesComponent::rawFsdMessageToString(const BlackMisc::Network::CRawFsdMessage &rawFsdMessage)
|
||||
{
|
||||
return QString("%1 %2").arg(rawFsdMessage.getReceptionTime().toString("HH:mm:ss"), rawFsdMessage.getRawMessage());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -14,15 +14,11 @@
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackcore/vatsim/vatsimsettings.h"
|
||||
#include "blackmisc/network/rawfsdmessage.h"
|
||||
#include "blackmisc/network/rawfsdmessagelist.h"
|
||||
#include "blackmisc/connectionguard.h"
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
class QAction;
|
||||
class QPoint;
|
||||
class QWidget;
|
||||
|
||||
namespace Ui { class CRawFsdMessagesComponent; }
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -41,17 +37,33 @@ namespace BlackGui
|
||||
virtual ~CRawFsdMessagesComponent();
|
||||
|
||||
private:
|
||||
void changeWritingToFile(bool enable);
|
||||
void setupConnections();
|
||||
void enableRawFsdMessages(bool enable);
|
||||
void expandFilters(bool expand);
|
||||
void expandWritingToFile(bool expand);
|
||||
void changeStringFilter();
|
||||
void changePacketTypeFilter(const QString &type);
|
||||
void changeMaxDisplayedMessages();
|
||||
void filterDisplayedMessages();
|
||||
void selectFileDir();
|
||||
void changeFileWritingMode();
|
||||
void setFileWritingModeFromSettings(BlackCore::Vatsim::CRawFsdMessageSettings::FileWriteMode mode);
|
||||
void addFsdMessage(const BlackMisc::Network::CRawFsdMessage &rawFsdMessage);
|
||||
void readSettings();
|
||||
|
||||
static QString rawFsdMessageToString(const BlackMisc::Network::CRawFsdMessage &rawFsdMessage);
|
||||
|
||||
BlackMisc::CSetting<BlackCore::Vatsim::TRawFsdMessageSetting> m_setting { this };
|
||||
|
||||
QScopedPointer<Ui::CRawFsdMessagesComponent> ui;
|
||||
BlackMisc::CConnectionGuard m_signalConnections; //!< connected signal/slots
|
||||
|
||||
QString m_filterString;
|
||||
QString m_filterPacketType;
|
||||
|
||||
BlackMisc::Network::CRawFsdMessageList m_buffer;
|
||||
|
||||
int m_maxDisplayedMessages = 100;
|
||||
int m_maxBufferSize = 1000;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>427</width>
|
||||
<height>516</height>
|
||||
<width>458</width>
|
||||
<height>571</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -22,7 +22,7 @@
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="gridLayout" rowstretch="1,0,0,0">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -35,19 +35,113 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QListWidget" name="lw_RawFsdMessages">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
<item row="0" column="0" alignment="Qt::AlignRight">
|
||||
<widget class="QCheckBox" name="cb_EnableRawFsdMessages">
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPlainTextEdit" name="pte_RawFsdMessages">
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="maximumBlockCount">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="gb_Filter">
|
||||
<property name="title">
|
||||
<string>Filter</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_Filters">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lbl_FilterText">
|
||||
<property name="text">
|
||||
<string>Text:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QComboBox" name="cb_FilterPacketType">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Packet Type Filter</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_FilterText">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Text Filter</p></body></html></string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_FilterPacketType">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="le_MaxDisplayedMessages">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Maximum No. of lines displayed</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="lbl_MaxDisplayedMessages">
|
||||
<property name="text">
|
||||
<string>Max Displayed Messages:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="gb_WriteToFile">
|
||||
<property name="title">
|
||||
<string>Write to File</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_WriteToFile">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_FileDir">
|
||||
<property name="text">
|
||||
@@ -55,13 +149,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cb_FileWritingMode">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_FileWriteMode">
|
||||
<property name="text">
|
||||
@@ -69,13 +156,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="cb_EnableFileWriting">
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="le_FileDir">
|
||||
<property name="enabled">
|
||||
@@ -85,7 +165,7 @@
|
||||
<string/>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -102,6 +182,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="cb_FileWritingMode">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "blackmisc/network/entityflags.h"
|
||||
#include "blackmisc/network/fsdsetup.h"
|
||||
#include "blackmisc/network/rawfsdmessage.h"
|
||||
#include "blackmisc/network/rawfsdmessagelist.h"
|
||||
#include "blackmisc/network/role.h"
|
||||
#include "blackmisc/network/rolelist.h"
|
||||
#include "blackmisc/network/remotefile.h"
|
||||
|
||||
@@ -34,6 +34,24 @@ namespace BlackMisc
|
||||
return s.arg(m_receptionTime.toString("dd.MM.yy HH:mm:ss"), m_rawMessage);
|
||||
}
|
||||
|
||||
bool CRawFsdMessage::isPacketType(const QString &type) const
|
||||
{
|
||||
return m_rawMessage.startsWith("FSD Sent=>" + type) || m_rawMessage.startsWith("FSD Recv=>" + type);
|
||||
}
|
||||
|
||||
bool CRawFsdMessage::containsString(const QString &str) const
|
||||
{
|
||||
return m_rawMessage.contains(str);
|
||||
}
|
||||
|
||||
const QStringList &CRawFsdMessage::getAllPacketTypes()
|
||||
{
|
||||
static const QStringList allPacketTypes = { "@", "%", "#AA", "#DA", "#AP", "#DP", "#TM", "#WX", "#DL", "#TD", "#WD"
|
||||
"#CD", "#PC", "#SB", "$FP", "$AM", "$PI", "$PO", "$HO", "$HA", "$AX", "$AR",
|
||||
"$CQ", "$CR", "$ER", "$!!" };
|
||||
return allPacketTypes;
|
||||
}
|
||||
|
||||
CVariant CRawFsdMessage::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
|
||||
@@ -51,7 +51,16 @@ namespace BlackMisc
|
||||
void setRawMessage(const QString &rawMessage) { m_rawMessage = rawMessage; }
|
||||
|
||||
//! Get reception time
|
||||
QDateTime getReceptionTime() const;
|
||||
const QDateTime &getReceptionTime() const { return m_receptionTime; }
|
||||
|
||||
//! Returns true if the raw message is from the given PDU packet type
|
||||
bool isPacketType(const QString &type) const;
|
||||
|
||||
//! Does the raw message contain str?
|
||||
bool containsString(const QString &str) const;
|
||||
|
||||
//! Returns a list of all known packet types.
|
||||
static const QStringList &getAllPacketTypes ();
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
41
src/blackmisc/network/rawfsdmessagelist.cpp
Normal file
41
src/blackmisc/network/rawfsdmessagelist.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 2017
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "rawfsdmessagelist.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
CRawFsdMessageList::CRawFsdMessageList() { }
|
||||
|
||||
CRawFsdMessageList::CRawFsdMessageList(const CSequence &other) : CSequence<CRawFsdMessage>(other)
|
||||
{ }
|
||||
|
||||
CRawFsdMessageList::CRawFsdMessageList(std::initializer_list<CRawFsdMessage> il) :
|
||||
CSequence<CRawFsdMessage>(il)
|
||||
{ }
|
||||
|
||||
CRawFsdMessageList CRawFsdMessageList::findByPacketType(const QString &type) const
|
||||
{
|
||||
return this->findBy([ & ](const CRawFsdMessage &rawFsdMessage)
|
||||
{
|
||||
return rawFsdMessage.isPacketType(type);
|
||||
});
|
||||
}
|
||||
|
||||
CRawFsdMessageList CRawFsdMessageList::findByContainsString(const QString &str) const
|
||||
{
|
||||
return this->findBy([ & ](const CRawFsdMessage &rawFsdMessage)
|
||||
{
|
||||
return rawFsdMessage.containsString(str);
|
||||
});
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
57
src/blackmisc/network/rawfsdmessagelist.h
Normal file
57
src/blackmisc/network/rawfsdmessagelist.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* Copyright (C) 2017
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_NETWORK_RAWFSDMESSAGELIST_H
|
||||
#define BLACKMISC_NETWORK_RAWFSDMESSAGELIST_H
|
||||
|
||||
#include "rawfsdmessage.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include <QStringList>
|
||||
#include <QMetaType>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
//! Value object encapsulating a list raw FSD messages.
|
||||
class BLACKMISC_EXPORT CRawFsdMessageList :
|
||||
public CSequence<CRawFsdMessage>,
|
||||
public BlackMisc::Mixin::MetaType<CRawFsdMessageList>
|
||||
{
|
||||
public:
|
||||
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CRawFsdMessageList)
|
||||
|
||||
//! Default constructor.
|
||||
CRawFsdMessageList();
|
||||
|
||||
//! Construct from a base class object.
|
||||
CRawFsdMessageList(const CSequence &other);
|
||||
|
||||
//! Construct from initializer list.
|
||||
CRawFsdMessageList(std::initializer_list<CRawFsdMessage> il);
|
||||
|
||||
//! Find by a given list of raw messages which are type
|
||||
CRawFsdMessageList findByPacketType(const QString &type) const;
|
||||
|
||||
//! Find by a given list of models by strings
|
||||
CRawFsdMessageList findByContainsString(const QString &str) const;
|
||||
};
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Network::CRawFsdMessageList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Network::CRawFsdMessageList>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Network::CRawFsdMessageList>)
|
||||
|
||||
#endif //guard
|
||||
@@ -24,6 +24,7 @@ namespace BlackMisc
|
||||
CEntityFlags::registerMetadata();
|
||||
CFsdSetup::registerMetadata();
|
||||
CRawFsdMessage::registerMetadata();
|
||||
CRawFsdMessageList::registerMetadata();
|
||||
CRemoteFile::registerMetadata();
|
||||
CRemoteFileList::registerMetadata();
|
||||
CRole::registerMetadata();
|
||||
|
||||
Reference in New Issue
Block a user