25 #include <QStylePainter> 27 #include <tulip/tulipconf.h> 38 class TLP_QT_SCOPE RangeSlider :
public QSlider {
40 Q_PROPERTY(
int lowerValue READ lowerValue WRITE setLowerValue)
41 Q_PROPERTY(
int upperValue READ upperValue WRITE setUpperValue)
42 Q_PROPERTY(HandleMovementMode handleMovementMode READ handleMovementMode WRITE setHandleMovementMode)
43 Q_ENUMS(HandleMovementMode)
46 explicit RangeSlider(QWidget* parent = 0);
47 explicit RangeSlider(Qt::Orientation orientation, QWidget* parent = 0);
50 enum HandleMovementMode {
56 HandleMovementMode handleMovementMode()
const;
57 void setHandleMovementMode(HandleMovementMode mode);
59 int lowerValue()
const;
60 int upperValue()
const;
62 int lowerPosition()
const;
63 int upperPosition()
const;
66 void setLowerValue(
int lower);
67 void setUpperValue(
int upper);
68 void setRange(
int lower,
int upper);
70 void setLowerPosition(
int lower);
71 void setUpperPosition(
int upper);
74 void rangeChanged(
int lower,
int upper);
75 void lowerValueChanged(
int lower);
76 void upperValueChanged(
int upper);
78 void lowerPositionChanged(
int lower);
79 void upperPositionChanged(
int upper);
82 virtual void keyPressEvent(QKeyEvent* event);
83 virtual void mousePressEvent(QMouseEvent* event);
84 virtual void mouseMoveEvent(QMouseEvent* event);
85 virtual void mouseReleaseEvent(QMouseEvent* event);
86 virtual void paintEvent(QPaintEvent* event);
95 Q_PROPERTY(
int lowerPosition READ lowerPosition WRITE setLowerPosition)
96 Q_PROPERTY(
int upperPosition READ upperPosition WRITE setUpperPosition)
98 void initStyleOption(QStyleOptionSlider* option, RangeHandle handle = UpperHandle)
const;
99 int pick(
const QPoint& pt)
const {
100 return orientation() == Qt::Horizontal ? pt.x() : pt.y();
102 int pixelPosToRangeValue(
int pos)
const;
103 void handleMousePress(
const QPoint& pos, QStyle::SubControl& control,
int value, RangeHandle handle);
104 void drawHandle(QStylePainter* painter, RangeHandle handle)
const;
105 void setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2)
const;
106 void drawRange(QStylePainter* painter,
const QRect& rect)
const;
107 void triggerAction(QAbstractSlider::SliderAction action,
bool main);
116 RangeHandle lastPressed;
117 RangeHandle mainControl;
118 QStyle::SubControl lowerPressed;
119 QStyle::SubControl upperPressed;
120 HandleMovementMode movement;
125 void updateRange(
int min,
int max);
126 void movePressedHandle();
131 #endif // RANGESLIDER_H