MCPcopy Create free account
hub / github.com/awawa-dev/HyperHDR / getBackup

Method getBackup

sources/db/DBManager.cpp:489–569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

487}
488
489const QJsonObject DBManager::getBackup()
490{
491 QJsonObject backup;
492 SqlDatabase* idb = getDB();
493 QStringList instanceKeys({ "enabled", "friendly_name", "instance" });
494 QStringList settingsKeys({ "config", "hyperhdr_instance", "type" });
495
496 bool rm = _readonlyMode;
497
498 _readonlyMode = true;
499
500 SqlQuery queryInst(idb);
501
502 queryInst.prepare(QString("SELECT * FROM instances"));
503 if (!queryInst.exec())
504 {
505 Error(_log, "Failed to get records from instances table");
506 _readonlyMode = rm;
507 return backup;
508 }
509
510 SqlQuery querySet(idb);
511
512 querySet.prepare(QString("SELECT * FROM settings"));
513 if (!querySet.exec())
514 {
515 Error(_log, "Failed to get records from settings table");
516 _readonlyMode = rm;
517 return backup;
518 }
519
520 // iterate through all found records
521 QJsonArray allInstances;
522 while (queryInst.next())
523 {
524 QJsonObject entry;
525 SqlRecord rec = queryInst.record();
526 for (unsigned int i = 0; i < rec.count(); i++)
527 if (instanceKeys.contains(rec.fieldName(i), Qt::CaseInsensitive) && !rec.value(i).isNull())
528 {
529 entry[rec.fieldName(i)] = QJsonValue::fromVariant(rec.value(i));
530 }
531 allInstances.append(entry);
532 }
533
534
535 QJsonArray allSettings;
536 while (querySet.next())
537 {
538 QJsonObject entry;
539 SqlRecord rec = querySet.record();
540 bool valid = false;
541
542 for (unsigned int i = 0; i < rec.count(); i++)
543 if (settingsKeys.contains(rec.fieldName(i), Qt::CaseInsensitive) && !rec.value(i).isNull())
544 {
545 QVariant column = rec.value(i);
546

Callers

nothing calls this directly

Calls 10

typeEnum · 0.85
typeToStringFunction · 0.85
execMethod · 0.80
recordMethod · 0.80
countMethod · 0.80
fieldNameMethod · 0.80
prepareMethod · 0.45
nextMethod · 0.45
valueMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected