void LocationDialog::retranslate() { if (dialog) { ui->retranslateUi(dialog); populatePlanetList(); populateCountryList(); } }
// 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(); }