diff --git a/plugins/channelrx/radioastronomy/radioastronomygui.cpp b/plugins/channelrx/radioastronomy/radioastronomygui.cpp index 9e196804f..83ad6ccce 100644 --- a/plugins/channelrx/radioastronomy/radioastronomygui.cpp +++ b/plugins/channelrx/radioastronomy/radioastronomygui.cpp @@ -2596,9 +2596,13 @@ void RadioAstronomyGUI::updateRotatorList(const QListrotator->findText(m_settings.m_rotator); - if (rotatorIndex >= 0) { + if (rotatorIndex >= 0) + { ui->rotator->setCurrentIndex(rotatorIndex); - } else { + setColumnPrecisionFromRotator(); + } + else + { ui->rotator->setCurrentIndex(0); // return to None } @@ -2709,6 +2713,36 @@ void RadioAstronomyGUI::on_rotator_currentTextChanged(const QString& text) { m_settings.m_rotator = text; applySettings(); + setColumnPrecisionFromRotator(); +} + +void RadioAstronomyGUI::setColumnPrecisionFromRotator() +{ + // Match rotator precision + const QRegExp re("F([0-9]+):([0-9]+)"); + if (re.indexIn(m_settings.m_rotator) >= 0) + { + int featureSetIndex = re.capturedTexts()[1].toInt(); + int featureIndex = re.capturedTexts()[2].toInt(); + + int precision = 0; + if (ChannelWebAPIUtils::getFeatureSetting(featureSetIndex, featureIndex, "precision", precision)) + { + int old = ((DecimalDelegate *)ui->powerTable->itemDelegateForColumn(POWER_COL_GAL_LAT))->getPrecision(); + ((DecimalDelegate *)ui->powerTable->itemDelegateForColumn(POWER_COL_GAL_LAT))->setPrecision(precision); + ((DecimalDelegate *)ui->powerTable->itemDelegateForColumn(POWER_COL_GAL_LON))->setPrecision(precision); + ((DecimalDelegate *)ui->powerTable->itemDelegateForColumn(POWER_COL_AZ))->setPrecision(precision); + ((DecimalDelegate *)ui->powerTable->itemDelegateForColumn(POWER_COL_EL))->setPrecision(precision); + if (precision > old) + { + ui->powerTable->resizeColumnToContents(POWER_COL_GAL_LAT); + ui->powerTable->resizeColumnToContents(POWER_COL_GAL_LON); + ui->powerTable->resizeColumnToContents(POWER_COL_AZ); + ui->powerTable->resizeColumnToContents(POWER_COL_EL); + } + ui->powerTable->viewport()->update(); + } + } } void RadioAstronomyGUI::on_showSensors_clicked() diff --git a/plugins/channelrx/radioastronomy/radioastronomygui.h b/plugins/channelrx/radioastronomy/radioastronomygui.h index 527af32b1..96fcdd595 100644 --- a/plugins/channelrx/radioastronomy/radioastronomygui.h +++ b/plugins/channelrx/radioastronomy/radioastronomygui.h @@ -449,6 +449,7 @@ private: void calcPowerChartTickCount(int width); void calcSpectrumChartTickCount(QValueAxis *axis, int width); int powerYUnitsToIndex(RadioAstronomySettings::PowerYUnits units); + void setColumnPrecisionFromRotator(); void leaveEvent(QEvent*); void enterEvent(EnterEventType*); diff --git a/sdrgui/gui/decimaldelegate.h b/sdrgui/gui/decimaldelegate.h index 25754c1ef..daa7dd0c5 100644 --- a/sdrgui/gui/decimaldelegate.h +++ b/sdrgui/gui/decimaldelegate.h @@ -29,6 +29,8 @@ public: DecimalDelegate(int precision = 2); virtual QString displayText(const QVariant &value, const QLocale &locale) const override; + int getPrecision() const { return m_precision; } + void setPrecision(int precision) { m_precision = precision; } private: int m_precision;