2 * This file is part of the PulseView project.
4 * Copyright (C) 2015 Jens Steinhauser <jens.steinhauser@gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef PULSEVIEW_PV_WIDGETS_TIMESTAMPSPINBOX_HPP
21 #define PULSEVIEW_PV_WIDGETS_TIMESTAMPSPINBOX_HPP
23 #include "pv/util.hpp"
25 #include <QAbstractSpinBox>
30 class TimestampSpinBox : public QAbstractSpinBox
34 Q_PROPERTY(unsigned precision
38 // Needed because of some strange behaviour of the Qt4 MOC that would add
39 // a reference to a 'staticMetaObject' member of 'pv::util' (the namespace)
40 // if pv::util::Timestamp is used directly in the Q_PROPERTY macros below.
41 // Didn't happen with the Qt5 MOC in this case, however others have had
42 // similar problems with Qt5: https://bugreports.qt.io/browse/QTBUG-37519
43 typedef pv::util::Timestamp Timestamp;
45 Q_PROPERTY(Timestamp singleStep
49 Q_PROPERTY(Timestamp value
56 TimestampSpinBox(QWidget* parent = nullptr);
58 void stepBy(int steps) override;
60 StepEnabled stepEnabled() const override;
62 unsigned precision() const;
63 void setPrecision(unsigned precision);
65 const pv::util::Timestamp& singleStep() const;
66 void setSingleStep(const pv::util::Timestamp& step);
68 const pv::util::Timestamp& value() const;
70 QSize minimumSizeHint() const override;
73 void setValue(const pv::util::Timestamp& val);
76 void valueChanged(const pv::util::Timestamp&);
79 void on_editingFinished();
83 pv::util::Timestamp stepsize_;
84 pv::util::Timestamp value_;
89 } // namespace widgets