refs #571, consolidate with own models or DB models when stashed (goal: better defaults)

* improved missing parts updates
* sync. with own and DB models
This commit is contained in:
Klaus Basan
2016-01-12 01:21:26 +01:00
parent 9f646f215c
commit 6625b83c5e
9 changed files with 130 additions and 35 deletions

View File

@@ -115,6 +115,16 @@ namespace BlackMisc
void CDistributor::updateMissingParts(const CDistributor &otherDistributor)
{
if (!this->hasValidDbKey() && otherDistributor.hasValidDbKey())
{
// we have no DB data, but the other one has
// so we change roles. We take the DB object as base, and update our parts
CDistributor copy(otherDistributor);
copy.updateMissingParts(*this);
*this = copy;
return;
}
if (!this->hasAlias1()) { this->setAlias1(otherDistributor.getAlias1()); }
if (!this->hasAlias2()) { this->setAlias1(otherDistributor.getAlias2()); }
if (!this->hasDescription()) { this->setDescription(otherDistributor.getDescription()); }
@@ -129,7 +139,8 @@ namespace BlackMisc
}
QString description(json.value(prefix + "description").toString());
if (description.isEmpty()) {
if (description.isEmpty())
{
// stub, only key, maybe also timestamps
CDistributor distributorStub;
distributorStub.setKeyAndTimestampFromDatabaseJson(json, prefix);