LocationDialog.cpp   LocationDialog.cpp 
skipping to change at line 44 skipping to change at line 44
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include <QFrame> #include <QFrame>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QTimer> #include <QTimer>
#include <QStringListModel> #include <QStringListModel>
LocationDialog::LocationDialog() : isEditingNew(false) LocationDialog::LocationDialog(QObject* parent) : StelDialog(parent), isEdi tingNew(false)
{ {
ui = new Ui_locationDialogForm; ui = new Ui_locationDialogForm;
lastVisionMode = StelApp::getInstance().getVisionModeNight();
} }
LocationDialog::~LocationDialog() LocationDialog::~LocationDialog()
{ {
delete ui; delete ui;
} }
void LocationDialog::retranslate() void LocationDialog::retranslate()
{ {
if (dialog) if (dialog)
skipping to change at line 150 skipping to change at line 149
// Move to setFieldsFromLocation()? --BM? // Move to setFieldsFromLocation()? --BM?
const bool b = currentLocation.getID() == stelCore->getDefaultLocati onID(); const bool b = currentLocation.getID() == stelCore->getDefaultLocati onID();
updateDefaultLocationControls(b); updateDefaultLocationControls(b);
const QString& key1 = currentLocation.getID(); const QString& key1 = currentLocation.getID();
const QString& key2 = locationFromFields().getID(); const QString& key2 = locationFromFields().getID();
if (key1!=key2) if (key1!=key2)
{ {
setFieldsFromLocation(currentLocation); setFieldsFromLocation(currentLocation);
} }
LandscapeMgr *lmgr = GETSTELMODULE(LandscapeMgr);
if (lmgr->getFlagUseLightPollutionFromDatabase())
{
int bidx = currentLocation.bortleScaleIndex;
if (!currentLocation.planetName.contains("Earth")) // locati
on 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::disconnectEditSignals() void LocationDialog::disconnectEditSignals()
{ {
disconnect(ui->longitudeSpinBox, SIGNAL(valueChanged()), this, SLOT( setPositionFromCoords())); disconnect(ui->longitudeSpinBox, SIGNAL(valueChanged()), this, SLOT( setPositionFromCoords()));
disconnect(ui->latitudeSpinBox, SIGNAL(valueChanged()), this, SLOT(s etPositionFromCoords())); disconnect(ui->latitudeSpinBox, SIGNAL(valueChanged()), this, SLOT(s etPositionFromCoords()));
disconnect(ui->altitudeSpinBox, SIGNAL(valueChanged(int)), this, SLO T(setPositionFromCoords(int))); disconnect(ui->altitudeSpinBox, SIGNAL(valueChanged(int)), this, SLO T(setPositionFromCoords(int)));
disconnect(ui->planetNameComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(moveToAnotherPlanet(const QString&))); disconnect(ui->planetNameComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(moveToAnotherPlanet(const QString&)));
disconnect(ui->countryNameComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(reportEdit())); disconnect(ui->countryNameComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(reportEdit()));
// Why an edit should be reported even if the country is not changed ? --BM // Why an edit should be reported even if the country is not changed ? --BM
skipping to change at line 210 skipping to change at line 221
idx = ui->planetNameComboBox->findData(QVariant("Earth"), Qt ::UserRole, Qt::MatchCaseSensitive); idx = ui->planetNameComboBox->findData(QVariant("Earth"), Qt ::UserRole, Qt::MatchCaseSensitive);
} }
ui->planetNameComboBox->setCurrentIndex(idx); ui->planetNameComboBox->setCurrentIndex(idx);
setMapForLocation(loc); setMapForLocation(loc);
// Set pointer position // Set pointer position
ui->mapLabel->setCursorPos(loc.longitude, loc.latitude); ui->mapLabel->setCursorPos(loc.longitude, loc.latitude);
ui->deleteLocationFromListPushButton->setEnabled(StelApp::getInstanc e().getLocationMgr().canDeleteUserLocation(loc.getID())); ui->deleteLocationFromListPushButton->setEnabled(StelApp::getInstanc e().getLocationMgr().canDeleteUserLocation(loc.getID()));
QSettings* conf = StelApp::getInstance().getSettings();
bool atmosphere = conf->value("landscape/flag_atmosphere", true).toB
ool();
bool fog = conf->value("landscape/flag_fog", true).toBool();
SolarSystem* ssm = GETSTELMODULE(SolarSystem); SolarSystem* ssm = GETSTELMODULE(SolarSystem);
PlanetP p = ssm->searchByEnglishName(loc.planetName); PlanetP p = ssm->searchByEnglishName(loc.planetName);
LandscapeMgr* ls = GETSTELMODULE(LandscapeMgr); LandscapeMgr* ls = GETSTELMODULE(LandscapeMgr);
ls->setFlagAtmosphere(p->hasAtmosphere() & atmosphere); if (ls->getFlagAtmosphereAutoEnable())
ls->setFlagFog(p->hasAtmosphere() & fog); {
QSettings* conf = StelApp::getInstance().getSettings();
ls->setFlagAtmosphere(p->hasAtmosphere() & conf->value("land
scape/flag_atmosphere", true).toBool());
ls->setFlagFog(p->hasAtmosphere() & conf->value("landscape/f
lag_fog", true).toBool());
}
// Reactivate edit signals // Reactivate edit signals
connectEditSignals(); connectEditSignals();
} }
// Update the map for the given location. // Update the map for the given location.
void LocationDialog::setMapForLocation(const StelLocation& loc) void LocationDialog::setMapForLocation(const StelLocation& loc)
{ {
// Avoids usless processing // Avoids usless processing
if (lastPlanet==loc.planetName && lastVisionMode==StelApp::getInstan ce().getVisionModeNight()) if (lastPlanet==loc.planetName)
return; return;
QPixmap pixmap; QPixmap pixmap;
// Try to set the proper planet map image // Try to set the proper planet map image
if (loc.planetName=="Earth") if (loc.planetName=="Earth")
{ {
// Special case for earth, we don't want to see the clouds // Special case for earth, we don't want to see the clouds
pixmap = QPixmap(":/graphicGui/world.png"); pixmap = QPixmap(":/graphicGui/world.png");
} }
else else
{ {
SolarSystem* ssm = GETSTELMODULE(SolarSystem); SolarSystem* ssm = GETSTELMODULE(SolarSystem);
PlanetP p = ssm->searchByEnglishName(loc.planetName); PlanetP p = ssm->searchByEnglishName(loc.planetName);
QString path;
if (p) if (p)
{ {
try QString path = StelFileMgr::findFile("textures/"+p->
{ getTextMapName());
path = StelFileMgr::findFile("textures/"+p-> if (path.isEmpty())
getTextMapName());
}
catch (std::runtime_error& e)
{ {
qWarning() << "ERROR - could not find planet map for " << loc.planetName << e.what(); qWarning() << "ERROR - could not find planet map for " << loc.planetName;
return; return;
} }
pixmap = QPixmap(path); pixmap = QPixmap(path);
} }
} }
ui->mapLabel->setPixmap(pixmap);
if (StelApp::getInstance().getVisionModeNight())
{
ui->mapLabel->setPixmap(StelButton::makeRed(pixmap));
}
else
{
ui->mapLabel->setPixmap(pixmap);
}
// For caching // For caching
lastPlanet = loc.planetName; lastPlanet = loc.planetName;
lastVisionMode = StelApp::getInstance().getVisionModeNight();
} }
void LocationDialog::populatePlanetList() void LocationDialog::populatePlanetList()
{ {
Q_ASSERT(ui->planetNameComboBox); Q_ASSERT(ui->planetNameComboBox);
QComboBox* planets = ui->planetNameComboBox; QComboBox* planets = ui->planetNameComboBox;
SolarSystem* ssystem = GETSTELMODULE(SolarSystem); SolarSystem* ssystem = GETSTELMODULE(SolarSystem);
QStringList planetNames(ssystem->getAllPlanetEnglishNames()); QStringList planetNames(ssystem->getAllPlanetEnglishNames());
skipping to change at line 349 skipping to change at line 347
else else
loc.country = ui->countryNameComboBox->itemData(index).toStr ing(); loc.country = ui->countryNameComboBox->itemData(index).toStr ing();
return loc; return loc;
} }
void LocationDialog::setPositionFromList(const QModelIndex& index) void LocationDialog::setPositionFromList(const QModelIndex& index)
{ {
isEditingNew=false; isEditingNew=false;
ui->addLocationToListPushButton->setEnabled(false); ui->addLocationToListPushButton->setEnabled(false);
StelLocation loc = StelApp::getInstance().getLocationMgr().locationF
StelLocation loc = StelApp::getInstance().getLocationMgr().locationF orString(index.data().toString());
orSmallString(index.data().toString());
setFieldsFromLocation(loc); setFieldsFromLocation(loc);
StelApp::getInstance().getCore()->moveObserverTo(loc, 0.); StelApp::getInstance().getCore()->moveObserverTo(loc, 0.);
// This calls indirectly updateFromProgram() // This calls indirectly updateFromProgram()
} }
void LocationDialog::setPositionFromMap(double longitude, double latitude) void LocationDialog::setPositionFromMap(double longitude, double latitude)
{ {
reportEdit(); reportEdit();
StelLocation loc = locationFromFields(); StelLocation loc = locationFromFields();
loc.latitude = latitude; loc.latitude = latitude;
skipping to change at line 427 skipping to change at line 423
{ {
if (ui->cityNameLineEdit->hasFocus()) if (ui->cityNameLineEdit->hasFocus())
{ {
// The user is editing the location name: don't chan ge it! // The user is editing the location name: don't chan ge it!
ui->addLocationToListPushButton->setEnabled(false); ui->addLocationToListPushButton->setEnabled(false);
ui->deleteLocationFromListPushButton->setEnabled(fal se); ui->deleteLocationFromListPushButton->setEnabled(fal se);
return; return;
} }
else else
{ {
ui->cityNameLineEdit->setText(q_("New Location")); ui->cityNameLineEdit->setText("");
ui->cityNameLineEdit->selectAll(); ui->cityNameLineEdit->selectAll();
loc = locationFromFields(); loc = locationFromFields();
} }
} }
ui->addLocationToListPushButton->setEnabled(isEditingNew && canSave) ; ui->addLocationToListPushButton->setEnabled(isEditingNew && canSave) ;
ui->deleteLocationFromListPushButton->setEnabled(locationMgr.canDele teUserLocation(loc.getID())); ui->deleteLocationFromListPushButton->setEnabled(locationMgr.canDele teUserLocation(loc.getID()));
} }
// Called when the user clic on the save button // Called when the user clic on the save button
void LocationDialog::addCurrentLocationToList() void LocationDialog::addCurrentLocationToList()
 End of changes. 13 change blocks. 
33 lines changed or deleted 31 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/