Quasars.cpp   Quasars.cpp 
skipping to change at line 185 skipping to change at line 185
// A timer for hiding alert messages // A timer for hiding alert messages
messageTimer = new QTimer(this); messageTimer = new QTimer(this);
messageTimer->setSingleShot(true); // recurring check for update messageTimer->setSingleShot(true); // recurring check for update
messageTimer->setInterval(9000); // 6 seconds should be enough time messageTimer->setInterval(9000); // 6 seconds should be enough time
messageTimer->stop(); messageTimer->stop();
connect(messageTimer, SIGNAL(timeout()), this, SLOT(messageTimeout() )); connect(messageTimer, SIGNAL(timeout()), this, SLOT(messageTimeout() ));
// If the json file does not already exist, create it from the resou rce in the Qt resource // If the json file does not already exist, create it from the resou rce in the Qt resource
if(QFileInfo(catalogJsonPath).exists()) if(QFileInfo(catalogJsonPath).exists())
{ {
if (getJsonFileFormatVersion() < CATALOG_FORMAT_VERSION) if (!checkJsonFileFormat() || getJsonFileFormatVersion()<CAT ALOG_FORMAT_VERSION)
{ {
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
} }
else else
{ {
qDebug() << "Quasars::init quasars.json does not exist - cop ying default file to " << QDir::toNativeSeparators(catalogJsonPath); qDebug() << "Quasars::init quasars.json does not exist - cop ying default file to " << QDir::toNativeSeparators(catalogJsonPath);
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
skipping to change at line 557 skipping to change at line 557
if (map.contains("version")) if (map.contains("version"))
{ {
jsonVersion = map.value("version").toInt(); jsonVersion = map.value("version").toInt();
} }
catalogJsonFile.close(); catalogJsonFile.close();
qDebug() << "Quasars::getJsonFileFormatVersion() version of format f rom file:" << jsonVersion; qDebug() << "Quasars::getJsonFileFormatVersion() version of format f rom file:" << jsonVersion;
return jsonVersion; return jsonVersion;
} }
bool Quasars::checkJsonFileFormat()
{
QFile catalogJsonFile(catalogJsonPath);
if (!catalogJsonFile.open(QIODevice::ReadOnly))
{
qWarning() << "Quasars::checkJsonFileFormat(): cannot open "
<< QDir::toNativeSeparators(catalogJsonPath);
return false;
}
QVariantMap map;
try
{
map = StelJsonParser::parse(&catalogJsonFile).toMap();
catalogJsonFile.close();
}
catch (std::runtime_error& e)
{
qDebug() << "Quasars::checkJsonFileFormat(): file format is
wrong!";
qDebug() << "Quasars::checkJsonFileFormat() error:" << e.wha
t();
return false;
}
return true;
}
QuasarP Quasars::getByID(const QString& id) QuasarP Quasars::getByID(const QString& id)
{ {
foreach(const QuasarP& quasar, QSO) foreach(const QuasarP& quasar, QSO)
{ {
if (quasar->initialized && quasar->designation == id) if (quasar->initialized && quasar->designation == id)
return quasar; return quasar;
} }
return QuasarP(); return QuasarP();
} }
 End of changes. 2 change blocks. 
1 lines changed or deleted 29 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/