// Update the widget to make sure it is synchrone if the location is changed programmatically void LocationDialog::updateFromProgram(const StelLocation& currentLocation) { if (!dialog->isVisible()) return; StelCore* stelCore = StelApp::getInstance().getCore(); isEditingNew = false; // Check that the use as default check box needs to be updated // Move to setFieldsFromLocation()? --BM? const bool b = currentLocation.getID() == stelCore->getDefaultLocationID(); QSettings* conf = StelApp::getInstance().getSettings(); if (conf->value("init_location/location", "auto").toString() != ("auto")) { updateDefaultLocationControls(b); ui->pushButtonReturnToDefault->setEnabled(!b); } const QString& key1 = currentLocation.getID(); const QString& key2 = locationFromFields().getID(); if (key1!=key2) { setFieldsFromLocation(currentLocation); } LandscapeMgr *lmgr = GETSTELMODULE(LandscapeMgr); if (lmgr->getFlagUseLightPollutionFromDatabase()) { int bidx = currentLocation.bortleScaleIndex; if (!currentLocation.planetName.contains("Earth")) // location not on Earth... bidx = 1; if (bidx<1) // ...or it observatory, or it unknown location bidx = currentLocation.DEFAULT_BORTLE_SCALE_INDEX; stelCore->getSkyDrawer()->setBortleScaleIndex(bidx); lmgr->setAtmosphereBortleLightPollution(bidx); } }
void LocationDialog::setFieldsFromLocation(const StelLocation& loc) { // Deactivate edit signals disconnectEditSignals(); ui->cityNameLineEdit->setText(loc.name); int idx = ui->countryNameComboBox->findData(loc.country, Qt::UserRole, Qt::MatchCaseSensitive); if (idx==-1) { // Use France as default ui->countryNameComboBox->findData(QVariant("France"), Qt::UserRole, Qt::MatchCaseSensitive); } ui->countryNameComboBox->setCurrentIndex(idx); ui->longitudeSpinBox->setDegrees(loc.longitude); ui->latitudeSpinBox->setDegrees(loc.latitude); ui->altitudeSpinBox->setValue(loc.altitude); idx = ui->planetNameComboBox->findData(loc.planetName, Qt::UserRole, Qt::MatchCaseSensitive); if (idx==-1) { // Use Earth as default idx = ui->planetNameComboBox->findData(QVariant("Earth"), Qt::UserRole, Qt::MatchCaseSensitive); } ui->planetNameComboBox->setCurrentIndex(idx); setMapForLocation(loc); // Set pointer position ui->mapLabel->setCursorPos(loc.longitude, loc.latitude); ui->deleteLocationFromListPushButton->setEnabled(StelApp::getInstance().getLocationMgr().canDeleteUserLocation(loc.getID())); // Reactivate edit signals connectEditSignals(); }
void LocationDialog::setFieldsFromLocation(const StelLocation& loc) { // Deactivate edit signals disconnectEditSignals(); ui->cityNameLineEdit->setText(loc.name); int idx = ui->countryNameComboBox->findData(loc.country, Qt::UserRole, Qt::MatchCaseSensitive); if (idx==-1) { // Use France as default ui->countryNameComboBox->findData(QVariant("France"), Qt::UserRole, Qt::MatchCaseSensitive); } ui->countryNameComboBox->setCurrentIndex(idx); ui->longitudeSpinBox->setDegrees(loc.longitude); ui->latitudeSpinBox->setDegrees(loc.latitude); ui->altitudeSpinBox->setValue(loc.altitude); idx = ui->planetNameComboBox->findData(loc.planetName, Qt::UserRole, Qt::MatchCaseSensitive); if (idx==-1) { // Use Earth as default idx = ui->planetNameComboBox->findData(QVariant("Earth"), Qt::UserRole, Qt::MatchCaseSensitive); } ui->planetNameComboBox->setCurrentIndex(idx); setMapForLocation(loc); // Set pointer position ui->mapLabel->setCursorPos(loc.longitude, loc.latitude); ui->deleteLocationFromListPushButton->setEnabled(StelApp::getInstance().getLocationMgr().canDeleteUserLocation(loc.getID())); SolarSystem* ssm = GETSTELMODULE(SolarSystem); PlanetP p = ssm->searchByEnglishName(loc.planetName); LandscapeMgr* ls = GETSTELMODULE(LandscapeMgr); if (ls->getFlagAtmosphereAutoEnable()) { if (loc.planetName != StelApp::getInstance().getCore()->getCurrentLocation().planetName) { QSettings* conf = StelApp::getInstance().getSettings(); ls->setFlagAtmosphere(p->hasAtmosphere() & conf->value("landscape/flag_atmosphere", true).toBool()); ls->setFlagFog(p->hasAtmosphere() & conf->value("landscape/flag_fog", true).toBool()); } } // Reactivate edit signals connectEditSignals(); }