File indexing completed on 2024-04-14 03:43:28
0001 /* 0002 SPDX-FileCopyrightText: 2002 Jason Harris <kstars@30doradus.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QWidget> 0010 0011 class QHBoxLayout; 0012 0013 class TimeSpinBox; 0014 class TimeUnitBox; 0015 0016 /** 0017 * @class TimeStepBox 0018 * @short Composite spinbox for specifying a time step. 0019 * This composite widget consists of a TimeSpinBox (a QSpinBox), coupled with a 0020 * TimeUnitBox (a second pair of up/down buttons). 0021 * The second set of buttons makes larger steps through the 82 possible 0022 * time-step values, skipping to the next even unit of time. 0023 * 0024 * @author Jason Harris 0025 * @version 1.0 0026 */ 0027 class TimeStepBox : public QWidget 0028 { 0029 Q_OBJECT 0030 public: 0031 /** Constructor. */ 0032 explicit TimeStepBox(QWidget *parent = nullptr, bool daysonly = false); 0033 0034 /** @return a pointer to the child TimeSpinBox */ 0035 TimeSpinBox *tsbox() const { return timeBox; } 0036 0037 /** @return a pointer to the child TimeUnitBox */ 0038 TimeUnitBox *unitbox() const { return unitBox; } 0039 0040 bool daysOnly() const { return DaysOnly; } 0041 void setDaysOnly(bool daysonly); 0042 0043 signals: 0044 void scaleChanged(float); 0045 0046 private slots: 0047 /** 0048 * Set the TimeSpinBox value according to the current UnitBox value. 0049 * This is connected to the UnitBox valueChanged() Signal. 0050 */ 0051 void changeUnits(void); 0052 0053 /** 0054 * Make sure the current UnitBox value represents the correct units for the 0055 * current TimeBox value. This slot is connected to the TimeBox valueChanged() Slot. 0056 */ 0057 void syncUnits(int); 0058 0059 private: 0060 bool DaysOnly { false }; 0061 QHBoxLayout *hlay { nullptr }; 0062 TimeSpinBox *timeBox { nullptr }; 0063 TimeUnitBox *unitBox { nullptr }; 0064 };