Ref T125, allow to get distribution list by JSON string. Also setup value object directly using JSON string now.

This commit is contained in:
Klaus Basan
2017-08-15 02:10:27 +02:00
committed by Mathew Sutcliffe
parent 15f5a7f489
commit 8c032fb4d7
3 changed files with 11 additions and 5 deletions

View File

@@ -13,7 +13,6 @@
#include "blackmisc/compare.h" #include "blackmisc/compare.h"
#include "blackmisc/fileutils.h" #include "blackmisc/fileutils.h"
#include "blackmisc/directoryutils.h" #include "blackmisc/directoryutils.h"
#include "blackmisc/json.h"
#include "blackmisc/logcategory.h" #include "blackmisc/logcategory.h"
#include "blackmisc/logcategorylist.h" #include "blackmisc/logcategorylist.h"
#include "blackmisc/logmessage.h" #include "blackmisc/logmessage.h"
@@ -331,7 +330,7 @@ namespace BlackCore
{ {
const CGlobalSetup currentSetup = m_setup.get(); const CGlobalSetup currentSetup = m_setup.get();
CGlobalSetup loadedSetup; CGlobalSetup loadedSetup;
loadedSetup.convertFromJson(Json::jsonObjectFromString(setupJson)); loadedSetup.convertFromJson(setupJson);
loadedSetup.markAsLoaded(true); loadedSetup.markAsLoaded(true);
if (lastModified > 0 && lastModified > loadedSetup.getMSecsSinceEpoch()) { loadedSetup.setMSecsSinceEpoch(lastModified); } if (lastModified > 0 && lastModified > loadedSetup.getMSecsSinceEpoch()) { loadedSetup.setMSecsSinceEpoch(lastModified); }
bool sameVersionLoaded = (loadedSetup == currentSetup); bool sameVersionLoaded = (loadedSetup == currentSetup);
@@ -422,9 +421,7 @@ namespace BlackCore
{ {
try try
{ {
const CDistributionList loadedDistributions = CDistributionList::fromDatabaseJson( const CDistributionList loadedDistributions = CDistributionList::fromDatabaseJson(distributionJson);
Json::jsonArrayFromString(distributionJson)
);
if (loadedDistributions.isEmpty()) if (loadedDistributions.isEmpty())
{ {
CLogMessage(this).error("Loading of distribution yielded no data"); CLogMessage(this).error("Loading of distribution yielded no data");

View File

@@ -70,5 +70,11 @@ namespace BlackMisc
} }
return distributions; return distributions;
} }
CDistributionList CDistributionList::fromDatabaseJson(const QString &json)
{
if (json.isEmpty()) { return CDistributionList(); }
return CDistributionList::fromDatabaseJson(Json::jsonArrayFromString(json));
}
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -59,6 +59,9 @@ namespace BlackMisc
//! From database JSON //! From database JSON
static CDistributionList fromDatabaseJson(const QJsonArray &array); static CDistributionList fromDatabaseJson(const QJsonArray &array);
//! From database JSON
static CDistributionList fromDatabaseJson(const QString &json);
}; };
//! Trait for global setup data //! Trait for global setup data