]>
Commit | Line | Data |
---|---|---|
806d3e1e JS |
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 | |
efdec55a | 17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
806d3e1e JS |
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 | ||
30 | class TimestampSpinBox : public QAbstractSpinBox | |
31 | { | |
32 | Q_OBJECT | |
33 | ||
34 | Q_PROPERTY(unsigned precision | |
35 | READ 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 | |
43 | typedef pv::util::Timestamp Timestamp; | |
44 | ||
45 | Q_PROPERTY(Timestamp singleStep | |
46 | READ singleStep | |
47 | WRITE setSingleStep) | |
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 | ||
870ea3db UH |
89 | } // namespace widgets |
90 | } // namespace pv | |
806d3e1e JS |
91 | |
92 | #endif |