mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 16:25:54 +08:00
Display number of included/DB models in "1st model set wizard"
This commit is contained in:
committed by
Mat Sutcliffe
parent
2de192600f
commit
7be54fde87
@@ -89,7 +89,19 @@ namespace BlackGui
|
|||||||
// avoid to fully init a loader logic here
|
// avoid to fully init a loader logic here
|
||||||
static const QString modelsNo("No models so far");
|
static const QString modelsNo("No models so far");
|
||||||
const int modelsCount = this->modelLoader()->getCachedModelsCount(simulator);
|
const int modelsCount = this->modelLoader()->getCachedModelsCount(simulator);
|
||||||
ui->le_ModelsInfo->setText(modelsCount > 0 ? this->modelLoader()->getCacheCountAndTimestamp(simulator) : modelsNo);
|
if (modelsCount > 0)
|
||||||
|
{
|
||||||
|
static const QString modelsInfo("%1 included %2 DB key %3");
|
||||||
|
const CAircraftModelList modelsInCache = this->modelLoader()->getCachedModels(simulator);
|
||||||
|
const int modelsIncluded = modelsInCache.countByMode(CAircraftModel::Include);
|
||||||
|
const int modelsDbKey = modelsInCache.countWithValidDbKey(true);
|
||||||
|
ui->le_ModelsInfo->setText(modelsInfo.arg(this->modelLoader()->getCacheCountAndTimestamp(simulator)).arg(modelsIncluded).arg(modelsDbKey));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->le_ModelsInfo->setText(modelsNo);
|
||||||
|
}
|
||||||
|
|
||||||
ui->pb_CreateModelSet->setEnabled(modelsCount > 0);
|
ui->pb_CreateModelSet->setEnabled(modelsCount > 0);
|
||||||
|
|
||||||
static const QString modelsSetNo("Model set is empty");
|
static const QString modelsSetNo("Model set is empty");
|
||||||
|
|||||||
@@ -224,16 +224,22 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class OBJ, class CONTAINER, typename KEYTYPE>
|
template<class OBJ, class CONTAINER, typename KEYTYPE>
|
||||||
int IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::countWithValidDbKey() const
|
int IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::countWithValidDbKey(bool withKey) const
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (const OBJ &obj : ITimestampObjectList<OBJ, CONTAINER>::container())
|
for (const OBJ &obj : ITimestampObjectList<OBJ, CONTAINER>::container())
|
||||||
{
|
{
|
||||||
if (obj.hasValidDbKey()) { count++; }
|
if (obj.hasValidDbKey() && withKey) { count++; }
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class OBJ, class CONTAINER, typename KEYTYPE>
|
||||||
|
int IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::countWithValidDbKey() const
|
||||||
|
{
|
||||||
|
return this->countWithValidDbKey(true);
|
||||||
|
}
|
||||||
|
|
||||||
template<class OBJ, class CONTAINER, typename KEYTYPE>
|
template<class OBJ, class CONTAINER, typename KEYTYPE>
|
||||||
bool IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::containsAnyObjectWithoutKey() const
|
bool IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::containsAnyObjectWithoutKey() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ namespace BlackMisc
|
|||||||
//! Latest DB timestamp (means objects with DB key)
|
//! Latest DB timestamp (means objects with DB key)
|
||||||
QDateTime oldestDbTimestamp() const;
|
QDateTime oldestDbTimestamp() const;
|
||||||
|
|
||||||
|
//! Number of objects with/without key
|
||||||
|
int countWithValidDbKey(bool withKey) const;
|
||||||
|
|
||||||
//! Number of entries with valid DB key
|
//! Number of entries with valid DB key
|
||||||
int countWithValidDbKey() const;
|
int countWithValidDbKey() const;
|
||||||
|
|
||||||
|
|||||||
@@ -777,6 +777,16 @@ namespace BlackMisc
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CAircraftModelList::countByMode(CAircraftModel::ModelMode mode) const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (const CAircraftModel &model : (*this))
|
||||||
|
{
|
||||||
|
if (model.matchesMode(mode)) { count++; }
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
int CAircraftModelList::countMilitaryAircraft() const
|
int CAircraftModelList::countMilitaryAircraft() const
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|||||||
@@ -308,6 +308,9 @@ namespace BlackMisc
|
|||||||
//! Count VTOL aircraft
|
//! Count VTOL aircraft
|
||||||
int countVtolAircraft() const;
|
int countVtolAircraft() const;
|
||||||
|
|
||||||
|
//! Count by mode
|
||||||
|
int countByMode(CAircraftModel::ModelMode mode) const;
|
||||||
|
|
||||||
//! Count military aircraft
|
//! Count military aircraft
|
||||||
int countMilitaryAircraft() const;
|
int countMilitaryAircraft() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user