Skip to content

Commit

Permalink
Hips: store and retrieve selected surveys.
Browse files Browse the repository at this point in the history
Also store and retrieve active status.
  • Loading branch information
gzotti committed Mar 19, 2018
1 parent ac81447 commit 9444a55
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/StelApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,9 @@ void StelApp::init(QSettings* conf)
localeMgr->init();

// Hips surveys
HipsMgr* hips = new HipsMgr();
hips->init();
getModuleMgr().registerModule(hips);
HipsMgr* hipsMgr = new HipsMgr();
hipsMgr->init();
getModuleMgr().registerModule(hipsMgr);

// Init the solar system first
SolarSystem* ssystem = new SolarSystem();
Expand Down
49 changes: 49 additions & 0 deletions src/core/modules/HipsMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,35 @@
HipsMgr::HipsMgr()
{
setObjectName("HipsMgr");
connect(this, SIGNAL(surveysChanged()), this, SLOT(restoreVisibleSurveys()));
}

HipsMgr::~HipsMgr()
{
//store active HIPS to config.ini
QSettings* conf = StelApp::getInstance().getSettings();
conf->beginGroup("hips");
conf->setValue("show", getFlagShow());
conf->beginGroup("visible");
if (surveys.count()>0)
conf->remove(""); // Don't clear list in case of just a short offline period.
for (auto survey: surveys)
{
if (survey->isVisible() && survey->planet.isEmpty())
{
conf->setValue(survey->getUrl(), "true");
}
}
conf->endGroup();
conf->endGroup();
conf->sync();
}

void HipsMgr::init()
{
QSettings* conf = StelApp::getInstance().getSettings();
conf->beginGroup("hips");
setFlagShow(conf->value("show", true).toBool());

// Start to load survey lists
QStringList sources;
Expand Down Expand Up @@ -74,11 +93,41 @@ void HipsMgr::init()
emit surveysChanged();
});
}

conf->endGroup();

addAction("actionShow_Hips_Surveys", N_("Display Options"), N_("Toggle Hierarchical Progressive Surveys (experimental)"), "flagShow", "Ctrl+Alt+D");
}


void HipsMgr::restoreVisibleSurveys()
{
//qDebug() << "HipsMgr::restoreVisibleSurveys()";
QSettings* conf = StelApp::getInstance().getSettings();
conf->beginGroup("hips");

// // restore visible state of last run, if possible
// for (auto survey: surveys)
// {
// qDebug() << "Known Survey: " << survey->getUrl();
// }
conf->beginGroup("visible");
for (QString key : conf->allKeys())
{
if (conf->value(key).toBool()==true)
{
// We have to restore one slash after colon.
QString realURL=key.replace(":/", "://");
qDebug() << "HIPS: Restore visible survey:" << realURL;
HipsSurveyP survey=getSurveyByUrl(realURL);
if (survey)
survey->setVisible(true);
}
}
conf->endGroup();
conf->endGroup();
}

void HipsMgr::deinit()
{
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/modules/HipsMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class HipsMgr : public StelModule
//! Emitted when a new survey has been loaded.
void gotNewSurvey(HipsSurveyP survey) const;

private slots:
// after loading survey list from network, restore the visible surveys from config.ini.
void restoreVisibleSurveys();

private:
QList<HipsSurveyP> surveys;
bool visible = true;
Expand Down

0 comments on commit 9444a55

Please sign in to comment.