Kstars

timespinbox.h
1/*
2 SPDX-FileCopyrightText: 2002 Jason Harris <kstars@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QSpinBox>
10#include <QStringList>
11
12/**
13 * @class TimeSpinBox
14 * Custom spinbox to handle selection of timestep values with variable units.
15 * @note this should only be used internally, embedded in a TimeStepBox widget.
16 *
17 * @author Jason Harris
18 * @version 1.0
19 */
20class TimeSpinBox : public QSpinBox
21{
23 public:
24 /** Constructor */
25 explicit TimeSpinBox(QWidget *parent, bool daysOnly = false);
26 /** Destructor (empty) */
27 ~TimeSpinBox() override = default;
28
29 /**
30 * Convert the internal value to a display string.
31 * @note reimplemented from QSpinBox
32 * @p value the internal value to convert to a display string
33 * @return the display string
34 */
35 QString textFromValue(int value) const override;
36
37 /**
38 * Convert the displayed string to an internal value.
39 * @note reimplemented from QSpinBox
40 * @p ok bool pointer set to true if conversion was successful
41 * @return internal value converted from displayed text
42 */
43 int valueFromText(const QString &text) const override;
44
45 /** @return the current TimeStep setting */
46 float timeScale() const;
47
48 void setDaysOnly(bool daysonly);
49 bool daysOnly() const { return DaysOnly; }
50
51 signals:
52 void scaleChanged(float s);
53
54 public slots:
55 void changeScale(float s);
56
57 protected slots:
58 void reportChange();
59
60 private:
61 bool DaysOnly { false };
62 float TimeScale[43];
63 QStringList TimeString;
64};
Custom spinbox to handle selection of timestep values with variable units.
TimeSpinBox(QWidget *parent, bool daysOnly=false)
Constructor.
QString textFromValue(int value) const override
Convert the internal value to a display string.
~TimeSpinBox() override=default
Destructor (empty)
float timeScale() const
int valueFromText(const QString &text) const override
Convert the displayed string to an internal value.
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:49:23 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.