Kstars

exposurewidget.cpp
1/*
2 SPDX-FileCopyrightText: 2024 John Evans <john.e.evans.email@googlemail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include <cmath>
8#include "exposurewidget.h"
9
10ExposureWidget::ExposureWidget(QWidget *parent) : QDoubleSpinBox(parent)
11{
12}
13
14ExposureWidget::~ExposureWidget()
15{
16}
17
18QString ExposureWidget::textFromValue(double value) const
19{
20 int count = 0;
21 const double delta = std::pow(10, -decimals() - 1);
22 double v = value;
23 for (int i = 0; i < decimals(); i++)
24 {
25 v = v - long(v + delta);
26 if (v < std::pow(10, (-decimals() + i)))
27 break;
28 count++;
29 v *= 10;
30 }
31 return QWidget::locale().toString(value, u'f', std::max(3, count));
32}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.