Quasars.cpp   Quasars.cpp 
skipping to change at line 52 skipping to change at line 52
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QTimer> #include <QTimer>
#include <QList> #include <QList>
#include <QSettings> #include <QSettings>
#include <QSharedPointer> #include <QSharedPointer>
#include <QStringList> #include <QStringList>
#include <QVariant> #include <QVariant>
#include <QVariantMap> #include <QVariantMap>
#include <QDir>
#define CATALOG_FORMAT_VERSION 1 /* Version of format of catalog */ #define CATALOG_FORMAT_VERSION 1 /* Version of format of catalog */
/* /*
This method is the one called automatically by the StelModuleMgr just This method is the one called automatically by the StelModuleMgr just
after loading the dynamic library after loading the dynamic library
*/ */
StelModule* QuasarsStelPluginInterface::getStelModule() const StelModule* QuasarsStelPluginInterface::getStelModule() const
{ {
return new Quasars(); return new Quasars();
skipping to change at line 85 skipping to change at line 86
} }
Q_EXPORT_PLUGIN2(Quasars, QuasarsStelPluginInterface) Q_EXPORT_PLUGIN2(Quasars, QuasarsStelPluginInterface)
/* /*
Constructor Constructor
*/ */
Quasars::Quasars() Quasars::Quasars()
: texPointer(NULL) : texPointer(NULL)
, markerTexture(NULL) , markerTexture(NULL)
, flagShowQuasars(false)
, OnIcon(NULL)
, OffIcon(NULL)
, GlowIcon(NULL)
, toolbarButton(NULL)
, progressBar(NULL) , progressBar(NULL)
{ {
setObjectName("Quasars"); setObjectName("Quasars");
configDialog = new QuasarsDialog(); configDialog = new QuasarsDialog();
conf = StelApp::getInstance().getSettings(); conf = StelApp::getInstance().getSettings();
font.setPixelSize(conf->value("gui/base_font_size", 13).toInt()); font.setPixelSize(conf->value("gui/base_font_size", 13).toInt());
} }
/* /*
Destructor Destructor
*/ */
Quasars::~Quasars() Quasars::~Quasars()
{ {
delete configDialog; delete configDialog;
if (GlowIcon)
delete GlowIcon;
if (OnIcon)
delete OnIcon;
if (OffIcon)
delete OffIcon;
} }
void Quasars::deinit() void Quasars::deinit()
{ {
if(NULL != texPointer) {delete texPointer;} if(NULL != texPointer) {delete texPointer;}
if(NULL != markerTexture) {delete markerTexture;} if(NULL != markerTexture) {delete markerTexture;}
texPointer = markerTexture = NULL; texPointer = markerTexture = NULL;
QSO.clear(); QSO.clear();
} }
skipping to change at line 124 skipping to change at line 137
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Cons tellationMgr")->getCallOrder(actionName)+10.; return StelApp::getInstance().getModuleMgr().getModule("Cons tellationMgr")->getCallOrder(actionName)+10.;
return 0; return 0;
} }
/* /*
Init our module Init our module
*/ */
void Quasars::init() void Quasars::init()
{ {
upgradeConfigIni();
try try
{ {
StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::get UserDir()+"/modules/Quasars"); StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::get UserDir()+"/modules/Quasars");
// If no settings in the main config file, create with defau lts // If no settings in the main config file, create with defau lts
if (!conf->childGroups().contains("Quasars")) if (!conf->childGroups().contains("Quasars"))
{ {
qDebug() << "Quasars::init no Quasars section exists in main config file - creating with defaults"; qDebug() << "Quasars::init no Quasars section exists in main config file - creating with defaults";
restoreDefaultConfigIni(); restoreDefaultConfigIni();
} }
// populate settings from main config file. // populate settings from main config file.
readSettingsFromConfig(); readSettingsFromConfig();
catalogJsonPath = StelFileMgr::findFile("modules/Quasars", ( StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/quas ars.json"; catalogJsonPath = StelFileMgr::findFile("modules/Quasars", ( StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/quas ars.json";
// key bindings and other actions // key bindings and other actions
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
GlowIcon = new QPixmap(":/graphicsGui/glow32x32.png");
OnIcon = new QPixmap(":/Quasars/btQuasars-on.png");
OffIcon = new QPixmap(":/Quasars/btQuasars-off.png");
setFlagShowQuasars(getEnableAtStartup());
setFlagShowQuasarsButton(flagShowQuasarsButton);
connect(gui->getGuiAction("actionShow_Quasars_ConfigDialog") , SIGNAL(toggled(bool)), configDialog, SLOT(setVisible(bool))); connect(gui->getGuiAction("actionShow_Quasars_ConfigDialog") , SIGNAL(toggled(bool)), configDialog, SLOT(setVisible(bool)));
connect(configDialog, SIGNAL(visibleChanged(bool)), gui->get GuiAction("actionShow_Quasars_ConfigDialog"), SLOT(setChecked(bool))); connect(configDialog, SIGNAL(visibleChanged(bool)), gui->get GuiAction("actionShow_Quasars_ConfigDialog"), SLOT(setChecked(bool)));
if (flagShowQuasarsButton)
{
connect(gui->getGuiAction("actionShow_Quasars"), SIG
NAL(toggled(bool)), this, SLOT(setFlagShowQuasars(bool)));
}
} }
catch (std::runtime_error &e) catch (std::runtime_error &e)
{ {
qWarning() << "Quasars::init error: " << e.what(); qWarning() << "Quasars::init error: " << e.what();
return; return;
} }
// 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 (getJsonFileVersion() < CATALOG_FORMAT_VERSION) if (getJsonFileFormatVersion() < CATALOG_FORMAT_VERSION)
{ {
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
} }
else else
{ {
qDebug() << "Quasars::init catalog.json does not exist - cop ying default file to " << catalogJsonPath; qDebug() << "Quasars::init quasars.json does not exist - cop ying default file to " << QDir::toNativeSeparators(catalogJsonPath);
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
qDebug() << "Quasars::init using catalog.json file: " << catalogJson Path; qDebug() << "Quasars::init using file: " << QDir::toNativeSeparators (catalogJsonPath);
readJsonFile(); readJsonFile();
// Set up download manager and the update schedule // Set up download manager and the update schedule
downloadMgr = new QNetworkAccessManager(this); downloadMgr = new QNetworkAccessManager(this);
connect(downloadMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(up dateDownloadComplete(QNetworkReply*))); connect(downloadMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(up dateDownloadComplete(QNetworkReply*)));
updateState = CompleteNoUpdates; updateState = CompleteNoUpdates;
updateTimer = new QTimer(this); updateTimer = new QTimer(this);
updateTimer->setSingleShot(false); // recurring check for update updateTimer->setSingleShot(false); // recurring check for update
updateTimer->setInterval(13000); // check once every 13 seconds to see if it is time for an update updateTimer->setInterval(13000); // check once every 13 seconds to see if it is time for an update
skipping to change at line 195 skipping to change at line 221
updateTimer->start(); updateTimer->start();
GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this); GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this);
} }
/* /*
Draw our module. This should print name of first QSO in the main window Draw our module. This should print name of first QSO in the main window
*/ */
void Quasars::draw(StelCore* core, class StelRenderer* renderer) void Quasars::draw(StelCore* core, class StelRenderer* renderer)
{ {
if (!flagShowQuasars)
return;
StelProjectorP prj = core->getProjection(StelCore::FrameJ2000); StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
renderer->setFont(font); renderer->setFont(font);
if(NULL == markerTexture) if(NULL == markerTexture)
{ {
markerTexture = renderer->createTexture(":/Quasars/quasar.pn g"); markerTexture = renderer->createTexture(":/Quasars/quasar.pn g");
} }
foreach (const QuasarP& quasar, QSO) foreach (const QuasarP& quasar, QSO)
{ {
skipping to change at line 249 skipping to change at line 278
renderer->setBlendMode(BlendMode_Alpha); renderer->setBlendMode(BlendMode_Alpha);
renderer->drawTexturedRect(screenPos[0] - 13.0f, screenPos[1 ] - 13.0f, 26.0f, 26.0f, renderer->drawTexturedRect(screenPos[0] - 13.0f, screenPos[1 ] - 13.0f, 26.0f, 26.0f,
StelApp::getInstance().getTotalRu nTime() * 40.0f); StelApp::getInstance().getTotalRu nTime() * 40.0f);
} }
} }
QList<StelObjectP> Quasars::searchAround(const Vec3d& av, double limitFov, const StelCore*) const QList<StelObjectP> Quasars::searchAround(const Vec3d& av, double limitFov, const StelCore*) const
{ {
QList<StelObjectP> result; QList<StelObjectP> result;
if (!flagShowQuasars)
return result;
Vec3d v(av); Vec3d v(av);
v.normalize(); v.normalize();
double cosLimFov = cos(limitFov * M_PI/180.); double cosLimFov = cos(limitFov * M_PI/180.);
Vec3d equPos; Vec3d equPos;
foreach(const QuasarP& quasar, QSO) foreach(const QuasarP& quasar, QSO)
{ {
if (quasar->initialized) if (quasar->initialized)
{ {
equPos = quasar->XYZ; equPos = quasar->XYZ;
skipping to change at line 272 skipping to change at line 304
result.append(qSharedPointerCast<StelObject> (quasar)); result.append(qSharedPointerCast<StelObject> (quasar));
} }
} }
} }
return result; return result;
} }
StelObjectP Quasars::searchByName(const QString& englishName) const StelObjectP Quasars::searchByName(const QString& englishName) const
{ {
QString objw = englishName.toUpper(); if (!flagShowQuasars)
return NULL;
foreach(const QuasarP& quasar, QSO) foreach(const QuasarP& quasar, QSO)
{ {
if (quasar->getEnglishName().toUpper() == englishName) if (quasar->getEnglishName().toUpper() == englishName.toUppe r())
return qSharedPointerCast<StelObject>(quasar); return qSharedPointerCast<StelObject>(quasar);
} }
return NULL; return NULL;
} }
StelObjectP Quasars::searchByNameI18n(const QString& nameI18n) const StelObjectP Quasars::searchByNameI18n(const QString& nameI18n) const
{ {
QString objw = nameI18n.toUpper(); if (!flagShowQuasars)
return NULL;
foreach(const QuasarP& quasar, QSO) foreach(const QuasarP& quasar, QSO)
{ {
if (quasar->getNameI18n().toUpper() == nameI18n) if (quasar->getNameI18n().toUpper() == nameI18n.toUpper())
return qSharedPointerCast<StelObject>(quasar); return qSharedPointerCast<StelObject>(quasar);
} }
return NULL; return NULL;
} }
QStringList Quasars::listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem) const QStringList Quasars::listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (!flagShowQuasars)
return result;
QString objw = objPrefix.toUpper(); if (maxNbItem==0)
return result;
QString qson;
foreach(const QuasarP& quasar, QSO) foreach(const QuasarP& quasar, QSO)
{ {
if (quasar->getNameI18n().toUpper().left(objw.length()) == o qson = quasar->getNameI18n();
bjw) if (qson.contains(objPrefix, Qt::CaseInsensitive))
{ {
result << quasar->getNameI18n().toUpper(); result << qson;
} }
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, if (result.size()>maxNbItem)
result.end()); result.erase(result.begin()+maxNbItem, result.end());
return result; return result;
} }
QStringList Quasars::listMatchingObjects(const QString& objPrefix, int maxN bItem) const QStringList Quasars::listMatchingObjects(const QString& objPrefix, int maxN bItem) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (!flagShowQuasars)
return result;
QString objw = objPrefix.toUpper(); if (maxNbItem==0)
return result;
QString qson;
foreach(const QuasarP& quasar, QSO) foreach(const QuasarP& quasar, QSO)
{ {
if (quasar->getEnglishName().toUpper().left(objw.length()) = qson = quasar->getEnglishName();
= objw) if (qson.contains(objPrefix, Qt::CaseInsensitive))
{ {
result << quasar->getEnglishName().toUpper() ; result << qson;
} }
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, if (result.size()>maxNbItem)
result.end()); result.erase(result.begin()+maxNbItem, result.end());
return result; return result;
} }
QStringList Quasars::listAllObjects(bool inEnglish) const QStringList Quasars::listAllObjects(bool inEnglish) const
{ {
QStringList result; QStringList result;
if (inEnglish) if (inEnglish)
{ {
foreach (const QuasarP& quasar, QSO) foreach (const QuasarP& quasar, QSO)
skipping to change at line 368 skipping to change at line 413
Replace the JSON file with the default from the compiled-in resource Replace the JSON file with the default from the compiled-in resource
*/ */
void Quasars::restoreDefaultJsonFile(void) void Quasars::restoreDefaultJsonFile(void)
{ {
if (QFileInfo(catalogJsonPath).exists()) if (QFileInfo(catalogJsonPath).exists())
backupJsonFile(true); backupJsonFile(true);
QFile src(":/Quasars/quasars.json"); QFile src(":/Quasars/quasars.json");
if (!src.copy(catalogJsonPath)) if (!src.copy(catalogJsonPath))
{ {
qWarning() << "Quasars::restoreDefaultJsonFile cannot copy j son resource to " + catalogJsonPath; qWarning() << "Quasars::restoreDefaultJsonFile cannot copy j son resource to " + QDir::toNativeSeparators(catalogJsonPath);
} }
else else
{ {
qDebug() << "Quasars::init copied default catalog.json to " << catalogJsonPath; qDebug() << "Quasars::init copied default catalog.json to " << QDir::toNativeSeparators(catalogJsonPath);
// The resource is read only, and the new file inherits this ... make sure the new file // The resource is read only, and the new file inherits this ... make sure the new file
// is writable by the Stellarium process so that updates can be done. // is writable by the Stellarium process so that updates can be done.
QFile dest(catalogJsonPath); QFile dest(catalogJsonPath);
dest.setPermissions(dest.permissions() | QFile::WriteOwner); dest.setPermissions(dest.permissions() | QFile::WriteOwner);
// Make sure that in the case where an online update has pre viously been done, but // Make sure that in the case where an online update has pre viously been done, but
// the json file has been manually removed, that an update i s schreduled in a timely // the json file has been manually removed, that an update i s schreduled in a timely
// manner // manner
conf->remove("Quasars/last_update"); conf->remove("Quasars/last_update");
lastUpdate = QDateTime::fromString("2012-05-24T12:00:00", Qt ::ISODate); lastUpdate = QDateTime::fromString("2012-05-24T12:00:00", Qt ::ISODate);
skipping to change at line 442 skipping to change at line 487
Parse JSON file and load quasarss to map Parse JSON file and load quasarss to map
*/ */
QVariantMap Quasars::loadQSOMap(QString path) QVariantMap Quasars::loadQSOMap(QString path)
{ {
if (path.isEmpty()) if (path.isEmpty())
path = catalogJsonPath; path = catalogJsonPath;
QVariantMap map; QVariantMap map;
QFile jsonFile(path); QFile jsonFile(path);
if (!jsonFile.open(QIODevice::ReadOnly)) if (!jsonFile.open(QIODevice::ReadOnly))
qWarning() << "Quasars::loadQSOMap cannot open " << path; qWarning() << "Quasars::loadQSOMap cannot open " << QDir::toNati veSeparators(path);
else else
map = StelJsonParser::parse(jsonFile.readAll()).toMap(); map = StelJsonParser::parse(jsonFile.readAll()).toMap();
jsonFile.close(); jsonFile.close();
return map; return map;
} }
/* /*
Set items for list of struct from data map Set items for list of struct from data map
*/ */
skipping to change at line 469 skipping to change at line 514
QVariantMap qsoData = qsoMap.value(qsoKey).toMap(); QVariantMap qsoData = qsoMap.value(qsoKey).toMap();
qsoData["designation"] = qsoKey; qsoData["designation"] = qsoKey;
QuasarP quasar(new Quasar(qsoData)); QuasarP quasar(new Quasar(qsoData));
if (quasar->initialized) if (quasar->initialized)
QSO.append(quasar); QSO.append(quasar);
} }
} }
int Quasars::getJsonFileVersion(void) int Quasars::getJsonFileFormatVersion(void)
{ {
int jsonVersion = -1; int jsonVersion = -1;
QFile catalogJsonFile(catalogJsonPath); QFile catalogJsonFile(catalogJsonPath);
if (!catalogJsonFile.open(QIODevice::ReadOnly)) if (!catalogJsonFile.open(QIODevice::ReadOnly))
{ {
qWarning() << "Quasars::init cannot open " << catalogJsonPat h; qWarning() << "Quasars::init cannot open " << QDir::toNative Separators(catalogJsonPath);
return jsonVersion; return jsonVersion;
} }
QVariantMap map; QVariantMap map;
map = StelJsonParser::parse(&catalogJsonFile).toMap(); map = StelJsonParser::parse(&catalogJsonFile).toMap();
if (map.contains("version")) if (map.contains("version"))
{ {
jsonVersion = map.value("version").toInt(); jsonVersion = map.value("version").toInt();
} }
catalogJsonFile.close(); catalogJsonFile.close();
qDebug() << "Quasars::getJsonFileVersion() version from file:" << js onVersion; qDebug() << "Quasars::getJsonFileFormatVersion() version of format f rom file:" << jsonVersion;
return jsonVersion; return jsonVersion;
} }
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;
} }
skipping to change at line 528 skipping to change at line 573
} }
void Quasars::restoreDefaultConfigIni(void) void Quasars::restoreDefaultConfigIni(void)
{ {
conf->beginGroup("Quasars"); conf->beginGroup("Quasars");
// delete all existing Quasars settings... // delete all existing Quasars settings...
conf->remove(""); conf->remove("");
conf->setValue("distribution_enabled", false); conf->setValue("distribution_enabled", false);
conf->setValue("enable_at_startup", false);
conf->setValue("updates_enabled", true); conf->setValue("updates_enabled", true);
conf->setValue("url", "http://stellarium.org/json/quasars.json"); conf->setValue("url", "http://stellarium.org/json/quasars.json");
conf->setValue("update_frequency_days", 100); conf->setValue("update_frequency_days", 100);
conf->setValue("flag_show_quasars_button", true);
conf->endGroup(); conf->endGroup();
} }
void Quasars::readSettingsFromConfig(void) void Quasars::readSettingsFromConfig(void)
{ {
conf->beginGroup("Quasars"); conf->beginGroup("Quasars");
updateUrl = conf->value("url", "http://stellarium.org/json/quasars.j son").toString(); updateUrl = conf->value("url", "http://stellarium.org/json/quasars.j son").toString();
updateFrequencyDays = conf->value("update_frequency_days", 100).toIn t(); updateFrequencyDays = conf->value("update_frequency_days", 100).toIn t();
lastUpdate = QDateTime::fromString(conf->value("last_update", "2012- 05-24T12:00:00").toString(), Qt::ISODate); lastUpdate = QDateTime::fromString(conf->value("last_update", "2012- 05-24T12:00:00").toString(), Qt::ISODate);
updatesEnabled = conf->value("updates_enabled", true).toBool(); updatesEnabled = conf->value("updates_enabled", true).toBool();
distributionEnabled = conf->value("distribution_enabled", false).toB ool(); distributionEnabled = conf->value("distribution_enabled", false).toB ool();
enableAtStartup = conf->value("enable_at_startup", false).toBool();
flagShowQuasarsButton = conf->value("flag_show_quasars_button", true
).toBool();
conf->endGroup(); conf->endGroup();
} }
void Quasars::saveSettingsToConfig(void) void Quasars::saveSettingsToConfig(void)
{ {
conf->beginGroup("Quasars"); conf->beginGroup("Quasars");
conf->setValue("url", updateUrl); conf->setValue("url", updateUrl);
conf->setValue("update_frequency_days", updateFrequencyDays); conf->setValue("update_frequency_days", updateFrequencyDays);
conf->setValue("updates_enabled", updatesEnabled ); conf->setValue("updates_enabled", updatesEnabled );
conf->setValue("distribution_enabled", distributionEnabled); conf->setValue("distribution_enabled", distributionEnabled);
conf->setValue("enable_at_startup", enableAtStartup);
conf->setValue("flag_show_quasars_button", flagShowQuasarsButton);
conf->endGroup(); conf->endGroup();
} }
int Quasars::getSecondsToUpdate(void) int Quasars::getSecondsToUpdate(void)
{ {
QDateTime nextUpdate = lastUpdate.addSecs(updateFrequencyDays * 3600 * 24); QDateTime nextUpdate = lastUpdate.addSecs(updateFrequencyDays * 3600 * 24);
return QDateTime::currentDateTime().secsTo(nextUpdate); return QDateTime::currentDateTime().secsTo(nextUpdate);
} }
skipping to change at line 586 skipping to change at line 637
return; return;
} }
else else
{ {
qDebug() << "Quasars: starting update..."; qDebug() << "Quasars: starting update...";
} }
lastUpdate = QDateTime::currentDateTime(); lastUpdate = QDateTime::currentDateTime();
conf->setValue("Quasars/last_update", lastUpdate.toString(Qt::ISODat e)); conf->setValue("Quasars/last_update", lastUpdate.toString(Qt::ISODat e));
emit(jsonUpdateComplete());
updateState = Quasars::Updating; updateState = Quasars::Updating;
emit(updateStateChanged(updateState)); emit(updateStateChanged(updateState));
updateFile.clear();
if (progressBar==NULL) if (progressBar==NULL)
progressBar = StelApp::getInstance().getGui()->addProgressBa r(); progressBar = StelApp::getInstance().getGui()->addProgressBa r();
progressBar->setValue(0); progressBar->setValue(0);
progressBar->setMaximum(updateUrl.size()); progressBar->setMaximum(100);
progressBar->setVisible(true);
progressBar->setFormat("Update quasars"); progressBar->setFormat("Update quasars");
progressBar->setVisible(true);
QNetworkRequest request; QNetworkRequest request;
request.setUrl(QUrl(updateUrl)); request.setUrl(QUrl(updateUrl));
request.setRawHeader("User-Agent", QString("Mozilla/5.0 (Stellarium Quasars Plugin %1; http://stellarium.org/)").arg(QUASARS_PLUGIN_VERSION).to Utf8()); request.setRawHeader("User-Agent", QString("Mozilla/5.0 (Stellarium Quasars Plugin %1; http://stellarium.org/)").arg(QUASARS_PLUGIN_VERSION).to Utf8());
downloadMgr->get(request); downloadMgr->get(request);
progressBar->setValue(100); updateState = Quasars::CompleteUpdates;
delete progressBar;
progressBar = NULL;
updateState = CompleteUpdates;
emit(updateStateChanged(updateState)); emit(updateStateChanged(updateState));
emit(jsonUpdateComplete()); emit(jsonUpdateComplete());
} }
void Quasars::updateDownloadComplete(QNetworkReply* reply) void Quasars::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)
{ {
qWarning() << "Quasars::updateDownloadComplete FAILED to dow nload" << reply->url() << " Error: " << reply->errorString(); qWarning() << "Quasars::updateDownloadComplete FAILED to dow nload" << reply->url() << " Error: " << reply->errorString();
skipping to change at line 645 skipping to change at line 687
jsonFile.close(); jsonFile.close();
} }
catch (std::runtime_error &e) catch (std::runtime_error &e)
{ {
qWarning() << "Quasars::updateDownloadComplete: cann ot write JSON data to file:" << e.what(); qWarning() << "Quasars::updateDownloadComplete: cann ot write JSON data to file:" << e.what();
} }
} }
if (progressBar) if (progressBar)
{
progressBar->setValue(100); progressBar->setValue(100);
delete progressBar;
progressBar = NULL;
}
} }
void Quasars::displayMessage(const QString& message, const QString hexColor ) void Quasars::displayMessage(const QString& message, const QString hexColor )
{ {
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 Quasars::messageTimeout(void) void Quasars::messageTimeout(void)
{ {
foreach(int i, messageIDs) foreach(int i, messageIDs)
{ {
GETSTELMODULE(LabelMgr)->deleteLabel(i); GETSTELMODULE(LabelMgr)->deleteLabel(i);
} }
} }
void Quasars::upgradeConfigIni(void)
{
// Upgrade settings for Quasars plugin
if (conf->contains("Quasars/flag_show_quasars"))
{
bool b = conf->value("Quasars/flag_show_quasars", false).toB
ool();
if (!conf->contains("Quasars/enable_at_startup"))
conf->setValue("Quasars/enable_at_startup", b);
conf->remove("Quasars/flag_show_quasars");
}
}
// Define whether the button toggling quasars should be visible
void Quasars::setFlagShowQuasarsButton(bool b)
{
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui(
));
if (b==true) {
if (toolbarButton==NULL) {
// Create the quasars button
gui->getGuiAction("actionShow_Quasars")->setChecked(
flagShowQuasars);
toolbarButton = new StelButton(NULL, *OnIcon, *OffIc
on, *GlowIcon, gui->getGuiAction("actionShow_Quasars"));
}
gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr
oup");
} else {
gui->getButtonBar()->hideButton("actionShow_Quasars");
}
flagShowQuasarsButton = b;
}
 End of changes. 46 change blocks. 
39 lines changed or deleted 83 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/