qscrollbar.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qscrollbar.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8bool QScrollBarPrivate::updateHoverControl(const QPoint &pos)-
9{-
10 QScrollBar * const q = q_func();-
11 QRect lastHoverRect = hoverRect;-
12 QStyle::SubControl lastHoverControl = hoverControl;-
13 bool doesHover = q->testAttribute(Qt::WA_Hover);-
14 if (lastHoverControl != newHoverControl(pos)
lastHoverContr...erControl(pos)Description
TRUEnever evaluated
FALSEnever evaluated
&& doesHover
doesHoverDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
15 q->update(lastHoverRect);-
16 q->update(hoverRect);-
17 return
never executed: return true;
true;
never executed: return true;
0
18 }-
19 return
never executed: return !doesHover;
!doesHover;
never executed: return !doesHover;
0
20}-
21-
22QStyle::SubControl QScrollBarPrivate::newHoverControl(const QPoint &pos)-
23{-
24 QScrollBar * const q = q_func();-
25 QStyleOptionSlider opt;-
26 q->initStyleOption(&opt);-
27 opt.subControls = QStyle::SC_All;-
28 hoverControl = q->style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, pos, q);-
29 if (hoverControl == QStyle::SC_None
hoverControl =...Style::SC_NoneDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
30 hoverRect = QRect();
never executed: hoverRect = QRect();
0
31 else-
32 hoverRect = q->style()->subControlRect(QStyle::CC_ScrollBar, &opt, hoverControl, q);
never executed: hoverRect = q->style()->subControlRect(QStyle::CC_ScrollBar, &opt, hoverControl, q);
0
33 return
never executed: return hoverControl;
hoverControl;
never executed: return hoverControl;
0
34}-
35-
36void QScrollBarPrivate::setTransient(bool value)-
37{-
38 QScrollBar * const q = q_func();-
39 if (transient != value
transient != valueDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
40 transient = value;-
41 if (q->isVisible()
q->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
42 if (q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q)
q->style()->st...ansient, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
43 q->update();
never executed: q->update();
0
44 }
never executed: end of block
else if (!transient
!transientDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
45 q->show();-
46 }
never executed: end of block
0
47 }
never executed: end of block
0
48}
never executed: end of block
0
49-
50void QScrollBarPrivate::flash()-
51{-
52 QScrollBar * const q = q_func();-
53 if (!flashed
!flashedDescription
TRUEnever evaluated
FALSEnever evaluated
&& q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q)
q->style()->st...ansient, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
54 flashed = true;-
55 if (!q->isVisible()
!q->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
56 q->show();
never executed: q->show();
0
57 else-
58 q->update();
never executed: q->update();
0
59 }-
60 if (!flashTimer
!flashTimerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
61 flashTimer = q->startTimer(0);
never executed: flashTimer = q->startTimer(0);
0
62}
never executed: end of block
0
63-
64void QScrollBarPrivate::activateControl(uint control, int threshold)-
65{-
66 QAbstractSlider::SliderAction action = QAbstractSlider::SliderNoAction;-
67 switch (control) {-
68 case
never executed: case QStyle::SC_ScrollBarAddPage:
QStyle::SC_ScrollBarAddPage:
never executed: case QStyle::SC_ScrollBarAddPage:
0
69 action = QAbstractSlider::SliderPageStepAdd;-
70 break;
never executed: break;
0
71 case
never executed: case QStyle::SC_ScrollBarSubPage:
QStyle::SC_ScrollBarSubPage:
never executed: case QStyle::SC_ScrollBarSubPage:
0
72 action = QAbstractSlider::SliderPageStepSub;-
73 break;
never executed: break;
0
74 case
never executed: case QStyle::SC_ScrollBarAddLine:
QStyle::SC_ScrollBarAddLine:
never executed: case QStyle::SC_ScrollBarAddLine:
0
75 action = QAbstractSlider::SliderSingleStepAdd;-
76 break;
never executed: break;
0
77 case
never executed: case QStyle::SC_ScrollBarSubLine:
QStyle::SC_ScrollBarSubLine:
never executed: case QStyle::SC_ScrollBarSubLine:
0
78 action = QAbstractSlider::SliderSingleStepSub;-
79 break;
never executed: break;
0
80 case
never executed: case QStyle::SC_ScrollBarFirst:
QStyle::SC_ScrollBarFirst:
never executed: case QStyle::SC_ScrollBarFirst:
0
81 action = QAbstractSlider::SliderToMinimum;-
82 break;
never executed: break;
0
83 case
never executed: case QStyle::SC_ScrollBarLast:
QStyle::SC_ScrollBarLast:
never executed: case QStyle::SC_ScrollBarLast:
0
84 action = QAbstractSlider::SliderToMaximum;-
85 break;
never executed: break;
0
86 default
never executed: default:
:
never executed: default:
0
87 break;
never executed: break;
0
88 }-
89-
90 if (action
actionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
91 q_func()->setRepeatAction(action, threshold);-
92 q_func()->triggerAction(action);-
93 }
never executed: end of block
0
94}
never executed: end of block
0
95-
96void QScrollBarPrivate::stopRepeatAction()-
97{-
98 QScrollBar * const q = q_func();-
99 QStyle::SubControl tmp = pressedControl;-
100 q->setRepeatAction(QAbstractSlider::SliderNoAction);-
101 pressedControl = QStyle::SC_None;-
102-
103 if (tmp == QStyle::SC_ScrollBarSlider
tmp == QStyle:...crollBarSliderDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
104 q->setSliderDown(false);
never executed: q->setSliderDown(false);
0
105-
106 QStyleOptionSlider opt;-
107 q->initStyleOption(&opt);-
108 q->repaint(q->style()->subControlRect(QStyle::CC_ScrollBar, &opt, tmp, q));-
109}
never executed: end of block
0
110void QScrollBar::initStyleOption(QStyleOptionSlider *option) const-
111{-
112 if (!option
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
113 return;
never executed: return;
0
114-
115 const QScrollBarPrivate * const d = d_func();-
116 option->initFrom(this);-
117 option->subControls = QStyle::SC_None;-
118 option->activeSubControls = QStyle::SC_None;-
119 option->orientation = d->orientation;-
120 option->minimum = d->minimum;-
121 option->maximum = d->maximum;-
122 option->sliderPosition = d->position;-
123 option->sliderValue = d->value;-
124 option->singleStep = d->singleStep;-
125 option->pageStep = d->pageStep;-
126 option->upsideDown = d->invertedAppearance;-
127 if (d->orientation == Qt::Horizontal
d->orientation...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
128 option->state |= QStyle::State_Horizontal;
never executed: option->state |= QStyle::State_Horizontal;
0
129 if ((d->flashed
d->flashedDescription
TRUEnever evaluated
FALSEnever evaluated
|| !d->transient
!d->transientDescription
TRUEnever evaluated
FALSEnever evaluated
) && style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this)
style()->style...ient, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
130 option->state |= QStyle::State_On;
never executed: option->state |= QStyle::State_On;
0
131}
never executed: end of block
0
132QScrollBar::QScrollBar(QWidget *parent)-
133 : QAbstractSlider(*new QScrollBarPrivate, parent)-
134{-
135 d_func()->orientation = Qt::Vertical;-
136 d_func()->init();-
137}
never executed: end of block
0
138QScrollBar::QScrollBar(Qt::Orientation orientation, QWidget *parent)-
139 : QAbstractSlider(*new QScrollBarPrivate, parent)-
140{-
141 d_func()->orientation = orientation;-
142 d_func()->init();-
143}
never executed: end of block
0
144-
145-
146-
147-
148-
149-
150QScrollBar::~QScrollBar()-
151{-
152}-
153-
154void QScrollBarPrivate::init()-
155{-
156 QScrollBar * const q = q_func();-
157 invertedControls = true;-
158 pressedControl = hoverControl = QStyle::SC_None;-
159 pointerOutsidePressedControl = false;-
160 transient = q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q);-
161 flashed = false;-
162 flashTimer = 0;-
163 q->setFocusPolicy(Qt::NoFocus);-
164 QSizePolicy sp(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::Slider);-
165 if (orientation == Qt::Vertical
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
166 sp.transpose();
never executed: sp.transpose();
0
167 q->setSizePolicy(sp);-
168 q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);-
169 q->setAttribute(Qt::WA_OpaquePaintEvent);-
170-
171-
172-
173-
174-
175-
176}
never executed: end of block
0
177-
178-
179-
180void QScrollBar::contextMenuEvent(QContextMenuEvent *event)-
181{-
182 if (!style()->styleHint(QStyle::SH_ScrollBar_ContextMenu, 0, this)
!style()->styl...Menu, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
183 QAbstractSlider::contextMenuEvent(event);-
184 return
never executed: return ;
;
never executed: return ;
0
185 }-
186-
187-
188 bool horiz = (d_func()->orientation == Qt::Horizontal);-
189 QPointer<QMenu> menu = new QMenu(this);-
190 QAction *actScrollHere = menu->addAction(tr("Scroll here"));-
191 menu->addSeparator();-
192 QAction *actScrollTop = menu->addAction(horiz ? tr("Left edge") : tr("Top"));-
193 QAction *actScrollBottom = menu->addAction(horiz ? tr("Right edge") : tr("Bottom"));-
194 menu->addSeparator();-
195 QAction *actPageUp = menu->addAction(horiz ? tr("Page left") : tr("Page up"));-
196 QAction *actPageDn = menu->addAction(horiz ? tr("Page right") : tr("Page down"));-
197 menu->addSeparator();-
198 QAction *actScrollUp = menu->addAction(horiz ? tr("Scroll left") : tr("Scroll up"));-
199 QAction *actScrollDn = menu->addAction(horiz ? tr("Scroll right") : tr("Scroll down"));-
200 QAction *actionSelected = menu->exec(event->globalPos());-
201 delete menu;-
202 if (actionSelected == 0
actionSelected == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
203 ;
never executed: ;
0
204 else if (actionSelected == actScrollHere
actionSelected... actScrollHereDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
205 setValue(d_func()->pixelPosToRangeValue(horiz ? event->pos().x() : event->pos().y()));
never executed: setValue(d_func()->pixelPosToRangeValue(horiz ? event->pos().x() : event->pos().y()));
0
206 else if (actionSelected == actScrollTop
actionSelected == actScrollTopDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
207 triggerAction(QAbstractSlider::SliderToMinimum);
never executed: triggerAction(QAbstractSlider::SliderToMinimum);
0
208 else if (actionSelected == actScrollBottom
actionSelected...ctScrollBottomDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
209 triggerAction(QAbstractSlider::SliderToMaximum);
never executed: triggerAction(QAbstractSlider::SliderToMaximum);
0
210 else if (actionSelected == actPageUp
actionSelected == actPageUpDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
211 triggerAction(QAbstractSlider::SliderPageStepSub);
never executed: triggerAction(QAbstractSlider::SliderPageStepSub);
0
212 else if (actionSelected == actPageDn
actionSelected == actPageDnDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
213 triggerAction(QAbstractSlider::SliderPageStepAdd);
never executed: triggerAction(QAbstractSlider::SliderPageStepAdd);
0
214 else if (actionSelected == actScrollUp
actionSelected == actScrollUpDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
215 triggerAction(QAbstractSlider::SliderSingleStepSub);
never executed: triggerAction(QAbstractSlider::SliderSingleStepSub);
0
216 else if (actionSelected == actScrollDn
actionSelected == actScrollDnDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
217 triggerAction(QAbstractSlider::SliderSingleStepAdd);
never executed: triggerAction(QAbstractSlider::SliderSingleStepAdd);
0
218-
219}
never executed: end of block
0
220-
221-
222-
223-
224QSize QScrollBar::sizeHint() const-
225{-
226 ensurePolished();-
227 QStyleOptionSlider opt;-
228 initStyleOption(&opt);-
229-
230 int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent, &opt, this);-
231 int scrollBarSliderMin = style()->pixelMetric(QStyle::PM_ScrollBarSliderMin, &opt, this);-
232 QSize size;-
233 if (opt.orientation == Qt::Horizontal
opt.orientatio...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
234 size = QSize(scrollBarExtent * 2 + scrollBarSliderMin, scrollBarExtent);
never executed: size = QSize(scrollBarExtent * 2 + scrollBarSliderMin, scrollBarExtent);
0
235 else-
236 size = QSize(scrollBarExtent, scrollBarExtent * 2 + scrollBarSliderMin);
never executed: size = QSize(scrollBarExtent, scrollBarExtent * 2 + scrollBarSliderMin);
0
237-
238 return
never executed: return style()->sizeFromContents(QStyle::CT_ScrollBar, &opt, size, this) .expandedTo(QApplication::globalStrut());
style()->sizeFromContents(QStyle::CT_ScrollBar, &opt, size, this)
never executed: return style()->sizeFromContents(QStyle::CT_ScrollBar, &opt, size, this) .expandedTo(QApplication::globalStrut());
0
239 .expandedTo(QApplication::globalStrut());
never executed: return style()->sizeFromContents(QStyle::CT_ScrollBar, &opt, size, this) .expandedTo(QApplication::globalStrut());
0
240 }-
241-
242-
243void QScrollBar::sliderChange(SliderChange change)-
244{-
245 QAbstractSlider::sliderChange(change);-
246}
never executed: end of block
0
247-
248-
249-
250-
251bool QScrollBar::event(QEvent *event)-
252{-
253 QScrollBarPrivate * const d = d_func();-
254 switch(event->type()) {-
255 case
never executed: case QEvent::HoverEnter:
QEvent::HoverEnter:
never executed: case QEvent::HoverEnter:
0
256 case
never executed: case QEvent::HoverLeave:
QEvent::HoverLeave:
never executed: case QEvent::HoverLeave:
0
257 case
never executed: case QEvent::HoverMove:
QEvent::HoverMove:
never executed: case QEvent::HoverMove:
0
258 if (const
const QHoverEv...vent *>(event)Description
TRUEnever evaluated
FALSEnever evaluated
QHoverEvent *he = static_cast<const QHoverEvent *>(event)
const QHoverEv...vent *>(event)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
259 d_func()->updateHoverControl(he->pos());
never executed: d_func()->updateHoverControl(he->pos());
0
260 break;
never executed: break;
0
261 case
never executed: case QEvent::StyleChange:
QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
262 d_func()->setTransient(style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this));-
263 break;
never executed: break;
0
264 case
never executed: case QEvent::Timer:
QEvent::Timer:
never executed: case QEvent::Timer:
0
265 if (static_cast<
static_cast<QT... d->flashTimerDescription
TRUEnever evaluated
FALSEnever evaluated
QTimerEvent *>(event)->timerId() == d->flashTimer
static_cast<QT... d->flashTimerDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
266 if (d->flashed
d->flashedDescription
TRUEnever evaluated
FALSEnever evaluated
&& style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this)
style()->style...ient, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
267 d->flashed = false;-
268 update();-
269 }
never executed: end of block
0
270 killTimer(d->flashTimer);-
271 d->flashTimer = 0;-
272 }
never executed: end of block
0
273 break;
never executed: break;
0
274 default
never executed: default:
:
never executed: default:
0
275 break;
never executed: break;
0
276 }-
277 return
never executed: return QAbstractSlider::event(event);
QAbstractSlider::event(event);
never executed: return QAbstractSlider::event(event);
0
278}-
279-
280-
281-
282-
283-
284void QScrollBar::wheelEvent(QWheelEvent *event)-
285{-
286 event->ignore();-
287 int delta = event->delta();-
288-
289-
290-
291-
292-
293 if (event->orientation() == Qt::Horizontal
event->orienta...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
294 delta = -delta;
never executed: delta = -delta;
0
295 QScrollBarPrivate * const d = d_func();-
296 if (d->scrollByDelta(event->orientation(), event->modifiers(), delta)
d->scrollByDel...iers(), delta)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
297 event->accept();
never executed: event->accept();
0
298-
299 if (event->phase() == Qt::ScrollBegin
event->phase()...t::ScrollBeginDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
300 d->setTransient(false);
never executed: d->setTransient(false);
0
301 else if (event->phase() == Qt::ScrollEnd
event->phase()... Qt::ScrollEndDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
302 d->setTransient(true);
never executed: d->setTransient(true);
0
303}
never executed: end of block
0
304-
305-
306-
307-
308-
309void QScrollBar::paintEvent(QPaintEvent *)-
310{-
311 QScrollBarPrivate * const d = d_func();-
312 QPainter p(this);-
313 QStyleOptionSlider opt;-
314 initStyleOption(&opt);-
315 opt.subControls = QStyle::SC_All;-
316 if (d->pressedControl
d->pressedControlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
317 opt.activeSubControls = (QStyle::SubControl)d->pressedControl;-
318 if (!d->pointerOutsidePressedControl
!d->pointerOut...PressedControlDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
319 opt.state |= QStyle::State_Sunken;
never executed: opt.state |= QStyle::State_Sunken;
0
320 }
never executed: end of block
else {
0
321 opt.activeSubControls = (QStyle::SubControl)d->hoverControl;-
322 }
never executed: end of block
0
323 style()->drawComplexControl(QStyle::CC_ScrollBar, &opt, &p, this);-
324}
never executed: end of block
0
325-
326-
327-
328-
329void QScrollBar::mousePressEvent(QMouseEvent *e)-
330{-
331 QScrollBarPrivate * const d = d_func();-
332-
333 if (d->repeatActionTimer.isActive()
d->repeatActio...mer.isActive()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
334 d->stopRepeatAction();
never executed: d->stopRepeatAction();
0
335-
336 bool midButtonAbsPos = style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition,-
337 0, this);-
338 QStyleOptionSlider opt;-
339 initStyleOption(&opt);-
340-
341 if (d->maximum == d->minimum
d->maximum == d->minimumDescription
TRUEnever evaluated
FALSEnever evaluated
0
342 || (
(e->buttons() ...~e->button()))Description
TRUEnever evaluated
FALSEnever evaluated
e->buttons() & (~e->button()))
(e->buttons() ...~e->button()))Description
TRUEnever evaluated
FALSEnever evaluated
0
343 || !(e->button() == Qt::LeftButton
e->button() == Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
|| (midButtonAbsPos
midButtonAbsPosDescription
TRUEnever evaluated
FALSEnever evaluated
&& e->button() == Qt::MidButton
e->button() == Qt::MidButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)))
0
344 return;
never executed: return;
0
345-
346 d->pressedControl = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, e->pos(), this);-
347 d->pointerOutsidePressedControl = false;-
348-
349 QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,-
350 QStyle::SC_ScrollBarSlider, this);-
351 QPoint click = e->pos();-
352 QPoint pressValue = click - sr.center() + sr.topLeft();-
353 d->pressValue = d->orientation == Qt::Horizontal
d->orientation...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
? d->pixelPosToRangeValue(pressValue.x()) :
0
354 d->pixelPosToRangeValue(pressValue.y());-
355 if (d->pressedControl == QStyle::SC_ScrollBarSlider
d->pressedCont...crollBarSliderDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
356 d->clickOffset = (
(d_func()->ori...t::Horizontal)Description
TRUEnever evaluated
FALSEnever evaluated
d_func()->orientation == Qt::Horizontal)
(d_func()->ori...t::Horizontal)Description
TRUEnever evaluated
FALSEnever evaluated
? (click.x()-sr.x()) : (click.y()-sr.y());
0
357 d->snapBackPosition = d->position;-
358 }
never executed: end of block
0
359-
360 if ((d->pressedControl == QStyle::SC_ScrollBarAddPage
d->pressedCont...rollBarAddPageDescription
TRUEnever evaluated
FALSEnever evaluated
0
361 || d->pressedControl == QStyle::SC_ScrollBarSubPage
d->pressedCont...rollBarSubPageDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
362 && ((midButtonAbsPos
midButtonAbsPosDescription
TRUEnever evaluated
FALSEnever evaluated
&& e->button() == Qt::MidButton
e->button() == Qt::MidButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
363 || (style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition, &opt, this)
style()->style...n, &opt, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
364 && e->button() == Qt::LeftButton
e->button() == Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
))) {
0
365 int sliderLength = (
(d_func()->ori...t::Horizontal)Description
TRUEnever evaluated
FALSEnever evaluated
d_func()->orientation == Qt::Horizontal)
(d_func()->ori...t::Horizontal)Description
TRUEnever evaluated
FALSEnever evaluated
? sr.width() : sr.height();
0
366 setSliderPosition(d->pixelPosToRangeValue(((d_func()->orientation == Qt::Horizontal) ? e->pos().x()-
367 : e->pos().y()) - sliderLength / 2));-
368 d->pressedControl = QStyle::SC_ScrollBarSlider;-
369 d->clickOffset = sliderLength / 2;-
370 }
never executed: end of block
0
371 const int initialDelay = 500;-
372 QElapsedTimer time;-
373 time.start();-
374 d->activateControl(d->pressedControl, initialDelay);-
375 repaint(style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this));-
376 if (time.elapsed() >= initialDelay
time.elapsed() >= initialDelayDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->repeatActionTimer.isActive()
d->repeatActio...mer.isActive()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
377-
378-
379-
380-
381-
382-
383 d->repeatActionTimer.start(50, this);-
384 }
never executed: end of block
0
385 if (d->pressedControl == QStyle::SC_ScrollBarSlider
d->pressedCont...crollBarSliderDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
386 setSliderDown(true);
never executed: setSliderDown(true);
0
387}
never executed: end of block
0
388-
389-
390-
391-
392-
393void QScrollBar::mouseReleaseEvent(QMouseEvent *e)-
394{-
395 QScrollBarPrivate * const d = d_func();-
396 if (!d->pressedControl
!d->pressedControlDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
397 return;
never executed: return;
0
398-
399 if (e->buttons() & (~e->button())
e->buttons() & (~e->button())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
400 return;
never executed: return;
0
401-
402 d->stopRepeatAction();-
403}
never executed: end of block
0
404-
405-
406-
407-
408-
409void QScrollBar::mouseMoveEvent(QMouseEvent *e)-
410{-
411 QScrollBarPrivate * const d = d_func();-
412 if (!d->pressedControl
!d->pressedControlDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
413 return;
never executed: return;
0
414-
415 QStyleOptionSlider opt;-
416 initStyleOption(&opt);-
417 if (!(e->buttons() & Qt::LeftButton
e->buttons() & Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
418 || ((
(e->buttons() & Qt::MidButton)Description
TRUEnever evaluated
FALSEnever evaluated
e->buttons() & Qt::MidButton)
(e->buttons() & Qt::MidButton)Description
TRUEnever evaluated
FALSEnever evaluated
0
419 && style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition, &opt, this)
style()->style...n, &opt, this)Description
TRUEnever evaluated
FALSEnever evaluated
)))
0
420 return;
never executed: return;
0
421-
422 if (d->pressedControl == QStyle::SC_ScrollBarSlider
d->pressedCont...crollBarSliderDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
423 QPoint click = e->pos();-
424 int newPosition = d->pixelPosToRangeValue(((d_func()->orientation == Qt::Horizontal) ? click.x() : click.y()) -d->clickOffset);-
425 int m = style()->pixelMetric(QStyle::PM_MaximumDragDistance, &opt, this);-
426 if (m >= 0
m >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
427 QRect r = rect();-
428 r.adjust(-m, -m, m, m);-
429 if (! r.contains(e->pos())
! r.contains(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
430 newPosition = d->snapBackPosition;
never executed: newPosition = d->snapBackPosition;
0
431 }
never executed: end of block
0
432 setSliderPosition(newPosition);-
433 }
never executed: end of block
else if (!style()->styleHint(QStyle::SH_ScrollBar_ScrollWhenPointerLeavesControl, &opt, this)
!style()->styl...l, &opt, this)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
434-
435 if (style()->styleHint(QStyle::SH_ScrollBar_RollBetweenButtons, &opt, this)
style()->style...s, &opt, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
436 && d->pressedControl & (QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine)
d->pressedCont...ollBarSubLine)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
437 QStyle::SubControl newSc = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, e->pos(), this);-
438 if (newSc == d->pressedControl
newSc == d->pressedControlDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->pointerOutsidePressedControl
!d->pointerOut...PressedControlDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
439 return;
never executed: return;
0
440 if (newSc & (QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine)
newSc & (QStyl...ollBarSubLine)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
441 d->pointerOutsidePressedControl = false;-
442 QRect scRect = style()->subControlRect(QStyle::CC_ScrollBar, &opt, newSc, this);-
443 scRect |= style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this);-
444 d->pressedControl = newSc;-
445 d->activateControl(d->pressedControl, 0);-
446 update(scRect);-
447 return;
never executed: return;
0
448 }-
449 }
never executed: end of block
0
450-
451-
452-
453 QRect pr = style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this);-
454 if (pr.contains(e->pos()) == d->pointerOutsidePressedControl
pr.contains(e-...PressedControlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
455 if ((
(d->pointerOut...ressedControl)Description
TRUEnever evaluated
FALSEnever evaluated
d->pointerOutsidePressedControl = !d->pointerOutsidePressedControl)
(d->pointerOut...ressedControl)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
456 d->pointerOutsidePressedControl = true;-
457 setRepeatAction(SliderNoAction);-
458 repaint(pr);-
459 }
never executed: end of block
else {
0
460 d->activateControl(d->pressedControl);-
461 }
never executed: end of block
0
462 }-
463 }
never executed: end of block
0
464}
never executed: end of block
0
465-
466-
467int QScrollBarPrivate::pixelPosToRangeValue(int pos) const-
468{-
469 const QScrollBar * const q = q_func();-
470 QStyleOptionSlider opt;-
471 q->initStyleOption(&opt);-
472 QRect gr = q->style()->subControlRect(QStyle::CC_ScrollBar, &opt,-
473 QStyle::SC_ScrollBarGroove, q);-
474 QRect sr = q->style()->subControlRect(QStyle::CC_ScrollBar, &opt,-
475 QStyle::SC_ScrollBarSlider, q);-
476 int sliderMin, sliderMax, sliderLength;-
477-
478 if (orientation == Qt::Horizontal
orientation == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
479 sliderLength = sr.width();-
480 sliderMin = gr.x();-
481 sliderMax = gr.right() - sliderLength + 1;-
482 if (q->layoutDirection() == Qt::RightToLeft
q->layoutDirec...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
483 opt.upsideDown = !opt.upsideDown;
never executed: opt.upsideDown = !opt.upsideDown;
0
484 }
never executed: end of block
else {
0
485 sliderLength = sr.height();-
486 sliderMin = gr.y();-
487 sliderMax = gr.bottom() - sliderLength + 1;-
488 }
never executed: end of block
0
489-
490 return
never executed: return QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin, sliderMax - sliderMin, opt.upsideDown);
QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin,
never executed: return QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin, sliderMax - sliderMin, opt.upsideDown);
0
491 sliderMax - sliderMin, opt.upsideDown);
never executed: return QStyle::sliderValueFromPosition(minimum, maximum, pos - sliderMin, sliderMax - sliderMin, opt.upsideDown);
0
492}-
493-
494-
495-
496void QScrollBar::hideEvent(QHideEvent *)-
497{-
498 QScrollBarPrivate * const d = d_func();-
499 if (d->pressedControl
d->pressedControlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
500 d->pressedControl = QStyle::SC_None;-
501 setRepeatAction(SliderNoAction);-
502 }
never executed: end of block
0
503}
never executed: end of block
0
504-
505-
506-
507-
508__attribute__((visibility("default"))) QStyleOptionSlider qt_qscrollbarStyleOption(QScrollBar *scrollbar)-
509{-
510 QStyleOptionSlider opt;-
511 scrollbar->initStyleOption(&opt);-
512 return
never executed: return opt;
opt;
never executed: return opt;
0
513}-
514-
515-
516-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9