LocationDialog.cpp   LocationDialog.cpp 
skipping to change at line 46 skipping to change at line 46
#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> #include <QTimeZone>
LocationDialog::LocationDialog(QObject* parent) LocationDialog::LocationDialog(QObject* parent)
: StelDialog(parent) : StelDialog("Location", parent)
, isEditingNew(false) , isEditingNew(false)
, allModel(NULL) , allModel(NULL)
, pickedModel(NULL) , pickedModel(NULL)
, proxyModel(NULL) , proxyModel(NULL)
{ {
dialogName = "Location";
ui = new Ui_locationDialogForm; ui = new Ui_locationDialogForm;
} }
LocationDialog::~LocationDialog() LocationDialog::~LocationDialog()
{ {
delete ui; delete ui;
} }
void LocationDialog::retranslate() void LocationDialog::retranslate()
{ {
skipping to change at line 249 skipping to change at line 248
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; QString tz = loc.ianaTimeZone;
if (loc.planetName=="Earth" && tz.isEmpty()) if (loc.planetName=="Earth" && tz.isEmpty())
tz = "system_default"; tz = "system_default";
if (!customTimeZone.isEmpty()) if (!customTimeZone.isEmpty())
tz = customTimeZone; tz = customTimeZone;
idx = ui->timeZoneNameComboBox->findData(tz, Qt::UserRole, Qt::Match CaseSensitive); idx = ui->timeZoneNameComboBox->findData(tz, Qt::UserRole, Qt::Match CaseSensitive);
if (idx==-1) if (idx==-1)
{ {
if (loc.planetName=="Earth") if (loc.planetName=="Earth")
tz = "system_default"; tz = "system_default";
else else
skipping to change at line 388 skipping to change at line 387
} }
void LocationDialog::populateTimeZonesList() void LocationDialog::populateTimeZonesList()
{ {
Q_ASSERT(ui->timeZoneNameComboBox); Q_ASSERT(ui->timeZoneNameComboBox);
QComboBox* timeZones = ui->timeZoneNameComboBox; QComboBox* timeZones = ui->timeZoneNameComboBox;
// Return a list of all the known time zone names (from Qt) // Return a list of all the known time zone names (from Qt)
QStringList tzNames; QStringList tzNames;
QList<QByteArray> tzList = QTimeZone::availableTimeZoneIds(); QList<QByteArray> tzList = QTimeZone::availableTimeZoneIds(); // Sys tem dependent set of IANA timezone names.
QList<QByteArray>::iterator i; QList<QByteArray>::iterator i;
for (i = tzList.begin(); i!= tzList.end(); ++i) for (i = tzList.begin(); i!= tzList.end(); ++i)
{
tzNames.append(*i); tzNames.append(*i);
// Activate this to get a list of known TZ names...
//qDebug() << "Qt/IANA TZ entry: " << *i;
}
tzNames.sort(); tzNames.sort();
//Save the current selection to be restored later //Save the current selection to be restored later
timeZones->blockSignals(true); timeZones->blockSignals(true);
int index = timeZones->currentIndex(); int index = timeZones->currentIndex();
QVariant selectedTzId = timeZones->itemData(index); QVariant selectedTzId = timeZones->itemData(index);
timeZones->clear(); timeZones->clear();
//For each time zone, display the localized name and store the origi nal as user //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. //data. Unfortunately, there's no other way to do this than with a l oop.
foreach(const QString& name, tzNames) foreach(const QString& name, tzNames)
{ {
timeZones->addItem(name, name); timeZones->addItem(name, name);
} }
timeZones->addItem(q_("Local Mean Solar Time"), "LMST"); timeZones->addItem(q_("Local Mean Solar Time"), "LMST");
timeZones->addItem(q_("Local True Solar Time"), "LTST"); timeZones->addItem(q_("Local True Solar Time"), "LTST");
timeZones->addItem(q_("System default"), "system_default"); timeZones->addItem(q_("System default"), "system_default");
//Restore the selection //Restore the selection
index = timeZones->findData(selectedTzId, Qt::UserRole, Qt::MatchCas eSensitive); index = timeZones->findData(selectedTzId, Qt::UserRole, Qt::MatchCas eSensitive);
// TODO: Handle notfound!?
Q_ASSERT(index!=-1);
timeZones->setCurrentIndex(index); timeZones->setCurrentIndex(index);
timeZones->blockSignals(false); 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();
skipping to change at line 437 skipping to change at line 442
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(); index = ui->timeZoneNameComboBox->currentIndex();
if (index < 0) if (index < 0)
loc.timeZone = QString(); //As returned by QComboBox::curren tText() loc.ianaTimeZone = QString(); //As returned by QComboBox::cu rrentText()
else else
loc.timeZone = ui->timeZoneNameComboBox->itemData(index).toS {
tring(); QString tz=ui->timeZoneNameComboBox->itemData(index).toStrin
g();
loc.ianaTimeZone = tz;
}
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);
skipping to change at line 531 skipping to change at line 539
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() void LocationDialog::saveTimeZone()
{ {
QString tz = ui->timeZoneNameComboBox->itemData(ui->timeZoneNameComb oBox->currentIndex()).toString(); QString tz = ui->timeZoneNameComboBox->itemData(ui->timeZoneNameComb oBox->currentIndex()).toString();
StelApp::getInstance().getCore()->setCurrentTimeZone(tz); StelCore* core = StelApp::getInstance().getCore();
core->setCurrentTimeZone(tz);
if (ui->useCustomTimeZoneCheckBox->isChecked()) if (ui->useCustomTimeZoneCheckBox->isChecked())
{
StelApp::getInstance().getSettings()->setValue("localization /time_zone", tz); StelApp::getInstance().getSettings()->setValue("localization /time_zone", tz);
core->setUseCustomTimeZone(true);
}
} }
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;
} }
skipping to change at line 638 skipping to change at line 650
void LocationDialog::updateTimeZoneControls(bool useCustomTimeZone) void LocationDialog::updateTimeZoneControls(bool useCustomTimeZone)
{ {
if (useCustomTimeZone) if (useCustomTimeZone)
{ {
ui->useCustomTimeZoneCheckBox->setChecked(true); ui->useCustomTimeZoneCheckBox->setChecked(true);
saveTimeZone(); saveTimeZone();
} }
else else
{ {
StelLocation loc = StelApp::getInstance().getCore()->getCurr StelCore* core = StelApp::getInstance().getCore();
entLocation(); StelLocation loc = core->getCurrentLocation();
QString tz = loc.timeZone; QString tz = loc.ianaTimeZone;
if (loc.planetName=="Earth" && tz.isEmpty()) if (loc.planetName=="Earth" && tz.isEmpty())
tz = "system_default"; tz = "system_default";
int idx = ui->timeZoneNameComboBox->findData(tz, Qt::UserRol e, Qt::MatchCaseSensitive); int idx = ui->timeZoneNameComboBox->findData(tz, Qt::UserRol e, Qt::MatchCaseSensitive);
if (idx==-1) if (idx==-1)
{ {
QString defTZ = "LMST"; QString defTZ = "LMST";
if (loc.planetName=="Earth") if (loc.planetName=="Earth")
defTZ = "system_default"; defTZ = "system_default";
// Use LMST/system_default as default // Use LMST/system_default as default
idx = ui->timeZoneNameComboBox->findData(defTZ, Qt:: UserRole, Qt::MatchCaseSensitive); idx = ui->timeZoneNameComboBox->findData(defTZ, Qt:: UserRole, Qt::MatchCaseSensitive);
} }
ui->timeZoneNameComboBox->setCurrentIndex(idx); ui->timeZoneNameComboBox->setCurrentIndex(idx);
StelApp::getInstance().getSettings()->remove("localization/t ime_zone"); StelApp::getInstance().getSettings()->remove("localization/t ime_zone");
core->setUseCustomTimeZone(false);
} }
ui->timeZoneNameComboBox->setEnabled(useCustomTimeZone); 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)
 End of changes. 15 change blocks. 
12 lines changed or deleted 25 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/