if (event->oldSize().height() != event->newSize().height()) {
m_dirtyCache = true;
}
+ updateSize();
}
void KItemListGroupHeader::updateCache()
m_separatorColor = mixedColor(c1, c2, 10);
m_roleColor = mixedColor(c1, c2, 60);
+ updateSize();
+
+ m_dirtyCache = false;
+}
+
+void KItemListGroupHeader::updateSize()
+{
const int padding = qMax(1, m_styleOption.padding);
const int horizontalMargin = qMax(2, m_styleOption.horizontalMargin);
size().width() - 2 * padding - horizontalMargin,
roleHeight);
- m_dirtyCache = false;
+ update();
}
QColor KItemListGroupHeader::mixedColor(const QColor& c1, const QColor& c2, int c1Percent)
m_text(),
m_pixmap()
{
- m_text.setTextFormat(Qt::PlainText);
- m_text.setPerformanceHint(QStaticText::AggressiveCaching);
+
}
KStandardItemListGroupHeader::~KStandardItemListGroupHeader()
{
if (m_pixmap.isNull()) {
painter->setPen(color);
- painter->drawStaticText(roleBounds.topLeft(), m_text);
+ painter->drawText(roleBounds, 0, m_text);
} else {
painter->drawPixmap(roleBounds.topLeft(), m_pixmap);
}
if (scrollOrientation() == Qt::Horizontal) {
painter->drawLine(0, 0, 0, size().height() - 1);
} else {
- painter->drawLine(0, 0, size().width() - 1, 0);
+ if (layoutDirection() == Qt::LeftToRight) {
+ painter->drawLine(0, 0, size().width() - 1, 0);
+ } else {
+ painter->drawLine(1, 0, size().width(), 0);
+ }
}
}
void KStandardItemListGroupHeader::resizeEvent(QGraphicsSceneResizeEvent* event)
{
- QGraphicsWidget::resizeEvent(event);
+ KItemListGroupHeader::resizeEvent(event);
m_dirtyCache = true;
}
const qreal maxWidth = size().width() - 4 * styleOption().padding;
if (role() == "rating") {
- m_text.setText(QString());
+ m_text = QString();
const qreal height = styleOption().fontMetrics.ascent();
const QSizeF pixmapSize(qMin(height * 5, maxWidth), height);
QFontMetricsF fontMetrics(font());
const QString text = fontMetrics.elidedText(data().toString(), Qt::ElideRight, maxWidth);
- m_text.setText(text);
+ m_text = text;
}
}
// The following code is based on the code from QHeaderView::paintSection().
// SPDX-FileCopyrightText: 2011 Nokia Corporation and/or its subsidiary(-ies).
QStyleOptionHeader option;
+ option.direction = widget->layoutDirection();
+ option.textAlignment =
+ widget->layoutDirection() == Qt::LeftToRight
+ ? Qt::AlignLeft
+ : Qt::AlignRight;
+
option.section = orderIndex;
option.state = QStyle::State_None | QStyle::State_Raised | QStyle::State_Horizontal;
if (isEnabled()) {