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, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef PULSEVIEW_PV_WIDGETS_TIMESTAMPSPINBOX_HPP
22 #define PULSEVIEW_PV_WIDGETS_TIMESTAMPSPINBOX_HPP
24 #include "pv/util.hpp"
26 #include <QAbstractSpinBox>
31 class TimestampSpinBox : public QAbstractSpinBox
35 Q_PROPERTY(unsigned precision
39 // Needed because of some strange behaviour of the Qt4 MOC that would add
40 // a reference to a 'staticMetaObject' member of 'pv::util' (the namespace)
41 // if pv::util::Timestamp is used directly in the Q_PROPERTY macros below.
42 // Didn't happen with the Qt5 MOC in this case, however others have had
43 // similar problems with Qt5: https://bugreports.qt.io/browse/QTBUG-37519
44 typedef pv::util::Timestamp Timestamp;
46 Q_PROPERTY(Timestamp singleStep
50 Q_PROPERTY(Timestamp value
57 TimestampSpinBox(QWidget* parent = nullptr);
59 void stepBy(int steps) override;
61 StepEnabled stepEnabled() const override;
63 unsigned precision() const;
64 void setPrecision(unsigned precision);
66 const pv::util::Timestamp& singleStep() const;
67 void setSingleStep(const pv::util::Timestamp& step);
69 const pv::util::Timestamp& value() const;
71 QSize minimumSizeHint() const override;
74 void setValue(const pv::util::Timestamp& val);
77 void valueChanged(const pv::util::Timestamp&);
80 void on_editingFinished();
84 pv::util::Timestamp stepsize_;
85 pv::util::Timestamp value_;