mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #452, DB flags describing what entities to read
This commit is contained in:
committed by
Mathew Sutcliffe
parent
0a74c3421d
commit
5718abe03c
@@ -8,7 +8,8 @@
|
||||
*/
|
||||
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "network/network.h"
|
||||
#include "blackmisc/network/network.h"
|
||||
#include "blackmisc/network/dbflags.h"
|
||||
|
||||
/*
|
||||
* Metadata for Network
|
||||
@@ -27,4 +28,12 @@ void BlackMisc::Network::registerMetadata()
|
||||
CClient::registerMetadata();
|
||||
CClientList::registerMetadata();
|
||||
CVoiceCapabilities::registerMetadata();
|
||||
|
||||
int id = qRegisterMetaType<CDbFlags::Entity>();
|
||||
Q_ASSERT_X(id >= 1024, Q_FUNC_INFO, "wrong id for metatype");
|
||||
id = qRegisterMetaType<CDbFlags::EntityFlags>();
|
||||
Q_ASSERT_X(id >= 1024, Q_FUNC_INFO, "wrong id for metatype");
|
||||
id = qRegisterMetaType<CDbFlags::ReadState>();
|
||||
Q_ASSERT_X(id >= 1024, Q_FUNC_INFO, "wrong id for metatype");
|
||||
Q_UNUSED(id);
|
||||
}
|
||||
|
||||
67
src/blackmisc/network/dbflags.cpp
Normal file
67
src/blackmisc/network/dbflags.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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/dbflags.h"
|
||||
#include <QStringList>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
QString CDbFlags::flagToString(CDbFlags::EntityFlags flag)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
case NoEntity: return "no data";
|
||||
case VatsimBookings: return "VATSIM bookings";
|
||||
case VatsimDataFile: return "VATSIM data file";
|
||||
case AircraftIcaoEntity: return "Aircraft ICAO";
|
||||
case AirlineIcaoEntity: return "Airline ICAO";
|
||||
case CountryEntity: return "Country";
|
||||
case DistributorEntity: return "Distributor";
|
||||
case LiveryEntity: return "Livery";
|
||||
case ModelEntity: return "Model";
|
||||
case AllIcaoEntities: return "All ICAO";
|
||||
case AllIcaoAndCountries: return "All ICAO + country";
|
||||
case AllEntities: return "All";
|
||||
default:
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "wrong flags");
|
||||
return "wrong flags";
|
||||
}
|
||||
}
|
||||
|
||||
QString CDbFlags::flagToString(Entity flag)
|
||||
{
|
||||
QStringList list;
|
||||
if (flag.testFlag(NoEntity)) list << "no data";
|
||||
if (flag.testFlag(VatsimBookings)) 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";
|
||||
if (flag.testFlag(CountryEntity)) list << "Country";
|
||||
if (flag.testFlag(DistributorEntity)) list << "Distributor";
|
||||
if (flag.testFlag(LiveryEntity)) list << "Livery";
|
||||
if (flag.testFlag(ModelEntity)) list << "Model";
|
||||
return list.join(',');
|
||||
}
|
||||
|
||||
QString CDbFlags::flagToString(CDbFlags::ReadState flag)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
case ReadFinished: return "finished";
|
||||
case ReadFailed: return "failed";
|
||||
case StartRead: return "read started";
|
||||
default:
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "wrong flags");
|
||||
return "wrong flags";
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
72
src/blackmisc/network/dbflags.h
Normal file
72
src/blackmisc/network/dbflags.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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_ENTITREADERFLAGS_H
|
||||
#define BLACKMISC_NETWORK_ENTITREADERFLAGS_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include <QObject>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
/*!
|
||||
* What and state of reading from DB
|
||||
*/
|
||||
class BLACKMISC_EXPORT CDbFlags
|
||||
{
|
||||
public:
|
||||
//! Which data to read, requires corresponding readers
|
||||
enum EntityFlags
|
||||
{
|
||||
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
|
||||
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)
|
||||
|
||||
//! State of operation
|
||||
enum ReadState
|
||||
{
|
||||
StartRead, ///< reading has been started
|
||||
ReadFinished, ///< reading done
|
||||
ReadFailed ///< reading failed
|
||||
};
|
||||
|
||||
//! Convert to string
|
||||
static QString flagToString(EntityFlags flag);
|
||||
|
||||
//! Convert to string
|
||||
static QString flagToString(BlackMisc::Network::CDbFlags::Entity flag);
|
||||
|
||||
//! Convert to string
|
||||
static QString flagToString(ReadState flag);
|
||||
};
|
||||
} // 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)
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user