| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qslider.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | class QSliderPrivate : public QAbstractSliderPrivate | - | ||||||||||||||||||
| 8 | { | - | ||||||||||||||||||
| 9 | inline QSlider* q_func() { return static_cast<QSlider *>(q_ptr); } inline const QSlider* q_func() const { return static_cast<const QSlider *>(q_ptr); } friend class QSlider; | - | ||||||||||||||||||
| 10 | public: | - | ||||||||||||||||||
| 11 | QStyle::SubControl pressedControl; | - | ||||||||||||||||||
| 12 | int tickInterval; | - | ||||||||||||||||||
| 13 | QSlider::TickPosition tickPosition; | - | ||||||||||||||||||
| 14 | int clickOffset; | - | ||||||||||||||||||
| 15 | void init(); | - | ||||||||||||||||||
| 16 | void resetLayoutItemMargins(); | - | ||||||||||||||||||
| 17 | int pixelPosToRangeValue(int pos) const; | - | ||||||||||||||||||
| 18 | inline int pick(const QPoint &pt) const; | - | ||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | QStyle::SubControl newHoverControl(const QPoint &pos); | - | ||||||||||||||||||
| 21 | bool updateHoverControl(const QPoint &pos); | - | ||||||||||||||||||
| 22 | QStyle::SubControl hoverControl; | - | ||||||||||||||||||
| 23 | QRect hoverRect; | - | ||||||||||||||||||
| 24 | }; | - | ||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | void QSliderPrivate::init() | - | ||||||||||||||||||
| 27 | { | - | ||||||||||||||||||
| 28 | QSlider * const q = q_func(); | - | ||||||||||||||||||
| 29 | pressedControl = QStyle::SC_None; | - | ||||||||||||||||||
| 30 | tickInterval = 0; | - | ||||||||||||||||||
| 31 | tickPosition = QSlider::NoTicks; | - | ||||||||||||||||||
| 32 | hoverControl = QStyle::SC_None; | - | ||||||||||||||||||
| 33 | q->setFocusPolicy(Qt::FocusPolicy(q->style()->styleHint(QStyle::SH_Button_FocusPolicy))); | - | ||||||||||||||||||
| 34 | QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::Slider); | - | ||||||||||||||||||
| 35 |     if (orientation == Qt::Vertical
  | 0 | ||||||||||||||||||
| 36 |         sp.transpose(); never executed:  sp.transpose(); | 0 | ||||||||||||||||||
| 37 | q->setSizePolicy(sp); | - | ||||||||||||||||||
| 38 | q->setAttribute(Qt::WA_WState_OwnSizePolicy, false); | - | ||||||||||||||||||
| 39 | resetLayoutItemMargins(); | - | ||||||||||||||||||
| 40 | } never executed:  end of block | 0 | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | void QSliderPrivate::resetLayoutItemMargins() | - | ||||||||||||||||||
| 43 | { | - | ||||||||||||||||||
| 44 | QSlider * const q = q_func(); | - | ||||||||||||||||||
| 45 | QStyleOptionSlider opt; | - | ||||||||||||||||||
| 46 | q->initStyleOption(&opt); | - | ||||||||||||||||||
| 47 | setLayoutItemMargins(QStyle::SE_SliderLayoutItem, &opt); | - | ||||||||||||||||||
| 48 | } never executed:  end of block | 0 | ||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | int QSliderPrivate::pixelPosToRangeValue(int pos) const | - | ||||||||||||||||||
| 51 | { | - | ||||||||||||||||||
| 52 | const QSlider * const q = q_func(); | - | ||||||||||||||||||
| 53 | QStyleOptionSlider opt; | - | ||||||||||||||||||
| 54 | q->initStyleOption(&opt); | - | ||||||||||||||||||
| 55 | QRect gr = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, q); | - | ||||||||||||||||||
| 56 | QRect sr = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, q); | - | ||||||||||||||||||
| 57 | int sliderMin, sliderMax, sliderLength; | - | ||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 |     if (orientation == Qt::Horizontal
  | 0 | ||||||||||||||||||
| 60 | sliderLength = sr.width(); | - | ||||||||||||||||||
| 61 | sliderMin = gr.x(); | - | ||||||||||||||||||
| 62 | sliderMax = gr.right() - sliderLength + 1; | - | ||||||||||||||||||
| 63 |     } never executed:   else {end of block | 0 | ||||||||||||||||||
| 64 | sliderLength = sr.height(); | - | ||||||||||||||||||
| 65 | sliderMin = gr.y(); | - | ||||||||||||||||||
| 66 | sliderMax = gr.bottom() - sliderLength + 1; | - | ||||||||||||||||||
| 67 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 68 |     return never executed:   QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin,return QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin, sliderMax - sliderMin, opt.upsideDown);never executed:  return QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin, sliderMax - sliderMin, opt.upsideDown); | 0 | ||||||||||||||||||
| 69 |                                            sliderMax - sliderMin, opt.upsideDown); never executed:  return QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin, sliderMax - sliderMin, opt.upsideDown); | 0 | ||||||||||||||||||
| 70 | } | - | ||||||||||||||||||
| 71 | - | |||||||||||||||||||
| 72 | inline int QSliderPrivate::pick(const QPoint &pt) const | - | ||||||||||||||||||
| 73 | { | - | ||||||||||||||||||
| 74 |     return never executed:   orientation == Qt::Horizontalreturn orientation == Qt::Horizontal ? pt.x() : pt.y();
 never executed:  return orientation == Qt::Horizontal ? pt.x() : pt.y(); | 0 | ||||||||||||||||||
| 75 | } | - | ||||||||||||||||||
| 76 | void QSlider::initStyleOption(QStyleOptionSlider *option) const | - | ||||||||||||||||||
| 77 | { | - | ||||||||||||||||||
| 78 |     if (!option
  | 0 | ||||||||||||||||||
| 79 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | const QSliderPrivate * const d = d_func(); | - | ||||||||||||||||||
| 82 | option->initFrom(this); | - | ||||||||||||||||||
| 83 | option->subControls = QStyle::SC_None; | - | ||||||||||||||||||
| 84 | option->activeSubControls = QStyle::SC_None; | - | ||||||||||||||||||
| 85 | option->orientation = d->orientation; | - | ||||||||||||||||||
| 86 | option->maximum = d->maximum; | - | ||||||||||||||||||
| 87 | option->minimum = d->minimum; | - | ||||||||||||||||||
| 88 | option->tickPosition = (QSlider::TickPosition)d->tickPosition; | - | ||||||||||||||||||
| 89 | option->tickInterval = d->tickInterval; | - | ||||||||||||||||||
| 90 |     option->upsideDown = (
 
  | 0 | ||||||||||||||||||
| 91 | (d->invertedAppearance != (option->direction == Qt::RightToLeft)) | - | ||||||||||||||||||
| 92 | : (!d->invertedAppearance); | - | ||||||||||||||||||
| 93 | option->direction = Qt::LeftToRight; | - | ||||||||||||||||||
| 94 | option->sliderPosition = d->position; | - | ||||||||||||||||||
| 95 | option->sliderValue = d->value; | - | ||||||||||||||||||
| 96 | option->singleStep = d->singleStep; | - | ||||||||||||||||||
| 97 | option->pageStep = d->pageStep; | - | ||||||||||||||||||
| 98 |     if (d->orientation == Qt::Horizontal
  | 0 | ||||||||||||||||||
| 99 |         option->state |= QStyle::State_Horizontal; never executed:  option->state |= QStyle::State_Horizontal; | 0 | ||||||||||||||||||
| 100 | } never executed:  end of block | 0 | ||||||||||||||||||
| 101 | - | |||||||||||||||||||
| 102 | bool QSliderPrivate::updateHoverControl(const QPoint &pos) | - | ||||||||||||||||||
| 103 | { | - | ||||||||||||||||||
| 104 | QSlider * const q = q_func(); | - | ||||||||||||||||||
| 105 | QRect lastHoverRect = hoverRect; | - | ||||||||||||||||||
| 106 | QStyle::SubControl lastHoverControl = hoverControl; | - | ||||||||||||||||||
| 107 | bool doesHover = q->testAttribute(Qt::WA_Hover); | - | ||||||||||||||||||
| 108 |     if (lastHoverControl != newHoverControl(pos)
 
  | 0 | ||||||||||||||||||
| 109 | q->update(lastHoverRect); | - | ||||||||||||||||||
| 110 | q->update(hoverRect); | - | ||||||||||||||||||
| 111 |         return never executed:   true;return true;never executed:  return true; | 0 | ||||||||||||||||||
| 112 | } | - | ||||||||||||||||||
| 113 |     return never executed:   !doesHover;return !doesHover;never executed:  return !doesHover; | 0 | ||||||||||||||||||
| 114 | } | - | ||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | QStyle::SubControl QSliderPrivate::newHoverControl(const QPoint &pos) | - | ||||||||||||||||||
| 117 | { | - | ||||||||||||||||||
| 118 | QSlider * const q = q_func(); | - | ||||||||||||||||||
| 119 | QStyleOptionSlider opt; | - | ||||||||||||||||||
| 120 | q->initStyleOption(&opt); | - | ||||||||||||||||||
| 121 | opt.subControls = QStyle::SC_All; | - | ||||||||||||||||||
| 122 | QRect handleRect = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, q); | - | ||||||||||||||||||
| 123 | QRect grooveRect = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, q); | - | ||||||||||||||||||
| 124 | QRect tickmarksRect = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderTickmarks, q); | - | ||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 |     if (handleRect.contains(pos)
  | 0 | ||||||||||||||||||
| 127 | hoverRect = handleRect; | - | ||||||||||||||||||
| 128 | hoverControl = QStyle::SC_SliderHandle; | - | ||||||||||||||||||
| 129 |     } never executed:   else if (grooveRect.contains(pos)end of block
  | 0 | ||||||||||||||||||
| 130 | hoverRect = grooveRect; | - | ||||||||||||||||||
| 131 | hoverControl = QStyle::SC_SliderGroove; | - | ||||||||||||||||||
| 132 |     } never executed:   else if (tickmarksRect.contains(pos)end of block
  | 0 | ||||||||||||||||||
| 133 | hoverRect = tickmarksRect; | - | ||||||||||||||||||
| 134 | hoverControl = QStyle::SC_SliderTickmarks; | - | ||||||||||||||||||
| 135 |     } never executed:   else {end of block | 0 | ||||||||||||||||||
| 136 | hoverRect = QRect(); | - | ||||||||||||||||||
| 137 | hoverControl = QStyle::SC_None; | - | ||||||||||||||||||
| 138 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 |     return never executed:   hoverControl;return hoverControl;never executed:  return hoverControl; | 0 | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | QSlider::QSlider(QWidget *parent) | - | ||||||||||||||||||
| 143 | : QAbstractSlider(*new QSliderPrivate, parent) | - | ||||||||||||||||||
| 144 | { | - | ||||||||||||||||||
| 145 | d_func()->orientation = Qt::Vertical; | - | ||||||||||||||||||
| 146 | d_func()->init(); | - | ||||||||||||||||||
| 147 | } never executed:  end of block | 0 | ||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | QSlider::QSlider(Qt::Orientation orientation, QWidget *parent) | - | ||||||||||||||||||
| 156 | : QAbstractSlider(*new QSliderPrivate, parent) | - | ||||||||||||||||||
| 157 | { | - | ||||||||||||||||||
| 158 | d_func()->orientation = orientation; | - | ||||||||||||||||||
| 159 | d_func()->init(); | - | ||||||||||||||||||
| 160 | } never executed:  end of block | 0 | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | QSlider::~QSlider() | - | ||||||||||||||||||
| 167 | { | - | ||||||||||||||||||
| 168 | } | - | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | - | |||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | void QSlider::paintEvent(QPaintEvent *) | - | ||||||||||||||||||
| 174 | { | - | ||||||||||||||||||
| 175 | QSliderPrivate * const d = d_func(); | - | ||||||||||||||||||
| 176 | QPainter p(this); | - | ||||||||||||||||||
| 177 | QStyleOptionSlider opt; | - | ||||||||||||||||||
| 178 | initStyleOption(&opt); | - | ||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 | opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle; | - | ||||||||||||||||||
| 181 |     if (d->tickPosition != NoTicks
  | 0 | ||||||||||||||||||
| 182 |         opt.subControls |= QStyle::SC_SliderTickmarks; never executed:  opt.subControls |= QStyle::SC_SliderTickmarks; | 0 | ||||||||||||||||||
| 183 |     if (d->pressedControl
  | 0 | ||||||||||||||||||
| 184 | opt.activeSubControls = d->pressedControl; | - | ||||||||||||||||||
| 185 | opt.state |= QStyle::State_Sunken; | - | ||||||||||||||||||
| 186 |     } never executed:   else {end of block | 0 | ||||||||||||||||||
| 187 | opt.activeSubControls = d->hoverControl; | - | ||||||||||||||||||
| 188 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | style()->drawComplexControl(QStyle::CC_Slider, &opt, &p, this); | - | ||||||||||||||||||
| 191 | } never executed:  end of block | 0 | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | - | |||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | - | |||||||||||||||||||
| 197 | bool QSlider::event(QEvent *event) | - | ||||||||||||||||||
| 198 | { | - | ||||||||||||||||||
| 199 | QSliderPrivate * const d = d_func(); | - | ||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | switch(event->type()) { | - | ||||||||||||||||||
| 202 |     case never executed:   QEvent::HoverEnter:case QEvent::HoverEnter:never executed:  case QEvent::HoverEnter: | 0 | ||||||||||||||||||
| 203 |     case never executed:   QEvent::HoverLeave:case QEvent::HoverLeave:never executed:  case QEvent::HoverLeave: | 0 | ||||||||||||||||||
| 204 |     case never executed:   QEvent::HoverMove:case QEvent::HoverMove:never executed:  case QEvent::HoverMove: | 0 | ||||||||||||||||||
| 205 |         if (const
 
  | 0 | ||||||||||||||||||
| 206 |             d->updateHoverControl(he->pos()); never executed:  d->updateHoverControl(he->pos()); | 0 | ||||||||||||||||||
| 207 |         break; never executed:  break; | 0 | ||||||||||||||||||
| 208 |     case never executed:   QEvent::StyleChange:case QEvent::StyleChange:never executed:  case QEvent::StyleChange: | 0 | ||||||||||||||||||
| 209 |     case never executed:   QEvent::MacSizeChange:case QEvent::MacSizeChange:never executed:  case QEvent::MacSizeChange: | 0 | ||||||||||||||||||
| 210 | d->resetLayoutItemMargins(); | - | ||||||||||||||||||
| 211 |         break; never executed:  break; | 0 | ||||||||||||||||||
| 212 |     default never executed:  :default:never executed:  default: | 0 | ||||||||||||||||||
| 213 |         break; never executed:  break; | 0 | ||||||||||||||||||
| 214 | } | - | ||||||||||||||||||
| 215 |     return never executed:   QAbstractSlider::event(event);return QAbstractSlider::event(event);never executed:  return QAbstractSlider::event(event); | 0 | ||||||||||||||||||
| 216 | } | - | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | - | |||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | - | |||||||||||||||||||
| 221 | void QSlider::mousePressEvent(QMouseEvent *ev) | - | ||||||||||||||||||
| 222 | { | - | ||||||||||||||||||
| 223 | QSliderPrivate * const d = d_func(); | - | ||||||||||||||||||
| 224 |     if (d->maximum == d->minimum
 
 
  | 0 | ||||||||||||||||||
| 225 | ev->ignore(); | - | ||||||||||||||||||
| 226 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 227 | } | - | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | - | |||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | ev->accept(); | - | ||||||||||||||||||
| 233 |     if ((
 
  | 0 | ||||||||||||||||||
| 234 | QStyleOptionSlider opt; | - | ||||||||||||||||||
| 235 | initStyleOption(&opt); | - | ||||||||||||||||||
| 236 | const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); | - | ||||||||||||||||||
| 237 | const QPoint center = sliderRect.center() - sliderRect.topLeft(); | - | ||||||||||||||||||
| 238 | - | |||||||||||||||||||
| 239 | - | |||||||||||||||||||
| 240 | setSliderPosition(d->pixelPosToRangeValue(d->pick(ev->pos() - center))); | - | ||||||||||||||||||
| 241 | triggerAction(SliderMove); | - | ||||||||||||||||||
| 242 | setRepeatAction(SliderNoAction); | - | ||||||||||||||||||
| 243 | d->pressedControl = QStyle::SC_SliderHandle; | - | ||||||||||||||||||
| 244 | update(); | - | ||||||||||||||||||
| 245 |     } never executed:   else if ((end of block
 
  | 0 | ||||||||||||||||||
| 246 | QStyleOptionSlider opt; | - | ||||||||||||||||||
| 247 | initStyleOption(&opt); | - | ||||||||||||||||||
| 248 | d->pressedControl = style()->hitTestComplexControl(QStyle::CC_Slider, | - | ||||||||||||||||||
| 249 | &opt, ev->pos(), this); | - | ||||||||||||||||||
| 250 | SliderAction action = SliderNoAction; | - | ||||||||||||||||||
| 251 |         if (d->pressedControl == QStyle::SC_SliderGroove
  | 0 | ||||||||||||||||||
| 252 | const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); | - | ||||||||||||||||||
| 253 | int pressValue = d->pixelPosToRangeValue(d->pick(ev->pos() - sliderRect.center() + sliderRect.topLeft())); | - | ||||||||||||||||||
| 254 | d->pressValue = pressValue; | - | ||||||||||||||||||
| 255 |             if (pressValue > d->value
  | 0 | ||||||||||||||||||
| 256 |                 action = SliderPageStepAdd; never executed:  action = SliderPageStepAdd; | 0 | ||||||||||||||||||
| 257 |             else if (pressValue < d->value
  | 0 | ||||||||||||||||||
| 258 |                 action = SliderPageStepSub; never executed:  action = SliderPageStepSub; | 0 | ||||||||||||||||||
| 259 |             if (action
  | 0 | ||||||||||||||||||
| 260 | triggerAction(action); | - | ||||||||||||||||||
| 261 | setRepeatAction(action); | - | ||||||||||||||||||
| 262 |             } never executed:  end of block | 0 | ||||||||||||||||||
| 263 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 264 |     } never executed:   else {end of block | 0 | ||||||||||||||||||
| 265 | ev->ignore(); | - | ||||||||||||||||||
| 266 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 267 | } | - | ||||||||||||||||||
| 268 | - | |||||||||||||||||||
| 269 |     if (d->pressedControl == QStyle::SC_SliderHandle
  | 0 | ||||||||||||||||||
| 270 | QStyleOptionSlider opt; | - | ||||||||||||||||||
| 271 | initStyleOption(&opt); | - | ||||||||||||||||||
| 272 | setRepeatAction(SliderNoAction); | - | ||||||||||||||||||
| 273 | QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); | - | ||||||||||||||||||
| 274 | d->clickOffset = d->pick(ev->pos() - sr.topLeft()); | - | ||||||||||||||||||
| 275 | update(sr); | - | ||||||||||||||||||
| 276 | setSliderDown(true); | - | ||||||||||||||||||
| 277 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 278 | } never executed:  end of block | 0 | ||||||||||||||||||
| 279 | - | |||||||||||||||||||
| 280 | - | |||||||||||||||||||
| 281 | - | |||||||||||||||||||
| 282 | - | |||||||||||||||||||
| 283 | void QSlider::mouseMoveEvent(QMouseEvent *ev) | - | ||||||||||||||||||
| 284 | { | - | ||||||||||||||||||
| 285 | QSliderPrivate * const d = d_func(); | - | ||||||||||||||||||
| 286 |     if (d->pressedControl != QStyle::SC_SliderHandle
  | 0 | ||||||||||||||||||
| 287 | ev->ignore(); | - | ||||||||||||||||||
| 288 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 289 | } | - | ||||||||||||||||||
| 290 | ev->accept(); | - | ||||||||||||||||||
| 291 | int newPosition = d->pixelPosToRangeValue(d->pick(ev->pos()) - d->clickOffset); | - | ||||||||||||||||||
| 292 | QStyleOptionSlider opt; | - | ||||||||||||||||||
| 293 | initStyleOption(&opt); | - | ||||||||||||||||||
| 294 | setSliderPosition(newPosition); | - | ||||||||||||||||||
| 295 | } never executed:  end of block | 0 | ||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | - | |||||||||||||||||||
| 300 | - | |||||||||||||||||||
| 301 | void QSlider::mouseReleaseEvent(QMouseEvent *ev) | - | ||||||||||||||||||
| 302 | { | - | ||||||||||||||||||
| 303 | QSliderPrivate * const d = d_func(); | - | ||||||||||||||||||
| 304 |     if (d->pressedControl == QStyle::SC_None
 
  | 0 | ||||||||||||||||||
| 305 | ev->ignore(); | - | ||||||||||||||||||
| 306 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 307 | } | - | ||||||||||||||||||
| 308 | ev->accept(); | - | ||||||||||||||||||
| 309 | QStyle::SubControl oldPressed = QStyle::SubControl(d->pressedControl); | - | ||||||||||||||||||
| 310 | d->pressedControl = QStyle::SC_None; | - | ||||||||||||||||||
| 311 | setRepeatAction(SliderNoAction); | - | ||||||||||||||||||
| 312 |     if (oldPressed == QStyle::SC_SliderHandle
  | 0 | ||||||||||||||||||
| 313 |         setSliderDown(false); never executed:  setSliderDown(false); | 0 | ||||||||||||||||||
| 314 | QStyleOptionSlider opt; | - | ||||||||||||||||||
| 315 | initStyleOption(&opt); | - | ||||||||||||||||||
| 316 | opt.subControls = oldPressed; | - | ||||||||||||||||||
| 317 | update(style()->subControlRect(QStyle::CC_Slider, &opt, oldPressed, this)); | - | ||||||||||||||||||
| 318 | } never executed:  end of block | 0 | ||||||||||||||||||
| 319 | - | |||||||||||||||||||
| 320 | - | |||||||||||||||||||
| 321 | - | |||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | QSize QSlider::sizeHint() const | - | ||||||||||||||||||
| 324 | { | - | ||||||||||||||||||
| 325 | const QSliderPrivate * const d = d_func(); | - | ||||||||||||||||||
| 326 | ensurePolished(); | - | ||||||||||||||||||
| 327 | const int SliderLength = 84, TickSpace = 5; | - | ||||||||||||||||||
| 328 | QStyleOptionSlider opt; | - | ||||||||||||||||||
| 329 | initStyleOption(&opt); | - | ||||||||||||||||||
| 330 | int thick = style()->pixelMetric(QStyle::PM_SliderThickness, &opt, this); | - | ||||||||||||||||||
| 331 |     if (d->tickPosition & TicksAbove
  | 0 | ||||||||||||||||||
| 332 |         thick += TickSpace; never executed:  thick += TickSpace; | 0 | ||||||||||||||||||
| 333 |     if (d->tickPosition & TicksBelow
  | 0 | ||||||||||||||||||
| 334 |         thick += TickSpace; never executed:  thick += TickSpace; | 0 | ||||||||||||||||||
| 335 | int w = thick, h = SliderLength; | - | ||||||||||||||||||
| 336 |     if (d->orientation == Qt::Horizontal
  | 0 | ||||||||||||||||||
| 337 | w = SliderLength; | - | ||||||||||||||||||
| 338 | h = thick; | - | ||||||||||||||||||
| 339 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 340 |     return never executed:   style()->sizeFromContents(QStyle::CT_Slider, &opt, QSize(w, h), this).expandedTo(QApplication::globalStrut());return style()->sizeFromContents(QStyle::CT_Slider, &opt, QSize(w, h), this).expandedTo(QApplication::globalStrut());never executed:  return style()->sizeFromContents(QStyle::CT_Slider, &opt, QSize(w, h), this).expandedTo(QApplication::globalStrut()); | 0 | ||||||||||||||||||
| 341 | } | - | ||||||||||||||||||
| 342 | - | |||||||||||||||||||
| 343 | - | |||||||||||||||||||
| 344 | - | |||||||||||||||||||
| 345 | - | |||||||||||||||||||
| 346 | QSize QSlider::minimumSizeHint() const | - | ||||||||||||||||||
| 347 | { | - | ||||||||||||||||||
| 348 | const QSliderPrivate * const d = d_func(); | - | ||||||||||||||||||
| 349 | QSize s = sizeHint(); | - | ||||||||||||||||||
| 350 | QStyleOptionSlider opt; | - | ||||||||||||||||||
| 351 | initStyleOption(&opt); | - | ||||||||||||||||||
| 352 | int length = style()->pixelMetric(QStyle::PM_SliderLength, &opt, this); | - | ||||||||||||||||||
| 353 |     if (d->orientation == Qt::Horizontal
  | 0 | ||||||||||||||||||
| 354 |         s.setWidth(length); never executed:  s.setWidth(length); | 0 | ||||||||||||||||||
| 355 | else | - | ||||||||||||||||||
| 356 |         s.setHeight(length); never executed:  s.setHeight(length); | 0 | ||||||||||||||||||
| 357 |     return never executed:   s;return s;never executed:  return s; | 0 | ||||||||||||||||||
| 358 | } | - | ||||||||||||||||||
| 359 | void QSlider::setTickPosition(TickPosition position) | - | ||||||||||||||||||
| 360 | { | - | ||||||||||||||||||
| 361 | QSliderPrivate * const d = d_func(); | - | ||||||||||||||||||
| 362 | d->tickPosition = position; | - | ||||||||||||||||||
| 363 | d->resetLayoutItemMargins(); | - | ||||||||||||||||||
| 364 | update(); | - | ||||||||||||||||||
| 365 | updateGeometry(); | - | ||||||||||||||||||
| 366 | } never executed:  end of block | 0 | ||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | QSlider::TickPosition QSlider::tickPosition() const | - | ||||||||||||||||||
| 369 | { | - | ||||||||||||||||||
| 370 |     return never executed:   d_func()->tickPosition;return d_func()->tickPosition;never executed:  return d_func()->tickPosition; | 0 | ||||||||||||||||||
| 371 | } | - | ||||||||||||||||||
| 372 | void QSlider::setTickInterval(int ts) | - | ||||||||||||||||||
| 373 | { | - | ||||||||||||||||||
| 374 | d_func()->tickInterval = qMax(0, ts); | - | ||||||||||||||||||
| 375 | update(); | - | ||||||||||||||||||
| 376 | } never executed:  end of block | 0 | ||||||||||||||||||
| 377 | - | |||||||||||||||||||
| 378 | int QSlider::tickInterval() const | - | ||||||||||||||||||
| 379 | { | - | ||||||||||||||||||
| 380 |     return never executed:   d_func()->tickInterval;return d_func()->tickInterval;never executed:  return d_func()->tickInterval; | 0 | ||||||||||||||||||
| 381 | } | - | ||||||||||||||||||
| 382 | - | |||||||||||||||||||
| 383 | __attribute__((visibility("default"))) QStyleOptionSlider qt_qsliderStyleOption(QSlider *slider) | - | ||||||||||||||||||
| 384 | { | - | ||||||||||||||||||
| 385 | QStyleOptionSlider sliderOption; | - | ||||||||||||||||||
| 386 | slider->initStyleOption(&sliderOption); | - | ||||||||||||||||||
| 387 |     return never executed:   sliderOption;return sliderOption;never executed:  return sliderOption; | 0 | ||||||||||||||||||
| 388 | } | - | ||||||||||||||||||
| 389 | - | |||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 | - | |||||||||||||||||||
| 393 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |