mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
refs #469, renamed flags
* db to entity flags as it also features entities not from DB * Flag enums singular (discussed with MS / slack)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
24432a56c7
commit
2cfd3540b8
@@ -7,19 +7,21 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackmisc/network/dbflags.h"
|
||||
#include "blackmisc/network/entityflags.h"
|
||||
#include "blackmisc/dbus.h"
|
||||
#include <QtDBus/QDBusMetaType>
|
||||
#include <QStringList>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
QString CDbFlags::flagToString(CDbFlags::EntityFlags flag)
|
||||
QString CEntityFlags::flagToString(CEntityFlags::EntityFlag flag)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
case NoEntity: return "no data";
|
||||
case VatsimBookings: return "VATSIM bookings";
|
||||
case BookingEntity: return "VATSIM bookings";
|
||||
case VatsimDataFile: return "VATSIM data file";
|
||||
case AircraftIcaoEntity: return "Aircraft ICAO";
|
||||
case AirlineIcaoEntity: return "Airline ICAO";
|
||||
@@ -36,11 +38,11 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
QString CDbFlags::flagToString(Entity flag)
|
||||
QString CEntityFlags::flagToString(Entity flag)
|
||||
{
|
||||
QStringList list;
|
||||
if (flag.testFlag(NoEntity)) list << "no data";
|
||||
if (flag.testFlag(VatsimBookings)) list << "VATSIM bookings";
|
||||
if (flag.testFlag(BookingEntity)) list << "VATSIM bookings";
|
||||
if (flag.testFlag(VatsimDataFile)) list << "VATSIM data file";
|
||||
if (flag.testFlag(AircraftIcaoEntity)) list << "Aircraft ICAO";
|
||||
if (flag.testFlag(AirlineIcaoEntity)) list << "Airline ICAO";
|
||||
@@ -51,7 +53,7 @@ namespace BlackMisc
|
||||
return list.join(',');
|
||||
}
|
||||
|
||||
QString CDbFlags::flagToString(CDbFlags::ReadState flag)
|
||||
QString CEntityFlags::flagToString(CEntityFlags::ReadState flag)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
@@ -63,5 +65,25 @@ namespace BlackMisc
|
||||
return "wrong flags";
|
||||
}
|
||||
}
|
||||
|
||||
void CEntityFlags::registerMetadata()
|
||||
{
|
||||
// this is no value class and I register enums here,
|
||||
// that's why I do not use the Mixins
|
||||
int id = qRegisterMetaType<CEntityFlags::Entity>();
|
||||
// int idb = qDBusRegisterMetaType<CEntityFlags::Entity>();
|
||||
// Q_ASSERT_X(id >= 1024 && id == idb, Q_FUNC_INFO, "wrong id for metatype");
|
||||
Q_ASSERT_X(id >= 1024, Q_FUNC_INFO, "wrong id for metatype");
|
||||
|
||||
id = qRegisterMetaType<CEntityFlags::EntityFlag>();
|
||||
// idb = qDBusRegisterMetaType<CEntityFlags::EntityFlag>();
|
||||
Q_ASSERT_X(id >= 1024, Q_FUNC_INFO, "wrong id for metatype");
|
||||
|
||||
id = qRegisterMetaType<CEntityFlags::ReadState>();
|
||||
// idb = qDBusRegisterMetaType<CEntityFlags::ReadState>();
|
||||
Q_ASSERT_X(id >= 1024, Q_FUNC_INFO, "wrong id for metatype");
|
||||
Q_UNUSED(id);
|
||||
// Q_UNUSED(idb);
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_NETWORK_ENTITREADERFLAGS_H
|
||||
#define BLACKMISC_NETWORK_ENTITREADERFLAGS_H
|
||||
#ifndef BLACKMISC_NETWORK_ENTITRFLAGS_H
|
||||
#define BLACKMISC_NETWORK_ENTITRFLAGS_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include <QObject>
|
||||
@@ -20,29 +20,30 @@ namespace BlackMisc
|
||||
namespace Network
|
||||
{
|
||||
/*!
|
||||
* What and state of reading from DB
|
||||
* What and state of reading from web services
|
||||
*/
|
||||
class BLACKMISC_EXPORT CDbFlags
|
||||
class BLACKMISC_EXPORT CEntityFlags
|
||||
{
|
||||
public:
|
||||
//! Which data to read, requires corresponding readers
|
||||
enum EntityFlags
|
||||
enum EntityFlag
|
||||
{
|
||||
NoEntity = 0, ///< no data at all
|
||||
VatsimBookings = 1 << 0, ///< bookings
|
||||
VatsimDataFile = 1 << 1, ///< the VATSIM data file
|
||||
AircraftIcaoEntity = 1 << 2, ///< ICAO codes for aircraft
|
||||
AirlineIcaoEntity = 1 << 3, ///< ICAO codes for airlines
|
||||
CountryEntity = 1 << 4, ///< Country codes
|
||||
DistributorEntity = 1 << 5, ///< distributors
|
||||
LiveryEntity = 1 << 6, ///< liveries
|
||||
ModelEntity = 1 << 7, ///< models
|
||||
VatsimDataFile = 1 << 0, ///< the VATSIM data file (multiple data entities)
|
||||
BookingEntity = 1 << 1, ///< bookings
|
||||
MetarEntity = 1 << 2,
|
||||
AircraftIcaoEntity = 1 << 3, ///< ICAO codes for aircraft
|
||||
AirlineIcaoEntity = 1 << 4, ///< ICAO codes for airlines
|
||||
CountryEntity = 1 << 5, ///< country codes
|
||||
DistributorEntity = 1 << 6, ///< distributors
|
||||
LiveryEntity = 1 << 7, ///< liveries
|
||||
ModelEntity = 1 << 8, ///< models
|
||||
AllIcaoEntities = AircraftIcaoEntity | AirlineIcaoEntity, ///< all ICAO codes
|
||||
AllIcaoAndCountries = AircraftIcaoEntity | AirlineIcaoEntity | CountryEntity, ///< all ICAO codes and countries
|
||||
DistributorLiveryModel = DistributorEntity | LiveryEntity | ModelEntity, ///< Combinded
|
||||
AllEntities = 0xFFFF ///< everything
|
||||
};
|
||||
Q_DECLARE_FLAGS(Entity, EntityFlags)
|
||||
Q_DECLARE_FLAGS(Entity, EntityFlag)
|
||||
|
||||
//! State of operation
|
||||
enum ReadState
|
||||
@@ -53,20 +54,23 @@ namespace BlackMisc
|
||||
};
|
||||
|
||||
//! Convert to string
|
||||
static QString flagToString(EntityFlags flag);
|
||||
static QString flagToString(EntityFlag flag);
|
||||
|
||||
//! Convert to string
|
||||
static QString flagToString(BlackMisc::Network::CDbFlags::Entity flag);
|
||||
static QString flagToString(BlackMisc::Network::CEntityFlags::Entity flag);
|
||||
|
||||
//! Convert to string
|
||||
static QString flagToString(ReadState flag);
|
||||
|
||||
//! Register metadata
|
||||
static void registerMetadata();
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Network::CDbFlags::EntityFlags)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Network::CDbFlags::Entity)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Network::CDbFlags::ReadState)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(BlackMisc::Network::CDbFlags::Entity)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Network::CEntityFlags::EntityFlag)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Network::CEntityFlags::Entity)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Network::CEntityFlags::ReadState)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(BlackMisc::Network::CEntityFlags::Entity)
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user