Supernovae.cpp   Supernovae.cpp 
skipping to change at line 85 skipping to change at line 85
info.version = SUPERNOVAE_PLUGIN_VERSION; info.version = SUPERNOVAE_PLUGIN_VERSION;
return info; return info;
} }
/* /*
Constructor Constructor
*/ */
Supernovae::Supernovae() Supernovae::Supernovae()
: SNCount(0) : SNCount(0)
, updateState(CompleteNoUpdates) , updateState(CompleteNoUpdates)
, downloadMgr(NULL) , downloadMgr(Q_NULLPTR)
, progressBar(NULL) , progressBar(Q_NULLPTR)
, updateTimer(0) , updateTimer(Q_NULLPTR)
, messageTimer(0) , messageTimer(Q_NULLPTR)
, updatesEnabled(false) , updatesEnabled(false)
, updateFrequencyDays(0) , updateFrequencyDays(0)
{ {
setObjectName("Supernovae"); setObjectName("Supernovae");
configDialog = new SupernovaeDialog(); configDialog = new SupernovaeDialog();
conf = StelApp::getInstance().getSettings(); conf = StelApp::getInstance().getSettings();
font.setPixelSize(StelApp::getInstance().getBaseFontSize()); font.setPixelSize(StelApp::getInstance().getBaseFontSize());
} }
/* /*
skipping to change at line 267 skipping to change at line 267
} }
StelObjectP Supernovae::searchByName(const QString& englishName) const StelObjectP Supernovae::searchByName(const QString& englishName) const
{ {
foreach(const SupernovaP& sn, snstar) foreach(const SupernovaP& sn, snstar)
{ {
if (sn->getEnglishName().toUpper() == englishName.toUpper()) if (sn->getEnglishName().toUpper() == englishName.toUpper())
return qSharedPointerCast<StelObject>(sn); return qSharedPointerCast<StelObject>(sn);
} }
return NULL; return Q_NULLPTR;
} }
StelObjectP Supernovae::searchByNameI18n(const QString& nameI18n) const StelObjectP Supernovae::searchByNameI18n(const QString& nameI18n) const
{ {
foreach(const SupernovaP& sn, snstar) foreach(const SupernovaP& sn, snstar)
{ {
if (sn->getNameI18n().toUpper() == nameI18n.toUpper()) if (sn->getNameI18n().toUpper() == nameI18n.toUpper())
return qSharedPointerCast<StelObject>(sn); return qSharedPointerCast<StelObject>(sn);
} }
return NULL; return Q_NULLPTR;
} }
QStringList Supernovae::listAllObjects(bool inEnglish) const QStringList Supernovae::listAllObjects(bool inEnglish) const
{ {
QStringList result; QStringList result;
if (inEnglish) if (inEnglish)
{ {
foreach (const SupernovaP& sn, snstar) foreach (const SupernovaP& sn, snstar)
{ {
result << sn->getEnglishName(); result << sn->getEnglishName();
skipping to change at line 418 skipping to change at line 418
snlist.insert(sneData.value("designation").toString(), sneDa ta.value("peakJD").toDouble()); snlist.insert(sneData.value("designation").toString(), sneDa ta.value("peakJD").toDouble());
SNCount++; SNCount++;
SupernovaP sn(new Supernova(sneData)); SupernovaP sn(new Supernova(sneData));
if (sn->initialized) if (sn->initialized)
snstar.append(sn); snstar.append(sn);
} }
} }
int Supernovae::getJsonFileVersion(void) int Supernovae::getJsonFileVersion(void) const
{ {
int jsonVersion = -1; int jsonVersion = -1;
QFile sneJsonFile(sneJsonPath); QFile sneJsonFile(sneJsonPath);
if (!sneJsonFile.open(QIODevice::ReadOnly)) if (!sneJsonFile.open(QIODevice::ReadOnly))
{ {
qWarning() << "[Supernovae] cannot open" << QDir::toNativeSe parators(sneJsonPath); qWarning() << "[Supernovae] cannot open" << QDir::toNativeSe parators(sneJsonPath);
return jsonVersion; return jsonVersion;
} }
QVariantMap map; QVariantMap map;
skipping to change at line 440 skipping to change at line 440
if (map.contains("version")) if (map.contains("version"))
{ {
jsonVersion = map.value("version").toInt(); jsonVersion = map.value("version").toInt();
} }
sneJsonFile.close(); sneJsonFile.close();
qDebug() << "[Supernovae] version of the catalog:" << jsonVersion; qDebug() << "[Supernovae] version of the catalog:" << jsonVersion;
return jsonVersion; return jsonVersion;
} }
bool Supernovae::checkJsonFileFormat() bool Supernovae::checkJsonFileFormat() const
{ {
QFile sneJsonFile(sneJsonPath); QFile sneJsonFile(sneJsonPath);
if (!sneJsonFile.open(QIODevice::ReadOnly)) if (!sneJsonFile.open(QIODevice::ReadOnly))
{ {
qWarning() << "[Supernovae] cannot open " << QDir::toNativeS eparators(sneJsonPath); qWarning() << "[Supernovae] cannot open " << QDir::toNativeS eparators(sneJsonPath);
return false; return false;
} }
QVariantMap map; QVariantMap map;
try try
skipping to change at line 464 skipping to change at line 464
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qDebug() << "[Supernovae] file format is wrong! Error:" << e .what(); qDebug() << "[Supernovae] file format is wrong! Error:" << e .what();
return false; return false;
} }
return true; return true;
} }
float Supernovae::getLowerLimitBrightness() float Supernovae::getLowerLimitBrightness() const
{ {
float lowerLimit = 10.f; float lowerLimit = 10.f;
QFile sneJsonFile(sneJsonPath); QFile sneJsonFile(sneJsonPath);
if (!sneJsonFile.open(QIODevice::ReadOnly)) if (!sneJsonFile.open(QIODevice::ReadOnly))
{ {
qWarning() << "[Supernovae] cannot open" << QDir::toNativeSe parators(sneJsonPath); qWarning() << "[Supernovae] cannot open" << QDir::toNativeSe parators(sneJsonPath);
return lowerLimit; return lowerLimit;
} }
QVariantMap map; QVariantMap map;
map = StelJsonParser::parse(&sneJsonFile).toMap(); map = StelJsonParser::parse(&sneJsonFile).toMap();
if (map.contains("limit")) if (map.contains("limit"))
{ {
lowerLimit = map.value("limit").toFloat(); lowerLimit = map.value("limit").toFloat();
} }
sneJsonFile.close(); sneJsonFile.close();
return lowerLimit; return lowerLimit;
} }
SupernovaP Supernovae::getByID(const QString& id) SupernovaP Supernovae::getByID(const QString& id) const
{ {
foreach(const SupernovaP& sn, snstar) foreach(const SupernovaP& sn, snstar)
{ {
if (sn->initialized && sn->designation == id) if (sn->initialized && sn->designation == id)
return sn; return sn;
} }
return SupernovaP(); return SupernovaP();
} }
bool Supernovae::configureGui(bool show) bool Supernovae::configureGui(bool show)
skipping to change at line 576 skipping to change at line 576
{ {
qDebug() << "[Supernovae] starting update..."; qDebug() << "[Supernovae] starting update...";
} }
lastUpdate = QDateTime::currentDateTime(); lastUpdate = QDateTime::currentDateTime();
conf->setValue("Supernovae/last_update", lastUpdate.toString(Qt::ISO Date)); conf->setValue("Supernovae/last_update", lastUpdate.toString(Qt::ISO Date));
updateState = Supernovae::Updating; updateState = Supernovae::Updating;
emit(updateStateChanged(updateState)); emit(updateStateChanged(updateState));
if (progressBar==NULL) if (progressBar==Q_NULLPTR)
progressBar = StelApp::getInstance().addProgressBar(); progressBar = StelApp::getInstance().addProgressBar();
progressBar->setValue(0); progressBar->setValue(0);
progressBar->setRange(0, 100); progressBar->setRange(0, 100);
progressBar->setFormat("Update historical supernovae"); progressBar->setFormat("Update historical supernovae");
QNetworkRequest request; QNetworkRequest request;
request.setUrl(QUrl(updateUrl)); request.setUrl(QUrl(updateUrl));
request.setRawHeader("User-Agent", QString("Mozilla/5.0 (Stellarium Historical Supernovae Plugin %1; http://stellarium.org/)").arg(SUPERNOVAE_P LUGIN_VERSION).toUtf8()); request.setRawHeader("User-Agent", QString("Mozilla/5.0 (Stellarium Historical Supernovae Plugin %1; http://stellarium.org/)").arg(SUPERNOVAE_P LUGIN_VERSION).toUtf8());
downloadMgr->get(request); downloadMgr->get(request);
skipping to change at line 624 skipping to change at line 624
{ {
jsonFile.write(reply->readAll()); jsonFile.write(reply->readAll());
jsonFile.close(); jsonFile.close();
} }
} }
if (progressBar) if (progressBar)
{ {
progressBar->setValue(100); progressBar->setValue(100);
StelApp::getInstance().removeProgressBar(progressBar); StelApp::getInstance().removeProgressBar(progressBar);
progressBar = NULL; progressBar = Q_NULLPTR;
} }
readJsonFile(); readJsonFile();
} }
void Supernovae::displayMessage(const QString& message, const QString hexCo lor) void Supernovae::displayMessage(const QString& message, const QString hexCo lor)
{ {
messageIDs << GETSTELMODULE(LabelMgr)->labelScreen(message, 30, 30 + (20*messageIDs.count()), true, 16, hexColor); messageIDs << GETSTELMODULE(LabelMgr)->labelScreen(message, 30, 30 + (20*messageIDs.count()), true, 16, hexColor);
messageTimer->start(); messageTimer->start();
} }
void Supernovae::messageTimeout(void) void Supernovae::messageTimeout(void)
{ {
foreach(int i, messageIDs) foreach(int i, messageIDs)
{ {
GETSTELMODULE(LabelMgr)->deleteLabel(i); GETSTELMODULE(LabelMgr)->deleteLabel(i);
} }
} }
QString Supernovae::getSupernovaeList() QString Supernovae::getSupernovaeList() const
{ {
QString smonth[] = {q_("January"), q_("February"), q_("March"), q_(" April"), q_("May"), q_("June"), q_("July"), q_("August"), q_("September"), q_("October"), q_("November"), q_("December")}; QString smonth[] = {q_("January"), q_("February"), q_("March"), q_(" April"), q_("May"), q_("June"), q_("July"), q_("August"), q_("September"), q_("October"), q_("November"), q_("December")};
QStringList out; QStringList out;
int year, month, day; int year, month, day;
QList<double> vals = snlist.values(); QList<double> vals = snlist.values();
qSort(vals); qSort(vals);
foreach(double val, vals) foreach(double val, vals)
{ {
StelUtils::getDateFromJulianDay(val, &year, &month, &day); StelUtils::getDateFromJulianDay(val, &year, &month, &day);
out << QString("%1 (%2 %3)").arg(snlist.key(val)).arg(day).a rg(smonth[month-1]); out << QString("%1 (%2 %3)").arg(snlist.key(val)).arg(day).a rg(smonth[month-1]);
 End of changes. 10 change blocks. 
13 lines changed or deleted 13 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/