mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-19 20:25:29 +08:00
Add CRawFsdMessage
Maniphest Tasks: T222
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include "blackmisc/network/ecosystemlist.h"
|
#include "blackmisc/network/ecosystemlist.h"
|
||||||
#include "blackmisc/network/entityflags.h"
|
#include "blackmisc/network/entityflags.h"
|
||||||
#include "blackmisc/network/fsdsetup.h"
|
#include "blackmisc/network/fsdsetup.h"
|
||||||
|
#include "blackmisc/network/rawfsdmessage.h"
|
||||||
#include "blackmisc/network/role.h"
|
#include "blackmisc/network/role.h"
|
||||||
#include "blackmisc/network/rolelist.h"
|
#include "blackmisc/network/rolelist.h"
|
||||||
#include "blackmisc/network/remotefile.h"
|
#include "blackmisc/network/remotefile.h"
|
||||||
|
|||||||
67
src/blackmisc/network/rawfsdmessage.cpp
Normal file
67
src/blackmisc/network/rawfsdmessage.cpp
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/* Copyright (C) 2016
|
||||||
|
* 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 "blackmisc/network/rawfsdmessage.h"
|
||||||
|
#include "blackmisc/logcategory.h"
|
||||||
|
#include "blackmisc/logcategorylist.h"
|
||||||
|
#include "blackmisc/propertyindex.h"
|
||||||
|
#include "blackmisc/statusmessage.h"
|
||||||
|
#include "blackmisc/stringutils.h"
|
||||||
|
#include "blackmisc/variant.h"
|
||||||
|
|
||||||
|
#include <Qt>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Network
|
||||||
|
{
|
||||||
|
CRawFsdMessage::CRawFsdMessage(const QString &rawMessage)
|
||||||
|
: m_rawMessage(rawMessage) {}
|
||||||
|
|
||||||
|
QString CRawFsdMessage::convertToQString(bool i18n) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(i18n);
|
||||||
|
static const QString s("%1 %2");
|
||||||
|
return s.arg(m_receptionTime.toString("dd.MM.yy HH:mm:ss"), m_rawMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
CVariant CRawFsdMessage::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||||
|
{
|
||||||
|
if (index.isMyself()) { return CVariant::from(*this); }
|
||||||
|
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case IndexReceptionTime:
|
||||||
|
return CVariant::fromValue(this->m_rawMessage);
|
||||||
|
case IndexRawMessage:
|
||||||
|
return CVariant::fromValue(this->m_receptionTime);
|
||||||
|
default:
|
||||||
|
return CValueObject::propertyByIndex(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRawFsdMessage::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||||
|
{
|
||||||
|
if (index.isMyself()) { (*this) = variant.to<CRawFsdMessage>(); return; }
|
||||||
|
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case IndexRawMessage:
|
||||||
|
this->setRawMessage(variant.value<QString>());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
CValueObject::setPropertyByIndex(index, variant);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
80
src/blackmisc/network/rawfsdmessage.h
Normal file
80
src/blackmisc/network/rawfsdmessage.h
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/* Copyright (C) 2018
|
||||||
|
* 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_RAWFSDMESSAGE_H
|
||||||
|
#define BLACKMISC_NETWORK_RAWFSDMESSAGE_H
|
||||||
|
|
||||||
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
#include "blackmisc/metaclass.h"
|
||||||
|
#include "blackmisc/statusmessagelist.h"
|
||||||
|
#include "blackmisc/propertyindex.h"
|
||||||
|
#include "blackmisc/valueobject.h"
|
||||||
|
#include "blackmisc/variant.h"
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Network
|
||||||
|
{
|
||||||
|
//! Value object for a raw FSD message
|
||||||
|
class BLACKMISC_EXPORT CRawFsdMessage : public CValueObject<CRawFsdMessage>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Properties by index
|
||||||
|
enum ColumnIndex
|
||||||
|
{
|
||||||
|
IndexReceptionTime = BlackMisc::CPropertyIndex::GlobalIndexCRawFsdMessage,
|
||||||
|
IndexRawMessage
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Default constructor.
|
||||||
|
CRawFsdMessage() {}
|
||||||
|
|
||||||
|
//! Constructor.
|
||||||
|
CRawFsdMessage(const QString &rawMessage);
|
||||||
|
|
||||||
|
//! Get raw message
|
||||||
|
const QString &getRawMessage() const { return m_rawMessage; }
|
||||||
|
|
||||||
|
//! Set raw message
|
||||||
|
void setRawMessage(const QString &rawMessage) { m_rawMessage = rawMessage; }
|
||||||
|
|
||||||
|
//! Get reception time
|
||||||
|
QDateTime getReceptionTime() const;
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||||
|
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||||
|
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Mixin::String::toQString()
|
||||||
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_rawMessage;
|
||||||
|
QDateTime m_receptionTime = QDateTime::currentDateTime();
|
||||||
|
|
||||||
|
BLACK_METACLASS(
|
||||||
|
CRawFsdMessage,
|
||||||
|
BLACK_METAMEMBER(rawMessage),
|
||||||
|
BLACK_METAMEMBER(receptionTime)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Network::CRawFsdMessage)
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
@@ -23,6 +23,7 @@ namespace BlackMisc
|
|||||||
CEcosystemList::registerMetadata();
|
CEcosystemList::registerMetadata();
|
||||||
CEntityFlags::registerMetadata();
|
CEntityFlags::registerMetadata();
|
||||||
CFsdSetup::registerMetadata();
|
CFsdSetup::registerMetadata();
|
||||||
|
CRawFsdMessage::registerMetadata();
|
||||||
CRemoteFile::registerMetadata();
|
CRemoteFile::registerMetadata();
|
||||||
CRemoteFileList::registerMetadata();
|
CRemoteFileList::registerMetadata();
|
||||||
CRole::registerMetadata();
|
CRole::registerMetadata();
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ namespace BlackMisc
|
|||||||
GlobalIndexCUrlLog = 6800,
|
GlobalIndexCUrlLog = 6800,
|
||||||
GlobalIndexCRemoteFile = 6900,
|
GlobalIndexCRemoteFile = 6900,
|
||||||
GlobalIndexCEcosystem = 7000,
|
GlobalIndexCEcosystem = 7000,
|
||||||
|
GlobalIndexCRawFsdMessage = 7100,
|
||||||
GlobalIndexCAircraftModel = 8000,
|
GlobalIndexCAircraftModel = 8000,
|
||||||
GlobalIndexCSimulatedAircraft = 8100,
|
GlobalIndexCSimulatedAircraft = 8100,
|
||||||
GlobalIndexCTextMessage = 8200,
|
GlobalIndexCTextMessage = 8200,
|
||||||
|
|||||||
Reference in New Issue
Block a user