| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qslider.h" | - |
| 43 | #ifndef QT_NO_SLIDER | - |
| 44 | #ifndef QT_NO_ACCESSIBILITY | - |
| 45 | #include "qaccessible.h" | - |
| 46 | #endif | - |
| 47 | #include "qapplication.h" | - |
| 48 | #include "qevent.h" | - |
| 49 | #include "qpainter.h" | - |
| 50 | #include "qstyle.h" | - |
| 51 | #include "qstyleoption.h" | - |
| 52 | #include "private/qabstractslider_p.h" | - |
| 53 | #include "qdebug.h" | - |
| 54 | | - |
| 55 | QT_BEGIN_NAMESPACE | - |
| 56 | | - |
| 57 | class QSliderPrivate : public QAbstractSliderPrivate | - |
| 58 | { | - |
| 59 | Q_DECLARE_PUBLIC(QSlider) | - |
| 60 | public: | - |
| 61 | QStyle::SubControl pressedControl; | - |
| 62 | int tickInterval; | - |
| 63 | QSlider::TickPosition tickPosition; | - |
| 64 | int clickOffset; | - |
| 65 | void init(); | - |
| 66 | void resetLayoutItemMargins(); | - |
| 67 | int pixelPosToRangeValue(int pos) const; | - |
| 68 | inline int pick(const QPoint &pt) const; | - |
| 69 | | - |
| 70 | QStyle::SubControl newHoverControl(const QPoint &pos); | - |
| 71 | bool updateHoverControl(const QPoint &pos); | - |
| 72 | QStyle::SubControl hoverControl; | - |
| 73 | QRect hoverRect; | - |
| 74 | }; | - |
| 75 | | - |
| 76 | void QSliderPrivate::init() | - |
| 77 | { | - |
| 78 | Q_Q(QSlider); executed (the execution status of this line is deduced): QSlider * const q = q_func(); | - |
| 79 | pressedControl = QStyle::SC_None; executed (the execution status of this line is deduced): pressedControl = QStyle::SC_None; | - |
| 80 | tickInterval = 0; executed (the execution status of this line is deduced): tickInterval = 0; | - |
| 81 | tickPosition = QSlider::NoTicks; executed (the execution status of this line is deduced): tickPosition = QSlider::NoTicks; | - |
| 82 | hoverControl = QStyle::SC_None; executed (the execution status of this line is deduced): hoverControl = QStyle::SC_None; | - |
| 83 | q->setFocusPolicy(Qt::FocusPolicy(q->style()->styleHint(QStyle::SH_Button_FocusPolicy))); executed (the execution status of this line is deduced): q->setFocusPolicy(Qt::FocusPolicy(q->style()->styleHint(QStyle::SH_Button_FocusPolicy))); | - |
| 84 | QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::Slider); executed (the execution status of this line is deduced): QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::Slider); | - |
| 85 | if (orientation == Qt::Vertical) partially evaluated: orientation == Qt::Vertical| yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
| 86 | sp.transpose(); executed: sp.transpose();Execution Count:12 | 12 |
| 87 | q->setSizePolicy(sp); executed (the execution status of this line is deduced): q->setSizePolicy(sp); | - |
| 88 | q->setAttribute(Qt::WA_WState_OwnSizePolicy, false); executed (the execution status of this line is deduced): q->setAttribute(Qt::WA_WState_OwnSizePolicy, false); | - |
| 89 | resetLayoutItemMargins(); executed (the execution status of this line is deduced): resetLayoutItemMargins(); | - |
| 90 | } executed: }Execution Count:12 | 12 |
| 91 | | - |
| 92 | void QSliderPrivate::resetLayoutItemMargins() | - |
| 93 | { | - |
| 94 | Q_Q(QSlider); executed (the execution status of this line is deduced): QSlider * const q = q_func(); | - |
| 95 | QStyleOptionSlider opt; executed (the execution status of this line is deduced): QStyleOptionSlider opt; | - |
| 96 | q->initStyleOption(&opt); executed (the execution status of this line is deduced): q->initStyleOption(&opt); | - |
| 97 | setLayoutItemMargins(QStyle::SE_SliderLayoutItem, &opt); executed (the execution status of this line is deduced): setLayoutItemMargins(QStyle::SE_SliderLayoutItem, &opt); | - |
| 98 | } executed: }Execution Count:16 | 16 |
| 99 | | - |
| 100 | int QSliderPrivate::pixelPosToRangeValue(int pos) const | - |
| 101 | { | - |
| 102 | Q_Q(const QSlider); executed (the execution status of this line is deduced): const QSlider * const q = q_func(); | - |
| 103 | QStyleOptionSlider opt; executed (the execution status of this line is deduced): QStyleOptionSlider opt; | - |
| 104 | q->initStyleOption(&opt); executed (the execution status of this line is deduced): q->initStyleOption(&opt); | - |
| 105 | QRect gr = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, q); executed (the execution status of this line is deduced): QRect gr = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, q); | - |
| 106 | QRect sr = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, q); executed (the execution status of this line is deduced): QRect sr = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, q); | - |
| 107 | int sliderMin, sliderMax, sliderLength; executed (the execution status of this line is deduced): int sliderMin, sliderMax, sliderLength; | - |
| 108 | | - |
| 109 | if (orientation == Qt::Horizontal) { partially evaluated: orientation == Qt::Horizontal| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 110 | sliderLength = sr.width(); never executed (the execution status of this line is deduced): sliderLength = sr.width(); | - |
| 111 | sliderMin = gr.x(); never executed (the execution status of this line is deduced): sliderMin = gr.x(); | - |
| 112 | sliderMax = gr.right() - sliderLength + 1; never executed (the execution status of this line is deduced): sliderMax = gr.right() - sliderLength + 1; | - |
| 113 | } else { | 0 |
| 114 | sliderLength = sr.height(); executed (the execution status of this line is deduced): sliderLength = sr.height(); | - |
| 115 | sliderMin = gr.y(); executed (the execution status of this line is deduced): sliderMin = gr.y(); | - |
| 116 | sliderMax = gr.bottom() - sliderLength + 1; executed (the execution status of this line is deduced): sliderMax = gr.bottom() - sliderLength + 1; | - |
| 117 | } executed: }Execution Count:1 | 1 |
| 118 | return QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin, executed: return QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin, sliderMax - sliderMin, opt.upsideDown);Execution Count:1 | 1 |
| 119 | sliderMax - sliderMin, opt.upsideDown); executed: return QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin, sliderMax - sliderMin, opt.upsideDown);Execution Count:1 | 1 |
| 120 | } | - |
| 121 | | - |
| 122 | inline int QSliderPrivate::pick(const QPoint &pt) const | - |
| 123 | { | - |
| 124 | return orientation == Qt::Horizontal ? pt.x() : pt.y(); executed: return orientation == Qt::Horizontal ? pt.x() : pt.y();Execution Count:2 | 2 |
| 125 | } | - |
| 126 | | - |
| 127 | /*! | - |
| 128 | Initialize \a option with the values from this QSlider. This method | - |
| 129 | is useful for subclasses when they need a QStyleOptionSlider, but don't want | - |
| 130 | to fill in all the information themselves. | - |
| 131 | | - |
| 132 | \sa QStyleOption::initFrom() | - |
| 133 | */ | - |
| 134 | void QSlider::initStyleOption(QStyleOptionSlider *option) const | - |
| 135 | { | - |
| 136 | if (!option) partially evaluated: !option| no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
| 137 | return; | 0 |
| 138 | | - |
| 139 | Q_D(const QSlider); executed (the execution status of this line is deduced): const QSliderPrivate * const d = d_func(); | - |
| 140 | option->initFrom(this); executed (the execution status of this line is deduced): option->initFrom(this); | - |
| 141 | option->subControls = QStyle::SC_None; executed (the execution status of this line is deduced): option->subControls = QStyle::SC_None; | - |
| 142 | option->activeSubControls = QStyle::SC_None; executed (the execution status of this line is deduced): option->activeSubControls = QStyle::SC_None; | - |
| 143 | option->orientation = d->orientation; executed (the execution status of this line is deduced): option->orientation = d->orientation; | - |
| 144 | option->maximum = d->maximum; executed (the execution status of this line is deduced): option->maximum = d->maximum; | - |
| 145 | option->minimum = d->minimum; executed (the execution status of this line is deduced): option->minimum = d->minimum; | - |
| 146 | option->tickPosition = (QSlider::TickPosition)d->tickPosition; executed (the execution status of this line is deduced): option->tickPosition = (QSlider::TickPosition)d->tickPosition; | - |
| 147 | option->tickInterval = d->tickInterval; executed (the execution status of this line is deduced): option->tickInterval = d->tickInterval; | - |
| 148 | option->upsideDown = (d->orientation == Qt::Horizontal) ? partially evaluated: (d->orientation == Qt::Horizontal)| no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
| 149 | (d->invertedAppearance != (option->direction == Qt::RightToLeft)) executed (the execution status of this line is deduced): (d->invertedAppearance != (option->direction == Qt::RightToLeft)) | - |
| 150 | : (!d->invertedAppearance); executed (the execution status of this line is deduced): : (!d->invertedAppearance); | - |
| 151 | option->direction = Qt::LeftToRight; // we use the upsideDown option instead executed (the execution status of this line is deduced): option->direction = Qt::LeftToRight; | - |
| 152 | option->sliderPosition = d->position; executed (the execution status of this line is deduced): option->sliderPosition = d->position; | - |
| 153 | option->sliderValue = d->value; executed (the execution status of this line is deduced): option->sliderValue = d->value; | - |
| 154 | option->singleStep = d->singleStep; executed (the execution status of this line is deduced): option->singleStep = d->singleStep; | - |
| 155 | option->pageStep = d->pageStep; executed (the execution status of this line is deduced): option->pageStep = d->pageStep; | - |
| 156 | if (d->orientation == Qt::Horizontal) partially evaluated: d->orientation == Qt::Horizontal| no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
| 157 | option->state |= QStyle::State_Horizontal; never executed: option->state |= QStyle::State_Horizontal; | 0 |
| 158 | } executed: }Execution Count:31 | 31 |
| 159 | | - |
| 160 | bool QSliderPrivate::updateHoverControl(const QPoint &pos) | - |
| 161 | { | - |
| 162 | Q_Q(QSlider); never executed (the execution status of this line is deduced): QSlider * const q = q_func(); | - |
| 163 | QRect lastHoverRect = hoverRect; never executed (the execution status of this line is deduced): QRect lastHoverRect = hoverRect; | - |
| 164 | QStyle::SubControl lastHoverControl = hoverControl; never executed (the execution status of this line is deduced): QStyle::SubControl lastHoverControl = hoverControl; | - |
| 165 | bool doesHover = q->testAttribute(Qt::WA_Hover); never executed (the execution status of this line is deduced): bool doesHover = q->testAttribute(Qt::WA_Hover); | - |
| 166 | if (lastHoverControl != newHoverControl(pos) && doesHover) { never evaluated: lastHoverControl != newHoverControl(pos) never evaluated: doesHover | 0 |
| 167 | q->update(lastHoverRect); never executed (the execution status of this line is deduced): q->update(lastHoverRect); | - |
| 168 | q->update(hoverRect); never executed (the execution status of this line is deduced): q->update(hoverRect); | - |
| 169 | return true; never executed: return true; | 0 |
| 170 | } | - |
| 171 | return !doesHover; never executed: return !doesHover; | 0 |
| 172 | } | - |
| 173 | | - |
| 174 | QStyle::SubControl QSliderPrivate::newHoverControl(const QPoint &pos) | - |
| 175 | { | - |
| 176 | Q_Q(QSlider); never executed (the execution status of this line is deduced): QSlider * const q = q_func(); | - |
| 177 | QStyleOptionSlider opt; never executed (the execution status of this line is deduced): QStyleOptionSlider opt; | - |
| 178 | q->initStyleOption(&opt); never executed (the execution status of this line is deduced): q->initStyleOption(&opt); | - |
| 179 | opt.subControls = QStyle::SC_All; never executed (the execution status of this line is deduced): opt.subControls = QStyle::SC_All; | - |
| 180 | QRect handleRect = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, q); never executed (the execution status of this line is deduced): QRect handleRect = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, q); | - |
| 181 | QRect grooveRect = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, q); never executed (the execution status of this line is deduced): QRect grooveRect = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, q); | - |
| 182 | QRect tickmarksRect = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderTickmarks, q); never executed (the execution status of this line is deduced): QRect tickmarksRect = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderTickmarks, q); | - |
| 183 | | - |
| 184 | if (handleRect.contains(pos)) { never evaluated: handleRect.contains(pos) | 0 |
| 185 | hoverRect = handleRect; never executed (the execution status of this line is deduced): hoverRect = handleRect; | - |
| 186 | hoverControl = QStyle::SC_SliderHandle; never executed (the execution status of this line is deduced): hoverControl = QStyle::SC_SliderHandle; | - |
| 187 | } else if (grooveRect.contains(pos)) { never executed: } never evaluated: grooveRect.contains(pos) | 0 |
| 188 | hoverRect = grooveRect; never executed (the execution status of this line is deduced): hoverRect = grooveRect; | - |
| 189 | hoverControl = QStyle::SC_SliderGroove; never executed (the execution status of this line is deduced): hoverControl = QStyle::SC_SliderGroove; | - |
| 190 | } else if (tickmarksRect.contains(pos)) { never executed: } never evaluated: tickmarksRect.contains(pos) | 0 |
| 191 | hoverRect = tickmarksRect; never executed (the execution status of this line is deduced): hoverRect = tickmarksRect; | - |
| 192 | hoverControl = QStyle::SC_SliderTickmarks; never executed (the execution status of this line is deduced): hoverControl = QStyle::SC_SliderTickmarks; | - |
| 193 | } else { | 0 |
| 194 | hoverRect = QRect(); never executed (the execution status of this line is deduced): hoverRect = QRect(); | - |
| 195 | hoverControl = QStyle::SC_None; never executed (the execution status of this line is deduced): hoverControl = QStyle::SC_None; | - |
| 196 | } | 0 |
| 197 | | - |
| 198 | return hoverControl; never executed: return hoverControl; | 0 |
| 199 | } | - |
| 200 | | - |
| 201 | /*! | - |
| 202 | \class QSlider | - |
| 203 | \brief The QSlider widget provides a vertical or horizontal slider. | - |
| 204 | | - |
| 205 | \ingroup basicwidgets | - |
| 206 | \inmodule QtWidgets | - |
| 207 | | - |
| 208 | The slider is the classic widget for controlling a bounded value. | - |
| 209 | It lets the user move a slider handle along a horizontal or vertical | - |
| 210 | groove and translates the handle's position into an integer value | - |
| 211 | within the legal range. | - |
| 212 | | - |
| 213 | QSlider has very few of its own functions; most of the functionality is in | - |
| 214 | QAbstractSlider. The most useful functions are setValue() to set | - |
| 215 | the slider directly to some value; triggerAction() to simulate | - |
| 216 | the effects of clicking (useful for shortcut keys); | - |
| 217 | setSingleStep(), setPageStep() to set the steps; and setMinimum() | - |
| 218 | and setMaximum() to define the range of the scroll bar. | - |
| 219 | | - |
| 220 | QSlider provides methods for controlling tickmarks. You can use | - |
| 221 | setTickPosition() to indicate where you want the tickmarks to be, | - |
| 222 | setTickInterval() to indicate how many of them you want. the | - |
| 223 | currently set tick position and interval can be queried using the | - |
| 224 | tickPosition() and tickInterval() functions, respectively. | - |
| 225 | | - |
| 226 | QSlider inherits a comprehensive set of signals: | - |
| 227 | \table | - |
| 228 | \header \li Signal \li Description | - |
| 229 | \row \li \l valueChanged() | - |
| 230 | \li Emitted when the slider's value has changed. The tracking() | - |
| 231 | determines whether this signal is emitted during user | - |
| 232 | interaction. | - |
| 233 | \row \li \l sliderPressed() | - |
| 234 | \li Emitted when the user starts to drag the slider. | - |
| 235 | \row \li \l sliderMoved() | - |
| 236 | \li Emitted when the user drags the slider. | - |
| 237 | \row \li \l sliderReleased() | - |
| 238 | \li Emitted when the user releases the slider. | - |
| 239 | \endtable | - |
| 240 | | - |
| 241 | QSlider only provides integer ranges. Note that although | - |
| 242 | QSlider handles very large numbers, it becomes difficult for users | - |
| 243 | to use a slider accurately for very large ranges. | - |
| 244 | | - |
| 245 | A slider accepts focus on Tab and provides both a mouse wheel and a | - |
| 246 | keyboard interface. The keyboard interface is the following: | - |
| 247 | | - |
| 248 | \list | - |
| 249 | \li Left/Right move a horizontal slider by one single step. | - |
| 250 | \li Up/Down move a vertical slider by one single step. | - |
| 251 | \li PageUp moves up one page. | - |
| 252 | \li PageDown moves down one page. | - |
| 253 | \li Home moves to the start (mininum). | - |
| 254 | \li End moves to the end (maximum). | - |
| 255 | \endlist | - |
| 256 | | - |
| 257 | \table 100% | - |
| 258 | \row \li \inlineimage macintosh-slider.png Screenshot of a Macintosh slider | - |
| 259 | \li A slider shown in the \l{Macintosh Style Widget Gallery}{Macintosh widget style}. | - |
| 260 | \row \li \inlineimage windowsvista-slider.png Screenshot of a Windows Vista slider | - |
| 261 | \li A slider shown in the \l{Windows Vista Style Widget Gallery}{Windows Vista widget style}. | - |
| 262 | \row \li \inlineimage fusion-slider.png Screenshot of a Fusion slider | - |
| 263 | \li A slider shown in the \l{Fusion Style Widget Gallery}{Fusion widget style}. | - |
| 264 | \endtable | - |
| 265 | | - |
| 266 | \sa QScrollBar, QSpinBox, QDial, {fowler}{GUI Design Handbook: Slider}, {Sliders Example} | - |
| 267 | */ | - |
| 268 | | - |
| 269 | | - |
| 270 | /*! | - |
| 271 | \enum QSlider::TickPosition | - |
| 272 | | - |
| 273 | This enum specifies where the tick marks are to be drawn relative | - |
| 274 | to the slider's groove and the handle the user moves. | - |
| 275 | | - |
| 276 | \value NoTicks Do not draw any tick marks. | - |
| 277 | \value TicksBothSides Draw tick marks on both sides of the groove. | - |
| 278 | \value TicksAbove Draw tick marks above the (horizontal) slider | - |
| 279 | \value TicksBelow Draw tick marks below the (horizontal) slider | - |
| 280 | \value TicksLeft Draw tick marks to the left of the (vertical) slider | - |
| 281 | \value TicksRight Draw tick marks to the right of the (vertical) slider | - |
| 282 | */ | - |
| 283 | | - |
| 284 | | - |
| 285 | /*! | - |
| 286 | Constructs a vertical slider with the given \a parent. | - |
| 287 | */ | - |
| 288 | QSlider::QSlider(QWidget *parent) | - |
| 289 | : QAbstractSlider(*new QSliderPrivate, parent) | - |
| 290 | { | - |
| 291 | d_func()->orientation = Qt::Vertical; executed (the execution status of this line is deduced): d_func()->orientation = Qt::Vertical; | - |
| 292 | d_func()->init(); executed (the execution status of this line is deduced): d_func()->init(); | - |
| 293 | } executed: }Execution Count:12 | 12 |
| 294 | | - |
| 295 | /*! | - |
| 296 | Constructs a slider with the given \a parent. The \a orientation | - |
| 297 | parameter determines whether the slider is horizontal or vertical; | - |
| 298 | the valid values are Qt::Vertical and Qt::Horizontal. | - |
| 299 | */ | - |
| 300 | | - |
| 301 | QSlider::QSlider(Qt::Orientation orientation, QWidget *parent) | - |
| 302 | : QAbstractSlider(*new QSliderPrivate, parent) | - |
| 303 | { | - |
| 304 | d_func()->orientation = orientation; never executed (the execution status of this line is deduced): d_func()->orientation = orientation; | - |
| 305 | d_func()->init(); never executed (the execution status of this line is deduced): d_func()->init(); | - |
| 306 | } | 0 |
| 307 | | - |
| 308 | | - |
| 309 | /*! | - |
| 310 | Destroys this slider. | - |
| 311 | */ | - |
| 312 | QSlider::~QSlider() | - |
| 313 | { | - |
| 314 | } | - |
| 315 | | - |
| 316 | /*! | - |
| 317 | \reimp | - |
| 318 | */ | - |
| 319 | void QSlider::paintEvent(QPaintEvent *) | - |
| 320 | { | - |
| 321 | Q_D(QSlider); executed (the execution status of this line is deduced): QSliderPrivate * const d = d_func(); | - |
| 322 | QPainter p(this); executed (the execution status of this line is deduced): QPainter p(this); | - |
| 323 | QStyleOptionSlider opt; executed (the execution status of this line is deduced): QStyleOptionSlider opt; | - |
| 324 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 325 | | - |
| 326 | opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle; executed (the execution status of this line is deduced): opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle; | - |
| 327 | if (d->tickPosition != NoTicks) partially evaluated: d->tickPosition != NoTicks| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 328 | opt.subControls |= QStyle::SC_SliderTickmarks; never executed: opt.subControls |= QStyle::SC_SliderTickmarks; | 0 |
| 329 | if (d->pressedControl) { partially evaluated: d->pressedControl| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 330 | opt.activeSubControls = d->pressedControl; never executed (the execution status of this line is deduced): opt.activeSubControls = d->pressedControl; | - |
| 331 | opt.state |= QStyle::State_Sunken; never executed (the execution status of this line is deduced): opt.state |= QStyle::State_Sunken; | - |
| 332 | } else { | 0 |
| 333 | opt.activeSubControls = d->hoverControl; executed (the execution status of this line is deduced): opt.activeSubControls = d->hoverControl; | - |
| 334 | } executed: }Execution Count:1 | 1 |
| 335 | | - |
| 336 | style()->drawComplexControl(QStyle::CC_Slider, &opt, &p, this); executed (the execution status of this line is deduced): style()->drawComplexControl(QStyle::CC_Slider, &opt, &p, this); | - |
| 337 | } executed: }Execution Count:1 | 1 |
| 338 | | - |
| 339 | /*! | - |
| 340 | \reimp | - |
| 341 | */ | - |
| 342 | | - |
| 343 | bool QSlider::event(QEvent *event) | - |
| 344 | { | - |
| 345 | Q_D(QSlider); executed (the execution status of this line is deduced): QSliderPrivate * const d = d_func(); | - |
| 346 | | - |
| 347 | switch(event->type()) { | - |
| 348 | case QEvent::HoverEnter: | - |
| 349 | case QEvent::HoverLeave: | - |
| 350 | case QEvent::HoverMove: | - |
| 351 | if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event)) never evaluated: const QHoverEvent *he = static_cast<const QHoverEvent *>(event) | 0 |
| 352 | d->updateHoverControl(he->pos()); never executed: d->updateHoverControl(he->pos()); | 0 |
| 353 | break; | 0 |
| 354 | case QEvent::StyleChange: | - |
| 355 | case QEvent::MacSizeChange: | - |
| 356 | d->resetLayoutItemMargins(); never executed (the execution status of this line is deduced): d->resetLayoutItemMargins(); | - |
| 357 | break; | 0 |
| 358 | default: | - |
| 359 | break; executed: break;Execution Count:33 | 33 |
| 360 | } | - |
| 361 | return QAbstractSlider::event(event); executed: return QAbstractSlider::event(event);Execution Count:33 | 33 |
| 362 | } | - |
| 363 | | - |
| 364 | /*! | - |
| 365 | \reimp | - |
| 366 | */ | - |
| 367 | void QSlider::mousePressEvent(QMouseEvent *ev) | - |
| 368 | { | - |
| 369 | Q_D(QSlider); executed (the execution status of this line is deduced): QSliderPrivate * const d = d_func(); | - |
| 370 | if (d->maximum == d->minimum || (ev->buttons() ^ ev->button())) { partially evaluated: d->maximum == d->minimum| no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: (ev->buttons() ^ ev->button())| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 371 | ev->ignore(); never executed (the execution status of this line is deduced): ev->ignore(); | - |
| 372 | return; | 0 |
| 373 | } | - |
| 374 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 375 | if (QApplication::keypadNavigationEnabled()) | - |
| 376 | setEditFocus(true); | - |
| 377 | #endif | - |
| 378 | ev->accept(); executed (the execution status of this line is deduced): ev->accept(); | - |
| 379 | if ((ev->button() & style()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons)) == ev->button()) { partially evaluated: (ev->button() & style()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons)) == ev->button()| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 380 | QStyleOptionSlider opt; never executed (the execution status of this line is deduced): QStyleOptionSlider opt; | - |
| 381 | initStyleOption(&opt); never executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 382 | const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); never executed (the execution status of this line is deduced): const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); | - |
| 383 | const QPoint center = sliderRect.center() - sliderRect.topLeft(); never executed (the execution status of this line is deduced): const QPoint center = sliderRect.center() - sliderRect.topLeft(); | - |
| 384 | // to take half of the slider off for the setSliderPosition call we use the center - topLeft | - |
| 385 | | - |
| 386 | setSliderPosition(d->pixelPosToRangeValue(d->pick(ev->pos() - center))); never executed (the execution status of this line is deduced): setSliderPosition(d->pixelPosToRangeValue(d->pick(ev->pos() - center))); | - |
| 387 | triggerAction(SliderMove); never executed (the execution status of this line is deduced): triggerAction(SliderMove); | - |
| 388 | setRepeatAction(SliderNoAction); never executed (the execution status of this line is deduced): setRepeatAction(SliderNoAction); | - |
| 389 | d->pressedControl = QStyle::SC_SliderHandle; never executed (the execution status of this line is deduced): d->pressedControl = QStyle::SC_SliderHandle; | - |
| 390 | update(); never executed (the execution status of this line is deduced): update(); | - |
| 391 | } else if ((ev->button() & style()->styleHint(QStyle::SH_Slider_PageSetButtons)) == ev->button()) { never executed: } partially evaluated: (ev->button() & style()->styleHint(QStyle::SH_Slider_PageSetButtons)) == ev->button()| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 392 | QStyleOptionSlider opt; executed (the execution status of this line is deduced): QStyleOptionSlider opt; | - |
| 393 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 394 | d->pressedControl = style()->hitTestComplexControl(QStyle::CC_Slider, executed (the execution status of this line is deduced): d->pressedControl = style()->hitTestComplexControl(QStyle::CC_Slider, | - |
| 395 | &opt, ev->pos(), this); executed (the execution status of this line is deduced): &opt, ev->pos(), this); | - |
| 396 | SliderAction action = SliderNoAction; executed (the execution status of this line is deduced): SliderAction action = SliderNoAction; | - |
| 397 | if (d->pressedControl == QStyle::SC_SliderGroove) { evaluated: d->pressedControl == QStyle::SC_SliderGroove| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 398 | const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); never executed (the execution status of this line is deduced): const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); | - |
| 399 | int pressValue = d->pixelPosToRangeValue(d->pick(ev->pos() - sliderRect.center() + sliderRect.topLeft())); never executed (the execution status of this line is deduced): int pressValue = d->pixelPosToRangeValue(d->pick(ev->pos() - sliderRect.center() + sliderRect.topLeft())); | - |
| 400 | d->pressValue = pressValue; never executed (the execution status of this line is deduced): d->pressValue = pressValue; | - |
| 401 | if (pressValue > d->value) partially evaluated: pressValue > d->value| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 402 | action = SliderPageStepAdd; executed: action = SliderPageStepAdd;Execution Count:1 | 1 |
| 403 | else if (pressValue < d->value) never evaluated: pressValue < d->value | 0 |
| 404 | action = SliderPageStepSub; never executed: action = SliderPageStepSub; | 0 |
| 405 | if (action) { partially evaluated: action| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 406 | triggerAction(action); executed (the execution status of this line is deduced): triggerAction(action); | - |
| 407 | setRepeatAction(action); executed (the execution status of this line is deduced): setRepeatAction(action); | - |
| 408 | } executed: }Execution Count:1 | 1 |
| 409 | } executed: }Execution Count:1 | 1 |
| 410 | } else { executed: }Execution Count:2 | 2 |
| 411 | ev->ignore(); never executed (the execution status of this line is deduced): ev->ignore(); | - |
| 412 | return; | 0 |
| 413 | } | - |
| 414 | | - |
| 415 | if (d->pressedControl == QStyle::SC_SliderHandle) { evaluated: d->pressedControl == QStyle::SC_SliderHandle| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 416 | QStyleOptionSlider opt; executed (the execution status of this line is deduced): QStyleOptionSlider opt; | - |
| 417 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 418 | setRepeatAction(SliderNoAction); executed (the execution status of this line is deduced): setRepeatAction(SliderNoAction); | - |
| 419 | QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); executed (the execution status of this line is deduced): QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); | - |
| 420 | d->clickOffset = d->pick(ev->pos() - sr.topLeft()); executed (the execution status of this line is deduced): d->clickOffset = d->pick(ev->pos() - sr.topLeft()); | - |
| 421 | update(sr); executed (the execution status of this line is deduced): update(sr); | - |
| 422 | setSliderDown(true); executed (the execution status of this line is deduced): setSliderDown(true); | - |
| 423 | } executed: }Execution Count:1 | 1 |
| 424 | } executed: }Execution Count:2 | 2 |
| 425 | | - |
| 426 | /*! | - |
| 427 | \reimp | - |
| 428 | */ | - |
| 429 | void QSlider::mouseMoveEvent(QMouseEvent *ev) | - |
| 430 | { | - |
| 431 | Q_D(QSlider); never executed (the execution status of this line is deduced): QSliderPrivate * const d = d_func(); | - |
| 432 | if (d->pressedControl != QStyle::SC_SliderHandle) { never evaluated: d->pressedControl != QStyle::SC_SliderHandle | 0 |
| 433 | ev->ignore(); never executed (the execution status of this line is deduced): ev->ignore(); | - |
| 434 | return; | 0 |
| 435 | } | - |
| 436 | ev->accept(); never executed (the execution status of this line is deduced): ev->accept(); | - |
| 437 | int newPosition = d->pixelPosToRangeValue(d->pick(ev->pos()) - d->clickOffset); never executed (the execution status of this line is deduced): int newPosition = d->pixelPosToRangeValue(d->pick(ev->pos()) - d->clickOffset); | - |
| 438 | QStyleOptionSlider opt; never executed (the execution status of this line is deduced): QStyleOptionSlider opt; | - |
| 439 | initStyleOption(&opt); never executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 440 | setSliderPosition(newPosition); never executed (the execution status of this line is deduced): setSliderPosition(newPosition); | - |
| 441 | } | 0 |
| 442 | | - |
| 443 | | - |
| 444 | /*! | - |
| 445 | \reimp | - |
| 446 | */ | - |
| 447 | void QSlider::mouseReleaseEvent(QMouseEvent *ev) | - |
| 448 | { | - |
| 449 | Q_D(QSlider); executed (the execution status of this line is deduced): QSliderPrivate * const d = d_func(); | - |
| 450 | if (d->pressedControl == QStyle::SC_None || ev->buttons()) { partially evaluated: d->pressedControl == QStyle::SC_None| no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: ev->buttons()| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 451 | ev->ignore(); never executed (the execution status of this line is deduced): ev->ignore(); | - |
| 452 | return; | 0 |
| 453 | } | - |
| 454 | ev->accept(); executed (the execution status of this line is deduced): ev->accept(); | - |
| 455 | QStyle::SubControl oldPressed = QStyle::SubControl(d->pressedControl); executed (the execution status of this line is deduced): QStyle::SubControl oldPressed = QStyle::SubControl(d->pressedControl); | - |
| 456 | d->pressedControl = QStyle::SC_None; executed (the execution status of this line is deduced): d->pressedControl = QStyle::SC_None; | - |
| 457 | setRepeatAction(SliderNoAction); executed (the execution status of this line is deduced): setRepeatAction(SliderNoAction); | - |
| 458 | if (oldPressed == QStyle::SC_SliderHandle) evaluated: oldPressed == QStyle::SC_SliderHandle| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 459 | setSliderDown(false); executed: setSliderDown(false);Execution Count:1 | 1 |
| 460 | QStyleOptionSlider opt; executed (the execution status of this line is deduced): QStyleOptionSlider opt; | - |
| 461 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 462 | opt.subControls = oldPressed; executed (the execution status of this line is deduced): opt.subControls = oldPressed; | - |
| 463 | update(style()->subControlRect(QStyle::CC_Slider, &opt, oldPressed, this)); executed (the execution status of this line is deduced): update(style()->subControlRect(QStyle::CC_Slider, &opt, oldPressed, this)); | - |
| 464 | } executed: }Execution Count:2 | 2 |
| 465 | | - |
| 466 | /*! | - |
| 467 | \reimp | - |
| 468 | */ | - |
| 469 | QSize QSlider::sizeHint() const | - |
| 470 | { | - |
| 471 | Q_D(const QSlider); executed (the execution status of this line is deduced): const QSliderPrivate * const d = d_func(); | - |
| 472 | ensurePolished(); executed (the execution status of this line is deduced): ensurePolished(); | - |
| 473 | const int SliderLength = 84, TickSpace = 5; executed (the execution status of this line is deduced): const int SliderLength = 84, TickSpace = 5; | - |
| 474 | QStyleOptionSlider opt; executed (the execution status of this line is deduced): QStyleOptionSlider opt; | - |
| 475 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 476 | int thick = style()->pixelMetric(QStyle::PM_SliderThickness, &opt, this); executed (the execution status of this line is deduced): int thick = style()->pixelMetric(QStyle::PM_SliderThickness, &opt, this); | - |
| 477 | if (d->tickPosition & TicksAbove) partially evaluated: d->tickPosition & TicksAbove| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 478 | thick += TickSpace; never executed: thick += TickSpace; | 0 |
| 479 | if (d->tickPosition & TicksBelow) partially evaluated: d->tickPosition & TicksBelow| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 480 | thick += TickSpace; never executed: thick += TickSpace; | 0 |
| 481 | int w = thick, h = SliderLength; executed (the execution status of this line is deduced): int w = thick, h = SliderLength; | - |
| 482 | if (d->orientation == Qt::Horizontal) { partially evaluated: d->orientation == Qt::Horizontal| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 483 | w = SliderLength; never executed (the execution status of this line is deduced): w = SliderLength; | - |
| 484 | h = thick; never executed (the execution status of this line is deduced): h = thick; | - |
| 485 | } | 0 |
| 486 | return style()->sizeFromContents(QStyle::CT_Slider, &opt, QSize(w, h), this).expandedTo(QApplication::globalStrut()); executed: return style()->sizeFromContents(QStyle::CT_Slider, &opt, QSize(w, h), this).expandedTo(QApplication::globalStrut());Execution Count:7 | 7 |
| 487 | } | - |
| 488 | | - |
| 489 | /*! | - |
| 490 | \reimp | - |
| 491 | */ | - |
| 492 | QSize QSlider::minimumSizeHint() const | - |
| 493 | { | - |
| 494 | Q_D(const QSlider); executed (the execution status of this line is deduced): const QSliderPrivate * const d = d_func(); | - |
| 495 | QSize s = sizeHint(); executed (the execution status of this line is deduced): QSize s = sizeHint(); | - |
| 496 | QStyleOptionSlider opt; executed (the execution status of this line is deduced): QStyleOptionSlider opt; | - |
| 497 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 498 | int length = style()->pixelMetric(QStyle::PM_SliderLength, &opt, this); executed (the execution status of this line is deduced): int length = style()->pixelMetric(QStyle::PM_SliderLength, &opt, this); | - |
| 499 | if (d->orientation == Qt::Horizontal) partially evaluated: d->orientation == Qt::Horizontal| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 500 | s.setWidth(length); never executed: s.setWidth(length); | 0 |
| 501 | else | - |
| 502 | s.setHeight(length); executed: s.setHeight(length);Execution Count:1 | 1 |
| 503 | return s; executed: return s;Execution Count:1 | 1 |
| 504 | } | - |
| 505 | | - |
| 506 | /*! | - |
| 507 | \property QSlider::tickPosition | - |
| 508 | \brief the tickmark position for this slider | - |
| 509 | | - |
| 510 | The valid values are described by the QSlider::TickPosition enum. | - |
| 511 | | - |
| 512 | The default value is \l QSlider::NoTicks. | - |
| 513 | | - |
| 514 | \sa tickInterval | - |
| 515 | */ | - |
| 516 | | - |
| 517 | void QSlider::setTickPosition(TickPosition position) | - |
| 518 | { | - |
| 519 | Q_D(QSlider); executed (the execution status of this line is deduced): QSliderPrivate * const d = d_func(); | - |
| 520 | d->tickPosition = position; executed (the execution status of this line is deduced): d->tickPosition = position; | - |
| 521 | d->resetLayoutItemMargins(); executed (the execution status of this line is deduced): d->resetLayoutItemMargins(); | - |
| 522 | update(); executed (the execution status of this line is deduced): update(); | - |
| 523 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
| 524 | } executed: }Execution Count:4 | 4 |
| 525 | | - |
| 526 | QSlider::TickPosition QSlider::tickPosition() const | - |
| 527 | { | - |
| 528 | return d_func()->tickPosition; executed: return d_func()->tickPosition;Execution Count:4 | 4 |
| 529 | } | - |
| 530 | | - |
| 531 | /*! | - |
| 532 | \property QSlider::tickInterval | - |
| 533 | \brief the interval between tickmarks | - |
| 534 | | - |
| 535 | This is a value interval, not a pixel interval. If it is 0, the | - |
| 536 | slider will choose between singleStep and pageStep. | - |
| 537 | | - |
| 538 | The default value is 0. | - |
| 539 | | - |
| 540 | \sa tickPosition, singleStep, pageStep | - |
| 541 | */ | - |
| 542 | | - |
| 543 | void QSlider::setTickInterval(int ts) | - |
| 544 | { | - |
| 545 | d_func()->tickInterval = qMax(0, ts); executed (the execution status of this line is deduced): d_func()->tickInterval = qMax(0, ts); | - |
| 546 | update(); executed (the execution status of this line is deduced): update(); | - |
| 547 | } executed: }Execution Count:3 | 3 |
| 548 | | - |
| 549 | int QSlider::tickInterval() const | - |
| 550 | { | - |
| 551 | return d_func()->tickInterval; executed: return d_func()->tickInterval;Execution Count:3 | 3 |
| 552 | } | - |
| 553 | | - |
| 554 | Q_WIDGETS_EXPORT QStyleOptionSlider qt_qsliderStyleOption(QSlider *slider) | - |
| 555 | { | - |
| 556 | QStyleOptionSlider sliderOption; never executed (the execution status of this line is deduced): QStyleOptionSlider sliderOption; | - |
| 557 | slider->initStyleOption(&sliderOption); never executed (the execution status of this line is deduced): slider->initStyleOption(&sliderOption); | - |
| 558 | return sliderOption; never executed: return sliderOption; | 0 |
| 559 | } | - |
| 560 | | - |
| 561 | #endif | - |
| 562 | | - |
| 563 | QT_END_NAMESPACE | - |
| 564 | | - |
| | |