LocationDialog.cpp   LocationDialog.cpp 
skipping to change at line 43 skipping to change at line 43
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#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>
#include <QTimeZone>
LocationDialog::LocationDialog(QObject* parent) LocationDialog::LocationDialog(QObject* parent)
: StelDialog(parent) : StelDialog(parent)
, isEditingNew(false) , isEditingNew(false)
, allModel(NULL) , allModel(NULL)
, pickedModel(NULL) , pickedModel(NULL)
, proxyModel(NULL) , proxyModel(NULL)
{ {
dialogName = "Location"; dialogName = "Location";
ui = new Ui_locationDialogForm; ui = new Ui_locationDialogForm;
skipping to change at line 67 skipping to change at line 68
delete ui; delete ui;
} }
void LocationDialog::retranslate() void LocationDialog::retranslate()
{ {
if (dialog) if (dialog)
{ {
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
populatePlanetList(); populatePlanetList();
populateCountryList(); populateCountryList();
populateTimeZonesList();
} }
} }
void LocationDialog::styleChanged() void LocationDialog::styleChanged()
{ {
// Make the map red if needed // Make the map red if needed
if (dialog) if (dialog)
setMapForLocation(StelApp::getInstance().getCore()->getCurre ntLocation()); setMapForLocation(StelApp::getInstance().getCore()->getCurre ntLocation());
} }
skipping to change at line 116 skipping to change at line 118
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
//Kinetic scrolling for tablet pc and pc //Kinetic scrolling for tablet pc and pc
QList<QWidget *> addscroll; QList<QWidget *> addscroll;
addscroll << ui->citiesListView; addscroll << ui->citiesListView;
installKineticScrolling(addscroll); installKineticScrolling(addscroll);
#endif #endif
populatePlanetList(); populatePlanetList();
populateCountryList(); populateCountryList();
populateTimeZonesList();
connect(ui->citySearchLineEdit, SIGNAL(textChanged(const QString&)), proxyModel, SLOT(setFilterWildcard(const QString&))); connect(ui->citySearchLineEdit, SIGNAL(textChanged(const QString&)), proxyModel, SLOT(setFilterWildcard(const QString&)));
connect(ui->citiesListView, SIGNAL(clicked(const QModelIndex&)), connect(ui->citiesListView, SIGNAL(clicked(const QModelIndex&)),
this, SLOT(setPositionFromList(const QModelIndex&))); this, SLOT(setPositionFromList(const QModelIndex&)));
// Connect all the QT signals // Connect all the QT signals
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMove dTo(QPoint))); connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMove dTo(QPoint)));
connect(ui->mapLabel, SIGNAL(positionChanged(double, double)), this, SLOT(setPositionFromMap(double, double))); connect(ui->mapLabel, SIGNAL(positionChanged(double, double)), this, SLOT(setPositionFromMap(double, double)));
skipping to change at line 140 skipping to change at line 143
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
const StelLocation& currentLocation = core->getCurrentLocation(); const StelLocation& currentLocation = core->getCurrentLocation();
bool b = (currentLocation.getID() == core->getDefaultLocationID()); bool b = (currentLocation.getID() == core->getDefaultLocationID());
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
if (conf->value("init_location/location", "auto").toString() == "aut o") if (conf->value("init_location/location", "auto").toString() == "aut o")
{ {
ui->useIpQueryCheckBox->setChecked(true); ui->useIpQueryCheckBox->setChecked(true);
b = false; b = false;
} }
updateDefaultLocationControls(b);
customTimeZone = conf->value("localization/time_zone", "").toString(
);
if (!customTimeZone.isEmpty())
ui->useCustomTimeZoneCheckBox->setChecked(true);
else
ui->timeZoneNameComboBox->setEnabled(false);
setFieldsFromLocation(currentLocation); setFieldsFromLocation(currentLocation);
updateDefaultLocationControls(b);
connect(ui->useIpQueryCheckBox, SIGNAL(clicked(bool)), this, SLOT(ip QueryLocation(bool))); connect(ui->useIpQueryCheckBox, SIGNAL(clicked(bool)), this, SLOT(ip QueryLocation(bool)));
connect(ui->useAsDefaultLocationCheckBox, SIGNAL(clicked(bool)), thi s, SLOT(setDefaultLocation(bool))); connect(ui->useAsDefaultLocationCheckBox, SIGNAL(clicked(bool)), thi s, SLOT(setDefaultLocation(bool)));
connect(ui->pushButtonReturnToDefault, SIGNAL(clicked()), core, SLOT (returnToDefaultLocation())); connect(ui->pushButtonReturnToDefault, SIGNAL(clicked()), core, SLOT (returnToDefaultLocation()));
connect(ui->useCustomTimeZoneCheckBox, SIGNAL(clicked(bool)), this,
SLOT(updateTimeZoneControls(bool)));
ui->dstCheckBox->setChecked(core->getUseDST());
connect(ui->dstCheckBox, SIGNAL(clicked(bool)), core, SLOT(setUseDST
(bool)));
connectEditSignals(); connectEditSignals();
connect(core, SIGNAL(locationChanged(StelLocation)), this, SLOT(upda teFromProgram(StelLocation))); connect(core, SIGNAL(locationChanged(StelLocation)), this, SLOT(upda teFromProgram(StelLocation)));
ui->citySearchLineEdit->setFocus(); ui->citySearchLineEdit->setFocus();
} }
void LocationDialog::reloadLocations() void LocationDialog::reloadLocations()
{ {
skipping to change at line 195 skipping to change at line 208
} }
} }
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()));
disconnect(ui->timeZoneNameComboBox, SIGNAL(currentIndexChanged(cons t QString&)), this, SLOT(saveTimeZone()));
disconnect(ui->cityNameLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(reportEdit())); disconnect(ui->cityNameLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(reportEdit()));
} }
void LocationDialog::connectEditSignals() void LocationDialog::connectEditSignals()
{ {
connect(ui->longitudeSpinBox, SIGNAL(valueChanged()), this, SLOT(set PositionFromCoords())); connect(ui->longitudeSpinBox, SIGNAL(valueChanged()), this, SLOT(set PositionFromCoords()));
connect(ui->latitudeSpinBox, SIGNAL(valueChanged()), this, SLOT(setP ositionFromCoords())); connect(ui->latitudeSpinBox, SIGNAL(valueChanged()), this, SLOT(setP ositionFromCoords()));
connect(ui->altitudeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(s etPositionFromCoords(int))); connect(ui->altitudeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(s etPositionFromCoords(int)));
connect(ui->planetNameComboBox, SIGNAL(currentIndexChanged(const QSt ring&)), this, SLOT(moveToAnotherPlanet(const QString&))); connect(ui->planetNameComboBox, SIGNAL(currentIndexChanged(const QSt ring&)), this, SLOT(moveToAnotherPlanet(const QString&)));
connect(ui->countryNameComboBox, SIGNAL(currentIndexChanged(const QS tring&)), this, SLOT(reportEdit())); connect(ui->countryNameComboBox, SIGNAL(currentIndexChanged(const QS tring&)), this, SLOT(reportEdit()));
connect(ui->timeZoneNameComboBox, SIGNAL(currentIndexChanged(const Q String&)), this, SLOT(saveTimeZone()));
connect(ui->cityNameLineEdit, SIGNAL(textEdited(const QString&)), th is, SLOT(reportEdit())); connect(ui->cityNameLineEdit, SIGNAL(textEdited(const QString&)), th is, SLOT(reportEdit()));
} }
void LocationDialog::setFieldsFromLocation(const StelLocation& loc) void LocationDialog::setFieldsFromLocation(const StelLocation& loc)
{ {
// Deactivate edit signals // Deactivate edit signals
disconnectEditSignals(); disconnectEditSignals();
ui->cityNameLineEdit->setText(loc.name); ui->cityNameLineEdit->setText(loc.name);
int idx = ui->countryNameComboBox->findData(loc.country, Qt::UserRol e, Qt::MatchCaseSensitive); int idx = ui->countryNameComboBox->findData(loc.country, Qt::UserRol e, Qt::MatchCaseSensitive);
skipping to change at line 233 skipping to change at line 248
ui->latitudeSpinBox->setDegrees(loc.latitude); ui->latitudeSpinBox->setDegrees(loc.latitude);
ui->altitudeSpinBox->setValue(loc.altitude); ui->altitudeSpinBox->setValue(loc.altitude);
idx = ui->planetNameComboBox->findData(loc.planetName, Qt::UserRole, Qt::MatchCaseSensitive); idx = ui->planetNameComboBox->findData(loc.planetName, Qt::UserRole, Qt::MatchCaseSensitive);
if (idx==-1) if (idx==-1)
{ {
// Use Earth as default // Use Earth as default
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);
QString tz = loc.timeZone;
if (loc.planetName=="Earth" && tz.isEmpty())
tz = "system_default";
if (!customTimeZone.isEmpty())
tz = customTimeZone;
idx = ui->timeZoneNameComboBox->findData(tz, Qt::UserRole, Qt::Match
CaseSensitive);
if (idx==-1)
{
if (loc.planetName=="Earth")
tz = "system_default";
else
tz = "LMST";
// Use LMST/system_default as default
idx = ui->timeZoneNameComboBox->findData(tz, Qt::UserRole, Q
t::MatchCaseSensitive);
}
ui->timeZoneNameComboBox->setCurrentIndex(idx);
StelApp::getInstance().getCore()->setCurrentTimeZone(tz);
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()));
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);
skipping to change at line 338 skipping to change at line 372
countries->blockSignals(true); countries->blockSignals(true);
int index = countries->currentIndex(); int index = countries->currentIndex();
QVariant selectedCountryId = countries->itemData(index); QVariant selectedCountryId = countries->itemData(index);
countries->clear(); countries->clear();
//For each country, display the localized name and store the origina l as user //For each country, display the localized name and store the origina l as user
//data. Unfortunately, there's no other way to do this than with a c ycle. //data. Unfortunately, there's no other way to do this than with a c ycle.
foreach(const QString& name, countryNames) foreach(const QString& name, countryNames)
{ {
countries->addItem(q_(name), name); countries->addItem(q_(name), name);
} }
countries->addItem(QChar(0x2014), "");
//Restore the selection //Restore the selection
index = countries->findData(selectedCountryId, Qt::UserRole, Qt::Mat chCaseSensitive); index = countries->findData(selectedCountryId, Qt::UserRole, Qt::Mat chCaseSensitive);
countries->setCurrentIndex(index); countries->setCurrentIndex(index);
countries->model()->sort(0); countries->model()->sort(0);
countries->blockSignals(false); countries->blockSignals(false);
} }
void LocationDialog::populateTimeZonesList()
{
Q_ASSERT(ui->timeZoneNameComboBox);
QComboBox* timeZones = ui->timeZoneNameComboBox;
// Return a list of all the known time zone names (from Qt)
QStringList tzNames;
QList<QByteArray> tzList = QTimeZone::availableTimeZoneIds();
QList<QByteArray>::iterator i;
for (i = tzList.begin(); i!= tzList.end(); ++i)
tzNames.append(*i);
tzNames.sort();
//Save the current selection to be restored later
timeZones->blockSignals(true);
int index = timeZones->currentIndex();
QVariant selectedTzId = timeZones->itemData(index);
timeZones->clear();
//For each time zone, display the localized name and store the origi
nal as user
//data. Unfortunately, there's no other way to do this than with a c
ycle.
foreach(const QString& name, tzNames)
{
timeZones->addItem(name, name);
}
timeZones->addItem(q_("Local Mean Solar Time"), "LMST");
timeZones->addItem(q_("Local True Solar Time"), "LTST");
timeZones->addItem(q_("System default"), "system_default");
//Restore the selection
index = timeZones->findData(selectedTzId, Qt::UserRole, Qt::MatchCas
eSensitive);
timeZones->setCurrentIndex(index);
timeZones->blockSignals(false);
}
// Create a StelLocation instance from the fields // Create a StelLocation instance from the fields
StelLocation LocationDialog::locationFromFields() const StelLocation LocationDialog::locationFromFields() const
{ {
StelLocation loc; StelLocation loc;
int index = ui->planetNameComboBox->currentIndex(); int index = ui->planetNameComboBox->currentIndex();
if (index < 0) if (index < 0)
loc.planetName = QString();//As returned by QComboBox::curre ntText() loc.planetName = QString();//As returned by QComboBox::curre ntText()
else else
loc.planetName = ui->planetNameComboBox->itemData(index).toS tring(); loc.planetName = ui->planetNameComboBox->itemData(index).toS tring();
loc.name = ui->cityNameLineEdit->text().trimmed(); // avoid location s with leading whitespace loc.name = ui->cityNameLineEdit->text().trimmed(); // avoid location s with leading whitespace
loc.latitude = qMin(90.0, qMax(-90.0, ui->latitudeSpinBox->valueDegr ees())); loc.latitude = qMin(90.0, qMax(-90.0, ui->latitudeSpinBox->valueDegr ees()));
loc.longitude = ui->longitudeSpinBox->valueDegrees(); loc.longitude = ui->longitudeSpinBox->valueDegrees();
loc.altitude = ui->altitudeSpinBox->value(); loc.altitude = ui->altitudeSpinBox->value();
index = ui->countryNameComboBox->currentIndex(); index = ui->countryNameComboBox->currentIndex();
if (index < 0) if (index < 0)
loc.country = QString();//As returned by QComboBox::currentT ext() loc.country = QString();//As returned by QComboBox::currentT ext()
else else
loc.country = ui->countryNameComboBox->itemData(index).toStr ing(); loc.country = ui->countryNameComboBox->itemData(index).toStr ing();
index = ui->timeZoneNameComboBox->currentIndex();
if (index < 0)
loc.timeZone = QString(); //As returned by QComboBox::curren
tText()
else
loc.timeZone = ui->timeZoneNameComboBox->itemData(index).toS
tring();
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 orString(index.data().toString()); StelLocation loc = StelApp::getInstance().getLocationMgr().locationF orString(index.data().toString());
setFieldsFromLocation(loc); setFieldsFromLocation(loc);
StelApp::getInstance().getCore()->moveObserverTo(loc, 0.); StelApp::getInstance().getCore()->moveObserverTo(loc, 0.);
skipping to change at line 386 skipping to change at line 462
} }
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;
loc.longitude = longitude; loc.longitude = longitude;
setFieldsFromLocation(loc); setFieldsFromLocation(loc);
StelApp::getInstance().getCore()->moveObserverTo(loc, 0.); StelApp::getInstance().getCore()->moveObserverTo(loc, 0.);
if (customTimeZone.isEmpty())
ui->timeZoneNameComboBox->setCurrentIndex(ui->timeZoneNameCo
mboBox->findData("LMST", Qt::UserRole, Qt::MatchCaseSensitive));
// GZ: Filter location list for nearby sites. I assume Earth locatio ns are better known. With only few locations on other planets in the list, 30 degrees seem OK. // GZ: Filter location list for nearby sites. I assume Earth locatio ns are better known. With only few locations on other planets in the list, 30 degrees seem OK.
LocationMap results = StelApp::getInstance().getLocationMgr().pickLo cationsNearby(loc.planetName, longitude, latitude, loc.planetName=="Earth" ? 3.0f: 30.0f); LocationMap results = StelApp::getInstance().getLocationMgr().pickLo cationsNearby(loc.planetName, longitude, latitude, loc.planetName=="Earth" ? 3.0f: 30.0f);
pickedModel->setStringList(results.keys()); pickedModel->setStringList(results.keys());
proxyModel->setSourceModel(pickedModel); proxyModel->setSourceModel(pickedModel);
proxyModel->sort(0, Qt::AscendingOrder); proxyModel->sort(0, Qt::AscendingOrder);
ui->citySearchLineEdit->clear(); ui->citySearchLineEdit->clear();
} }
// Called when the planet name is changed by hand // Called when the planet name is changed by hand
void LocationDialog::moveToAnotherPlanet(const QString&) void LocationDialog::moveToAnotherPlanet(const QString&)
skipping to change at line 425 skipping to change at line 503
StelLocationMgr &locMgr=StelApp::getInstance().getLocationMg r(); StelLocationMgr &locMgr=StelApp::getInstance().getLocationMg r();
if (loc.planetName == "Earth") if (loc.planetName == "Earth")
{ {
proxyModel->setSourceModel(allModel); proxyModel->setSourceModel(allModel);
} }
else else
{ {
LocationMap results = locMgr.pickLocationsNearby(loc .planetName, 0.0f, 0.0f, 180.0f); LocationMap results = locMgr.pickLocationsNearby(loc .planetName, 0.0f, 0.0f, 180.0f);
pickedModel->setStringList(results.keys()); pickedModel->setStringList(results.keys());
proxyModel->setSourceModel(pickedModel); proxyModel->setSourceModel(pickedModel);
ui->countryNameComboBox->setCurrentIndex(ui->country
NameComboBox->findData("", Qt::UserRole, Qt::MatchCaseSensitive));
if (customTimeZone.isEmpty())
ui->timeZoneNameComboBox->setCurrentIndex(ui
->timeZoneNameComboBox->findData("LMST", Qt::UserRole, Qt::MatchCaseSensiti
ve));
} }
proxyModel->sort(0, Qt::AscendingOrder); proxyModel->sort(0, Qt::AscendingOrder);
ui->citySearchLineEdit->clear(); ui->citySearchLineEdit->clear();
ui->citySearchLineEdit->setFocus(); ui->citySearchLineEdit->setFocus();
} }
// Planet transition time also set to null to prevent uglyness when // Planet transition time also set to null to prevent uglyness when
// "use landscape location" is enabled for that planet's landscape. --BM // "use landscape location" is enabled for that planet's landscape. --BM
// NOTE: I think it also makes sense in the other cases. --BM // NOTE: I think it also makes sense in the other cases. --BM
// FIXME: Avoid the unnecessary change of the location anyway. --BM // FIXME: Avoid the unnecessary change of the location anyway. --BM
stelCore->moveObserverTo(loc, 0., 0.); stelCore->moveObserverTo(loc, 0., 0.);
skipping to change at line 446 skipping to change at line 528
void LocationDialog::setPositionFromCoords(int ) void LocationDialog::setPositionFromCoords(int )
{ {
reportEdit(); reportEdit();
StelLocation loc = locationFromFields(); StelLocation loc = locationFromFields();
StelApp::getInstance().getCore()->moveObserverTo(loc, 0.); StelApp::getInstance().getCore()->moveObserverTo(loc, 0.);
//Update the position of the map pointer //Update the position of the map pointer
ui->mapLabel->setCursorPos(loc.longitude, loc.latitude); ui->mapLabel->setCursorPos(loc.longitude, loc.latitude);
} }
void LocationDialog::saveTimeZone()
{
QString tz = ui->timeZoneNameComboBox->itemData(ui->timeZoneNameComb
oBox->currentIndex()).toString();
StelApp::getInstance().getCore()->setCurrentTimeZone(tz);
if (ui->useCustomTimeZoneCheckBox->isChecked())
StelApp::getInstance().getSettings()->setValue("localization
/time_zone", tz);
}
void LocationDialog::reportEdit() void LocationDialog::reportEdit()
{ {
if (isEditingNew==false) if (isEditingNew==false)
{ {
// The user starts editing manually a field, this creates au tomatically a new location // The user starts editing manually a field, this creates au tomatically a new location
// and allows to save it to the user locations list // and allows to save it to the user locations list
isEditingNew=true; isEditingNew=true;
} }
StelLocation loc = locationFromFields(); StelLocation loc = locationFromFields();
skipping to change at line 476 skipping to change at line 566
} }
else else
{ {
ui->cityNameLineEdit->setText(""); 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()));
ui->timeZoneNameComboBox->setEnabled(isEditingNew && canSave);
} }
// Called when the user clicks on the save button // Called when the user clicks on the save button
void LocationDialog::addCurrentLocationToList() void LocationDialog::addCurrentLocationToList()
{ {
const StelLocation& loc = locationFromFields(); const StelLocation& loc = locationFromFields();
ui->citySearchLineEdit->clear(); ui->citySearchLineEdit->clear();
StelApp::getInstance().getLocationMgr().saveUserLocation(loc); StelApp::getInstance().getLocationMgr().saveUserLocation(loc);
isEditingNew=false; isEditingNew=false;
ui->addLocationToListPushButton->setEnabled(false); ui->addLocationToListPushButton->setEnabled(false);
skipping to change at line 538 skipping to change at line 629
const StelLocation& loc = locationFromFields(); const StelLocation& loc = locationFromFields();
StelApp::getInstance().getLocationMgr().deleteUserLocation(loc.getID ()); StelApp::getInstance().getLocationMgr().deleteUserLocation(loc.getID ());
} }
void LocationDialog::updateDefaultLocationControls(bool currentIsDefault) void LocationDialog::updateDefaultLocationControls(bool currentIsDefault)
{ {
ui->useAsDefaultLocationCheckBox->setChecked(currentIsDefault); ui->useAsDefaultLocationCheckBox->setChecked(currentIsDefault);
ui->useAsDefaultLocationCheckBox->setEnabled(!currentIsDefault); ui->useAsDefaultLocationCheckBox->setEnabled(!currentIsDefault);
} }
void LocationDialog::updateTimeZoneControls(bool useCustomTimeZone)
{
if (useCustomTimeZone)
{
ui->useCustomTimeZoneCheckBox->setChecked(true);
saveTimeZone();
}
else
{
StelLocation loc = StelApp::getInstance().getCore()->getCurr
entLocation();
QString tz = loc.timeZone;
if (loc.planetName=="Earth" && tz.isEmpty())
tz = "system_default";
int idx = ui->timeZoneNameComboBox->findData(tz, Qt::UserRol
e, Qt::MatchCaseSensitive);
if (idx==-1)
{
QString defTZ = "LMST";
if (loc.planetName=="Earth")
defTZ = "system_default";
// Use LMST/system_default as default
idx = ui->timeZoneNameComboBox->findData(defTZ, Qt::
UserRole, Qt::MatchCaseSensitive);
}
ui->timeZoneNameComboBox->setCurrentIndex(idx);
StelApp::getInstance().getSettings()->remove("localization/t
ime_zone");
}
ui->timeZoneNameComboBox->setEnabled(useCustomTimeZone);
}
// called when the user clicks on the IP Query button // called when the user clicks on the IP Query button
void LocationDialog::ipQueryLocation(bool state) void LocationDialog::ipQueryLocation(bool state)
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
if (state) if (state)
{ {
conf->setValue("init_location/location", "auto"); conf->setValue("init_location/location", "auto");
disconnectEditSignals(); disconnectEditSignals();
resetCompleteList(); // in case we are on Moon/Mars, we must get list back to show all (earth) locations... resetCompleteList(); // in case we are on Moon/Mars, we must get list back to show all (earth) locations...
StelLocationMgr &locMgr=StelApp::getInstance().getLocationMg r(); StelLocationMgr &locMgr=StelApp::getInstance().getLocationMg r();
locMgr.locationFromIP(); // This just triggers asynchronous lookup. locMgr.locationFromIP(); // This just triggers asynchronous lookup.
ui->useAsDefaultLocationCheckBox->setChecked(!state); ui->useAsDefaultLocationCheckBox->setChecked(!state);
ui->pushButtonReturnToDefault->setEnabled(!state); ui->pushButtonReturnToDefault->setEnabled(!state);
ui->useCustomTimeZoneCheckBox->setChecked(!state);
updateTimeZoneControls(!state);
connectEditSignals(); connectEditSignals();
ui->citySearchLineEdit->setFocus(); ui->citySearchLineEdit->setFocus();
} }
else else
conf->setValue("init_location/location", StelApp::getInstanc e().getCore()->getCurrentLocation().getID()); conf->setValue("init_location/location", StelApp::getInstanc e().getCore()->getCurrentLocation().getID());
} }
// called when user clicks "reset list" // called when user clicks "reset list"
void LocationDialog::resetCompleteList() void LocationDialog::resetCompleteList()
 End of changes. 18 change blocks. 
1 lines changed or deleted 143 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/