PulseView  unreleased development snapshot
A Qt-based sigrok GUI
timestampspinbox.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the PulseView project.
3  *
4  * Copyright (C) 2015 Jens Steinhauser <jens.steinhauser@gmail.com>
5  *
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.
10  *
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.
15  *
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/>.
18  */
19 
20 #ifndef PULSEVIEW_PV_WIDGETS_TIMESTAMPSPINBOX_HPP
21 #define PULSEVIEW_PV_WIDGETS_TIMESTAMPSPINBOX_HPP
22 
23 #include "pv/util.hpp"
24 
25 #include <QAbstractSpinBox>
26 
27 namespace pv {
28 namespace widgets {
29 
31 {
32  Q_OBJECT
33 
34  Q_PROPERTY(unsigned precision
36  WRITE setPrecision)
37 
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
44 
45  Q_PROPERTY(Timestamp singleStep
48 
49  Q_PROPERTY(Timestamp value
50  READ value
51  WRITE setValue
52  NOTIFY valueChanged
53  USER true)
54 
55 public:
56  TimestampSpinBox(QWidget* parent = nullptr);
57 
58  void stepBy(int steps) override;
59 
60  StepEnabled stepEnabled() const override;
61 
62  unsigned precision() const;
63  void setPrecision(unsigned precision);
64 
65  const pv::util::Timestamp& singleStep() const;
66  void setSingleStep(const pv::util::Timestamp& step);
67 
68  const pv::util::Timestamp& value() const;
69 
70  QSize minimumSizeHint() const override;
71 
72 public Q_SLOTS:
73  void setValue(const pv::util::Timestamp& val);
74 
75 Q_SIGNALS:
76  void valueChanged(const pv::util::Timestamp&);
77 
78 private Q_SLOTS:
79  void on_editingFinished();
80 
81 private:
82  unsigned precision_;
83  pv::util::Timestamp stepsize_;
84  pv::util::Timestamp value_;
85 
86  void updateEdit();
87 };
88 
89 } // namespace widgets
90 } // namespace pv
91 
92 #endif // PULSEVIEW_PV_WIDGETS_TIMESTAMPSPINBOX_HPP
QSize minimumSizeHint() const override
void setPrecision(unsigned precision)
void valueChanged(const pv::util::Timestamp &)
void setSingleStep(const pv::util::Timestamp &step)
void stepBy(int steps) override
void setValue(const pv::util::Timestamp &val)
StepEnabled stepEnabled() const override
const pv::util::Timestamp & singleStep() const
const pv::util::Timestamp & value() const
util
Definition: CMakeCache.txt:655