| 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 "qdial.h" | - |
| 43 | | - |
| 44 | #ifndef QT_NO_DIAL | - |
| 45 | | - |
| 46 | #include <qapplication.h> | - |
| 47 | #include <qbitmap.h> | - |
| 48 | #include <qcolor.h> | - |
| 49 | #include <qevent.h> | - |
| 50 | #include <qpainter.h> | - |
| 51 | #include <qpolygon.h> | - |
| 52 | #include <qregion.h> | - |
| 53 | #include <qstyle.h> | - |
| 54 | #include <qstylepainter.h> | - |
| 55 | #include <qstyleoption.h> | - |
| 56 | #include <qslider.h> | - |
| 57 | #include <private/qabstractslider_p.h> | - |
| 58 | #include <private/qmath_p.h> | - |
| 59 | #ifndef QT_NO_ACCESSIBILITY | - |
| 60 | #include "qaccessible.h" | - |
| 61 | #endif | - |
| 62 | #include <qmath.h> | - |
| 63 | | - |
| 64 | QT_BEGIN_NAMESPACE | - |
| 65 | | - |
| 66 | class QDialPrivate : public QAbstractSliderPrivate | - |
| 67 | { | - |
| 68 | Q_DECLARE_PUBLIC(QDial) | - |
| 69 | public: | - |
| 70 | QDialPrivate() | - |
| 71 | { | - |
| 72 | wrapping = false; executed (the execution status of this line is deduced): wrapping = false; | - |
| 73 | tracking = true; executed (the execution status of this line is deduced): tracking = true; | - |
| 74 | doNotEmit = false; executed (the execution status of this line is deduced): doNotEmit = false; | - |
| 75 | target = qreal(3.7); executed (the execution status of this line is deduced): target = qreal(3.7); | - |
| 76 | } executed: }Execution Count:7 | 7 |
| 77 | | - |
| 78 | qreal target; | - |
| 79 | uint showNotches : 1; | - |
| 80 | uint wrapping : 1; | - |
| 81 | uint doNotEmit : 1; | - |
| 82 | | - |
| 83 | int valueFromPoint(const QPoint &) const; | - |
| 84 | double angle(const QPoint &, const QPoint &) const; | - |
| 85 | void init(); | - |
| 86 | virtual int bound(int val) const; | - |
| 87 | }; | - |
| 88 | | - |
| 89 | void QDialPrivate::init() | - |
| 90 | { | - |
| 91 | Q_Q(QDial); executed (the execution status of this line is deduced): QDial * const q = q_func(); | - |
| 92 | showNotches = false; executed (the execution status of this line is deduced): showNotches = false; | - |
| 93 | q->setFocusPolicy(Qt::WheelFocus); executed (the execution status of this line is deduced): q->setFocusPolicy(Qt::WheelFocus); | - |
| 94 | } executed: }Execution Count:7 | 7 |
| 95 | | - |
| 96 | int QDialPrivate::bound(int val) const | - |
| 97 | { | - |
| 98 | if (wrapping) { evaluated: wrapping| yes Evaluation Count:20 | yes Evaluation Count:27 |
| 20-27 |
| 99 | if ((val >= minimum) && (val <= maximum)) evaluated: (val >= minimum)| yes Evaluation Count:17 | yes Evaluation Count:3 |
evaluated: (val <= maximum)| yes Evaluation Count:14 | yes Evaluation Count:3 |
| 3-17 |
| 100 | return val; executed: return val;Execution Count:14 | 14 |
| 101 | val = minimum + ((val - minimum) % (maximum - minimum)); executed (the execution status of this line is deduced): val = minimum + ((val - minimum) % (maximum - minimum)); | - |
| 102 | if (val < minimum) evaluated: val < minimum| yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
| 103 | val += maximum - minimum; executed: val += maximum - minimum;Execution Count:3 | 3 |
| 104 | return val; executed: return val;Execution Count:6 | 6 |
| 105 | } else { | - |
| 106 | return QAbstractSliderPrivate::bound(val); executed: return QAbstractSliderPrivate::bound(val);Execution Count:27 | 27 |
| 107 | } | - |
| 108 | } | - |
| 109 | | - |
| 110 | /*! | - |
| 111 | Initialize \a option with the values from this QDial. This method | - |
| 112 | is useful for subclasses when they need a QStyleOptionSlider, but don't want | - |
| 113 | to fill in all the information themselves. | - |
| 114 | | - |
| 115 | \sa QStyleOption::initFrom() | - |
| 116 | */ | - |
| 117 | void QDial::initStyleOption(QStyleOptionSlider *option) const | - |
| 118 | { | - |
| 119 | if (!option) partially evaluated: !option| no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
| 120 | return; | 0 |
| 121 | | - |
| 122 | Q_D(const QDial); executed (the execution status of this line is deduced): const QDialPrivate * const d = d_func(); | - |
| 123 | option->initFrom(this); executed (the execution status of this line is deduced): option->initFrom(this); | - |
| 124 | option->minimum = d->minimum; executed (the execution status of this line is deduced): option->minimum = d->minimum; | - |
| 125 | option->maximum = d->maximum; executed (the execution status of this line is deduced): option->maximum = d->maximum; | - |
| 126 | option->sliderPosition = d->position; executed (the execution status of this line is deduced): option->sliderPosition = d->position; | - |
| 127 | option->sliderValue = d->value; executed (the execution status of this line is deduced): option->sliderValue = d->value; | - |
| 128 | option->singleStep = d->singleStep; executed (the execution status of this line is deduced): option->singleStep = d->singleStep; | - |
| 129 | option->pageStep = d->pageStep; executed (the execution status of this line is deduced): option->pageStep = d->pageStep; | - |
| 130 | option->upsideDown = !d->invertedAppearance; executed (the execution status of this line is deduced): option->upsideDown = !d->invertedAppearance; | - |
| 131 | option->notchTarget = d->target; executed (the execution status of this line is deduced): option->notchTarget = d->target; | - |
| 132 | option->dialWrapping = d->wrapping; executed (the execution status of this line is deduced): option->dialWrapping = d->wrapping; | - |
| 133 | option->subControls = QStyle::SC_All; executed (the execution status of this line is deduced): option->subControls = QStyle::SC_All; | - |
| 134 | option->activeSubControls = QStyle::SC_None; executed (the execution status of this line is deduced): option->activeSubControls = QStyle::SC_None; | - |
| 135 | if (!d->showNotches) { partially evaluated: !d->showNotches| yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
| 136 | option->subControls &= ~QStyle::SC_DialTickmarks; executed (the execution status of this line is deduced): option->subControls &= ~QStyle::SC_DialTickmarks; | - |
| 137 | option->tickPosition = QSlider::TicksAbove; executed (the execution status of this line is deduced): option->tickPosition = QSlider::TicksAbove; | - |
| 138 | } else { executed: }Execution Count:3 | 3 |
| 139 | option->tickPosition = QSlider::NoTicks; never executed (the execution status of this line is deduced): option->tickPosition = QSlider::NoTicks; | - |
| 140 | } | 0 |
| 141 | option->tickInterval = notchSize(); executed (the execution status of this line is deduced): option->tickInterval = notchSize(); | - |
| 142 | } executed: }Execution Count:3 | 3 |
| 143 | | - |
| 144 | int QDialPrivate::valueFromPoint(const QPoint &p) const | - |
| 145 | { | - |
| 146 | Q_Q(const QDial); executed (the execution status of this line is deduced): const QDial * const q = q_func(); | - |
| 147 | double yy = (double)q->height()/2.0 - p.y(); executed (the execution status of this line is deduced): double yy = (double)q->height()/2.0 - p.y(); | - |
| 148 | double xx = (double)p.x() - q->width()/2.0; executed (the execution status of this line is deduced): double xx = (double)p.x() - q->width()/2.0; | - |
| 149 | double a = (xx || yy) ? qAtan2(yy, xx) : 0; evaluated: xx| yes Evaluation Count:3 | yes Evaluation Count:1 |
partially evaluated: yy| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-3 |
| 150 | | - |
| 151 | if (a < Q_PI / -2) partially evaluated: a < Q_PI / -2| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 152 | a = a + Q_PI * 2; never executed: a = a + Q_PI * 2; | 0 |
| 153 | | - |
| 154 | int dist = 0; executed (the execution status of this line is deduced): int dist = 0; | - |
| 155 | int minv = minimum, maxv = maximum; executed (the execution status of this line is deduced): int minv = minimum, maxv = maximum; | - |
| 156 | | - |
| 157 | if (minimum < 0) { partially evaluated: minimum < 0| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 158 | dist = -minimum; never executed (the execution status of this line is deduced): dist = -minimum; | - |
| 159 | minv = 0; never executed (the execution status of this line is deduced): minv = 0; | - |
| 160 | maxv = maximum + dist; never executed (the execution status of this line is deduced): maxv = maximum + dist; | - |
| 161 | } | 0 |
| 162 | | - |
| 163 | int r = maxv - minv; executed (the execution status of this line is deduced): int r = maxv - minv; | - |
| 164 | int v; executed (the execution status of this line is deduced): int v; | - |
| 165 | if (wrapping) partially evaluated: wrapping| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 166 | v = (int)(0.5 + minv + r * (Q_PI * 3 / 2 - a) / (2 * Q_PI)); never executed: v = (int)(0.5 + minv + r * (Q_PI * 3 / 2 - a) / (2 * Q_PI)); | 0 |
| 167 | else | - |
| 168 | v = (int)(0.5 + minv + r* (Q_PI * 4 / 3 - a) / (Q_PI * 10 / 6)); executed: v = (int)(0.5 + minv + r* (Q_PI * 4 / 3 - a) / (Q_PI * 10 / 6));Execution Count:4 | 4 |
| 169 | | - |
| 170 | if (dist > 0) partially evaluated: dist > 0| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 171 | v -= dist; never executed: v -= dist; | 0 |
| 172 | | - |
| 173 | return !invertedAppearance ? bound(v) : maximum - bound(v); executed: return !invertedAppearance ? bound(v) : maximum - bound(v);Execution Count:4 | 4 |
| 174 | } | - |
| 175 | | - |
| 176 | /*! | - |
| 177 | \class QDial | - |
| 178 | | - |
| 179 | \brief The QDial class provides a rounded range control (like a speedometer or potentiometer). | - |
| 180 | | - |
| 181 | \ingroup basicwidgets | - |
| 182 | \inmodule QtWidgets | - |
| 183 | | - |
| 184 | QDial is used when the user needs to control a value within a | - |
| 185 | program-definable range, and the range either wraps around | - |
| 186 | (for example, with angles measured from 0 to 359 degrees) or the | - |
| 187 | dialog layout needs a square widget. | - |
| 188 | | - |
| 189 | Since QDial inherits from QAbstractSlider, the dial behaves in | - |
| 190 | a similar way to a \l{QSlider}{slider}. When wrapping() is false | - |
| 191 | (the default setting) there is no real difference between a slider | - |
| 192 | and a dial. They both share the same signals, slots and member | - |
| 193 | functions. Which one you use depends on the expectations of | - |
| 194 | your users and on the type of application. | - |
| 195 | | - |
| 196 | The dial initially emits valueChanged() signals continuously while | - |
| 197 | the slider is being moved; you can make it emit the signal less | - |
| 198 | often by disabling the \l{QAbstractSlider::tracking} {tracking} | - |
| 199 | property. The sliderMoved() signal is emitted continuously even | - |
| 200 | when tracking is disabled. | - |
| 201 | | - |
| 202 | The dial also emits sliderPressed() and sliderReleased() signals | - |
| 203 | when the mouse button is pressed and released. Note that the | - |
| 204 | dial's value can change without these signals being emitted since | - |
| 205 | the keyboard and wheel can also be used to change the value. | - |
| 206 | | - |
| 207 | Unlike the slider, QDial attempts to draw a "nice" number of | - |
| 208 | notches rather than one per line step. If possible, the number of | - |
| 209 | notches drawn is one per line step, but if there aren't enough pixels | - |
| 210 | to draw every one, QDial will skip notches to try and draw a uniform | - |
| 211 | set (e.g. by drawing every second or third notch). | - |
| 212 | | - |
| 213 | Like the slider, the dial makes the QAbstractSlider functions | - |
| 214 | setValue(), addLine(), subtractLine(), addPage() and | - |
| 215 | subtractPage() available as slots. | - |
| 216 | | - |
| 217 | The dial's keyboard interface is fairly simple: The | - |
| 218 | \uicontrol{left}/\uicontrol{up} and \uicontrol{right}/\uicontrol{down} arrow keys adjust | - |
| 219 | the dial's \l {QAbstractSlider::value} {value} by the defined | - |
| 220 | \l {QAbstractSlider::singleStep} {singleStep}, \uicontrol{Page Up} and | - |
| 221 | \uicontrol{Page Down} by the defined \l {QAbstractSlider::pageStep} | - |
| 222 | {pageStep}, and the \uicontrol Home and \uicontrol End keys set the value to | - |
| 223 | the defined \l {QAbstractSlider::minimum} {minimum} and | - |
| 224 | \l {QAbstractSlider::maximum} {maximum} values. | - |
| 225 | | - |
| 226 | If you are using the mouse wheel to adjust the dial, the increment | - |
| 227 | value is determined by the lesser value of | - |
| 228 | \l{QApplication::wheelScrollLines()} {wheelScrollLines} multipled | - |
| 229 | by \l {QAbstractSlider::singleStep} {singleStep}, and | - |
| 230 | \l {QAbstractSlider::pageStep} {pageStep}. | - |
| 231 | | - |
| 232 | \table | - |
| 233 | \row \li \inlineimage fusion-dial.png Screenshot of a dial in the Fusion widget style | - |
| 234 | \li \inlineimage windowsvista-dial.png Screenshot of a dial in the Windows Vista widget style | - |
| 235 | \li \inlineimage macintosh-dial.png Screenshot of a dial in the Macintosh widget style | - |
| 236 | \row \li {3,1} Dials shown in various widget styles (from left to right): | - |
| 237 | \l{Fusion Style Widget Gallery}{Fusion}, | - |
| 238 | \l{Windows Vista Style Widget Gallery}{Windows Vista}, | - |
| 239 | \l{Macintosh Style Widget Gallery}{Macintosh}. | - |
| 240 | \endtable | - |
| 241 | | - |
| 242 | \sa QScrollBar, QSpinBox, QSlider, {fowler}{GUI Design Handbook: Slider}, {Sliders Example} | - |
| 243 | */ | - |
| 244 | | - |
| 245 | /*! | - |
| 246 | Constructs a dial. | - |
| 247 | | - |
| 248 | The \a parent argument is sent to the QAbstractSlider constructor. | - |
| 249 | */ | - |
| 250 | QDial::QDial(QWidget *parent) | - |
| 251 | : QAbstractSlider(*new QDialPrivate, parent) | - |
| 252 | { | - |
| 253 | Q_D(QDial); executed (the execution status of this line is deduced): QDialPrivate * const d = d_func(); | - |
| 254 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
| 255 | } executed: }Execution Count:7 | 7 |
| 256 | | - |
| 257 | /*! | - |
| 258 | Destroys the dial. | - |
| 259 | */ | - |
| 260 | QDial::~QDial() | - |
| 261 | { | - |
| 262 | } | - |
| 263 | | - |
| 264 | /*! \reimp */ | - |
| 265 | void QDial::resizeEvent(QResizeEvent *e) | - |
| 266 | { | - |
| 267 | QWidget::resizeEvent(e); executed (the execution status of this line is deduced): QWidget::resizeEvent(e); | - |
| 268 | } executed: }Execution Count:7 | 7 |
| 269 | | - |
| 270 | /*! | - |
| 271 | \reimp | - |
| 272 | */ | - |
| 273 | | - |
| 274 | void QDial::paintEvent(QPaintEvent *) | - |
| 275 | { | - |
| 276 | QStylePainter p(this); executed (the execution status of this line is deduced): QStylePainter p(this); | - |
| 277 | QStyleOptionSlider option; executed (the execution status of this line is deduced): QStyleOptionSlider option; | - |
| 278 | initStyleOption(&option); executed (the execution status of this line is deduced): initStyleOption(&option); | - |
| 279 | p.drawComplexControl(QStyle::CC_Dial, option); executed (the execution status of this line is deduced): p.drawComplexControl(QStyle::CC_Dial, option); | - |
| 280 | } executed: }Execution Count:3 | 3 |
| 281 | | - |
| 282 | /*! | - |
| 283 | \reimp | - |
| 284 | */ | - |
| 285 | | - |
| 286 | void QDial::mousePressEvent(QMouseEvent *e) | - |
| 287 | { | - |
| 288 | Q_D(QDial); executed (the execution status of this line is deduced): QDialPrivate * const d = d_func(); | - |
| 289 | if (d->maximum == d->minimum || partially evaluated: d->maximum == d->minimum| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 290 | (e->button() != Qt::LeftButton) || partially evaluated: (e->button() != Qt::LeftButton)| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 291 | (e->buttons() ^ e->button())) { partially evaluated: (e->buttons() ^ e->button())| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 292 | e->ignore(); never executed (the execution status of this line is deduced): e->ignore(); | - |
| 293 | return; | 0 |
| 294 | } | - |
| 295 | e->accept(); executed (the execution status of this line is deduced): e->accept(); | - |
| 296 | setSliderPosition(d->valueFromPoint(e->pos())); executed (the execution status of this line is deduced): setSliderPosition(d->valueFromPoint(e->pos())); | - |
| 297 | // ### This isn't quite right, | - |
| 298 | // we should be doing a hit test and only setting this if it's | - |
| 299 | // the actual dial thingie (similar to what QSlider does), but we have no | - |
| 300 | // subControls for QDial. | - |
| 301 | setSliderDown(true); executed (the execution status of this line is deduced): setSliderDown(true); | - |
| 302 | } executed: }Execution Count:1 | 1 |
| 303 | | - |
| 304 | | - |
| 305 | /*! | - |
| 306 | \reimp | - |
| 307 | */ | - |
| 308 | | - |
| 309 | void QDial::mouseReleaseEvent(QMouseEvent * e) | - |
| 310 | { | - |
| 311 | Q_D(QDial); executed (the execution status of this line is deduced): QDialPrivate * const d = d_func(); | - |
| 312 | if (e->buttons() & (~e->button()) || partially evaluated: e->buttons() & (~e->button())| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 313 | (e->button() != Qt::LeftButton)) { partially evaluated: (e->button() != Qt::LeftButton)| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 314 | e->ignore(); never executed (the execution status of this line is deduced): e->ignore(); | - |
| 315 | return; | 0 |
| 316 | } | - |
| 317 | e->accept(); executed (the execution status of this line is deduced): e->accept(); | - |
| 318 | setValue(d->valueFromPoint(e->pos())); executed (the execution status of this line is deduced): setValue(d->valueFromPoint(e->pos())); | - |
| 319 | setSliderDown(false); executed (the execution status of this line is deduced): setSliderDown(false); | - |
| 320 | } executed: }Execution Count:1 | 1 |
| 321 | | - |
| 322 | | - |
| 323 | /*! | - |
| 324 | \reimp | - |
| 325 | */ | - |
| 326 | | - |
| 327 | void QDial::mouseMoveEvent(QMouseEvent * e) | - |
| 328 | { | - |
| 329 | Q_D(QDial); executed (the execution status of this line is deduced): QDialPrivate * const d = d_func(); | - |
| 330 | if (!(e->buttons() & Qt::LeftButton)) { partially evaluated: !(e->buttons() & Qt::LeftButton)| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 331 | e->ignore(); never executed (the execution status of this line is deduced): e->ignore(); | - |
| 332 | return; | 0 |
| 333 | } | - |
| 334 | e->accept(); executed (the execution status of this line is deduced): e->accept(); | - |
| 335 | d->doNotEmit = true; executed (the execution status of this line is deduced): d->doNotEmit = true; | - |
| 336 | setSliderPosition(d->valueFromPoint(e->pos())); executed (the execution status of this line is deduced): setSliderPosition(d->valueFromPoint(e->pos())); | - |
| 337 | d->doNotEmit = false; executed (the execution status of this line is deduced): d->doNotEmit = false; | - |
| 338 | } executed: }Execution Count:2 | 2 |
| 339 | | - |
| 340 | | - |
| 341 | /*! | - |
| 342 | \reimp | - |
| 343 | */ | - |
| 344 | | - |
| 345 | void QDial::sliderChange(SliderChange change) | - |
| 346 | { | - |
| 347 | QAbstractSlider::sliderChange(change); executed (the execution status of this line is deduced): QAbstractSlider::sliderChange(change); | - |
| 348 | } executed: }Execution Count:31 | 31 |
| 349 | | - |
| 350 | void QDial::setWrapping(bool enable) | - |
| 351 | { | - |
| 352 | Q_D(QDial); executed (the execution status of this line is deduced): QDialPrivate * const d = d_func(); | - |
| 353 | if (d->wrapping == enable) evaluated: d->wrapping == enable| yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
| 354 | return; executed: return;Execution Count:1 | 1 |
| 355 | d->wrapping = enable; executed (the execution status of this line is deduced): d->wrapping = enable; | - |
| 356 | update(); executed (the execution status of this line is deduced): update(); | - |
| 357 | } executed: }Execution Count:4 | 4 |
| 358 | | - |
| 359 | | - |
| 360 | /*! | - |
| 361 | \property QDial::wrapping | - |
| 362 | \brief whether wrapping is enabled | - |
| 363 | | - |
| 364 | If true, wrapping is enabled; otherwise some space is inserted at the bottom | - |
| 365 | of the dial to separate the ends of the range of valid values. | - |
| 366 | | - |
| 367 | If enabled, the arrow can be oriented at any angle on the dial. If disabled, | - |
| 368 | the arrow will be restricted to the upper part of the dial; if it is rotated | - |
| 369 | into the space at the bottom of the dial, it will be clamped to the closest | - |
| 370 | end of the valid range of values. | - |
| 371 | | - |
| 372 | By default this property is false. | - |
| 373 | */ | - |
| 374 | | - |
| 375 | bool QDial::wrapping() const | - |
| 376 | { | - |
| 377 | Q_D(const QDial); executed (the execution status of this line is deduced): const QDialPrivate * const d = d_func(); | - |
| 378 | return d->wrapping; executed: return d->wrapping;Execution Count:2 | 2 |
| 379 | } | - |
| 380 | | - |
| 381 | | - |
| 382 | /*! | - |
| 383 | \property QDial::notchSize | - |
| 384 | \brief the current notch size | - |
| 385 | | - |
| 386 | The notch size is in range control units, not pixels, and if | - |
| 387 | possible it is a multiple of singleStep() that results in an | - |
| 388 | on-screen notch size near notchTarget(). | - |
| 389 | | - |
| 390 | By default, this property has a value of 1. | - |
| 391 | | - |
| 392 | \sa notchTarget(), singleStep() | - |
| 393 | */ | - |
| 394 | | - |
| 395 | int QDial::notchSize() const | - |
| 396 | { | - |
| 397 | Q_D(const QDial); executed (the execution status of this line is deduced): const QDialPrivate * const d = d_func(); | - |
| 398 | // radius of the arc | - |
| 399 | int r = qMin(width(), height())/2; executed (the execution status of this line is deduced): int r = qMin(width(), height())/2; | - |
| 400 | // length of the whole arc | - |
| 401 | int l = (int)(r * (d->wrapping ? 6 : 5) * Q_PI / 6); executed (the execution status of this line is deduced): int l = (int)(r * (d->wrapping ? 6 : 5) * Q_PI / 6); | - |
| 402 | // length of the arc from minValue() to minValue()+pageStep() | - |
| 403 | if (d->maximum > d->minimum + d->pageStep) partially evaluated: d->maximum > d->minimum + d->pageStep| yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
| 404 | l = (int)(0.5 + l * d->pageStep / (d->maximum - d->minimum)); executed: l = (int)(0.5 + l * d->pageStep / (d->maximum - d->minimum));Execution Count:3 | 3 |
| 405 | // length of a singleStep arc | - |
| 406 | l = l * d->singleStep / (d->pageStep ? d->pageStep : 1); partially evaluated: d->pageStep| yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
| 407 | if (l < 1) evaluated: l < 1| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
| 408 | l = 1; executed: l = 1;Execution Count:1 | 1 |
| 409 | // how many times singleStep can be draw in d->target pixels | - |
| 410 | l = (int)(0.5 + d->target / l); executed (the execution status of this line is deduced): l = (int)(0.5 + d->target / l); | - |
| 411 | // we want notchSize() to be a non-zero multiple of lineStep() | - |
| 412 | if (!l) partially evaluated: !l| no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
| 413 | l = 1; | 0 |
| 414 | return d->singleStep * l; executed: return d->singleStep * l;Execution Count:3 | 3 |
| 415 | } | - |
| 416 | | - |
| 417 | void QDial::setNotchTarget(double target) | - |
| 418 | { | - |
| 419 | Q_D(QDial); never executed (the execution status of this line is deduced): QDialPrivate * const d = d_func(); | - |
| 420 | d->target = target; never executed (the execution status of this line is deduced): d->target = target; | - |
| 421 | update(); never executed (the execution status of this line is deduced): update(); | - |
| 422 | } | 0 |
| 423 | | - |
| 424 | /*! | - |
| 425 | \property QDial::notchTarget | - |
| 426 | \brief the target number of pixels between notches | - |
| 427 | | - |
| 428 | The notch target is the number of pixels QDial attempts to put | - |
| 429 | between each notch. | - |
| 430 | | - |
| 431 | The actual size may differ from the target size. | - |
| 432 | | - |
| 433 | The default notch target is 3.7 pixels. | - |
| 434 | */ | - |
| 435 | qreal QDial::notchTarget() const | - |
| 436 | { | - |
| 437 | Q_D(const QDial); never executed (the execution status of this line is deduced): const QDialPrivate * const d = d_func(); | - |
| 438 | return d->target; never executed: return d->target; | 0 |
| 439 | } | - |
| 440 | | - |
| 441 | | - |
| 442 | void QDial::setNotchesVisible(bool visible) | - |
| 443 | { | - |
| 444 | Q_D(QDial); executed (the execution status of this line is deduced): QDialPrivate * const d = d_func(); | - |
| 445 | d->showNotches = visible; executed (the execution status of this line is deduced): d->showNotches = visible; | - |
| 446 | update(); executed (the execution status of this line is deduced): update(); | - |
| 447 | } executed: }Execution Count:2 | 2 |
| 448 | | - |
| 449 | /*! | - |
| 450 | \property QDial::notchesVisible | - |
| 451 | \brief whether the notches are shown | - |
| 452 | | - |
| 453 | If the property is true, a series of notches are drawn around the dial | - |
| 454 | to indicate the range of values available; otherwise no notches are | - |
| 455 | shown. | - |
| 456 | | - |
| 457 | By default, this property is disabled. | - |
| 458 | */ | - |
| 459 | bool QDial::notchesVisible() const | - |
| 460 | { | - |
| 461 | Q_D(const QDial); executed (the execution status of this line is deduced): const QDialPrivate * const d = d_func(); | - |
| 462 | return d->showNotches; executed: return d->showNotches;Execution Count:2 | 2 |
| 463 | } | - |
| 464 | | - |
| 465 | /*! | - |
| 466 | \reimp | - |
| 467 | */ | - |
| 468 | | - |
| 469 | QSize QDial::minimumSizeHint() const | - |
| 470 | { | - |
| 471 | return QSize(50, 50); executed: return QSize(50, 50);Execution Count:2 | 2 |
| 472 | } | - |
| 473 | | - |
| 474 | /*! | - |
| 475 | \reimp | - |
| 476 | */ | - |
| 477 | | - |
| 478 | QSize QDial::sizeHint() const | - |
| 479 | { | - |
| 480 | return QSize(100, 100).expandedTo(QApplication::globalStrut()); executed: return QSize(100, 100).expandedTo(QApplication::globalStrut());Execution Count:5 | 5 |
| 481 | } | - |
| 482 | | - |
| 483 | /*! | - |
| 484 | \reimp | - |
| 485 | */ | - |
| 486 | bool QDial::event(QEvent *e) | - |
| 487 | { | - |
| 488 | return QAbstractSlider::event(e); executed: return QAbstractSlider::event(e);Execution Count:74 | 74 |
| 489 | } | - |
| 490 | | - |
| 491 | QT_END_NAMESPACE | - |
| 492 | | - |
| 493 | #endif // QT_NO_DIAL | - |
| 494 | | - |
| | |