mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 15:45:42 +08:00
refs #267, classes for model matching
* extended model class, refactored model class * new mapping classes: value class / list
This commit is contained in:
@@ -98,6 +98,8 @@ void BlackMisc::Network::registerMetadata()
|
|||||||
CClientList::registerMetadata();
|
CClientList::registerMetadata();
|
||||||
CAircraftModel::registerMetadata();
|
CAircraftModel::registerMetadata();
|
||||||
CVoiceCapabilities::registerMetadata();
|
CVoiceCapabilities::registerMetadata();
|
||||||
|
CAircraftMapping::registerMetadata();
|
||||||
|
CAircraftMappingList::registerMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -14,5 +14,7 @@
|
|||||||
#include "blackmisc/nwclientlist.h"
|
#include "blackmisc/nwclientlist.h"
|
||||||
#include "blackmisc/nwaircraftmodel.h"
|
#include "blackmisc/nwaircraftmodel.h"
|
||||||
#include "blackmisc/nwvoicecapabilities.h"
|
#include "blackmisc/nwvoicecapabilities.h"
|
||||||
|
#include "blackmisc/nwaircraftmapping.h"
|
||||||
|
#include "blackmisc/nwaircraftmappinglist.h"
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
176
src/blackmisc/nwaircraftmapping.cpp
Normal file
176
src/blackmisc/nwaircraftmapping.cpp
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
#include "nwaircraftmapping.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
|
using namespace BlackMisc::Network;
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Network
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
CAircraftMapping::CAircraftMapping(const QString &aircraftDesignator, const QString &airlineDesignator, const QString &model) :
|
||||||
|
m_icao(CAircraftIcao(aircraftDesignator, airlineDesignator)), m_model(CAircraftModel(model, false))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert to string
|
||||||
|
*/
|
||||||
|
QString CAircraftMapping::convertToQString(bool i18n) const
|
||||||
|
{
|
||||||
|
QString s = QString(this->m_model.toQString(i18n)).append(' ').append(this->m_icao.toQString(i18n));
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compare
|
||||||
|
*/
|
||||||
|
int CAircraftMapping::compareImpl(const CValueObject &otherBase) const
|
||||||
|
{
|
||||||
|
const auto &other = static_cast<const CAircraftMapping &>(otherBase);
|
||||||
|
return compare(TupleConverter<CAircraftMapping>::toTuple(*this), TupleConverter<CAircraftMapping>::toTuple(other));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Marshall to DBus
|
||||||
|
*/
|
||||||
|
void CAircraftMapping::marshallToDbus(QDBusArgument &argument) const
|
||||||
|
{
|
||||||
|
argument << TupleConverter<CAircraftMapping>::toTuple(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unmarshall from DBus
|
||||||
|
*/
|
||||||
|
void CAircraftMapping::unmarshallFromDbus(const QDBusArgument &argument)
|
||||||
|
{
|
||||||
|
argument >> TupleConverter<CAircraftMapping>::toTuple(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hash
|
||||||
|
*/
|
||||||
|
uint CAircraftMapping::getValueHash() const
|
||||||
|
{
|
||||||
|
return qHash(TupleConverter<CAircraftMapping>::toTuple(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Model string?
|
||||||
|
*/
|
||||||
|
bool CAircraftMapping::matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const
|
||||||
|
{
|
||||||
|
return this->m_model.matchesModelString(modelString, sensitivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Equal?
|
||||||
|
*/
|
||||||
|
bool CAircraftMapping::operator ==(const CAircraftMapping &other) const
|
||||||
|
{
|
||||||
|
if (this == &other) return true;
|
||||||
|
return TupleConverter<CAircraftMapping>::toTuple(*this) == TupleConverter<CAircraftMapping>::toTuple(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unequal?
|
||||||
|
*/
|
||||||
|
bool CAircraftMapping::operator !=(const CAircraftMapping &other) const
|
||||||
|
{
|
||||||
|
return !((*this) == other);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* metaTypeId
|
||||||
|
*/
|
||||||
|
int CAircraftMapping::getMetaTypeId() const
|
||||||
|
{
|
||||||
|
return qMetaTypeId<CAircraftMapping>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* is a
|
||||||
|
*/
|
||||||
|
bool CAircraftMapping::isA(int metaTypeId) const
|
||||||
|
{
|
||||||
|
if (metaTypeId == qMetaTypeId<CAircraftMapping>()) { return true; }
|
||||||
|
return this->CValueObject::isA(metaTypeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Register metadata
|
||||||
|
*/
|
||||||
|
void CAircraftMapping::registerMetadata()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<CAircraftMapping>();
|
||||||
|
qDBusRegisterMetaType<CAircraftMapping>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Members
|
||||||
|
*/
|
||||||
|
const QStringList &CAircraftMapping::jsonMembers()
|
||||||
|
{
|
||||||
|
return TupleConverter<CAircraftMapping>::jsonMembers();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To JSON
|
||||||
|
*/
|
||||||
|
QJsonObject CAircraftMapping::toJson() const
|
||||||
|
{
|
||||||
|
return BlackMisc::serializeJson(CAircraftMapping::jsonMembers(), TupleConverter<CAircraftMapping>::toTuple(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* From Json
|
||||||
|
*/
|
||||||
|
void CAircraftMapping::fromJson(const QJsonObject &json)
|
||||||
|
{
|
||||||
|
BlackMisc::deserializeJson(json, CAircraftMapping::jsonMembers(), TupleConverter<CAircraftMapping>::toTuple(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Property by index
|
||||||
|
*/
|
||||||
|
QVariant CAircraftMapping::propertyByIndex(int index) const
|
||||||
|
{
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case IndexModel:
|
||||||
|
return this->m_model.toQVariant();
|
||||||
|
break;
|
||||||
|
case IndexIcaoCode:
|
||||||
|
return this->m_icao.toQVariant();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Q_ASSERT_X(false, "CAircraftMapping", "index unknown");
|
||||||
|
QString m = QString("no property, index ").append(QString::number(index));
|
||||||
|
return QVariant::fromValue(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set property as index
|
||||||
|
*/
|
||||||
|
void CAircraftMapping::setPropertyByIndex(const QVariant &variant, int index)
|
||||||
|
{
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case IndexModel:
|
||||||
|
this->m_model = variant.value<BlackMisc::Network::CAircraftModel>();
|
||||||
|
break;
|
||||||
|
case IndexIcaoCode:
|
||||||
|
this->m_icao = variant.value<BlackMisc::Aviation::CAircraftIcao>();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_ASSERT_X(false, "CAircraftMapping", "index unknown");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
114
src/blackmisc/nwaircraftmapping.h
Normal file
114
src/blackmisc/nwaircraftmapping.h
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef BLACKMISC_NETWORK_AIRCRAFTMAPPING_H
|
||||||
|
#define BLACKMISC_NETWORK_AIRCRAFTMAPPING_H
|
||||||
|
|
||||||
|
#include "blackmisc/avaircrafticao.h"
|
||||||
|
#include "blackmisc/nwaircraftmodel.h"
|
||||||
|
#include "blackmisc/valueobject.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Network
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* Mapping
|
||||||
|
*/
|
||||||
|
class CAircraftMapping: public BlackMisc::CValueObject
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
BLACK_ENABLE_TUPLE_CONVERSION(CAircraftMapping)
|
||||||
|
BlackMisc::Aviation::CAircraftIcao m_icao; //!< ICAO code
|
||||||
|
BlackMisc::Network::CAircraftModel m_model; //!< aircraft model
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! \copydoc CValueObject::convertToQString
|
||||||
|
virtual QString convertToQString(bool i18n = false) const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::marshallToDbus
|
||||||
|
virtual void marshallToDbus(QDBusArgument &) const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::unmarshallFromDbus
|
||||||
|
virtual void unmarshallFromDbus(const QDBusArgument &) override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::compareImpl
|
||||||
|
int compareImpl(const CValueObject &otherBase) const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::getMetaTypeId()
|
||||||
|
int getMetaTypeId() const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::isA
|
||||||
|
virtual bool isA(int metaTypeId) const override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Properties
|
||||||
|
enum IndexProperties
|
||||||
|
{
|
||||||
|
IndexModel,
|
||||||
|
IndexIcaoCode
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Default constructor
|
||||||
|
CAircraftMapping() {}
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
CAircraftMapping(const QString &aircraftDesignator, const QString &airlineDesignator, const QString &model);
|
||||||
|
|
||||||
|
//! Virtual destructor
|
||||||
|
virtual ~CAircraftMapping() {}
|
||||||
|
|
||||||
|
//! operator ==
|
||||||
|
bool operator ==(const CAircraftMapping &other) const;
|
||||||
|
|
||||||
|
//! operator !=
|
||||||
|
bool operator !=(const CAircraftMapping &other) const;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::propertyByIndex
|
||||||
|
QVariant propertyByIndex(int index) const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::setPropertyByIndex
|
||||||
|
void setPropertyByIndex(const QVariant &variant, int index) override;
|
||||||
|
|
||||||
|
//! ICAO
|
||||||
|
void setIcao(const BlackMisc::Aviation::CAircraftIcao &icao) { this->m_icao = icao; }
|
||||||
|
|
||||||
|
//! ICAO
|
||||||
|
const BlackMisc::Aviation::CAircraftIcao &getIcao() const { return this->m_icao; }
|
||||||
|
|
||||||
|
//! Model
|
||||||
|
void setModel(const BlackMisc::Network::CAircraftModel &model) { this->m_model = model; }
|
||||||
|
|
||||||
|
//! Model
|
||||||
|
const BlackMisc::Network::CAircraftModel &getModel() const { return this->m_model; }
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::getValueHash()
|
||||||
|
virtual uint getValueHash() const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::toQVariant()
|
||||||
|
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||||
|
|
||||||
|
//! Matches model string?
|
||||||
|
bool matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const;
|
||||||
|
|
||||||
|
//! Register the metatypes
|
||||||
|
static void registerMetadata();
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::toJson
|
||||||
|
virtual QJsonObject toJson() const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::fromJson
|
||||||
|
virtual void fromJson(const QJsonObject &json) override;
|
||||||
|
|
||||||
|
//! Members
|
||||||
|
static const QStringList &jsonMembers();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Network::CAircraftMapping, (o.m_icao, o.m_model))
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Network::CAircraftMapping)
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
64
src/blackmisc/nwaircraftmappinglist.cpp
Normal file
64
src/blackmisc/nwaircraftmappinglist.cpp
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / authors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "nwaircraftmappinglist.h"
|
||||||
|
#include "predicates.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc::Network;
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Network
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Empty constructor
|
||||||
|
*/
|
||||||
|
CAircraftMappingList::CAircraftMappingList() { }
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Construct from base class object
|
||||||
|
*/
|
||||||
|
CAircraftMappingList::CAircraftMappingList(const CSequence<CAircraftMapping> &other) :
|
||||||
|
CSequence<CAircraftMapping>(other)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
CAircraftMappingList CAircraftMappingList::findByIcaoCode(const CAircraftIcao &searchIcao, bool emptyMeansWildcard) const
|
||||||
|
{
|
||||||
|
if (!emptyMeansWildcard) return this->findBy(&CAircraftMapping::getIcao, searchIcao);
|
||||||
|
|
||||||
|
CAircraftMappingList result;
|
||||||
|
for (auto it = this->begin() ; it != this->end(); ++it)
|
||||||
|
{
|
||||||
|
if (it->getIcao().matchesWildcardIcao(searchIcao)) result.push_back(*it);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAircraftMappingList CAircraftMappingList::findByModelString(const QString modelString, Qt::CaseSensitivity sensitivity) const
|
||||||
|
{
|
||||||
|
CAircraftMappingList result;
|
||||||
|
for (auto it = this->begin() ; it != this->end(); ++it)
|
||||||
|
{
|
||||||
|
if (it->matchesModelString(modelString, sensitivity)) result.push_back(*it);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Register metadata
|
||||||
|
*/
|
||||||
|
void CAircraftMappingList::registerMetadata()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<BlackMisc::CSequence<CAircraftMapping>>();
|
||||||
|
qDBusRegisterMetaType<BlackMisc::CSequence<CAircraftMapping>>();
|
||||||
|
qRegisterMetaType<BlackMisc::CCollection<CAircraftMapping>>();
|
||||||
|
qDBusRegisterMetaType<BlackMisc::CCollection<CAircraftMapping>>();
|
||||||
|
qRegisterMetaType<CAircraftMappingList>();
|
||||||
|
qDBusRegisterMetaType<CAircraftMappingList>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
57
src/blackmisc/nwaircraftmappinglist.h
Normal file
57
src/blackmisc/nwaircraftmappinglist.h
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / authors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BLACKMISC_AIRCRAFTMAPPINGLIST_H
|
||||||
|
#define BLACKMISC_AIRCRAFTMAPPINGLIST_H
|
||||||
|
|
||||||
|
#include "nwaircraftmapping.h"
|
||||||
|
#include "collection.h"
|
||||||
|
#include "sequence.h"
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Network
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* Value object encapsulating a list of aircraft mappings
|
||||||
|
*/
|
||||||
|
class CAircraftMappingList : public CSequence<CAircraftMapping>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Empty constructor.
|
||||||
|
CAircraftMappingList();
|
||||||
|
|
||||||
|
//! Construct from a base class object.
|
||||||
|
CAircraftMappingList(const CSequence<CAircraftMapping> &other);
|
||||||
|
|
||||||
|
//! QVariant, required for DBus QVariant lists
|
||||||
|
virtual QVariant toQVariant() const { return QVariant::fromValue(*this); }
|
||||||
|
|
||||||
|
//! Find by frequency
|
||||||
|
CAircraftMappingList findByIcaoCode(const BlackMisc::Aviation::CAircraftIcao &searchIcao, bool emptyMeansWildcard = true) const;
|
||||||
|
|
||||||
|
//! Find by model string
|
||||||
|
CAircraftMappingList findByModelString(const QString modelString, Qt::CaseSensitivity sensitivity) const;
|
||||||
|
|
||||||
|
//! Register metadata
|
||||||
|
static void registerMetadata();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Network::CAircraftMappingList)
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Network::CAircraftMapping>)
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Network::CAircraftMapping>)
|
||||||
|
|
||||||
|
#endif //guard
|
||||||
@@ -10,7 +10,9 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
QString CAircraftModel::convertToQString(bool /** i18n **/) const
|
QString CAircraftModel::convertToQString(bool /** i18n **/) const
|
||||||
{
|
{
|
||||||
QString s = this->m_queriedModelString;
|
QString s = this->m_modelString;
|
||||||
|
if (!s.isEmpty()) s.append(' ');
|
||||||
|
s.append(this->m_queriedModelStringFlag ? "queried" : "mapped");
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,8 +123,11 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
|
case IndexModelString:
|
||||||
|
return QVariant(this->m_modelString);
|
||||||
|
break;
|
||||||
case IndexQueriedModelString:
|
case IndexQueriedModelString:
|
||||||
return QVariant(this->m_queriedModelString);
|
return QVariant(this->m_queriedModelStringFlag);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -139,8 +144,11 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
|
case IndexModelString:
|
||||||
|
this->m_modelString = variant.toString();
|
||||||
|
break;
|
||||||
case IndexQueriedModelString:
|
case IndexQueriedModelString:
|
||||||
this->m_queriedModelString = variant.toString();
|
this->m_queriedModelStringFlag = variant.toBool();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Q_ASSERT_X(false, "CAircraftModel", "index unknown");
|
Q_ASSERT_X(false, "CAircraftModel", "index unknown");
|
||||||
@@ -148,5 +156,16 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Matches string?
|
||||||
|
*/
|
||||||
|
bool CAircraftModel::matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const
|
||||||
|
{
|
||||||
|
if (sensitivity == Qt::CaseSensitive)
|
||||||
|
return modelString == this->m_modelString;
|
||||||
|
else
|
||||||
|
return this->m_modelString.indexOf(modelString) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -19,14 +19,15 @@ namespace BlackMisc
|
|||||||
//! Indexes
|
//! Indexes
|
||||||
enum ColumnIndex : uint
|
enum ColumnIndex : uint
|
||||||
{
|
{
|
||||||
IndexQueriedModelString = 100
|
IndexModelString = 100,
|
||||||
|
IndexQueriedModelString
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \brief Default constructor.
|
//! \brief Default constructor.
|
||||||
CAircraftModel() {}
|
CAircraftModel() {}
|
||||||
|
|
||||||
//! \brief Constructor.
|
//! \brief Constructor.
|
||||||
CAircraftModel(const QString &directModel) : m_queriedModelString(directModel) {}
|
CAircraftModel(const QString &model, bool queriedString) : m_modelString(model), m_queriedModelStringFlag(queriedString) {}
|
||||||
|
|
||||||
//! \copydoc CValueObject::toQVariant
|
//! \copydoc CValueObject::toQVariant
|
||||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||||
@@ -53,13 +54,16 @@ namespace BlackMisc
|
|||||||
virtual void setPropertyByIndex(const QVariant &variant, int index) override;
|
virtual void setPropertyByIndex(const QVariant &variant, int index) override;
|
||||||
|
|
||||||
//! Queried model string
|
//! Queried model string
|
||||||
const QString &getQueriedModelString() const { return this->m_queriedModelString; }
|
const QString &getModelString() const { return this->m_modelString; }
|
||||||
|
|
||||||
//! Set queried model string
|
//! Set queried model string
|
||||||
void setQueriedModelString(const QString &model) { this->m_queriedModelString = model; }
|
void setQueriedModelString(const QString &model) { this->m_modelString = model; }
|
||||||
|
|
||||||
//! Queried model string?
|
//! Queried model string?
|
||||||
bool hasQueriedModelString() const { return !this->m_queriedModelString.isEmpty(); }
|
bool hasQueriedModelString() const { return this->m_queriedModelStringFlag && !this->m_modelString.isEmpty(); }
|
||||||
|
|
||||||
|
//! Matches model string?
|
||||||
|
bool matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const;
|
||||||
|
|
||||||
//! \brief Register metadata
|
//! \brief Register metadata
|
||||||
static void registerMetadata();
|
static void registerMetadata();
|
||||||
@@ -88,12 +92,13 @@ namespace BlackMisc
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BLACK_ENABLE_TUPLE_CONVERSION(CAircraftModel)
|
BLACK_ENABLE_TUPLE_CONVERSION(CAircraftModel)
|
||||||
QString m_queriedModelString;
|
QString m_modelString;
|
||||||
|
bool m_queriedModelStringFlag; //!< model string is queried from network
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Network::CAircraftModel, (o.m_queriedModelString))
|
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Network::CAircraftModel, (o.m_modelString, o.m_queriedModelStringFlag))
|
||||||
Q_DECLARE_METATYPE(BlackMisc::Network::CAircraftModel)
|
Q_DECLARE_METATYPE(BlackMisc::Network::CAircraftModel)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
Reference in New Issue
Block a user