Ref T310, added model statistics dialog

* UI for statistics
* renamed to "coverageSummaryForModel"
* model list "htmlStatistics"
This commit is contained in:
Klaus Basan
2018-08-26 19:36:17 +02:00
parent 35b70db67d
commit 54802e9ea9
11 changed files with 278 additions and 28 deletions

View File

@@ -47,6 +47,30 @@ namespace BlackMisc
return this->container().findFirstByOrDefault(&OBJ::getDbKey, key, notFound);
}
template<class OBJ, class CONTAINER, typename KEYTYPE>
CONTAINER IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::findObjectsWithDbKey() const
{
CONTAINER objects;
for (const OBJ &obj : ITimestampObjectList<OBJ, CONTAINER>::container())
{
if (!obj.hasValidDbKey()) { continue; }
objects.push_back(obj);
}
return objects;
}
template<class OBJ, class CONTAINER, typename KEYTYPE>
CONTAINER IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::findObjectsWithoutDbKey() const
{
CONTAINER objects;
for (const OBJ &obj : ITimestampObjectList<OBJ, CONTAINER>::container())
{
if (obj.hasValidDbKey()) { continue; }
objects.push_back(obj);
}
return objects;
}
template <class OBJ, class CONTAINER, typename KEYTYPE>
OBJ IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::maxKeyObject() const
{
@@ -139,8 +163,8 @@ namespace BlackMisc
if (keys.contains(obj.getDbKey())) { continue; }
newValues.push_back(obj);
}
int delta = this->container().size() - newValues.size();
this->container() = newValues;
const int delta = this->container().size() - newValues.size();
if (delta > 0) { this->container() = newValues; }
return delta;
}
@@ -197,6 +221,16 @@ namespace BlackMisc
return count;
}
template<class OBJ, class CONTAINER, typename KEYTYPE>
bool IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::containsAnyObjectWithoutKey() const
{
for (const OBJ &obj : ITimestampObjectList<OBJ, CONTAINER>::container())
{
if (!obj.hasValidDbKey()) { return true; }
}
return false;
}
template<class OBJ, class CONTAINER, typename KEYTYPE>
CONTAINER IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::fromMultipleJsonFormats(const QJsonObject &jsonObject)
{

View File

@@ -30,6 +30,12 @@ namespace BlackMisc
//! Object with key, notFound otherwise
OBJ findByKey(KEYTYPE key, const OBJ &notFound = OBJ()) const;
//! Objects with DB key
CONTAINER findObjectsWithDbKey() const;
//! Objects without DB key
CONTAINER findObjectsWithoutDbKey() const;
//! Object with max.key
OBJ maxKeyObject() const;
@@ -66,6 +72,9 @@ namespace BlackMisc
//! Number of entries with valid DB key
int countWithValidDbKey() const;
//! Any object without key?
bool containsAnyObjectWithoutKey() const;
//! From multiple JSON formats
//! \remark supports native swift C++ format, DB format, and cache format
static CONTAINER fromMultipleJsonFormats(const QJsonObject &jsonObject);