itom  4.1.0
doubleSlider.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom and its software development toolkit (SDK).
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  In addition, as a special exception, the Institut fuer Technische
15  Optik (ITO) gives you certain additional rights.
16  These rights are described in the ITO LGPL Exception version 1.0,
17  which can be found in the file LGPL_EXCEPTION.txt in this package.
18 
19  itom is distributed in the hope that it will be useful, but
20  WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22  General Public Licence for more details.
23 
24  You should have received a copy of the GNU Library General Public License
25  along with itom. If not, see <http://www.gnu.org/licenses/>.
26 
27  This file is a port and modified version of the
28  Common framework (http://www.commontk.org)
29 *********************************************************************** */
30 
31 #ifndef DOUBLESLIDER_H
32 #define DOUBLESLIDER_H
33 
34 // Qt includes
35 #include <QSlider>
36 #include <QWidget>
37 
38 #include "commonWidgets.h"
39 
41 class ValueProxy;
42 
52 class ITOMWIDGETS_EXPORT DoubleSlider : public QWidget
53 {
54  Q_OBJECT
55  Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true)
56  Q_PROPERTY(double sliderPosition READ sliderPosition WRITE setSliderPosition)
57  Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
58  Q_PROPERTY(double pageStep READ pageStep WRITE setPageStep)
59  Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
60  Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
61  Q_PROPERTY(double tickInterval READ tickInterval WRITE setTickInterval)
62  Q_PROPERTY(QSlider::TickPosition tickPosition READ tickPosition WRITE setTickPosition)
63  Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking)
64  Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
65  Q_PROPERTY(QString handleToolTip READ handleToolTip WRITE setHandleToolTip)
66  Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance)
67  Q_PROPERTY(bool invertedControls READ invertedControls WRITE setInvertedControls)
68 
69 public:
71  typedef QWidget Superclass;
72 
75  explicit DoubleSlider(QWidget* parent = 0);
78  explicit DoubleSlider(Qt::Orientation orient, QWidget* parent = 0);
80  virtual ~DoubleSlider();
81 
87  void setMinimum(double min);
88  double minimum()const;
89 
95  void setMaximum(double max);
96  double maximum()const;
97 
101  void setRange(double min, double max);
102 
108  double value()const;
109 
116  void setSingleStep(double step);
117  double singleStep()const;
118 
123  bool isValidStep(double step)const;
124 
130  void setPageStep(double step);
131  double pageStep()const;
132 
138  void setTickInterval(double ti);
139  double tickInterval()const;
140 
145  void setTickPosition(QSlider::TickPosition position);
146  QSlider::TickPosition tickPosition()const;
147 
154  double sliderPosition()const;
155  void setSliderPosition(double);
156 
163  void setTracking(bool enable);
164  bool hasTracking()const;
165 
170  void triggerAction(QAbstractSlider::SliderAction action);
171 
175  Qt::Orientation orientation()const;
176 
186  void setInvertedAppearance(bool invertedAppearance);
187  bool invertedAppearance()const;
188 
195  void setInvertedControls(bool invertedControls);
196  bool invertedControls()const;
197 
203  QString handleToolTip()const;
204  void setHandleToolTip(const QString& toolTip);
205 
207  virtual bool eventFilter(QObject*, QEvent*);
208 
217  void setValueProxy(ValueProxy* proxy);
218  ValueProxy* valueProxy() const;
219 
220 public slots:
226  void setValue(double value);
227 
231  void setOrientation(Qt::Orientation orientation);
232 
233 signals:
237  void valueChanged(double value);
238 
244  void sliderMoved(double position);
245 
249  void sliderPressed();
250 
254  void sliderReleased();
255 
261  void rangeChanged(double min, double max);
262 
263 protected slots:
264  void onValueChanged(int value);
265  void onSliderMoved(int position);
266  void onRangeChanged(int min, int max);
267  void onValueProxyAboutToBeModified();
268  void onValueProxyModified();
269 
270 protected:
271  QScopedPointer<DoubleSliderPrivate> d_ptr;
272 
273 private:
274  Q_DECLARE_PRIVATE(DoubleSlider);
275  Q_DISABLE_COPY(DoubleSlider);
276 };
277 
278 #endif
Definition: doubleSlider.h:52
Definition: doubleSlider.cpp:56
QWidget Superclass
Superclass typedef.
Definition: doubleSlider.h:71
Base class for value proxies. Value proxy allows to decouple the displayed value from the values acce...
Definition: valueProxy.h:45