Exoplanets.cpp   Exoplanets.cpp 
skipping to change at line 54 skipping to change at line 54
#include <QFileInfo> #include <QFileInfo>
#include <QFile> #include <QFile>
#include <QTimer> #include <QTimer>
#include <QVariantMap> #include <QVariantMap>
#include <QVariant> #include <QVariant>
#include <QList> #include <QList>
#include <QSettings> #include <QSettings>
#include <QSharedPointer> #include <QSharedPointer>
#include <QStringList> #include <QStringList>
#include <QPixmap> #include <QPixmap>
#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* ExoplanetsStelPluginInterface::getStelModule() const StelModule* ExoplanetsStelPluginInterface::getStelModule() const
{ {
return new Exoplanets(); return new Exoplanets();
skipping to change at line 105 skipping to change at line 106
exoplanetsConfigDialog = new ExoplanetsDialog(); exoplanetsConfigDialog = new ExoplanetsDialog();
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
*/ */
Exoplanets::~Exoplanets() Exoplanets::~Exoplanets()
{ {
StelApp::getInstance().getStelObjectMgr().unSelect();
delete exoplanetsConfigDialog; delete exoplanetsConfigDialog;
if (GlowIcon) if (GlowIcon)
delete GlowIcon; delete GlowIcon;
if (OnIcon) if (OnIcon)
delete OnIcon; delete OnIcon;
if (OffIcon) if (OffIcon)
delete OffIcon; delete OffIcon;
} }
void Exoplanets::deinit() void Exoplanets::deinit()
{ {
ep.clear(); ep.clear();
if(NULL != texPointer) {delete texPointer;} if(NULL != texPointer) {delete texPointer;}
if(NULL != markerTexture) {delete markerTexture;} if(NULL != markerTexture) {delete markerTexture;}
texPointer = markerTexture = NULL;
} }
void Exoplanets::update(double) //deltaTime void Exoplanets::update(double) //deltaTime
{ {
// //
} }
/* /*
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*/ */
skipping to change at line 143 skipping to change at line 145
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 Exoplanets::init() void Exoplanets::init()
{ {
upgradeConfigIni();
try try
{ {
StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::get UserDir()+"/modules/Exoplanets"); StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::get UserDir()+"/modules/Exoplanets");
// 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("Exoplanets")) if (!conf->childGroups().contains("Exoplanets"))
{ {
qDebug() << "Exoplanets::init no Exoplanets section exists in main config file - creating with defaults"; qDebug() << "Exoplanets::init no Exoplanets section exists in main config file - creating with defaults";
restoreDefaultConfigIni(); restoreDefaultConfigIni();
} }
skipping to change at line 166 skipping to change at line 170
jsonCatalogPath = StelFileMgr::findFile("modules/Exoplanets" , (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/e xoplanets.json"; jsonCatalogPath = StelFileMgr::findFile("modules/Exoplanets" , (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/e xoplanets.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"); GlowIcon = new QPixmap(":/graphicsGui/glow32x32.png");
OnIcon = new QPixmap(":/Exoplanets/btExoplanets-on.png"); OnIcon = new QPixmap(":/Exoplanets/btExoplanets-on.png");
OffIcon = new QPixmap(":/Exoplanets/btExoplanets-off.png"); OffIcon = new QPixmap(":/Exoplanets/btExoplanets-off.png");
gui->getGuiAction("actionShow_Exoplanets")->setChecked(flagS setFlagShowExoplanets(getEnableAtStartup());
howExoplanets); setFlagShowExoplanetsButton(flagShowExoplanetsButton);
toolbarButton = new StelButton(NULL, *OnIcon, *OffIcon, *Glo
wIcon, gui->getGuiAction("actionShow_Exoplanets"));
gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr
oup");
connect(gui->getGuiAction("actionShow_Exoplanets_ConfigDialo g"), SIGNAL(toggled(bool)), exoplanetsConfigDialog, SLOT(setVisible(bool))) ; connect(gui->getGuiAction("actionShow_Exoplanets_ConfigDialo g"), SIGNAL(toggled(bool)), exoplanetsConfigDialog, SLOT(setVisible(bool))) ;
connect(exoplanetsConfigDialog, SIGNAL(visibleChanged(bool)) , gui->getGuiAction("actionShow_Exoplanets_ConfigDialog"), SLOT(setChecked( bool))); connect(exoplanetsConfigDialog, SIGNAL(visibleChanged(bool)) , gui->getGuiAction("actionShow_Exoplanets_ConfigDialog"), SLOT(setChecked( bool)));
connect(gui->getGuiAction("actionShow_Exoplanets"), SIGNAL(t if (flagShowExoplanetsButton)
oggled(bool)), this, SLOT(setFlagShowExoplanets(bool))); {
connect(gui->getGuiAction("actionShow_Exoplanets"),
SIGNAL(toggled(bool)), this, SLOT(setFlagShowExoplanets(bool)));
}
} }
catch (std::runtime_error &e) catch (std::runtime_error &e)
{ {
qWarning() << "Exoplanets::init error: " << e.what(); qWarning() << "Exoplanets::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(jsonCatalogPath).exists()) if(QFileInfo(jsonCatalogPath).exists())
{ {
if (getJsonFileVersion() < CATALOG_FORMAT_VERSION) if (getJsonFileFormatVersion() < CATALOG_FORMAT_VERSION)
{ {
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
} }
else else
{ {
qDebug() << "Exoplanets::init catalog.json does not exist - copying default file to " << jsonCatalogPath; qDebug() << "Exoplanets::init exoplanets.json does not exist - copying default file to " << QDir::toNativeSeparators(jsonCatalogPath);
restoreDefaultJsonFile(); restoreDefaultJsonFile();
} }
qDebug() << "Exoplanets::init using catalog.json file: " << jsonCata logPath; qDebug() << "Exoplanets::init using file: " << QDir::toNativeSeparat ors(jsonCatalogPath);
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 304 skipping to change at line 310
return result; return result;
} }
StelObjectP Exoplanets::searchByName(const QString& englishName) const StelObjectP Exoplanets::searchByName(const QString& englishName) const
{ {
if (!flagShowExoplanets) if (!flagShowExoplanets)
return NULL; return NULL;
foreach(const ExoplanetP& eps, ep) foreach(const ExoplanetP& eps, ep)
{ {
if (eps->getEnglishName().toUpper() == englishName) if (eps->getEnglishName().toUpper() == englishName.toUpper() )
return qSharedPointerCast<StelObject>(eps); return qSharedPointerCast<StelObject>(eps);
} }
return NULL; return NULL;
} }
StelObjectP Exoplanets::searchByNameI18n(const QString& nameI18n) const StelObjectP Exoplanets::searchByNameI18n(const QString& nameI18n) const
{ {
if (!flagShowExoplanets) if (!flagShowExoplanets)
return NULL; return NULL;
foreach(const ExoplanetP& eps, ep) foreach(const ExoplanetP& eps, ep)
{ {
if (eps->getNameI18n().toUpper() == nameI18n) if (eps->getNameI18n().toUpper() == nameI18n.toUpper())
return qSharedPointerCast<StelObject>(eps); return qSharedPointerCast<StelObject>(eps);
} }
return NULL; return NULL;
} }
QStringList Exoplanets::listMatchingObjectsI18n(const QString& objPrefix, i nt maxNbItem) const QStringList Exoplanets::listMatchingObjectsI18n(const QString& objPrefix, i nt maxNbItem) const
{ {
QStringList result; QStringList result;
if (!flagShowExoplanets) if (!flagShowExoplanets)
return result; return result;
if (maxNbItem==0) return result; if (maxNbItem==0)
return result;
QString objw = objPrefix.toUpper();
QString epsn;
foreach(const ExoplanetP& eps, ep) foreach(const ExoplanetP& eps, ep)
{ {
if (eps->getNameI18n().toUpper().left(objw.length()) == objw epsn = eps->getNameI18n();
) if (epsn.contains(objPrefix, Qt::CaseInsensitive))
{ {
result << eps->getNameI18n().toUpper(); result << epsn;
} }
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end());
return result; if (result.size()>maxNbItem)
result.erase(result.begin()+maxNbItem, result.end());
return result;
} }
QStringList Exoplanets::listMatchingObjects(const QString& objPrefix, int m axNbItem) const QStringList Exoplanets::listMatchingObjects(const QString& objPrefix, int m axNbItem) const
{ {
QStringList result; QStringList result;
if (!flagShowExoplanets) if (!flagShowExoplanets)
return result; return result;
if (maxNbItem==0) return result; if (maxNbItem==0)
return result;
QString objw = objPrefix.toUpper();
QString epsn;
foreach(const ExoplanetP& eps, ep) foreach(const ExoplanetP& eps, ep)
{ {
if (eps->getEnglishName().toUpper().left(objw.length()) == o epsn = eps->getNameI18n();
bjw) if (epsn.contains(objPrefix, Qt::CaseInsensitive))
{ {
result << eps->getEnglishName().toUpper(); result << epsn;
} }
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end());
return result; if (result.size()>maxNbItem)
result.erase(result.begin()+maxNbItem, result.end());
return result;
} }
QStringList Exoplanets::listAllObjects(bool inEnglish) const QStringList Exoplanets::listAllObjects(bool inEnglish) const
{ {
QStringList result; QStringList result;
if (inEnglish) if (inEnglish)
{ {
foreach (const ExoplanetP& planet, ep) foreach (const ExoplanetP& planet, ep)
{ {
result << planet->getEnglishName(); result << planet->getEnglishName();
skipping to change at line 404 skipping to change at line 416
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 Exoplanets::restoreDefaultJsonFile(void) void Exoplanets::restoreDefaultJsonFile(void)
{ {
if (QFileInfo(jsonCatalogPath).exists()) if (QFileInfo(jsonCatalogPath).exists())
backupJsonFile(true); backupJsonFile(true);
QFile src(":/Exoplanets/exoplanets.json"); QFile src(":/Exoplanets/exoplanets.json");
if (!src.copy(jsonCatalogPath)) if (!src.copy(jsonCatalogPath))
{ {
qWarning() << "Exoplanets::restoreDefaultJsonFile cannot cop y json resource to " + jsonCatalogPath; qWarning() << "Exoplanets::restoreDefaultJsonFile cannot cop y json resource to " + QDir::toNativeSeparators(jsonCatalogPath);
} }
else else
{ {
qDebug() << "Exoplanets::init copied default exoplanets.json to " << jsonCatalogPath; qDebug() << "Exoplanets::init copied default exoplanets.json to " << QDir::toNativeSeparators(jsonCatalogPath);
// 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(jsonCatalogPath); QFile dest(jsonCatalogPath);
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("Exoplanets/last_update"); conf->remove("Exoplanets/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 477 skipping to change at line 489
Parse JSON file and load exoplanets to map Parse JSON file and load exoplanets to map
*/ */
QVariantMap Exoplanets::loadEPMap(QString path) QVariantMap Exoplanets::loadEPMap(QString path)
{ {
if (path.isEmpty()) if (path.isEmpty())
path = jsonCatalogPath; path = jsonCatalogPath;
QVariantMap map; QVariantMap map;
QFile jsonFile(path); QFile jsonFile(path);
if (!jsonFile.open(QIODevice::ReadOnly)) if (!jsonFile.open(QIODevice::ReadOnly))
qWarning() << "Exoplanets::loadEPMap cannot open " << path; qWarning() << "Exoplanets::loadEPMap cannot open " << QDir::toNa tiveSeparators(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 504 skipping to change at line 516
QVariantMap epsData = epsMap.value(epsKey).toMap(); QVariantMap epsData = epsMap.value(epsKey).toMap();
epsData["designation"] = epsKey; epsData["designation"] = epsKey;
ExoplanetP eps(new Exoplanet(epsData)); ExoplanetP eps(new Exoplanet(epsData));
if (eps->initialized) if (eps->initialized)
ep.append(eps); ep.append(eps);
} }
} }
int Exoplanets::getJsonFileVersion(void) int Exoplanets::getJsonFileFormatVersion(void)
{ {
int jsonVersion = -1; int jsonVersion = -1;
QFile jsonEPCatalogFile(jsonCatalogPath); QFile jsonEPCatalogFile(jsonCatalogPath);
if (!jsonEPCatalogFile.open(QIODevice::ReadOnly)) if (!jsonEPCatalogFile.open(QIODevice::ReadOnly))
{ {
qWarning() << "Exoplanets::init cannot open " << jsonCatalog Path; qWarning() << "Exoplanets::init cannot open " << QDir::toNat iveSeparators(jsonCatalogPath);
return jsonVersion; return jsonVersion;
} }
QVariantMap map; QVariantMap map;
map = StelJsonParser::parse(&jsonEPCatalogFile).toMap(); map = StelJsonParser::parse(&jsonEPCatalogFile).toMap();
if (map.contains("version")) if (map.contains("version"))
{ {
jsonVersion = map.value("version").toInt(); jsonVersion = map.value("version").toInt();
} }
jsonEPCatalogFile.close(); jsonEPCatalogFile.close();
qDebug() << "Exoplanets::getJsonFileVersion() version from file:" << jsonVersion; qDebug() << "Exoplanets::getJsonFileFormatVersion() version of forma t from file:" << jsonVersion;
return jsonVersion; return jsonVersion;
} }
ExoplanetP Exoplanets::getByID(const QString& id) ExoplanetP Exoplanets::getByID(const QString& id)
{ {
foreach(const ExoplanetP& eps, ep) foreach(const ExoplanetP& eps, ep)
{ {
if (eps->initialized && eps->designation == id) if (eps->initialized && eps->designation == id)
return eps; return eps;
} }
skipping to change at line 564 skipping to change at line 576
void Exoplanets::restoreDefaultConfigIni(void) void Exoplanets::restoreDefaultConfigIni(void)
{ {
conf->beginGroup("Exoplanets"); conf->beginGroup("Exoplanets");
// delete all existing Exoplanets settings... // delete all existing Exoplanets settings...
conf->remove(""); conf->remove("");
conf->setValue("distribution_enabled", false); conf->setValue("distribution_enabled", false);
conf->setValue("timeline_enabled", false); conf->setValue("timeline_enabled", false);
conf->setValue("enable_at_startup", false);
conf->setValue("updates_enabled", true); conf->setValue("updates_enabled", true);
conf->setValue("flag_show_exoplanets", false);
conf->setValue("url", "http://stellarium.org/json/exoplanets.json"); conf->setValue("url", "http://stellarium.org/json/exoplanets.json");
conf->setValue("update_frequency_hours", 72); conf->setValue("update_frequency_hours", 72);
conf->setValue("flag_show_exoplanets_button", true);
conf->endGroup(); conf->endGroup();
} }
void Exoplanets::readSettingsFromConfig(void) void Exoplanets::readSettingsFromConfig(void)
{ {
conf->beginGroup("Exoplanets"); conf->beginGroup("Exoplanets");
updateUrl = conf->value("url", "http://stellarium.org/json/exoplanet s.json").toString(); updateUrl = conf->value("url", "http://stellarium.org/json/exoplanet s.json").toString();
updateFrequencyHours = conf->value("update_frequency_hours", 72).toI nt(); updateFrequencyHours = conf->value("update_frequency_hours", 72).toI nt();
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();
timelineEnabled = conf->value("timeline_enabled", false).toBool(); timelineEnabled = conf->value("timeline_enabled", false).toBool();
flagShowExoplanets = conf->value("flag_show_exoplanets", false).toBo enableAtStartup = conf->value("enable_at_startup", false).toBool();
ol(); flagShowExoplanetsButton = conf->value("flag_show_exoplanets_button"
, true).toBool();
conf->endGroup(); conf->endGroup();
} }
void Exoplanets::saveSettingsToConfig(void) void Exoplanets::saveSettingsToConfig(void)
{ {
conf->beginGroup("Exoplanets"); conf->beginGroup("Exoplanets");
conf->setValue("url", updateUrl); conf->setValue("url", updateUrl);
conf->setValue("update_frequency_hours", updateFrequencyHours); conf->setValue("update_frequency_hours", updateFrequencyHours);
conf->setValue("updates_enabled", updatesEnabled ); conf->setValue("updates_enabled", updatesEnabled );
conf->setValue("distribution_enabled", distributionEnabled); conf->setValue("distribution_enabled", distributionEnabled);
conf->setValue("timeline_enabled", timelineEnabled); conf->setValue("timeline_enabled", timelineEnabled);
conf->setValue("flag_show_exoplanets", flagShowExoplanets); conf->setValue("enable_at_startup", enableAtStartup);
conf->setValue("flag_show_exoplanets_button", flagShowExoplanetsButt
on);
conf->endGroup(); conf->endGroup();
} }
int Exoplanets::getSecondsToUpdate(void) int Exoplanets::getSecondsToUpdate(void)
{ {
QDateTime nextUpdate = lastUpdate.addSecs(updateFrequencyHours * 360 0); QDateTime nextUpdate = lastUpdate.addSecs(updateFrequencyHours * 360 0);
return QDateTime::currentDateTime().secsTo(nextUpdate); return QDateTime::currentDateTime().secsTo(nextUpdate);
} }
skipping to change at line 627 skipping to change at line 642
return; return;
} }
else else
{ {
qDebug() << "Exoplanets: starting update..."; qDebug() << "Exoplanets: starting update...";
} }
lastUpdate = QDateTime::currentDateTime(); lastUpdate = QDateTime::currentDateTime();
conf->setValue("Exoplanets/last_update", lastUpdate.toString(Qt::ISO Date)); conf->setValue("Exoplanets/last_update", lastUpdate.toString(Qt::ISO Date));
emit(jsonUpdateComplete());
updateState = Exoplanets::Updating; updateState = Exoplanets::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 exoplanets"); progressBar->setFormat("Update exoplanets");
progressBar->setVisible(true);
QNetworkRequest request; QNetworkRequest request;
request.setUrl(QUrl(updateUrl)); request.setUrl(QUrl(updateUrl));
request.setRawHeader("User-Agent", QString("Mozilla/5.0 (Stellarium Exoplanets Plugin %1; http://stellarium.org/)").arg(EXOPLANETS_PLUGIN_VERSI ON).toUtf8()); request.setRawHeader("User-Agent", QString("Mozilla/5.0 (Stellarium Exoplanets Plugin %1; http://stellarium.org/)").arg(EXOPLANETS_PLUGIN_VERSI ON).toUtf8());
downloadMgr->get(request); downloadMgr->get(request);
progressBar->setValue(100); updateState = Exoplanets::CompleteUpdates;
delete progressBar;
progressBar = NULL;
updateState = CompleteUpdates;
emit(updateStateChanged(updateState)); emit(updateStateChanged(updateState));
emit(jsonUpdateComplete()); emit(jsonUpdateComplete());
} }
void Exoplanets::updateDownloadComplete(QNetworkReply* reply) void Exoplanets::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() << "Exoplanets::updateDownloadComplete FAILED to download" << reply->url() << " Error: " << reply->errorString(); qWarning() << "Exoplanets::updateDownloadComplete FAILED to download" << reply->url() << " Error: " << reply->errorString();
skipping to change at line 686 skipping to change at line 692
jsonFile.close(); jsonFile.close();
} }
catch (std::runtime_error &e) catch (std::runtime_error &e)
{ {
qWarning() << "Exoplanets::updateDownloadComplete: c annot write JSON data to file:" << e.what(); qWarning() << "Exoplanets::updateDownloadComplete: c annot write JSON data to file:" << e.what();
} }
} }
if (progressBar) if (progressBar)
{
progressBar->setValue(100); progressBar->setValue(100);
delete progressBar;
progressBar = NULL;
}
} }
void Exoplanets::displayMessage(const QString& message, const QString hexCo lor) void Exoplanets::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 Exoplanets::messageTimeout(void) void Exoplanets::messageTimeout(void)
{ {
foreach(int i, messageIDs) foreach(int i, messageIDs)
{ {
GETSTELMODULE(LabelMgr)->deleteLabel(i); GETSTELMODULE(LabelMgr)->deleteLabel(i);
} }
} }
void Exoplanets::upgradeConfigIni(void)
{
// Upgrade settings for Exoplanets plugin
if (conf->contains("Exoplanets/flag_show_exoplanets"))
{
bool b = conf->value("Exoplanets/flag_show_exoplanets", fals
e).toBool();
if (!conf->contains("Exoplanets/enable_at_startup"))
conf->setValue("Exoplanets/enable_at_startup", b);
conf->remove("Exoplanets/flag_show_exoplanets");
}
}
// Define whether the button toggling exoplanets should be visible
void Exoplanets::setFlagShowExoplanetsButton(bool b)
{
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui(
));
if (b==true) {
if (toolbarButton==NULL) {
// Create the exoplanets button
gui->getGuiAction("actionShow_Exoplanets")->setCheck
ed(flagShowExoplanets);
toolbarButton = new StelButton(NULL, *OnIcon, *OffIc
on, *GlowIcon, gui->getGuiAction("actionShow_Exoplanets"));
}
gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr
oup");
} else {
gui->getButtonBar()->hideButton("actionShow_Exoplanets");
}
flagShowExoplanetsButton = b;
}
 End of changes. 43 change blocks. 
52 lines changed or deleted 58 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/