Pulsars.cpp   Pulsars.cpp 
skipping to change at line 76 skipping to change at line 76
{ {
Q_INIT_RESOURCE(Pulsars); Q_INIT_RESOURCE(Pulsars);
StelPluginInfo info; StelPluginInfo info;
info.id = "Pulsars"; info.id = "Pulsars";
info.displayedName = N_("Pulsars"); info.displayedName = N_("Pulsars");
info.authors = "Alexander Wolf"; info.authors = "Alexander Wolf";
info.contact = "alex.v.wolf@gmail.com"; info.contact = "alex.v.wolf@gmail.com";
info.description = N_("This plugin plots the position of various pul sars, with object information about each one."); info.description = N_("This plugin plots the position of various pul sars, with object information about each one.");
info.version = PULSARS_PLUGIN_VERSION; info.version = PULSARS_PLUGIN_VERSION;
info.version = PULSARS_PLUGIN_LICENSE;
return info; return info;
} }
/* /*
Constructor Constructor
*/ */
Pulsars::Pulsars() Pulsars::Pulsars()
: PsrCount(0) : PsrCount(0)
, updateState(CompleteNoUpdates) , updateState(CompleteNoUpdates)
, downloadMgr(Q_NULLPTR) , downloadMgr(Q_NULLPTR)
skipping to change at line 645 skipping to change at line 646
downloadMgr->get(request); downloadMgr->get(request);
updateState = Pulsars::CompleteUpdates; updateState = Pulsars::CompleteUpdates;
emit(updateStateChanged(updateState)); emit(updateStateChanged(updateState));
emit(jsonUpdateComplete()); emit(jsonUpdateComplete());
} }
void Pulsars::updateDownloadComplete(QNetworkReply* reply) void Pulsars::updateDownloadComplete(QNetworkReply* reply)
{ {
// check the download worked, and save the data to file if this is t he case. // check the download worked, and save the data to file if this is t he case.
if (reply->error() != QNetworkReply::NoError) if (reply->error() == QNetworkReply::NoError && reply->bytesAvailabl
{ e()>0)
qWarning() << "[Pulsars] FAILED to download" << reply->url()
<< " Error: " << reply->errorString();
}
else
{ {
// download completed successfully. // download completed successfully.
QString jsonFilePath = StelFileMgr::findFile("modules/Pulsar s", StelFileMgr::Flags(StelFileMgr::Writable|StelFileMgr::Directory)) + "/p ulsars.json"; QString jsonFilePath = StelFileMgr::findFile("modules/Pulsar s", StelFileMgr::Flags(StelFileMgr::Writable|StelFileMgr::Directory)) + "/p ulsars.json";
if (jsonFilePath.isEmpty()) if (jsonFilePath.isEmpty())
{ {
qWarning() << "[Pulsars] Cannot write JSON data to f ile:" << QDir::toNativeSeparators(jsonCatalogPath); qWarning() << "[Pulsars] Cannot write JSON data to f ile:" << QDir::toNativeSeparators(jsonCatalogPath);
return; return;
} }
QFile jsonFile(jsonFilePath); QFile jsonFile(jsonFilePath);
if (jsonFile.exists()) if (jsonFile.exists())
jsonFile.remove(); jsonFile.remove();
if(jsonFile.open(QIODevice::WriteOnly | QIODevice::Text)) if(jsonFile.open(QIODevice::WriteOnly | QIODevice::Text))
{ {
jsonFile.write(reply->readAll()); jsonFile.write(reply->readAll());
jsonFile.close(); jsonFile.close();
} }
} }
else
qWarning() << "[Pulsars] FAILED to download" << reply->url()
<< " Error: " << reply->errorString();
if (progressBar) if (progressBar)
{ {
progressBar->setValue(100); progressBar->setValue(100);
StelApp::getInstance().removeProgressBar(progressBar); StelApp::getInstance().removeProgressBar(progressBar);
progressBar=Q_NULLPTR; progressBar=Q_NULLPTR;
} }
} }
void Pulsars::displayMessage(const QString& message, const QString hexColor ) void Pulsars::displayMessage(const QString& message, const QString hexColor )
 End of changes. 3 change blocks. 
6 lines changed or deleted 6 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/