// Update the widget to make sure it is synchrone if the location is changed programmatically void LocationDialog::updateFromProgram(const StelLocation& currentLocation) { if (!dialog->isVisible()) return; StelCore* stelCore = StelApp::getInstance().getCore(); isEditingNew = false; // Check that the use as default check box needs to be updated // Move to setFieldsFromLocation()? --BM? const bool b = currentLocation.getID() == stelCore->getDefaultLocationID(); QSettings* conf = StelApp::getInstance().getSettings(); if (conf->value("init_location/location", "auto").toString() != ("auto")) { updateDefaultLocationControls(b); ui->pushButtonReturnToDefault->setEnabled(!b); } const QString& key1 = currentLocation.getID(); const QString& key2 = locationFromFields().getID(); if (key1!=key2) { setFieldsFromLocation(currentLocation); } LandscapeMgr *lmgr = GETSTELMODULE(LandscapeMgr); if (lmgr->getFlagUseLightPollutionFromDatabase()) { int bidx = currentLocation.bortleScaleIndex; if (!currentLocation.planetName.contains("Earth")) // location 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); } }
// Initialize the dialog widgets and connect the signals/slots void LocationDialog::createDialogContent() { // We try to directly connect to the observer slots as much as we can ui->setupUi(dialog); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); // Init the SpinBox entries ui->longitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols); ui->longitudeSpinBox->setPrefixType(AngleSpinBox::Longitude); ui->longitudeSpinBox->setMinimum(-180.0, true); ui->longitudeSpinBox->setMaximum( 180.0, true); ui->longitudeSpinBox->setWrapping(true); ui->latitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols); ui->latitudeSpinBox->setPrefixType(AngleSpinBox::Latitude); ui->latitudeSpinBox->setMinimum(-90.0, true); ui->latitudeSpinBox->setMaximum( 90.0, true); ui->latitudeSpinBox->setWrapping(false); QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel((QAbstractItemModel*)StelApp::getInstance().getLocationMgr().getModelAll()); proxyModel->sort(0, Qt::AscendingOrder); proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); ui->citiesListView->setModel(proxyModel); #ifdef Q_OS_WIN //Kinetic scrolling for tablet pc and pc QList<QWidget *> addscroll; addscroll << ui->citiesListView; installKineticScrolling(addscroll); #endif populatePlanetList(); populateCountryList(); connect(ui->citySearchLineEdit, SIGNAL(textChanged(const QString&)), proxyModel, SLOT(setFilterWildcard(const QString&))); connect(ui->citiesListView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(setPositionFromList(const QModelIndex&))); // Connect all the QT signals connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint))); connect(ui->mapLabel, SIGNAL(positionChanged(double, double)), this, SLOT(setPositionFromMap(double, double))); connect(ui->addLocationToListPushButton, SIGNAL(clicked()), this, SLOT(addCurrentLocationToList())); connect(ui->deleteLocationFromListPushButton, SIGNAL(clicked()), this, SLOT(deleteCurrentLocationFromList())); connect(ui->resetListPushButton, SIGNAL(clicked()), this, SLOT(resetCompleteList())); connect(ui->countryNameComboBox, SIGNAL(activated(const QString &)), this, SLOT(filterSitesByCountry())); StelCore* core = StelApp::getInstance().getCore(); const StelLocation& currentLocation = core->getCurrentLocation(); bool b = (currentLocation.getID() == core->getDefaultLocationID()); QSettings* conf = StelApp::getInstance().getSettings(); if (conf->value("init_location/location", "auto").toString() == "auto") { ui->useIpQueryCheckBox->setChecked(true); b = false; } setFieldsFromLocation(currentLocation); updateDefaultLocationControls(b); connect(ui->useIpQueryCheckBox, SIGNAL(clicked(bool)), this, SLOT(ipQueryLocation(bool))); connect(ui->useAsDefaultLocationCheckBox, SIGNAL(clicked(bool)), this, SLOT(setDefaultLocation(bool))); connect(ui->pushButtonReturnToDefault, SIGNAL(clicked()), core, SLOT(returnToDefaultLocation())); connectEditSignals(); connect(core, SIGNAL(locationChanged(StelLocation)), this, SLOT(updateFromProgram(StelLocation))); ui->citySearchLineEdit->setFocus(); }