mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
refs #768, return DB keys as set
This commit is contained in:
@@ -128,9 +128,9 @@ namespace BlackCore
|
||||
return this->getModels().size();
|
||||
}
|
||||
|
||||
QList<int> CModelDataReader::getModelDbKeys() const
|
||||
QSet<int> CModelDataReader::getModelDbKeys() const
|
||||
{
|
||||
return this->getModels().toDbKeyList();
|
||||
return this->getModels().toDbKeySet();
|
||||
}
|
||||
|
||||
QStringList CModelDataReader::getModelStringList() const
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace BlackCore
|
||||
|
||||
//! Get model keys
|
||||
//! \threadsafe
|
||||
QList<int> getModelDbKeys() const;
|
||||
QSet<int> getModelDbKeys() const;
|
||||
|
||||
//! Get model keys
|
||||
//! \threadsafe
|
||||
|
||||
@@ -407,10 +407,10 @@ namespace BlackCore
|
||||
return 0;
|
||||
}
|
||||
|
||||
QList<int> CWebDataServices::getModelDbKeys() const
|
||||
QSet<int> CWebDataServices::getModelDbKeys() const
|
||||
{
|
||||
if (m_modelDataReader) { return m_modelDataReader->getModelDbKeys(); }
|
||||
return QList<int>();
|
||||
return QSet<int>();
|
||||
}
|
||||
|
||||
QStringList CWebDataServices::getModelStrings() const
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
@@ -205,7 +206,7 @@ namespace BlackCore
|
||||
|
||||
//! Model keys
|
||||
//! \threadsafe
|
||||
QList<int> getModelDbKeys() const;
|
||||
QSet<int> getModelDbKeys() const;
|
||||
|
||||
//! Model strings
|
||||
//! \threadsafe
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace BlackGui
|
||||
ui->tvp_StashAircraftModels->updateContainerMaybeAsync(models);
|
||||
}
|
||||
|
||||
int CDbStashComponent::unstashModels(QList<int> keys)
|
||||
int CDbStashComponent::unstashModels(QSet<int> keys)
|
||||
{
|
||||
if (keys.isEmpty()) { return 0; }
|
||||
return ui->tvp_StashAircraftModels->removeDbKeys(keys);
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace BlackGui
|
||||
BlackMisc::CStatusMessage validateStashModel(const BlackMisc::Simulation::CAircraftModel &model, bool allowReplace) const;
|
||||
|
||||
//! Unstash given models with keys
|
||||
int unstashModels(QList<int> keys);
|
||||
int unstashModels(QSet<int> keys);
|
||||
|
||||
//! Unstash given models by model string
|
||||
int unstashModels(QStringList modelStrings);
|
||||
|
||||
@@ -67,13 +67,13 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER, typename KEYTYPE>
|
||||
QList<KEYTYPE> IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::toDbKeyList() const
|
||||
QSet<KEYTYPE> IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::toDbKeySet() const
|
||||
{
|
||||
QList<KEYTYPE> keys;
|
||||
QSet<KEYTYPE> keys;
|
||||
for (const OBJ &obj : ITimestampObjectList<OBJ, CONTAINER>::container())
|
||||
{
|
||||
if (!obj.hasValidDbKey()) { continue; }
|
||||
keys.append(obj.getDbKey());
|
||||
keys.insert(obj.getDbKey());
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace BlackMisc
|
||||
template <class OBJ, class CONTAINER, typename KEYTYPE>
|
||||
KEYTYPE IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::getMaxKey(bool *ok) const
|
||||
{
|
||||
QList<KEYTYPE> keys(this->toDbKeyList());
|
||||
QSet<KEYTYPE> keys(this->toDbKeySet());
|
||||
if (keys.isEmpty())
|
||||
{
|
||||
if (ok) { *ok = false; }
|
||||
@@ -93,7 +93,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER, typename KEYTYPE>
|
||||
int IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::removeObjectsWithKeys(const QList<KEYTYPE> &keys)
|
||||
int IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::removeObjectsWithKeys(const QSet<KEYTYPE> &keys)
|
||||
{
|
||||
if (keys.isEmpty()) { return 0; }
|
||||
if (this->container().isEmpty()) { return 0; }
|
||||
@@ -133,7 +133,7 @@ namespace BlackMisc
|
||||
return this->container().size();
|
||||
}
|
||||
CONTAINER newValues(this->container());
|
||||
const QList<KEYTYPE> keys(container.toDbKeyList());
|
||||
const QSet<KEYTYPE> keys(container.toDbKeySet());
|
||||
newValues.removeObjectsWithKeys(keys);
|
||||
int removeSize = newValues.size(); // size after removing data
|
||||
newValues.push_back(container);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "blackmisc/timestampobjectlist.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -37,13 +37,13 @@ namespace BlackMisc
|
||||
void sortByKey();
|
||||
|
||||
//! All keys as list
|
||||
QList<KEYTYPE> toDbKeyList() const;
|
||||
QSet<KEYTYPE> toDbKeySet() const;
|
||||
|
||||
//! Max.key value (making sense with integer key)
|
||||
KEYTYPE getMaxKey(bool *ok = nullptr) const;
|
||||
|
||||
//! Remove objects with key
|
||||
int removeObjectsWithKeys(const QList<KEYTYPE> &keys);
|
||||
int removeObjectsWithKeys(const QSet<KEYTYPE> &keys);
|
||||
|
||||
//! Remove objects without key
|
||||
int removeObjectsWithoutDbKey();
|
||||
|
||||
Reference in New Issue
Block a user