LocationDialog.cpp   LocationDialog.cpp 
skipping to change at line 57 skipping to change at line 57
} }
LocationDialog::~LocationDialog() LocationDialog::~LocationDialog()
{ {
delete ui; delete ui;
} }
void LocationDialog::languageChanged() void LocationDialog::languageChanged()
{ {
if (dialog) if (dialog)
{
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
populatePlanetList();
}
} }
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());
} }
// Initialize the dialog widgets and connect the signals/slots // Initialize the dialog widgets and connect the signals/slots
skipping to change at line 86 skipping to change at line 89
ui->longitudeSpinBox->setPrefixType(AngleSpinBox::Longitude); ui->longitudeSpinBox->setPrefixType(AngleSpinBox::Longitude);
ui->latitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols); ui->latitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols);
ui->latitudeSpinBox->setPrefixType(AngleSpinBox::Latitude); ui->latitudeSpinBox->setPrefixType(AngleSpinBox::Latitude);
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel((QAbstractItemModel*)StelApp::getInstance ().getLocationMgr().getModelAll()); proxyModel->setSourceModel((QAbstractItemModel*)StelApp::getInstance ().getLocationMgr().getModelAll());
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);
SolarSystem* ssystem = GETSTELMODULE(SolarSystem); populatePlanetList();
ui->planetNameComboBox->insertItems(0, ssystem->getAllPlanetLocalize
dNames());
ui->countryNameComboBox->insertItems(0, StelLocaleMgr::getAllCountry Names()); ui->countryNameComboBox->insertItems(0, StelLocaleMgr::getAllCountry Names());
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&)), thi s, SLOT(listItemActivated(const QModelIndex&))); connect(ui->citiesListView, SIGNAL(clicked(const QModelIndex&)), thi s, SLOT(listItemActivated(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->mapLabel, SIGNAL(positionChanged(double, double)), this, SLOT(setPositionFromMap(double, double))); connect(ui->mapLabel, SIGNAL(positionChanged(double, double)), this, SLOT(setPositionFromMap(double, double)));
connect(ui->addLocationToListPushButton, SIGNAL(clicked()), this, SL OT(addCurrentLocationToList())); connect(ui->addLocationToListPushButton, SIGNAL(clicked()), this, SL OT(addCurrentLocationToList()));
skipping to change at line 184 skipping to change at line 186
if (idx==-1) if (idx==-1)
{ {
// Use France as default // Use France as default
ui->countryNameComboBox->findText("France", Qt::MatchCaseSen sitive); ui->countryNameComboBox->findText("France", Qt::MatchCaseSen sitive);
} }
ui->countryNameComboBox->setCurrentIndex(idx); ui->countryNameComboBox->setCurrentIndex(idx);
ui->longitudeSpinBox->setDegrees(loc.longitude); ui->longitudeSpinBox->setDegrees(loc.longitude);
ui->latitudeSpinBox->setDegrees(loc.latitude); ui->latitudeSpinBox->setDegrees(loc.latitude);
ui->altitudeSpinBox->setValue(loc.altitude); ui->altitudeSpinBox->setValue(loc.altitude);
SolarSystem* ssystem = GETSTELMODULE(SolarSystem);
idx = ui->planetNameComboBox->findText(ssystem->searchByEnglishName( idx = ui->planetNameComboBox->findData(loc.planetName, Qt::UserRole,
loc.planetName)->getNameI18n(), Qt::MatchCaseSensitive); Qt::MatchCaseSensitive);
if (idx==-1) if (idx==-1)
{ {
// Use Earth as default // Use Earth as default
ui->planetNameComboBox->findText(ssystem->getEarth()->getNam eI18n()); 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()));
// Reactivate edit signals // Reactivate edit signals
skipping to change at line 251 skipping to change at line 253
else else
{ {
ui->mapLabel->setPixmap(pixmap); ui->mapLabel->setPixmap(pixmap);
} }
// For caching // For caching
lastPlanet = loc.planetName; lastPlanet = loc.planetName;
lastVisionMode = StelApp::getInstance().getVisionModeNight(); lastVisionMode = StelApp::getInstance().getVisionModeNight();
} }
void LocationDialog::populatePlanetList()
{
Q_ASSERT(ui);
Q_ASSERT(ui->planetNameComboBox);
QComboBox* planets = ui->planetNameComboBox;
SolarSystem* ssystem = GETSTELMODULE(SolarSystem);
QStringList planetNames(ssystem->getAllPlanetEnglishNames());
//Save the current selection to be restored later
planets->blockSignals(true);
int index = planets->currentIndex();
QVariant selectedPlanetId = planets->itemData(index);
planets->clear();
//For each planet, display the localized name and store the original
as user
//data. Unfortunately, there's no other way to do this than with a c
ycle.
foreach(const QString& name, planetNames)
{
planets->addItem(q_(name), name);
}
//Restore the selection
index = planets->findData(selectedPlanetId, Qt::UserRole, Qt::MatchC
aseSensitive);
planets->setCurrentIndex(index);
planets->blockSignals(false);
}
// Create a StelLocation instance from the fields // Create a StelLocation instance from the fields
StelLocation LocationDialog::locationFromFields() const StelLocation LocationDialog::locationFromFields() const
{ {
SolarSystem* ssystem = GETSTELMODULE(SolarSystem);
StelLocation loc; StelLocation loc;
loc.planetName = ssystem->searchByNameI18n(ui->planetNameComboBox->c int index = ui->planetNameComboBox->currentIndex();
urrentText())->getEnglishName(); if (index < 0)
loc.planetName = QString();//As returned by QComboBox::curre
ntText()
else
loc.planetName = ui->planetNameComboBox->itemData(index).toS
tring();
loc.name = ui->cityNameLineEdit->text(); loc.name = ui->cityNameLineEdit->text();
loc.latitude = ui->latitudeSpinBox->valueDegrees(); loc.latitude = ui->latitudeSpinBox->valueDegrees();
loc.longitude = ui->longitudeSpinBox->valueDegrees(); loc.longitude = ui->longitudeSpinBox->valueDegrees();
loc.altitude = ui->altitudeSpinBox->value(); loc.altitude = ui->altitudeSpinBox->value();
loc.country = ui->countryNameComboBox->currentText(); loc.country = ui->countryNameComboBox->currentText();
return loc; return loc;
} }
void LocationDialog::listItemActivated(const QModelIndex& index) void LocationDialog::listItemActivated(const QModelIndex& index)
{ {
skipping to change at line 305 skipping to change at line 336
if (loc.planetName!=StelApp::getInstance().getCore()->getCurrentLoca tion().planetName) if (loc.planetName!=StelApp::getInstance().getCore()->getCurrentLoca tion().planetName)
setFieldsFromLocation(loc); setFieldsFromLocation(loc);
StelApp::getInstance().getCore()->moveObserverTo(loc, 0.); StelApp::getInstance().getCore()->moveObserverTo(loc, 0.);
} }
void LocationDialog::spinBoxChanged(int ) void LocationDialog::spinBoxChanged(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
ui->mapLabel->setCursorPos(loc.longitude, loc.latitude);
} }
// Called when the location name is manually changed // Called when the location name is manually changed
void LocationDialog::locationNameChanged(const QString&) void LocationDialog::locationNameChanged(const QString&)
{ {
reportEdit(); reportEdit();
} }
void LocationDialog::reportEdit() void LocationDialog::reportEdit()
{ {
skipping to change at line 369 skipping to change at line 402
ui->citiesListView->selectionModel()->select(model-> index(i,0), QItemSelectionModel::ClearAndSelect|QItemSelectionModel::Rows); ui->citiesListView->selectionModel()->select(model-> index(i,0), QItemSelectionModel::ClearAndSelect|QItemSelectionModel::Rows);
listItemActivated(model->index(i,0)); listItemActivated(model->index(i,0));
break; break;
} }
} }
} }
// Called when the user wants to use the current location as default // Called when the user wants to use the current location as default
void LocationDialog::useAsDefaultClicked() void LocationDialog::useAsDefaultClicked()
{ {
StelApp::getInstance().getCore()->setDefaultLocationID(StelApp::getI StelCore* core = StelApp::getInstance().getCore();
nstance().getCore()->getCurrentLocation().getID()); QString newDefaultLocationId = core->getCurrentLocation().getID();
const bool b = StelApp::getInstance().getCore()->getCurrentLocation( core->setDefaultLocationID(newDefaultLocationId);
).getID()==
StelApp::getInstance().getCore()->getDefaultLocation QString currentLocationId = core->getCurrentLocation().getID();
ID(); const bool show = (currentLocationId == core->getDefaultLocationID()
ui->useAsDefaultLocationCheckBox->setChecked(b); );
ui->useAsDefaultLocationCheckBox->setEnabled(!b); disconnectEditSignals();
ui->useAsDefaultLocationCheckBox->setChecked(show);
ui->useAsDefaultLocationCheckBox->setEnabled(!show);
//The focus need to be switched to another control, otherwise
//ui->latitudeSpinBox receives it and emits a valueChanged() signal
when
//the window is closed.
ui->citySearchLineEdit->setFocus();
connectEditSignals();
} }
// Called when the user clic on the delete button // Called when the user clic on the delete button
void LocationDialog::deleteCurrentLocationFromList() void LocationDialog::deleteCurrentLocationFromList()
{ {
const StelLocation& loc = locationFromFields(); const StelLocation& loc = locationFromFields();
StelApp::getInstance().getLocationMgr().deleteUserLocation(loc.getID ()); StelApp::getInstance().getLocationMgr().deleteUserLocation(loc.getID ());
} }
 End of changes. 10 change blocks. 
18 lines changed or deleted 62 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/