Kstars

timeunitbox.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 <QWidget>
10#include <QAction>
11
12class QToolButton;
13
14#define TUB_ALLUNITS 8
15
16/**
17 * @class TimeUnitBox
18 * @short Provides a second set of up/down buttons for TimeStepBox.
19 * A pair of buttons, arranged one above the other, labeled "+"/"-". These buttons
20 * are to be paired with the TimeSpinBox widget. Their function is to provide
21 * a way to cycle through the possible time steps using larger intervals than the up/down
22 * buttons of the TimeSpinBox. For example, say the Spinbox currently shows a timestep of
23 * "1 sec". Increasing the timestep with the spinbox up-button will change it to
24 * "2 sec", while using the "+" button of this widget will change it to "1 min".
25 *
26 * The idea is that these "outer" buttons always change to the next even unit of time.
27 *
28 * @note this widget is not to be used on its own; it is combined with the TimeSpinBox
29 * widget to form the TimeStepBox composite widget.
30 *
31 * @author Jason Harris
32 * @version 1.0
33 */
34
35class QToolButton;
36
37class TimeUnitBox : public QWidget
38{
40
41 public:
42 /** Constructor */
43 explicit TimeUnitBox(QWidget *parent = nullptr, bool daysonly = false);
44
45 /** @return the value of UnitStep for the current spinbox value() */
46 int unitValue();
47
48 /**
49 * @short the same as unitValue, except you can get the UnitStep for any value, not just the current one.
50 * @return the value of UnitStep for the index value given as an argument.
51 */
52 int getUnitValue(int);
53
54 /**
55 * Set the value which describes which time-unit is displayed in the TimeSpinBox.
56 * @p value the new value
57 */
58 void setValue(int value) { Value = value; }
59 /** @return the internal value describing the time-unit of the TimeSpinBox. */
60 int value() const { return Value; }
61
62 /** Set the minimum value for the internal time-unit value */
63 void setMinimum(int minValue) { MinimumValue = minValue; }
64 /** Set the maximum value for the internal time-unit value */
65 void setMaximum(int maxValue) { MaximumValue = maxValue; }
66
67 /** @return the minimum value for the internal time-unit value */
68 int minValue() const { return MinimumValue; }
69 /** @return the maximum value for the internal time-unit value */
70 int maxValue() const { return MaximumValue; }
71
72 bool daysOnly() const { return DaysOnly; }
73 void setDaysOnly(bool daysonly);
74
75 QAction *increaseUnitsAction() const { return IncreaseAction; }
76 QAction *decreaseUnitsAction() const { return DecreaseAction; }
77
78 signals:
79 void valueChanged(int);
80
81 private slots:
82 /** Increment the internal time-unit value */
83 void increase();
84 /** Decrement the internal time-unit value */
85 void decrease();
86
87 private:
88 bool DaysOnly { false };
89 QToolButton *UpButton { nullptr };
90 QToolButton *DownButton { nullptr };
91 QAction *IncreaseAction { nullptr };
92 QAction *DecreaseAction { nullptr };
93 int MinimumValue { 0 };
94 int MaximumValue { 0 };
95 int Value { 0 };
96 int UnitStep[TUB_ALLUNITS];
97};
Provides a second set of up/down buttons for TimeStepBox.
Definition timeunitbox.h:38
void setMinimum(int minValue)
Set the minimum value for the internal time-unit value.
Definition timeunitbox.h:63
int value() const
Definition timeunitbox.h:60
int getUnitValue(int)
the same as unitValue, except you can get the UnitStep for any value, not just the current one.
int maxValue() const
Definition timeunitbox.h:70
TimeUnitBox(QWidget *parent=nullptr, bool daysonly=false)
Constructor.
void setMaximum(int maxValue)
Set the maximum value for the internal time-unit value.
Definition timeunitbox.h:65
int minValue() const
Definition timeunitbox.h:68
void setValue(int value)
Set the value which describes which time-unit is displayed in the TimeSpinBox.
Definition timeunitbox.h:58
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.