115 QPainter painter(viewport());
118 const QColor textColor = qApp->palette().color(QPalette::ButtonText);
119 const QColor majorNotchColor = QColor(textColor.red(), textColor.green(), textColor.blue(), 192);
120 const QColor minorNotchColor = QColor(textColor.red(), textColor.green(), textColor.blue(), 128);
121 const QColor zeroColor = qApp->palette().highlight().color();
123 const qreal valueStep =
step();
128 const int majorNotchLength =
rect().width();
129 const int minorNotchLength = 12;
133 for (
int major = 0; major <= visibleSteps + 1; major++) {
134 const qreal
value = firstVisibleValue + valueStep * major;
139 painter.setPen(
value != 0 ? majorNotchColor : zeroColor);
140 painter.drawLine(majorLeft, majorRight);
143 const qreal pixelsPerMinorNotch =
pixelsPerStep(valueStep) / (minorNotches + 1);
144 for (
int minor = 0; minor < minorNotches; minor++) {
145 const QPoint minorRight = QPoint(
rect().width(), majorRight.y() + pixelsPerMinorNotch * (minor + 1));
146 const QPoint minorLeft = QPoint(minorRight.x() - minorNotchLength, minorRight.y());
148 painter.setPen(minorNotchColor);
149 painter.drawLine(minorLeft, minorRight);
153 const int padding = 4;
155 const QString label = QString::number(
value,
'f', valueStep < 1 ? 2 : 0);
156 const QRect textRect = QRect(0, majorLeft.y(),
rect().width() - minorNotchLength - padding, 32);
158 painter.setPen(
value != 0 ? textColor : zeroColor);
159 painter.drawText(textRect, label, QTextOption(Qt::AlignRight));
165 if (mouseEvent->buttons() & Qt::LeftButton) {
166 if (
m_d->mouseTracking) {
167 const qreal oldValue = orientation() == Qt::Vertical ?
m_d->mouseLastPos.y() :
m_d->mouseLastPos.x();
168 const qreal newValue = orientation() == Qt::Vertical ? mouseEvent->pos().y() : mouseEvent->pos().x();
169 if (
m_d->modifiersCatcher->modifierPressed(
"pan-zoom")) {
170 const qreal delta = (newValue - oldValue);
173 const qreal delta = -1 * (newValue - oldValue) / 16;
176 m_d->mouseLastPos = mouseEvent->pos();
179 if (
m_d->mouseTracking ==
true) {
180 m_d->mouseTracking =
false;
184 QHeaderView::mouseMoveEvent(mouseEvent);