void LocationDialog::setFieldsFromLocation(const StelLocation& loc) { // Deactivate edit signals disconnectEditSignals(); ui->cityNameLineEdit->setText(loc.name); int idx = ui->countryNameComboBox->findData(loc.country, Qt::UserRole, Qt::MatchCaseSensitive); if (idx==-1) { // Use France as default ui->countryNameComboBox->findData(QVariant("France"), Qt::UserRole, Qt::MatchCaseSensitive); } ui->countryNameComboBox->setCurrentIndex(idx); ui->longitudeSpinBox->setDegrees(loc.longitude); ui->latitudeSpinBox->setDegrees(loc.latitude); ui->altitudeSpinBox->setValue(loc.altitude); idx = ui->planetNameComboBox->findData(loc.planetName, Qt::UserRole, Qt::MatchCaseSensitive); if (idx==-1) { // Use Earth as default idx = ui->planetNameComboBox->findData(QVariant("Earth"), Qt::UserRole, Qt::MatchCaseSensitive); } ui->planetNameComboBox->setCurrentIndex(idx); setMapForLocation(loc); // Set pointer position ui->mapLabel->setCursorPos(loc.longitude, loc.latitude); ui->deleteLocationFromListPushButton->setEnabled(StelApp::getInstance().getLocationMgr().canDeleteUserLocation(loc.getID())); // Reactivate edit signals connectEditSignals(); }
void LocationDialog::setFieldsFromLocation(const StelLocation& loc) { // Deactivate edit signals disconnectEditSignals(); ui->cityNameLineEdit->setText(loc.name); int idx = ui->countryNameComboBox->findData(loc.country, Qt::UserRole, Qt::MatchCaseSensitive); if (idx==-1) { // Use France as default ui->countryNameComboBox->findData(QVariant("France"), Qt::UserRole, Qt::MatchCaseSensitive); } ui->countryNameComboBox->setCurrentIndex(idx); ui->longitudeSpinBox->setDegrees(loc.longitude); ui->latitudeSpinBox->setDegrees(loc.latitude); ui->altitudeSpinBox->setValue(loc.altitude); idx = ui->planetNameComboBox->findData(loc.planetName, Qt::UserRole, Qt::MatchCaseSensitive); if (idx==-1) { // Use Earth as default idx = ui->planetNameComboBox->findData(QVariant("Earth"), Qt::UserRole, Qt::MatchCaseSensitive); } ui->planetNameComboBox->setCurrentIndex(idx); setMapForLocation(loc); // Set pointer position ui->mapLabel->setCursorPos(loc.longitude, loc.latitude); ui->deleteLocationFromListPushButton->setEnabled(StelApp::getInstance().getLocationMgr().canDeleteUserLocation(loc.getID())); SolarSystem* ssm = GETSTELMODULE(SolarSystem); PlanetP p = ssm->searchByEnglishName(loc.planetName); LandscapeMgr* ls = GETSTELMODULE(LandscapeMgr); if (ls->getFlagAtmosphereAutoEnable()) { if (loc.planetName != StelApp::getInstance().getCore()->getCurrentLocation().planetName) { QSettings* conf = StelApp::getInstance().getSettings(); ls->setFlagAtmosphere(p->hasAtmosphere() & conf->value("landscape/flag_atmosphere", true).toBool()); ls->setFlagFog(p->hasAtmosphere() & conf->value("landscape/flag_fog", true).toBool()); } } // Reactivate edit signals connectEditSignals(); }
// 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->latitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols); ui->latitudeSpinBox->setPrefixType(AngleSpinBox::Latitude); 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); populatePlanetList(); populateCountryList(); connect(ui->citySearchLineEdit, SIGNAL(textChanged(const QString&)), proxyModel, SLOT(setFilterWildcard(const QString&))); connect(ui->citiesListView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(listItemActivated(const QModelIndex&))); // Connect all the QT signals connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); 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())); setFieldsFromLocation(StelApp::getInstance().getCore()->getCurrentLocation()); const bool b = StelApp::getInstance().getCore()->getCurrentLocation().getID() ==StelApp::getInstance().getCore()->getDefaultLocationID(); ui->useAsDefaultLocationCheckBox->setChecked(b); ui->useAsDefaultLocationCheckBox->setEnabled(!b); connect(ui->useAsDefaultLocationCheckBox, SIGNAL(clicked()), this, SLOT(useAsDefaultClicked())); SensorMgr* sensorMgr = (SensorMgr*)StelApp::getInstance().getModuleMgr().getModule("SensorMgr"); if(sensorMgr->getGpsPermitted()) { bool bg = StelApp::getInstance().getCore()->getUseGPS(); bg = !bg; bg = !bg; qDebug() << "getUseGPS(): " << bg; ui->useGPScheckBox->setChecked(bg); } else { qDebug() << "Disable GPS checkbox"; ui->useGPScheckBox->setChecked(false); ui->useGPScheckBox->setEnabled(false); } connect(ui->useGPScheckBox, SIGNAL(clicked()), this, SLOT(useGPSClicked())); connectEditSignals(); QTimer* refreshTimer = new QTimer(this); connect(refreshTimer, SIGNAL(timeout()), this, SLOT(updateFromProgram())); refreshTimer->start(200); ui->citySearchLineEdit->setFocus(); }
// 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(); }