File indexing completed on 2024-05-19 03:49:43

0001 /*
0002  * SPDX-FileCopyrightText: 2006-2011 the LibQxt project <http://libqxt.org, foundation@libqxt.org>
0003  * SPDX-License-Identifier: BSD-3-Clause
0004  */
0005 
0006 #ifndef QXTSPANSLIDER_P_H
0007 #define QXTSPANSLIDER_P_H
0008 
0009 #include "qxtspanslider.h"
0010 #include <QObject>
0011 #include <QStyle>
0012 
0013 QT_FORWARD_DECLARE_CLASS(QStylePainter)
0014 QT_FORWARD_DECLARE_CLASS(QStyleOptionSlider)
0015 
0016 class QxtSpanSliderPrivate : public QObject, public QxtPrivate<QxtSpanSlider> {
0017     Q_OBJECT
0018 
0019 public:
0020     QXT_DECLARE_PUBLIC(QxtSpanSlider)
0021 
0022     QxtSpanSliderPrivate();
0023     void initStyleOption(QStyleOptionSlider* option, QxtSpanSlider::SpanHandle handle = QxtSpanSlider::UpperHandle) const;
0024     int pick(QPoint pt) const {
0025         return qxt_p().orientation() == Qt::Horizontal ? pt.x() : pt.y();
0026     }
0027     int pixelPosToRangeValue(int pos) const;
0028     void handleMousePress(QPoint pos, QStyle::SubControl& control, int value, QxtSpanSlider::SpanHandle handle);
0029     void drawHandle(QStylePainter* painter, QxtSpanSlider::SpanHandle handle) const;
0030     void setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2) const;
0031     void drawSpan(QStylePainter* painter, QRect rect) const;
0032     void triggerAction(QAbstractSlider::SliderAction action, bool main);
0033     void swapControls();
0034 
0035     int lower{0};
0036     int upper{0};
0037     int lowerPos{0};
0038     int upperPos{0};
0039     int offset{0};
0040     int position{0};
0041     QxtSpanSlider::SpanHandle lastPressed{QxtSpanSlider::NoHandle};
0042     QxtSpanSlider::SpanHandle mainControl{QxtSpanSlider::LowerHandle};
0043     QStyle::SubControl lowerPressed{QStyle::SC_None};
0044     QStyle::SubControl upperPressed{QStyle::SC_None};
0045     QxtSpanSlider::HandleMovementMode movement{QxtSpanSlider::FreeMovement};
0046     bool firstMovement{false};
0047     bool blockTracking{false};
0048 
0049 public Q_SLOTS:
0050     void updateRange(int min, int max);
0051     void movePressedHandle();
0052 };
0053 
0054 #endif // QXTSPANSLIDER_P_H