return m_textRect;
}
+QRectF KStandardItemListWidget::selectionRect() const
+{
+ const_cast<KStandardItemListWidget*>(this)->triggerCacheRefreshing();
+
+ switch (m_layout) {
+ case IconsLayout:
+ return m_textRect;
+
+ case CompactLayout:
+ case DetailsLayout: {
+ const int padding = styleOption().padding;
+ QRectF adjustedIconRect = iconRect().adjusted(-padding, -padding, padding, padding);
+ return adjustedIconRect | m_textRect;
+ }
+
+ default:
+ Q_ASSERT(false);
+ break;
+ }
+
+ return m_textRect;
+}
+
QRectF KStandardItemListWidget::expansionToggleRect() const
{
const_cast<KStandardItemListWidget*>(this)->triggerCacheRefreshing();
KIconEffect::semiTransparent(m_pixmap);
}
- if (isSelected()) {
+ if (m_layout == IconsLayout && isSelected()) {
const QColor color = palette().brush(QPalette::Normal, QPalette::Highlight).color();
QImage image = m_pixmap.toImage();
KIconEffect::colorize(image, color, 0.8f);
const int textLength = line.textStart() + line.textLength();
if (textLength < nameText.length()) {
// Elide the last line of the text
- QString lastTextLine = nameText.mid(line.textStart());
- lastTextLine = m_customizedFontMetrics.elidedText(lastTextLine,
- Qt::ElideRight,
- maxWidth);
- const QString elidedText = nameText.left(line.textStart()) + lastTextLine;
- nameTextInfo->staticText.setText(elidedText);
-
- const qreal lastLineWidth = m_customizedFontMetrics.boundingRect(lastTextLine).width();
+ qreal elidingWidth = maxWidth;
+ qreal lastLineWidth;
+ do {
+ QString lastTextLine = nameText.mid(line.textStart());
+ lastTextLine = m_customizedFontMetrics.elidedText(lastTextLine,
+ Qt::ElideRight,
+ elidingWidth);
+ const QString elidedText = nameText.left(line.textStart()) + lastTextLine;
+ nameTextInfo->staticText.setText(elidedText);
+
+ lastLineWidth = m_customizedFontMetrics.boundingRect(lastTextLine).width();
+
+ // We do the text eliding in a loop with decreasing width (1 px / iteration)
+ // to avoid problems related to different width calculation code paths
+ // within Qt. (see bug 337104)
+ elidingWidth -= 1.0;
+ } while (lastLineWidth > maxWidth);
+
nameWidth = qMax(nameWidth, lastLineWidth);
}
break;