LocationDialog.cpp   LocationDialog.cpp 
skipping to change at line 48 skipping to change at line 48
#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("Location", parent) : StelDialog("Location", parent)
, isEditingNew(false) , isEditingNew(false)
, allModel(NULL) , allModel(Q_NULLPTR)
, pickedModel(NULL) , pickedModel(Q_NULLPTR)
, proxyModel(NULL) , proxyModel(Q_NULLPTR)
{ {
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 100 skipping to change at line 100
ui->longitudeSpinBox->setWrapping(true); ui->longitudeSpinBox->setWrapping(true);
ui->latitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols); ui->latitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols);
ui->latitudeSpinBox->setPrefixType(AngleSpinBox::Latitude); ui->latitudeSpinBox->setPrefixType(AngleSpinBox::Latitude);
ui->latitudeSpinBox->setMinimum(-90.0, true); ui->latitudeSpinBox->setMinimum(-90.0, true);
ui->latitudeSpinBox->setMaximum( 90.0, true); ui->latitudeSpinBox->setMaximum( 90.0, true);
ui->latitudeSpinBox->setWrapping(false); ui->latitudeSpinBox->setWrapping(false);
//initialize list model //initialize list model
allModel = new QStringListModel(this); allModel = new QStringListModel(this);
pickedModel = new QStringListModel(this); pickedModel = new QStringListModel(this);
connect(&StelApp::getInstance().getLocationMgr(), SIGNAL(locationLis StelLocationMgr *locMgr=&(StelApp::getInstance().getLocationMgr());
tChanged()), this, SLOT(reloadLocations())); connect(locMgr, SIGNAL(locationListChanged()), this, SLOT(reloadLoca
tions()));
reloadLocations(); reloadLocations();
proxyModel = new QSortFilterProxyModel(ui->citiesListView); proxyModel = new QSortFilterProxyModel(ui->citiesListView);
proxyModel->setSourceModel(allModel); proxyModel->setSourceModel(allModel);
proxyModel->sort(0, Qt::AscendingOrder); proxyModel->sort(0, Qt::AscendingOrder);
proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui->citiesListView->setModel(proxyModel); ui->citiesListView->setModel(proxyModel);
#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;
skipping to change at line 152 skipping to change at line 153
updateDefaultLocationControls(b); updateDefaultLocationControls(b);
customTimeZone = conf->value("localization/time_zone", "").toString( ); customTimeZone = conf->value("localization/time_zone", "").toString( );
if (!customTimeZone.isEmpty()) if (!customTimeZone.isEmpty())
ui->useCustomTimeZoneCheckBox->setChecked(true); ui->useCustomTimeZoneCheckBox->setChecked(true);
else else
ui->timeZoneNameComboBox->setEnabled(false); ui->timeZoneNameComboBox->setEnabled(false);
setFieldsFromLocation(currentLocation); setFieldsFromLocation(currentLocation);
#ifdef ENABLE_GPS
connect(ui->gpsPushButton, SIGNAL(clicked(bool)), this, SLOT(gpsQuer
yLocation()));
connect(locMgr, SIGNAL(gpsQueryFinished(bool)), this, SLOT(gpsReturn
(bool)));
#else
ui->gpsPushButton->setEnabled(false);
ui->gpsPushButton->hide();
#endif
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))); connect(ui->useCustomTimeZoneCheckBox, SIGNAL(clicked(bool)), this, SLOT(updateTimeZoneControls(bool)));
ui->dstCheckBox->setChecked(core->getUseDST()); ui->dstCheckBox->setChecked(core->getUseDST());
connect(ui->dstCheckBox, SIGNAL(clicked(bool)), core, SLOT(setUseDST (bool))); 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::handleDialogSizeChanged(QSizeF size)
{
StelDialog::handleDialogSizeChanged(size);
StelLocation loc = locationFromFields();
ui->mapLabel->setCursorPos(loc.longitude, loc.latitude);
}
void LocationDialog::reloadLocations() void LocationDialog::reloadLocations()
{ {
allModel->setStringList(StelApp::getInstance().getLocationMgr().getA llMap().keys()); allModel->setStringList(StelApp::getInstance().getLocationMgr().getA llMap().keys());
} }
// Update the widget to make sure it is synchrone if the location is change d programmatically // Update the widget to make sure it is synchrone if the location is change d programmatically
void LocationDialog::updateFromProgram(const StelLocation& currentLocation) void LocationDialog::updateFromProgram(const StelLocation& currentLocation)
{ {
if (!dialog->isVisible()) if (!dialog->isVisible())
return; return;
skipping to change at line 415 skipping to change at line 430
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!? // TODO: Handle notfound!?
Q_ASSERT(index!=-1); //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();
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 = qBound(-90.0, ui->latitudeSpinBox->valueDegrees(), 90 .0);
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)
skipping to change at line 527 skipping to change at line 542
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.);
} }
void LocationDialog::setPositionFromCoords(int ) void LocationDialog::setPositionFromCoords(int i)
{ {
Q_UNUSED(i)
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();
skipping to change at line 692 skipping to change at line 708
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); ui->useCustomTimeZoneCheckBox->setChecked(!state);
updateTimeZoneControls(!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());
}
#ifdef ENABLE_GPS
// called when the user clicks on the GPS Query button. Use gpsd or Qt's NM
EA reader.
void LocationDialog::gpsQueryLocation()
{
disconnectEditSignals();
ui->gpsPushButton->setText(q_("GPS..."));
//only use a single call from a service class here
StelApp::getInstance().getLocationMgr().locationFromGPS();
} }
void LocationDialog::gpsReturn(bool success)
{
if (success)
{
StelCore* core = StelApp::getInstance().getCore();
ui->gpsPushButton->setText(q_("GPS:SUCCESS"));
ui->useAsDefaultLocationCheckBox->setChecked(false);
ui->pushButtonReturnToDefault->setEnabled(true);
ui->useCustomTimeZoneCheckBox->setChecked(true);
resetCompleteList(); // in case we come back from Moon/Mars,
we must get list back to show all (earth) locations...
updateTimeZoneControls(true);
StelLocation loc=core->getCurrentLocation();
setFieldsFromLocation(loc);
}
else
{
ui->gpsPushButton->setText(q_("GPS:FAILED"));
}
connectEditSignals();
ui->citySearchLineEdit->setFocus();
// Use QTimer to reset the labels after 2 seconds.
QTimer::singleShot(2000, this, SLOT(resetGPSbuttonLabel()));
}
void LocationDialog::resetGPSbuttonLabel()
{
ui->gpsPushButton->setText(q_("Get location from GPS"));
}
#endif
// called when user clicks "reset list" // called when user clicks "reset list"
void LocationDialog::resetCompleteList() void LocationDialog::resetCompleteList()
{ {
//reset search before setting model, prevents unnecessary search in full list //reset search before setting model, prevents unnecessary search in full list
ui->citySearchLineEdit->clear(); ui->citySearchLineEdit->clear();
ui->citySearchLineEdit->setFocus(); ui->citySearchLineEdit->setFocus();
proxyModel->setSourceModel(allModel); proxyModel->setSourceModel(allModel);
proxyModel->sort(0, Qt::AscendingOrder); proxyModel->sort(0, Qt::AscendingOrder);
} }
 End of changes. 11 change blocks. 
8 lines changed or deleted 70 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/