mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
This commit is contained in:
@@ -95,6 +95,21 @@ namespace BlackMisc
|
|||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class OBJ, class CONTAINER, typename KEYTYPE>
|
||||||
|
int IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::removeObjectsWithoutDbKey()
|
||||||
|
{
|
||||||
|
if (this->container().isEmpty()) { return 0; }
|
||||||
|
CONTAINER newValues;
|
||||||
|
for (const OBJ &obj : ITimestampObjectList<OBJ, CONTAINER>::container())
|
||||||
|
{
|
||||||
|
if (!obj.hasValidDbKey()) { continue; }
|
||||||
|
newValues.push_back(obj);
|
||||||
|
}
|
||||||
|
int delta = this->container().size() - newValues.size();
|
||||||
|
this->container() = newValues;
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
template <class OBJ, class CONTAINER, typename KEYTYPE>
|
template <class OBJ, class CONTAINER, typename KEYTYPE>
|
||||||
int IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::replaceOrAddObjectsByKey(const CONTAINER &container)
|
int IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::replaceOrAddObjectsByKey(const CONTAINER &container)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ namespace BlackMisc
|
|||||||
//! Remove objects with key
|
//! Remove objects with key
|
||||||
int removeObjectsWithKeys(const QList<KEYTYPE> &keys);
|
int removeObjectsWithKeys(const QList<KEYTYPE> &keys);
|
||||||
|
|
||||||
|
//! Remove objects without key
|
||||||
|
int removeObjectsWithoutDbKey();
|
||||||
|
|
||||||
//! Update or insert data (based on DB key)
|
//! Update or insert data (based on DB key)
|
||||||
int replaceOrAddObjectsByKey(const CONTAINER &container);
|
int replaceOrAddObjectsByKey(const CONTAINER &container);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "aircraftmodel.h"
|
#include "aircraftmodel.h"
|
||||||
#include "distributor.h"
|
#include "distributorlist.h"
|
||||||
#include "blackmisc/datastoreutility.h"
|
#include "blackmisc/datastoreutility.h"
|
||||||
#include "blackmisc/comparefunctions.h"
|
#include "blackmisc/comparefunctions.h"
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -276,6 +276,25 @@ namespace BlackMisc
|
|||||||
return this->m_livery.hasValidAirlineDesignator();
|
return this->m_livery.hasValidAirlineDesignator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAircraftModel::hasDistributor() const
|
||||||
|
{
|
||||||
|
return this->m_distributor.hasValidDbKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CAircraftModel::matchesDistributor(const CDistributor &distributor) const
|
||||||
|
{
|
||||||
|
if (!distributor.hasValidDbKey()) { return false; }
|
||||||
|
if (!this->hasDistributor()) { return false; }
|
||||||
|
return this->m_distributor.getDbKey() == distributor.getDbKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CAircraftModel::matchesAnyDistributor(const CDistributorList &distributors) const
|
||||||
|
{
|
||||||
|
if (distributors.isEmpty()) { return false; }
|
||||||
|
if (!this->hasDistributor()) { return false; }
|
||||||
|
return distributors.matchesAnyKeyOrAlias(this->m_distributor.getDbKey());
|
||||||
|
}
|
||||||
|
|
||||||
const CIcon &CAircraftModel::getModelModeAsIcon() const
|
const CIcon &CAircraftModel::getModelModeAsIcon() const
|
||||||
{
|
{
|
||||||
switch (this->getModelMode())
|
switch (this->getModelMode())
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "blackmisc/blackmiscexport.h"
|
#include "blackmisc/blackmiscexport.h"
|
||||||
#include "blackmisc/simulation/simulatorinfo.h"
|
#include "blackmisc/simulation/simulatorinfo.h"
|
||||||
#include "blackmisc/simulation/distributor.h"
|
#include "blackmisc/simulation/distributorlist.h"
|
||||||
#include "blackmisc/aviation/livery.h"
|
#include "blackmisc/aviation/livery.h"
|
||||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||||
#include "blackmisc/network/user.h"
|
#include "blackmisc/network/user.h"
|
||||||
@@ -174,6 +174,15 @@ namespace BlackMisc
|
|||||||
//! Set distributor
|
//! Set distributor
|
||||||
void setDistributor(const CDistributor &distributor) { m_distributor = distributor; }
|
void setDistributor(const CDistributor &distributor) { m_distributor = distributor; }
|
||||||
|
|
||||||
|
//! Distributor
|
||||||
|
bool hasDistributor() const;
|
||||||
|
|
||||||
|
//! By distributor
|
||||||
|
bool matchesDistributor(const CDistributor &distributor) const;
|
||||||
|
|
||||||
|
//! By distributor
|
||||||
|
bool matchesAnyDistributor(const CDistributorList &distributors) const;
|
||||||
|
|
||||||
//! Name
|
//! Name
|
||||||
const QString &getName() const { return this->m_name; }
|
const QString &getName() const { return this->m_name; }
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "blackmisc/blackmiscexport.h"
|
#include "blackmisc/blackmiscexport.h"
|
||||||
#include "blackmisc/simulation/aircraftmodel.h"
|
#include "blackmisc/simulation/aircraftmodel.h"
|
||||||
|
#include "blackmisc/simulation/distributorlist.h"
|
||||||
#include "blackmisc/datastoreobjectlist.h"
|
#include "blackmisc/datastoreobjectlist.h"
|
||||||
#include "blackmisc/collection.h"
|
#include "blackmisc/collection.h"
|
||||||
#include "blackmisc/sequence.h"
|
#include "blackmisc/sequence.h"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace BlackMisc
|
|||||||
CSequence<CDistributor>(other)
|
CSequence<CDistributor>(other)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
CDistributor CDistributorList::findByKeyOrAlias(const QString &keyOrAlias)
|
CDistributor CDistributorList::findByKeyOrAlias(const QString &keyOrAlias) const
|
||||||
{
|
{
|
||||||
if (keyOrAlias.isEmpty()) { return CDistributor(); }
|
if (keyOrAlias.isEmpty()) { return CDistributor(); }
|
||||||
for (const CDistributor &distributor : (*this))
|
for (const CDistributor &distributor : (*this))
|
||||||
@@ -44,6 +44,15 @@ namespace BlackMisc
|
|||||||
return CDistributor();
|
return CDistributor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CDistributorList::matchesAnyKeyOrAlias(const QString &keyOrAlias) const
|
||||||
|
{
|
||||||
|
for (const CDistributor &distributor : (*this))
|
||||||
|
{
|
||||||
|
if (distributor.matchesKeyOrAlias(keyOrAlias)) { return true; }
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList CDistributorList::getDbKeysAndAliases() const
|
QStringList CDistributorList::getDbKeysAndAliases() const
|
||||||
{
|
{
|
||||||
if (this->isEmpty()) { return QStringList(); }
|
if (this->isEmpty()) { return QStringList(); }
|
||||||
|
|||||||
@@ -41,11 +41,14 @@ namespace BlackMisc
|
|||||||
CDistributorList(const CSequence<CDistributor> &other);
|
CDistributorList(const CSequence<CDistributor> &other);
|
||||||
|
|
||||||
//! Find by id or alias
|
//! Find by id or alias
|
||||||
CDistributor findByKeyOrAlias(const QString &keyOrAlias);
|
CDistributor findByKeyOrAlias(const QString &keyOrAlias) const;
|
||||||
|
|
||||||
//! Best match by given pattern
|
//! Best match by given pattern
|
||||||
CDistributor smartDistributorSelector(const CDistributor &distributorPattern);
|
CDistributor smartDistributorSelector(const CDistributor &distributorPattern);
|
||||||
|
|
||||||
|
//! At least is matching key or alias
|
||||||
|
bool matchesAnyKeyOrAlias(const QString &keyOrAlias) const;
|
||||||
|
|
||||||
//! All DB keys and aliases
|
//! All DB keys and aliases
|
||||||
QStringList getDbKeysAndAliases() const;
|
QStringList getDbKeysAndAliases() const;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user