| 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 <qapplication.h> | - |
| 43 | #include "qabstractslider.h" | - |
| 44 | #include "qevent.h" | - |
| 45 | #include "qabstractslider_p.h" | - |
| 46 | #include "qdebug.h" | - |
| 47 | #ifndef QT_NO_ACCESSIBILITY | - |
| 48 | #include "qaccessible.h" | - |
| 49 | #endif | - |
| 50 | #include <limits.h> | - |
| 51 | | - |
| 52 | QT_BEGIN_NAMESPACE | - |
| 53 | | - |
| 54 | /*! | - |
| 55 | \class QAbstractSlider | - |
| 56 | \brief The QAbstractSlider class provides an integer value within a range. | - |
| 57 | | - |
| 58 | \ingroup abstractwidgets | - |
| 59 | \inmodule QtWidgets | - |
| 60 | | - |
| 61 | The class is designed as a common super class for widgets like | - |
| 62 | QScrollBar, QSlider and QDial. | - |
| 63 | | - |
| 64 | Here are the main properties of the class: | - |
| 65 | | - |
| 66 | \list 1 | - |
| 67 | | - |
| 68 | \li \l value: The bounded integer that QAbstractSlider maintains. | - |
| 69 | | - |
| 70 | \li \l minimum: The lowest possible value. | - |
| 71 | | - |
| 72 | \li \l maximum: The highest possible value. | - |
| 73 | | - |
| 74 | \li \l singleStep: The smaller of two natural steps that an | - |
| 75 | abstract sliders provides and typically corresponds to the user | - |
| 76 | pressing an arrow key. | - |
| 77 | | - |
| 78 | \li \l pageStep: The larger of two natural steps that an abstract | - |
| 79 | slider provides and typically corresponds to the user pressing | - |
| 80 | PageUp or PageDown. | - |
| 81 | | - |
| 82 | \li \l tracking: Whether slider tracking is enabled. | - |
| 83 | | - |
| 84 | \li \l sliderPosition: The current position of the slider. If \l | - |
| 85 | tracking is enabled (the default), this is identical to \l value. | - |
| 86 | | - |
| 87 | \endlist | - |
| 88 | | - |
| 89 | Unity (1) may be viewed as a third step size. setValue() lets you | - |
| 90 | set the current value to any integer in the allowed range, not | - |
| 91 | just minimum() + \e n * singleStep() for integer values of \e n. | - |
| 92 | Some widgets may allow the user to set any value at all; others | - |
| 93 | may just provide multiples of singleStep() or pageStep(). | - |
| 94 | | - |
| 95 | QAbstractSlider emits a comprehensive set of signals: | - |
| 96 | | - |
| 97 | \table | - |
| 98 | \header \li Signal \li Emitted when | - |
| 99 | \row \li \l valueChanged() | - |
| 100 | \li the value has changed. The \l tracking | - |
| 101 | determines whether this signal is emitted during user | - |
| 102 | interaction. | - |
| 103 | \row \li \l sliderPressed() | - |
| 104 | \li the user starts to drag the slider. | - |
| 105 | \row \li \l sliderMoved() | - |
| 106 | \li the user drags the slider. | - |
| 107 | \row \li \l sliderReleased() | - |
| 108 | \li the user releases the slider. | - |
| 109 | \row \li \l actionTriggered() | - |
| 110 | \li a slider action was triggerd. | - |
| 111 | \row \li \l rangeChanged() | - |
| 112 | \li a the range has changed. | - |
| 113 | \endtable | - |
| 114 | | - |
| 115 | QAbstractSlider provides a virtual sliderChange() function that is | - |
| 116 | well suited for updating the on-screen representation of | - |
| 117 | sliders. By calling triggerAction(), subclasses trigger slider | - |
| 118 | actions. Two helper functions QStyle::sliderPositionFromValue() and | - |
| 119 | QStyle::sliderValueFromPosition() help subclasses and styles to map | - |
| 120 | screen coordinates to logical range values. | - |
| 121 | | - |
| 122 | \sa QAbstractSpinBox, QSlider, QDial, QScrollBar, {Sliders Example} | - |
| 123 | */ | - |
| 124 | | - |
| 125 | /*! | - |
| 126 | \enum QAbstractSlider::SliderAction | - |
| 127 | | - |
| 128 | \value SliderNoAction | - |
| 129 | \value SliderSingleStepAdd | - |
| 130 | \value SliderSingleStepSub | - |
| 131 | \value SliderPageStepAdd | - |
| 132 | \value SliderPageStepSub | - |
| 133 | \value SliderToMinimum | - |
| 134 | \value SliderToMaximum | - |
| 135 | \value SliderMove | - |
| 136 | | - |
| 137 | */ | - |
| 138 | | - |
| 139 | /*! | - |
| 140 | \fn void QAbstractSlider::valueChanged(int value) | - |
| 141 | | - |
| 142 | This signal is emitted when the slider value has changed, with the | - |
| 143 | new slider \a value as argument. | - |
| 144 | */ | - |
| 145 | | - |
| 146 | /*! | - |
| 147 | \fn void QAbstractSlider::sliderPressed() | - |
| 148 | | - |
| 149 | This signal is emitted when the user presses the slider with the | - |
| 150 | mouse, or programmatically when setSliderDown(true) is called. | - |
| 151 | | - |
| 152 | \sa sliderReleased(), sliderMoved(), isSliderDown() | - |
| 153 | */ | - |
| 154 | | - |
| 155 | /*! | - |
| 156 | \fn void QAbstractSlider::sliderMoved(int value) | - |
| 157 | | - |
| 158 | This signal is emitted when sliderDown is true and the slider moves. This | - |
| 159 | usually happens when the user is dragging the slider. The \a value | - |
| 160 | is the new slider position. | - |
| 161 | | - |
| 162 | This signal is emitted even when tracking is turned off. | - |
| 163 | | - |
| 164 | \sa setTracking(), valueChanged(), isSliderDown(), | - |
| 165 | sliderPressed(), sliderReleased() | - |
| 166 | */ | - |
| 167 | | - |
| 168 | /*! | - |
| 169 | \fn void QAbstractSlider::sliderReleased() | - |
| 170 | | - |
| 171 | This signal is emitted when the user releases the slider with the | - |
| 172 | mouse, or programmatically when setSliderDown(false) is called. | - |
| 173 | | - |
| 174 | \sa sliderPressed(), sliderMoved(), sliderDown | - |
| 175 | */ | - |
| 176 | | - |
| 177 | /*! | - |
| 178 | \fn void QAbstractSlider::rangeChanged(int min, int max) | - |
| 179 | | - |
| 180 | This signal is emitted when the slider range has changed, with \a | - |
| 181 | min being the new minimum, and \a max being the new maximum. | - |
| 182 | | - |
| 183 | \sa minimum, maximum | - |
| 184 | */ | - |
| 185 | | - |
| 186 | /*! | - |
| 187 | \fn void QAbstractSlider::actionTriggered(int action) | - |
| 188 | | - |
| 189 | This signal is emitted when the slider action \a action is | - |
| 190 | triggered. Actions are \l SliderSingleStepAdd, \l | - |
| 191 | SliderSingleStepSub, \l SliderPageStepAdd, \l SliderPageStepSub, | - |
| 192 | \l SliderToMinimum, \l SliderToMaximum, and \l SliderMove. | - |
| 193 | | - |
| 194 | When the signal is emitted, the \l sliderPosition has been | - |
| 195 | adjusted according to the action, but the \l value has not yet | - |
| 196 | been propagated (meaning the valueChanged() signal was not yet | - |
| 197 | emitted), and the visual display has not been updated. In slots | - |
| 198 | connected to this signal you can thus safely adjust any action by | - |
| 199 | calling setSliderPosition() yourself, based on both the action and | - |
| 200 | the slider's value. | - |
| 201 | | - |
| 202 | \sa triggerAction() | - |
| 203 | */ | - |
| 204 | | - |
| 205 | /*! | - |
| 206 | \enum QAbstractSlider::SliderChange | - |
| 207 | | - |
| 208 | \value SliderRangeChange | - |
| 209 | \value SliderOrientationChange | - |
| 210 | \value SliderStepsChange | - |
| 211 | \value SliderValueChange | - |
| 212 | */ | - |
| 213 | | - |
| 214 | QAbstractSliderPrivate::QAbstractSliderPrivate() | - |
| 215 | : minimum(0), maximum(99), pageStep(10), value(0), position(0), pressValue(-1), | - |
| 216 | singleStep(1), offset_accumulated(0), tracking(true), | - |
| 217 | blocktracking(false), pressed(false), | - |
| 218 | invertedAppearance(false), invertedControls(false), | - |
| 219 | orientation(Qt::Horizontal), repeatAction(QAbstractSlider::SliderNoAction) | - |
| 220 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 221 | , isAutoRepeating(false) | - |
| 222 | , repeatMultiplier(1) | - |
| 223 | { | - |
| 224 | firstRepeat.invalidate(); | - |
| 225 | #else | - |
| 226 | { | - |
| 227 | #endif | - |
| 228 | | - |
| 229 | } executed: }Execution Count:10240 | 10240 |
| 230 | | - |
| 231 | QAbstractSliderPrivate::~QAbstractSliderPrivate() | - |
| 232 | { | - |
| 233 | } | - |
| 234 | | - |
| 235 | /*! | - |
| 236 | Sets the slider's minimum to \a min and its maximum to \a max. | - |
| 237 | | - |
| 238 | If \a max is smaller than \a min, \a min becomes the only legal | - |
| 239 | value. | - |
| 240 | | - |
| 241 | \sa minimum, maximum | - |
| 242 | */ | - |
| 243 | void QAbstractSlider::setRange(int min, int max) | - |
| 244 | { | - |
| 245 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 246 | int oldMin = d->minimum; executed (the execution status of this line is deduced): int oldMin = d->minimum; | - |
| 247 | int oldMax = d->maximum; executed (the execution status of this line is deduced): int oldMax = d->maximum; | - |
| 248 | d->minimum = min; executed (the execution status of this line is deduced): d->minimum = min; | - |
| 249 | d->maximum = qMax(min, max); executed (the execution status of this line is deduced): d->maximum = qMax(min, max); | - |
| 250 | if (oldMin != d->minimum || oldMax != d->maximum) { evaluated: oldMin != d->minimum| yes Evaluation Count:805 | yes Evaluation Count:48877 |
evaluated: oldMax != d->maximum| yes Evaluation Count:12794 | yes Evaluation Count:36083 |
| 805-48877 |
| 251 | sliderChange(SliderRangeChange); executed (the execution status of this line is deduced): sliderChange(SliderRangeChange); | - |
| 252 | emit rangeChanged(d->minimum, d->maximum); executed (the execution status of this line is deduced): rangeChanged(d->minimum, d->maximum); | - |
| 253 | setValue(d->value); // re-bound executed (the execution status of this line is deduced): setValue(d->value); | - |
| 254 | } executed: }Execution Count:13599 | 13599 |
| 255 | } executed: }Execution Count:49682 | 49682 |
| 256 | | - |
| 257 | | - |
| 258 | void QAbstractSliderPrivate::setSteps(int single, int page) | - |
| 259 | { | - |
| 260 | Q_Q(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSlider * const q = q_func(); | - |
| 261 | singleStep = qAbs(single); executed (the execution status of this line is deduced): singleStep = qAbs(single); | - |
| 262 | pageStep = qAbs(page); executed (the execution status of this line is deduced): pageStep = qAbs(page); | - |
| 263 | q->sliderChange(QAbstractSlider::SliderStepsChange); executed (the execution status of this line is deduced): q->sliderChange(QAbstractSlider::SliderStepsChange); | - |
| 264 | } executed: }Execution Count:7341 | 7341 |
| 265 | | - |
| 266 | /*! | - |
| 267 | Constructs an abstract slider. | - |
| 268 | | - |
| 269 | The \a parent argument is sent to the QWidget constructor. | - |
| 270 | | - |
| 271 | The \l minimum defaults to 0, the \l maximum to 99, with a \l | - |
| 272 | singleStep size of 1 and a \l pageStep size of 10, and an initial | - |
| 273 | \l value of 0. | - |
| 274 | */ | - |
| 275 | QAbstractSlider::QAbstractSlider(QWidget *parent) | - |
| 276 | :QWidget(*new QAbstractSliderPrivate, parent, 0) | - |
| 277 | { | - |
| 278 | } executed: }Execution Count:2 | 2 |
| 279 | | - |
| 280 | /*! \internal */ | - |
| 281 | QAbstractSlider::QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent) | - |
| 282 | :QWidget(dd, parent, 0) | - |
| 283 | { | - |
| 284 | } executed: }Execution Count:10238 | 10238 |
| 285 | | - |
| 286 | /*! | - |
| 287 | Destroys the slider. | - |
| 288 | */ | - |
| 289 | QAbstractSlider::~QAbstractSlider() | - |
| 290 | { | - |
| 291 | } | - |
| 292 | | - |
| 293 | /*! | - |
| 294 | \property QAbstractSlider::orientation | - |
| 295 | \brief the orientation of the slider | - |
| 296 | | - |
| 297 | The orientation must be \l Qt::Vertical (the default) or \l | - |
| 298 | Qt::Horizontal. | - |
| 299 | */ | - |
| 300 | void QAbstractSlider::setOrientation(Qt::Orientation orientation) | - |
| 301 | { | - |
| 302 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 303 | if (d->orientation == orientation) evaluated: d->orientation == orientation| yes Evaluation Count:39 | yes Evaluation Count:28 |
| 28-39 |
| 304 | return; executed: return;Execution Count:39 | 39 |
| 305 | | - |
| 306 | d->orientation = orientation; executed (the execution status of this line is deduced): d->orientation = orientation; | - |
| 307 | if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) { partially evaluated: !testAttribute(Qt::WA_WState_OwnSizePolicy)| yes Evaluation Count:28 | no Evaluation Count:0 |
| 0-28 |
| 308 | QSizePolicy sp = sizePolicy(); executed (the execution status of this line is deduced): QSizePolicy sp = sizePolicy(); | - |
| 309 | sp.transpose(); executed (the execution status of this line is deduced): sp.transpose(); | - |
| 310 | setSizePolicy(sp); executed (the execution status of this line is deduced): setSizePolicy(sp); | - |
| 311 | setAttribute(Qt::WA_WState_OwnSizePolicy, false); executed (the execution status of this line is deduced): setAttribute(Qt::WA_WState_OwnSizePolicy, false); | - |
| 312 | } executed: }Execution Count:28 | 28 |
| 313 | update(); executed (the execution status of this line is deduced): update(); | - |
| 314 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
| 315 | } executed: }Execution Count:28 | 28 |
| 316 | | - |
| 317 | Qt::Orientation QAbstractSlider::orientation() const | - |
| 318 | { | - |
| 319 | Q_D(const QAbstractSlider); executed (the execution status of this line is deduced): const QAbstractSliderPrivate * const d = d_func(); | - |
| 320 | return d->orientation; executed: return d->orientation;Execution Count:3934 | 3934 |
| 321 | } | - |
| 322 | | - |
| 323 | | - |
| 324 | /*! | - |
| 325 | \property QAbstractSlider::minimum | - |
| 326 | \brief the sliders's minimum value | - |
| 327 | | - |
| 328 | When setting this property, the \l maximum is adjusted if | - |
| 329 | necessary to ensure that the range remains valid. Also the | - |
| 330 | slider's current value is adjusted to be within the new range. | - |
| 331 | | - |
| 332 | */ | - |
| 333 | | - |
| 334 | void QAbstractSlider::setMinimum(int min) | - |
| 335 | { | - |
| 336 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 337 | setRange(min, qMax(d->maximum, min)); executed (the execution status of this line is deduced): setRange(min, qMax(d->maximum, min)); | - |
| 338 | } executed: }Execution Count:22 | 22 |
| 339 | | - |
| 340 | int QAbstractSlider::minimum() const | - |
| 341 | { | - |
| 342 | Q_D(const QAbstractSlider); executed (the execution status of this line is deduced): const QAbstractSliderPrivate * const d = d_func(); | - |
| 343 | return d->minimum; executed: return d->minimum;Execution Count:30871 | 30871 |
| 344 | } | - |
| 345 | | - |
| 346 | | - |
| 347 | /*! | - |
| 348 | \property QAbstractSlider::maximum | - |
| 349 | \brief the slider's maximum value | - |
| 350 | | - |
| 351 | When setting this property, the \l minimum is adjusted if | - |
| 352 | necessary to ensure that the range remains valid. Also the | - |
| 353 | slider's current value is adjusted to be within the new range. | - |
| 354 | | - |
| 355 | | - |
| 356 | */ | - |
| 357 | | - |
| 358 | void QAbstractSlider::setMaximum(int max) | - |
| 359 | { | - |
| 360 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 361 | setRange(qMin(d->minimum, max), max); executed (the execution status of this line is deduced): setRange(qMin(d->minimum, max), max); | - |
| 362 | } executed: }Execution Count:22 | 22 |
| 363 | | - |
| 364 | int QAbstractSlider::maximum() const | - |
| 365 | { | - |
| 366 | Q_D(const QAbstractSlider); executed (the execution status of this line is deduced): const QAbstractSliderPrivate * const d = d_func(); | - |
| 367 | return d->maximum; executed: return d->maximum;Execution Count:48561 | 48561 |
| 368 | } | - |
| 369 | | - |
| 370 | | - |
| 371 | | - |
| 372 | /*! | - |
| 373 | \property QAbstractSlider::singleStep | - |
| 374 | \brief the single step. | - |
| 375 | | - |
| 376 | The smaller of two natural steps that an | - |
| 377 | abstract sliders provides and typically corresponds to the user | - |
| 378 | pressing an arrow key. | - |
| 379 | | - |
| 380 | If the property is modified during an auto repeating key event, behavior | - |
| 381 | is undefined. | - |
| 382 | | - |
| 383 | \sa pageStep | - |
| 384 | */ | - |
| 385 | | - |
| 386 | void QAbstractSlider::setSingleStep(int step) | - |
| 387 | { | - |
| 388 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 389 | if (step != d->singleStep) evaluated: step != d->singleStep| yes Evaluation Count:2247 | yes Evaluation Count:22033 |
| 2247-22033 |
| 390 | d->setSteps(step, d->pageStep); executed: d->setSteps(step, d->pageStep);Execution Count:2247 | 2247 |
| 391 | } executed: }Execution Count:24280 | 24280 |
| 392 | | - |
| 393 | int QAbstractSlider::singleStep() const | - |
| 394 | { | - |
| 395 | Q_D(const QAbstractSlider); executed (the execution status of this line is deduced): const QAbstractSliderPrivate * const d = d_func(); | - |
| 396 | return d->singleStep; executed: return d->singleStep;Execution Count:104 | 104 |
| 397 | } | - |
| 398 | | - |
| 399 | | - |
| 400 | /*! | - |
| 401 | \property QAbstractSlider::pageStep | - |
| 402 | \brief the page step. | - |
| 403 | | - |
| 404 | The larger of two natural steps that an abstract slider provides | - |
| 405 | and typically corresponds to the user pressing PageUp or PageDown. | - |
| 406 | | - |
| 407 | \sa singleStep | - |
| 408 | */ | - |
| 409 | | - |
| 410 | void QAbstractSlider::setPageStep(int step) | - |
| 411 | { | - |
| 412 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 413 | if (step != d->pageStep) evaluated: step != d->pageStep| yes Evaluation Count:5094 | yes Evaluation Count:19841 |
| 5094-19841 |
| 414 | d->setSteps(d->singleStep, step); executed: d->setSteps(d->singleStep, step);Execution Count:5094 | 5094 |
| 415 | } executed: }Execution Count:24935 | 24935 |
| 416 | | - |
| 417 | int QAbstractSlider::pageStep() const | - |
| 418 | { | - |
| 419 | Q_D(const QAbstractSlider); executed (the execution status of this line is deduced): const QAbstractSliderPrivate * const d = d_func(); | - |
| 420 | return d->pageStep; executed: return d->pageStep;Execution Count:2952 | 2952 |
| 421 | } | - |
| 422 | | - |
| 423 | /*! | - |
| 424 | \property QAbstractSlider::tracking | - |
| 425 | \brief whether slider tracking is enabled | - |
| 426 | | - |
| 427 | If tracking is enabled (the default), the slider emits the | - |
| 428 | valueChanged() signal while the slider is being dragged. If | - |
| 429 | tracking is disabled, the slider emits the valueChanged() signal | - |
| 430 | only when the user releases the slider. | - |
| 431 | | - |
| 432 | \sa sliderDown | - |
| 433 | */ | - |
| 434 | void QAbstractSlider::setTracking(bool enable) | - |
| 435 | { | - |
| 436 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 437 | d->tracking = enable; executed (the execution status of this line is deduced): d->tracking = enable; | - |
| 438 | } executed: }Execution Count:39 | 39 |
| 439 | | - |
| 440 | bool QAbstractSlider::hasTracking() const | - |
| 441 | { | - |
| 442 | Q_D(const QAbstractSlider); executed (the execution status of this line is deduced): const QAbstractSliderPrivate * const d = d_func(); | - |
| 443 | return d->tracking; executed: return d->tracking;Execution Count:10 | 10 |
| 444 | } | - |
| 445 | | - |
| 446 | | - |
| 447 | /*! | - |
| 448 | \property QAbstractSlider::sliderDown | - |
| 449 | \brief whether the slider is pressed down. | - |
| 450 | | - |
| 451 | The property is set by subclasses in order to let the abstract | - |
| 452 | slider know whether or not \l tracking has any effect. | - |
| 453 | | - |
| 454 | Changing the slider down property emits the sliderPressed() and | - |
| 455 | sliderReleased() signals. | - |
| 456 | | - |
| 457 | */ | - |
| 458 | void QAbstractSlider::setSliderDown(bool down) | - |
| 459 | { | - |
| 460 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 461 | bool doEmit = d->pressed != down; executed (the execution status of this line is deduced): bool doEmit = d->pressed != down; | - |
| 462 | | - |
| 463 | d->pressed = down; executed (the execution status of this line is deduced): d->pressed = down; | - |
| 464 | | - |
| 465 | if (doEmit) { evaluated: doEmit| yes Evaluation Count:14 | yes Evaluation Count:33 |
| 14-33 |
| 466 | if (down) evaluated: down| yes Evaluation Count:8 | yes Evaluation Count:6 |
| 6-8 |
| 467 | emit sliderPressed(); executed: sliderPressed();Execution Count:8 | 8 |
| 468 | else | - |
| 469 | emit sliderReleased(); executed: sliderReleased();Execution Count:6 | 6 |
| 470 | } | - |
| 471 | | - |
| 472 | if (!down && d->position != d->value) evaluated: !down| yes Evaluation Count:39 | yes Evaluation Count:8 |
evaluated: d->position != d->value| yes Evaluation Count:1 | yes Evaluation Count:38 |
| 1-39 |
| 473 | triggerAction(SliderMove); executed: triggerAction(SliderMove);Execution Count:1 | 1 |
| 474 | } executed: }Execution Count:47 | 47 |
| 475 | | - |
| 476 | bool QAbstractSlider::isSliderDown() const | - |
| 477 | { | - |
| 478 | Q_D(const QAbstractSlider); executed (the execution status of this line is deduced): const QAbstractSliderPrivate * const d = d_func(); | - |
| 479 | return d->pressed; executed: return d->pressed;Execution Count:8 | 8 |
| 480 | } | - |
| 481 | | - |
| 482 | | - |
| 483 | /*! | - |
| 484 | \property QAbstractSlider::sliderPosition | - |
| 485 | \brief the current slider position | - |
| 486 | | - |
| 487 | If \l tracking is enabled (the default), this is identical to \l value. | - |
| 488 | */ | - |
| 489 | void QAbstractSlider::setSliderPosition(int position) | - |
| 490 | { | - |
| 491 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 492 | position = d->bound(position); executed (the execution status of this line is deduced): position = d->bound(position); | - |
| 493 | if (position == d->position) evaluated: position == d->position| yes Evaluation Count:25 | yes Evaluation Count:227 |
| 25-227 |
| 494 | return; executed: return;Execution Count:25 | 25 |
| 495 | d->position = position; executed (the execution status of this line is deduced): d->position = position; | - |
| 496 | if (!d->tracking) evaluated: !d->tracking| yes Evaluation Count:11 | yes Evaluation Count:216 |
| 11-216 |
| 497 | update(); executed: update();Execution Count:11 | 11 |
| 498 | if (d->pressed) evaluated: d->pressed| yes Evaluation Count:6 | yes Evaluation Count:221 |
| 6-221 |
| 499 | emit sliderMoved(position); executed: sliderMoved(position);Execution Count:6 | 6 |
| 500 | if (d->tracking && !d->blocktracking) evaluated: d->tracking| yes Evaluation Count:216 | yes Evaluation Count:11 |
evaluated: !d->blocktracking| yes Evaluation Count:91 | yes Evaluation Count:125 |
| 11-216 |
| 501 | triggerAction(SliderMove); executed: triggerAction(SliderMove);Execution Count:91 | 91 |
| 502 | } executed: }Execution Count:227 | 227 |
| 503 | | - |
| 504 | int QAbstractSlider::sliderPosition() const | - |
| 505 | { | - |
| 506 | Q_D(const QAbstractSlider); executed (the execution status of this line is deduced): const QAbstractSliderPrivate * const d = d_func(); | - |
| 507 | return d->position; executed: return d->position;Execution Count:178 | 178 |
| 508 | } | - |
| 509 | | - |
| 510 | | - |
| 511 | /*! | - |
| 512 | \property QAbstractSlider::value | - |
| 513 | \brief the slider's current value | - |
| 514 | | - |
| 515 | The slider forces the value to be within the legal range: \l | - |
| 516 | minimum <= \c value <= \l maximum. | - |
| 517 | | - |
| 518 | Changing the value also changes the \l sliderPosition. | - |
| 519 | */ | - |
| 520 | | - |
| 521 | | - |
| 522 | int QAbstractSlider::value() const | - |
| 523 | { | - |
| 524 | Q_D(const QAbstractSlider); executed (the execution status of this line is deduced): const QAbstractSliderPrivate * const d = d_func(); | - |
| 525 | return d->value; executed: return d->value;Execution Count:122880 | 122880 |
| 526 | } | - |
| 527 | | - |
| 528 | void QAbstractSlider::setValue(int value) | - |
| 529 | { | - |
| 530 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 531 | value = d->bound(value); executed (the execution status of this line is deduced): value = d->bound(value); | - |
| 532 | if (d->value == value && d->position == value) evaluated: d->value == value| yes Evaluation Count:19224 | yes Evaluation Count:9513 |
evaluated: d->position == value| yes Evaluation Count:19222 | yes Evaluation Count:2 |
| 2-19224 |
| 533 | return; executed: return;Execution Count:19222 | 19222 |
| 534 | d->value = value; executed (the execution status of this line is deduced): d->value = value; | - |
| 535 | if (d->position != value) { evaluated: d->position != value| yes Evaluation Count:9272 | yes Evaluation Count:243 |
| 243-9272 |
| 536 | d->position = value; executed (the execution status of this line is deduced): d->position = value; | - |
| 537 | if (d->pressed) evaluated: d->pressed| yes Evaluation Count:4 | yes Evaluation Count:9268 |
| 4-9268 |
| 538 | emit sliderMoved((d->position = value)); executed: sliderMoved((d->position = value));Execution Count:4 | 4 |
| 539 | } executed: }Execution Count:9272 | 9272 |
| 540 | #ifndef QT_NO_ACCESSIBILITY | - |
| 541 | QAccessibleValueChangeEvent event(this, d->value); executed (the execution status of this line is deduced): QAccessibleValueChangeEvent event(this, d->value); | - |
| 542 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
| 543 | #endif | - |
| 544 | sliderChange(SliderValueChange); executed (the execution status of this line is deduced): sliderChange(SliderValueChange); | - |
| 545 | emit valueChanged(value); executed (the execution status of this line is deduced): valueChanged(value); | - |
| 546 | } executed: }Execution Count:9515 | 9515 |
| 547 | | - |
| 548 | /*! | - |
| 549 | \property QAbstractSlider::invertedAppearance | - |
| 550 | \brief whether or not a slider shows its values inverted. | - |
| 551 | | - |
| 552 | If this property is false (the default), the minimum and maximum will | - |
| 553 | be shown in its classic position for the inherited widget. If the | - |
| 554 | value is true, the minimum and maximum appear at their opposite location. | - |
| 555 | | - |
| 556 | Note: This property makes most sense for sliders and dials. For | - |
| 557 | scroll bars, the visual effect of the scroll bar subcontrols depends on | - |
| 558 | whether or not the styles understand inverted appearance; most styles | - |
| 559 | ignore this property for scroll bars. | - |
| 560 | */ | - |
| 561 | | - |
| 562 | bool QAbstractSlider::invertedAppearance() const | - |
| 563 | { | - |
| 564 | Q_D(const QAbstractSlider); executed (the execution status of this line is deduced): const QAbstractSliderPrivate * const d = d_func(); | - |
| 565 | return d->invertedAppearance; executed: return d->invertedAppearance;Execution Count:14 | 14 |
| 566 | } | - |
| 567 | | - |
| 568 | void QAbstractSlider::setInvertedAppearance(bool invert) | - |
| 569 | { | - |
| 570 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 571 | d->invertedAppearance = invert; executed (the execution status of this line is deduced): d->invertedAppearance = invert; | - |
| 572 | update(); executed (the execution status of this line is deduced): update(); | - |
| 573 | } executed: }Execution Count:54 | 54 |
| 574 | | - |
| 575 | | - |
| 576 | /*! | - |
| 577 | \property QAbstractSlider::invertedControls | - |
| 578 | \brief whether or not the slider inverts its wheel and key events. | - |
| 579 | | - |
| 580 | If this property is false, scrolling the mouse wheel "up" and using keys | - |
| 581 | like page up will increase the slider's value towards its maximum. Otherwise | - |
| 582 | pressing page up will move value towards the slider's minimum. | - |
| 583 | */ | - |
| 584 | | - |
| 585 | | - |
| 586 | bool QAbstractSlider::invertedControls() const | - |
| 587 | { | - |
| 588 | Q_D(const QAbstractSlider); executed (the execution status of this line is deduced): const QAbstractSliderPrivate * const d = d_func(); | - |
| 589 | return d->invertedControls; executed: return d->invertedControls;Execution Count:10 | 10 |
| 590 | } | - |
| 591 | | - |
| 592 | void QAbstractSlider::setInvertedControls(bool invert) | - |
| 593 | { | - |
| 594 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 595 | d->invertedControls = invert; executed (the execution status of this line is deduced): d->invertedControls = invert; | - |
| 596 | } executed: }Execution Count:62 | 62 |
| 597 | | - |
| 598 | /*! Triggers a slider \a action. Possible actions are \l | - |
| 599 | SliderSingleStepAdd, \l SliderSingleStepSub, \l SliderPageStepAdd, | - |
| 600 | \l SliderPageStepSub, \l SliderToMinimum, \l SliderToMaximum, and \l | - |
| 601 | SliderMove. | - |
| 602 | | - |
| 603 | \sa actionTriggered() | - |
| 604 | */ | - |
| 605 | void QAbstractSlider::triggerAction(SliderAction action) | - |
| 606 | { | - |
| 607 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 608 | d->blocktracking = true; executed (the execution status of this line is deduced): d->blocktracking = true; | - |
| 609 | switch (action) { | - |
| 610 | case SliderSingleStepAdd: | - |
| 611 | setSliderPosition(d->overflowSafeAdd(d->effectiveSingleStep())); executed (the execution status of this line is deduced): setSliderPosition(d->overflowSafeAdd(d->effectiveSingleStep())); | - |
| 612 | break; executed: break;Execution Count:41 | 41 |
| 613 | case SliderSingleStepSub: | - |
| 614 | setSliderPosition(d->overflowSafeAdd(-d->effectiveSingleStep())); executed (the execution status of this line is deduced): setSliderPosition(d->overflowSafeAdd(-d->effectiveSingleStep())); | - |
| 615 | break; executed: break;Execution Count:40 | 40 |
| 616 | case SliderPageStepAdd: | - |
| 617 | setSliderPosition(d->overflowSafeAdd(d->pageStep)); executed (the execution status of this line is deduced): setSliderPosition(d->overflowSafeAdd(d->pageStep)); | - |
| 618 | break; executed: break;Execution Count:25 | 25 |
| 619 | case SliderPageStepSub: | - |
| 620 | setSliderPosition(d->overflowSafeAdd(-d->pageStep)); executed (the execution status of this line is deduced): setSliderPosition(d->overflowSafeAdd(-d->pageStep)); | - |
| 621 | break; executed: break;Execution Count:17 | 17 |
| 622 | case SliderToMinimum: | - |
| 623 | setSliderPosition(d->minimum); executed (the execution status of this line is deduced): setSliderPosition(d->minimum); | - |
| 624 | break; executed: break;Execution Count:9 | 9 |
| 625 | case SliderToMaximum: | - |
| 626 | setSliderPosition(d->maximum); executed (the execution status of this line is deduced): setSliderPosition(d->maximum); | - |
| 627 | break; executed: break;Execution Count:9 | 9 |
| 628 | case SliderMove: | - |
| 629 | case SliderNoAction: | - |
| 630 | break; executed: break;Execution Count:119 | 119 |
| 631 | }; | - |
| 632 | emit actionTriggered(action); executed (the execution status of this line is deduced): actionTriggered(action); | - |
| 633 | d->blocktracking = false; executed (the execution status of this line is deduced): d->blocktracking = false; | - |
| 634 | setValue(d->position); executed (the execution status of this line is deduced): setValue(d->position); | - |
| 635 | } executed: }Execution Count:260 | 260 |
| 636 | | - |
| 637 | /*! Sets action \a action to be triggered repetitively in intervals | - |
| 638 | of \a repeatTime, after an initial delay of \a thresholdTime. | - |
| 639 | | - |
| 640 | \sa triggerAction(), repeatAction() | - |
| 641 | */ | - |
| 642 | void QAbstractSlider::setRepeatAction(SliderAction action, int thresholdTime, int repeatTime) | - |
| 643 | { | - |
| 644 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 645 | if ((d->repeatAction = action) == SliderNoAction) { evaluated: (d->repeatAction = action) == SliderNoAction| yes Evaluation Count:8 | yes Evaluation Count:5 |
| 5-8 |
| 646 | d->repeatActionTimer.stop(); executed (the execution status of this line is deduced): d->repeatActionTimer.stop(); | - |
| 647 | } else { executed: }Execution Count:8 | 8 |
| 648 | d->repeatActionTime = repeatTime; executed (the execution status of this line is deduced): d->repeatActionTime = repeatTime; | - |
| 649 | d->repeatActionTimer.start(thresholdTime, this); executed (the execution status of this line is deduced): d->repeatActionTimer.start(thresholdTime, this); | - |
| 650 | } executed: }Execution Count:5 | 5 |
| 651 | } | - |
| 652 | | - |
| 653 | /*! | - |
| 654 | Returns the current repeat action. | - |
| 655 | \sa setRepeatAction() | - |
| 656 | */ | - |
| 657 | QAbstractSlider::SliderAction QAbstractSlider::repeatAction() const | - |
| 658 | { | - |
| 659 | Q_D(const QAbstractSlider); never executed (the execution status of this line is deduced): const QAbstractSliderPrivate * const d = d_func(); | - |
| 660 | return d->repeatAction; never executed: return d->repeatAction; | 0 |
| 661 | } | - |
| 662 | | - |
| 663 | /*!\reimp | - |
| 664 | */ | - |
| 665 | void QAbstractSlider::timerEvent(QTimerEvent *e) | - |
| 666 | { | - |
| 667 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 668 | if (e->timerId() == d->repeatActionTimer.timerId()) { partially evaluated: e->timerId() == d->repeatActionTimer.timerId()| yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
| 669 | if (d->repeatActionTime) { // was threshold time, use repeat time next time evaluated: d->repeatActionTime| yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
| 670 | d->repeatActionTimer.start(d->repeatActionTime, this); executed (the execution status of this line is deduced): d->repeatActionTimer.start(d->repeatActionTime, this); | - |
| 671 | d->repeatActionTime = 0; executed (the execution status of this line is deduced): d->repeatActionTime = 0; | - |
| 672 | } executed: }Execution Count:1 | 1 |
| 673 | if (d->repeatAction == SliderPageStepAdd) partially evaluated: d->repeatAction == SliderPageStepAdd| yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
| 674 | d->setAdjustedSliderPosition(d->overflowSafeAdd(d->pageStep)); executed: d->setAdjustedSliderPosition(d->overflowSafeAdd(d->pageStep));Execution Count:6 | 6 |
| 675 | else if (d->repeatAction == SliderPageStepSub) never evaluated: d->repeatAction == SliderPageStepSub | 0 |
| 676 | d->setAdjustedSliderPosition(d->overflowSafeAdd(-d->pageStep)); never executed: d->setAdjustedSliderPosition(d->overflowSafeAdd(-d->pageStep)); | 0 |
| 677 | else | - |
| 678 | triggerAction(d->repeatAction); never executed: triggerAction(d->repeatAction); | 0 |
| 679 | } | - |
| 680 | } executed: }Execution Count:6 | 6 |
| 681 | | - |
| 682 | /*! | - |
| 683 | Reimplement this virtual function to track slider changes such as | - |
| 684 | \l SliderRangeChange, \l SliderOrientationChange, \l | - |
| 685 | SliderStepsChange, or \l SliderValueChange. The default | - |
| 686 | implementation only updates the display and ignores the \a change | - |
| 687 | parameter. | - |
| 688 | */ | - |
| 689 | void QAbstractSlider::sliderChange(SliderChange) | - |
| 690 | { | - |
| 691 | update(); executed (the execution status of this line is deduced): update(); | - |
| 692 | } executed: }Execution Count:30455 | 30455 |
| 693 | | - |
| 694 | bool QAbstractSliderPrivate::scrollByDelta(Qt::Orientation orientation, Qt::KeyboardModifiers modifiers, int delta) | - |
| 695 | { | - |
| 696 | Q_Q(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSlider * const q = q_func(); | - |
| 697 | int stepsToScroll = 0; executed (the execution status of this line is deduced): int stepsToScroll = 0; | - |
| 698 | // in Qt scrolling to the right gives negative values. | - |
| 699 | if (orientation == Qt::Horizontal) evaluated: orientation == Qt::Horizontal| yes Evaluation Count:12 | yes Evaluation Count:13 |
| 12-13 |
| 700 | delta = -delta; executed: delta = -delta;Execution Count:12 | 12 |
| 701 | qreal offset = qreal(delta) / 120; executed (the execution status of this line is deduced): qreal offset = qreal(delta) / 120; | - |
| 702 | | - |
| 703 | if ((modifiers & Qt::ControlModifier) || (modifiers & Qt::ShiftModifier)) { evaluated: (modifiers & Qt::ControlModifier)| yes Evaluation Count:1 | yes Evaluation Count:24 |
evaluated: (modifiers & Qt::ShiftModifier)| yes Evaluation Count:1 | yes Evaluation Count:23 |
| 1-24 |
| 704 | // Scroll one page regardless of delta: | - |
| 705 | stepsToScroll = qBound(-pageStep, int(offset * pageStep), pageStep); executed (the execution status of this line is deduced): stepsToScroll = qBound(-pageStep, int(offset * pageStep), pageStep); | - |
| 706 | offset_accumulated = 0; executed (the execution status of this line is deduced): offset_accumulated = 0; | - |
| 707 | } else { executed: }Execution Count:2 | 2 |
| 708 | // Calculate how many lines to scroll. Depending on what delta is (and | - |
| 709 | // offset), we might end up with a fraction (e.g. scroll 1.3 lines). We can | - |
| 710 | // only scroll whole lines, so we keep the reminder until next event. | - |
| 711 | qreal stepsToScrollF = executed (the execution status of this line is deduced): qreal stepsToScrollF = | - |
| 712 | #ifndef QT_NO_WHEELEVENT executed (the execution status of this line is deduced): | - |
| 713 | QApplication::wheelScrollLines() * executed (the execution status of this line is deduced): QApplication::wheelScrollLines() * | - |
| 714 | #endif executed (the execution status of this line is deduced): | - |
| 715 | offset * effectiveSingleStep(); executed (the execution status of this line is deduced): offset * effectiveSingleStep(); | - |
| 716 | // Check if wheel changed direction since last event: | - |
| 717 | if (offset_accumulated != 0 && (offset / offset_accumulated) < 0) partially evaluated: offset_accumulated != 0| no Evaluation Count:0 | yes Evaluation Count:23 |
never evaluated: (offset / offset_accumulated) < 0 | 0-23 |
| 718 | offset_accumulated = 0; never executed: offset_accumulated = 0; | 0 |
| 719 | | - |
| 720 | offset_accumulated += stepsToScrollF; executed (the execution status of this line is deduced): offset_accumulated += stepsToScrollF; | - |
| 721 | #ifndef Q_WS_MAC | - |
| 722 | // Don't scroll more than one page in any case: | - |
| 723 | stepsToScroll = qBound(-pageStep, int(offset_accumulated), pageStep); executed (the execution status of this line is deduced): stepsToScroll = qBound(-pageStep, int(offset_accumulated), pageStep); | - |
| 724 | #else | - |
| 725 | // Native UI-elements on Mac can scroll hundreds of lines at a time as | - |
| 726 | // a result of acceleration. So keep the same behaviour in Qt, and | - |
| 727 | // don't restrict stepsToScroll to certain maximum (pageStep): | - |
| 728 | stepsToScroll = int(offset_accumulated); | - |
| 729 | #endif | - |
| 730 | offset_accumulated -= int(offset_accumulated); executed (the execution status of this line is deduced): offset_accumulated -= int(offset_accumulated); | - |
| 731 | if (stepsToScroll == 0) partially evaluated: stepsToScroll == 0| no Evaluation Count:0 | yes Evaluation Count:23 |
| 0-23 |
| 732 | return false; never executed: return false; | 0 |
| 733 | } executed: }Execution Count:23 | 23 |
| 734 | | - |
| 735 | if (invertedControls) evaluated: invertedControls| yes Evaluation Count:11 | yes Evaluation Count:14 |
| 11-14 |
| 736 | stepsToScroll = -stepsToScroll; executed: stepsToScroll = -stepsToScroll;Execution Count:11 | 11 |
| 737 | | - |
| 738 | int prevValue = value; executed (the execution status of this line is deduced): int prevValue = value; | - |
| 739 | position = overflowSafeAdd(stepsToScroll); // value will be updated by triggerAction() executed (the execution status of this line is deduced): position = overflowSafeAdd(stepsToScroll); | - |
| 740 | q->triggerAction(QAbstractSlider::SliderMove); executed (the execution status of this line is deduced): q->triggerAction(QAbstractSlider::SliderMove); | - |
| 741 | | - |
| 742 | if (prevValue == value) { evaluated: prevValue == value| yes Evaluation Count:2 | yes Evaluation Count:23 |
| 2-23 |
| 743 | offset_accumulated = 0; executed (the execution status of this line is deduced): offset_accumulated = 0; | - |
| 744 | return false; executed: return false;Execution Count:2 | 2 |
| 745 | } | - |
| 746 | return true; executed: return true;Execution Count:23 | 23 |
| 747 | } | - |
| 748 | | - |
| 749 | /*! | - |
| 750 | \reimp | - |
| 751 | */ | - |
| 752 | #ifndef QT_NO_WHEELEVENT | - |
| 753 | void QAbstractSlider::wheelEvent(QWheelEvent * e) | - |
| 754 | { | - |
| 755 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 756 | e->ignore(); executed (the execution status of this line is deduced): e->ignore(); | - |
| 757 | int delta = e->delta(); executed (the execution status of this line is deduced): int delta = e->delta(); | - |
| 758 | if (d->scrollByDelta(e->orientation(), e->modifiers(), delta)) partially evaluated: d->scrollByDelta(e->orientation(), e->modifiers(), delta)| yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
| 759 | e->accept(); executed: e->accept();Execution Count:16 | 16 |
| 760 | } executed: }Execution Count:16 | 16 |
| 761 | | - |
| 762 | #endif | - |
| 763 | | - |
| 764 | /*! | - |
| 765 | \reimp | - |
| 766 | */ | - |
| 767 | void QAbstractSlider::keyPressEvent(QKeyEvent *ev) | - |
| 768 | { | - |
| 769 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 770 | SliderAction action = SliderNoAction; executed (the execution status of this line is deduced): SliderAction action = SliderNoAction; | - |
| 771 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 772 | if (ev->isAutoRepeat()) { | - |
| 773 | if (!d->firstRepeat.isValid()) | - |
| 774 | d->firstRepeat.start(); | - |
| 775 | else if (1 == d->repeatMultiplier) { | - |
| 776 | // This is the interval in milli seconds which one key repetition | - |
| 777 | // takes. | - |
| 778 | const int repeatMSecs = d->firstRepeat.elapsed(); | - |
| 779 | | - |
| 780 | /** | - |
| 781 | * The time it takes to currently navigate the whole slider. | - |
| 782 | */ | - |
| 783 | const qreal currentTimeElapse = (qreal(maximum()) / singleStep()) * repeatMSecs; | - |
| 784 | | - |
| 785 | /** | - |
| 786 | * This is an arbitrarily determined constant in msecs that | - |
| 787 | * specifies how long time it should take to navigate from the | - |
| 788 | * start to the end(excluding starting key auto repeat). | - |
| 789 | */ | - |
| 790 | const int SliderRepeatElapse = 2500; | - |
| 791 | | - |
| 792 | d->repeatMultiplier = currentTimeElapse / SliderRepeatElapse; | - |
| 793 | } | - |
| 794 | | - |
| 795 | } | - |
| 796 | else if (d->firstRepeat.isValid()) { | - |
| 797 | d->firstRepeat.invalidate(); | - |
| 798 | d->repeatMultiplier = 1; | - |
| 799 | } | - |
| 800 | | - |
| 801 | #endif | - |
| 802 | | - |
| 803 | switch (ev->key()) { | - |
| 804 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 805 | case Qt::Key_Select: | - |
| 806 | if (QApplication::keypadNavigationEnabled()) | - |
| 807 | setEditFocus(!hasEditFocus()); | - |
| 808 | else | - |
| 809 | ev->ignore(); | - |
| 810 | break; | - |
| 811 | case Qt::Key_Back: | - |
| 812 | if (QApplication::keypadNavigationEnabled() && hasEditFocus()) { | - |
| 813 | setValue(d->origValue); | - |
| 814 | setEditFocus(false); | - |
| 815 | } else | - |
| 816 | ev->ignore(); | - |
| 817 | break; | - |
| 818 | #endif | - |
| 819 | | - |
| 820 | // It seems we need to use invertedAppearance for Left and right, otherwise, things look weird. | - |
| 821 | case Qt::Key_Left: | - |
| 822 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 823 | // In QApplication::KeypadNavigationDirectional, we want to change the slider | - |
| 824 | // value if there is no left/right navigation possible and if this slider is not | - |
| 825 | // inside a tab widget. | - |
| 826 | if (QApplication::keypadNavigationEnabled() | - |
| 827 | && (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder | - |
| 828 | || d->orientation == Qt::Vertical | - |
| 829 | || !hasEditFocus() | - |
| 830 | && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) { | - |
| 831 | ev->ignore(); | - |
| 832 | return; | - |
| 833 | } | - |
| 834 | if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical) | - |
| 835 | action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd; | - |
| 836 | else | - |
| 837 | #endif | - |
| 838 | if (isRightToLeft()) partially evaluated: isRightToLeft()| no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
| 839 | action = d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; never executed: action = d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; never evaluated: d->invertedAppearance | 0 |
| 840 | else | - |
| 841 | action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; executed: action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd;Execution Count:12 evaluated: !d->invertedAppearance| yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6-12 |
| 842 | break; executed: break;Execution Count:12 | 12 |
| 843 | case Qt::Key_Right: | - |
| 844 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 845 | // Same logic as in Qt::Key_Left | - |
| 846 | if (QApplication::keypadNavigationEnabled() | - |
| 847 | && (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder | - |
| 848 | || d->orientation == Qt::Vertical | - |
| 849 | || !hasEditFocus() | - |
| 850 | && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) { | - |
| 851 | ev->ignore(); | - |
| 852 | return; | - |
| 853 | } | - |
| 854 | if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical) | - |
| 855 | action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub; | - |
| 856 | else | - |
| 857 | #endif | - |
| 858 | if (isRightToLeft()) partially evaluated: isRightToLeft()| no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
| 859 | action = d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; never executed: action = d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; never evaluated: d->invertedAppearance | 0 |
| 860 | else | - |
| 861 | action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; executed: action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub;Execution Count:12 evaluated: !d->invertedAppearance| yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6-12 |
| 862 | break; executed: break;Execution Count:12 | 12 |
| 863 | case Qt::Key_Up: | - |
| 864 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 865 | // In QApplication::KeypadNavigationDirectional, we want to change the slider | - |
| 866 | // value if there is no up/down navigation possible. | - |
| 867 | if (QApplication::keypadNavigationEnabled() | - |
| 868 | && (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder | - |
| 869 | || d->orientation == Qt::Horizontal | - |
| 870 | || !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical))) { | - |
| 871 | ev->ignore(); | - |
| 872 | break; | - |
| 873 | } | - |
| 874 | #endif | - |
| 875 | action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd; evaluated: d->invertedControls| yes Evaluation Count:8 | yes Evaluation Count:12 |
| 8-12 |
| 876 | break; executed: break;Execution Count:20 | 20 |
| 877 | case Qt::Key_Down: | - |
| 878 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 879 | // Same logic as in Qt::Key_Up | - |
| 880 | if (QApplication::keypadNavigationEnabled() | - |
| 881 | && (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder | - |
| 882 | || d->orientation == Qt::Horizontal | - |
| 883 | || !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical))) { | - |
| 884 | ev->ignore(); | - |
| 885 | break; | - |
| 886 | } | - |
| 887 | #endif | - |
| 888 | action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub; evaluated: d->invertedControls| yes Evaluation Count:8 | yes Evaluation Count:13 |
| 8-13 |
| 889 | break; executed: break;Execution Count:21 | 21 |
| 890 | case Qt::Key_PageUp: | - |
| 891 | action = d->invertedControls ? SliderPageStepSub : SliderPageStepAdd; evaluated: d->invertedControls| yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6 |
| 892 | break; executed: break;Execution Count:12 | 12 |
| 893 | case Qt::Key_PageDown: | - |
| 894 | action = d->invertedControls ? SliderPageStepAdd : SliderPageStepSub; evaluated: d->invertedControls| yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6 |
| 895 | break; executed: break;Execution Count:12 | 12 |
| 896 | case Qt::Key_Home: | - |
| 897 | action = SliderToMinimum; executed (the execution status of this line is deduced): action = SliderToMinimum; | - |
| 898 | break; executed: break;Execution Count:8 | 8 |
| 899 | case Qt::Key_End: | - |
| 900 | action = SliderToMaximum; executed (the execution status of this line is deduced): action = SliderToMaximum; | - |
| 901 | break; executed: break;Execution Count:8 | 8 |
| 902 | default: | - |
| 903 | ev->ignore(); never executed (the execution status of this line is deduced): ev->ignore(); | - |
| 904 | break; | 0 |
| 905 | } | - |
| 906 | if (action) partially evaluated: action| yes Evaluation Count:105 | no Evaluation Count:0 |
| 0-105 |
| 907 | triggerAction(action); executed: triggerAction(action);Execution Count:105 | 105 |
| 908 | } executed: }Execution Count:105 | 105 |
| 909 | | - |
| 910 | /*! | - |
| 911 | \reimp | - |
| 912 | */ | - |
| 913 | void QAbstractSlider::changeEvent(QEvent *ev) | - |
| 914 | { | - |
| 915 | Q_D(QAbstractSlider); executed (the execution status of this line is deduced): QAbstractSliderPrivate * const d = d_func(); | - |
| 916 | switch (ev->type()) { | - |
| 917 | case QEvent::EnabledChange: | - |
| 918 | if (!isEnabled()) { evaluated: !isEnabled()| yes Evaluation Count:23 | yes Evaluation Count:20 |
| 20-23 |
| 919 | d->repeatActionTimer.stop(); executed (the execution status of this line is deduced): d->repeatActionTimer.stop(); | - |
| 920 | setSliderDown(false); executed (the execution status of this line is deduced): setSliderDown(false); | - |
| 921 | } executed: }Execution Count:23 | 23 |
| 922 | // fall through... | - |
| 923 | default: code before this statement executed: default:Execution Count:43 | 43 |
| 924 | QWidget::changeEvent(ev); executed (the execution status of this line is deduced): QWidget::changeEvent(ev); | - |
| 925 | } executed: }Execution Count:927 | 927 |
| 926 | } executed: }Execution Count:927 | 927 |
| 927 | | - |
| 928 | /*! | - |
| 929 | \reimp | - |
| 930 | */ | - |
| 931 | bool QAbstractSlider::event(QEvent *e) | - |
| 932 | { | - |
| 933 | #ifdef QT_KEYPAD_NAVIGATION | - |
| 934 | Q_D(QAbstractSlider); | - |
| 935 | switch (e->type()) { | - |
| 936 | case QEvent::FocusIn: | - |
| 937 | d->origValue = d->value; | - |
| 938 | break; | - |
| 939 | default: | - |
| 940 | break; | - |
| 941 | } | - |
| 942 | #endif | - |
| 943 | | - |
| 944 | return QWidget::event(e); executed: return QWidget::event(e);Execution Count:25885 | 25885 |
| 945 | } | - |
| 946 | | - |
| 947 | QT_END_NAMESPACE | - |
| 948 | | - |
| | |