7#include "timespinbox.h"
9#include "kstars_debug.h"
11#include <KLocalizedString>
18#define SECS_PER_DAY 86400.
19#define SIDEREAL_YEAR 31558149.77
32 setDaysOnly(_daysonly);
46 for (
int i = 0; i <
maximum(); ++i)
59void TimeSpinBox::setDaysOnly(
bool daysonly)
77 TimeScale[11] = 120.0;
78 TimeScale[12] = 300.0;
79 TimeScale[13] = 600.0;
80 TimeScale[14] = 900.0;
81 TimeScale[15] = 1800.0;
82 TimeScale[16] = 3600.0;
83 TimeScale[17] = 7200.0;
84 TimeScale[18] = 10800.0;
85 TimeScale[19] = 21600.0;
86 TimeScale[20] = 43200.0;
89 TimeScale[i + 1] = 86164.1;
90 TimeScale[i + 2] = SECS_PER_DAY;
91 TimeScale[i + 3] = 2. * SECS_PER_DAY;
92 TimeScale[i + 4] = 3. * SECS_PER_DAY;
93 TimeScale[i + 5] = 5. * SECS_PER_DAY;
94 TimeScale[i + 6] = 7. * SECS_PER_DAY;
95 TimeScale[i + 7] = 14. * SECS_PER_DAY;
96 TimeScale[i + 8] = 21. * SECS_PER_DAY;
98 TimeScale[i + 9] = SIDEREAL_YEAR / 12.0;
99 TimeScale[i + 10] = SIDEREAL_YEAR / 6.0;
100 TimeScale[i + 11] = 0.25 * SIDEREAL_YEAR;
101 TimeScale[i + 12] = SIDEREAL_YEAR / 3.0;
102 TimeScale[i + 13] = 0.5 * SIDEREAL_YEAR;
103 TimeScale[i + 14] = 0.75 * SIDEREAL_YEAR;
104 TimeScale[i + 15] = SIDEREAL_YEAR;
105 TimeScale[i + 16] = 2.0 * SIDEREAL_YEAR;
106 TimeScale[i + 17] = 3.0 * SIDEREAL_YEAR;
107 TimeScale[i + 18] = 5.0 * SIDEREAL_YEAR;
108 TimeScale[i + 19] = 10.0 * SIDEREAL_YEAR;
109 TimeScale[i + 20] = 25.0 * SIDEREAL_YEAR;
110 TimeScale[i + 21] = 50.0 * SIDEREAL_YEAR;
111 TimeScale[i + 22] = 100.0 * SIDEREAL_YEAR;
116 TimeString.
append(
"0 " +
i18nc(
"seconds",
"secs"));
117 TimeString.
append(
"0.1 " +
i18nc(
"seconds",
"secs"));
118 TimeString.
append(
"0.25 " +
i18nc(
"seconds",
"secs"));
119 TimeString.
append(
"0.5 " +
i18nc(
"seconds",
"secs"));
121 TimeString.
append(
"2 " +
i18nc(
"seconds",
"secs"));
122 TimeString.
append(
"5 " +
i18nc(
"seconds",
"secs"));
123 TimeString.
append(
"10 " +
i18nc(
"seconds",
"secs"));
124 TimeString.
append(
"20 " +
i18nc(
"seconds",
"secs"));
125 TimeString.
append(
"30 " +
i18nc(
"seconds",
"secs"));
127 TimeString.
append(
"2 " +
i18nc(
"minutes",
"mins"));
128 TimeString.
append(
"5 " +
i18nc(
"minutes",
"mins"));
129 TimeString.
append(
"10 " +
i18nc(
"minutes",
"mins"));
130 TimeString.
append(
"15 " +
i18nc(
"minutes",
"mins"));
131 TimeString.
append(
"30 " +
i18nc(
"minutes",
"mins"));
142 TimeString.
append(
"1 " +
i18nc(
"sidereal day",
"sid day"));
177int TimeSpinBox::valueFromText(
const QString &text)
const
179 for (
int i = 0; i < TimeString.
size(); i++)
181 if (
text == TimeString[i])
185 if (
text.mid(1,
text.length()) == TimeString[i])
194QString TimeSpinBox::textFromValue(
int value)
const
197 int posval(abs(
value));
199 if (posval > TimeString.
size() - 1)
202 result = TimeString[posval];
206 result =
'-' + result;
211void TimeSpinBox::changeScale(
float x)
215 float dxlast(10000000000.0), dxmin(10000000000.0);
217 for (
unsigned int i = 0; i < 42; ++i)
219 float dx = fabs(TimeScale[i] - fabs(
x));
237float TimeSpinBox::timeScale(
void)
const
239 return value() > 0 ? TimeScale[
value()] : -1. * TimeScale[abs(
value())];
242void TimeSpinBox::reportChange()
244 qCDebug(KSTARS) <<
"Reporting new timestep value: " << timeScale();
245 emit scaleChanged(timeScale());
TimeSpinBox(QWidget *parent, bool daysOnly=false)
Constructor.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QLineEdit * lineEdit() const const
int horizontalAdvance(QChar ch) const const
void append(QList< T > &&value)
qsizetype size() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void setSingleStep(int val)