mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25: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
@@ -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