m_hoverPixmap(),
m_textPos(),
m_text(),
- m_textsBoundingRect(),
+ m_textBoundingRect(),
m_sortedVisibleRoles(),
m_expansionArea(),
m_additionalInfoTextColor()
drawPixmap(painter, m_hoverPixmap);
// Draw the hover background for the text
- QRectF textsBoundingRect = m_textsBoundingRect;
+ QRectF textsBoundingRect = m_textBoundingRect;
const qreal marginDiff = itemListStyleOption.margin / 2;
textsBoundingRect.adjust(marginDiff, marginDiff, -marginDiff, -marginDiff);
painter->setOpacity(hoverOpacity() * opacity * 0.1);
#endif
}
-bool KFileItemListWidget::contains(const QPointF& point) const
-{
- return KItemListWidget::contains(point) || m_textsBoundingRect.contains(point);
-}
-
-QRectF KFileItemListWidget::hoverBoundingRect() const
+QRectF KFileItemListWidget::iconBoundingRect() const
{
QRectF bounds = m_hoverPixmapRect;
const qreal margin = styleOption().margin;
return bounds;
}
+QRectF KFileItemListWidget::textBoundingRect() const
+{
+ return m_textBoundingRect;
+}
+
QRectF KFileItemListWidget::expansionToggleRect() const
{
return m_isDir ? m_expansionArea : QRectF();
m_text[Name].setTextWidth(maxWidth);
m_textPos[Name] = QPointF(option.margin, widgetHeight - textLinesCount * fontHeight - option.margin);
- m_textsBoundingRect = QRectF(option.margin + (maxWidth - requiredWidthForName) / 2,
+ m_textBoundingRect = QRectF(option.margin + (maxWidth - requiredWidthForName) / 2,
m_textPos[Name].y(),
requiredWidthForName,
m_text[Name].size().height());
m_text[textId].setTextWidth(maxWidth);
const QRectF textBoundingRect(option.margin + (maxWidth - requiredWidth) / 2, y, requiredWidth, fontHeight);
- m_textsBoundingRect |= textBoundingRect;
+ m_textBoundingRect |= textBoundingRect;
y += fontHeight;
}
// Add a margin to the text bounding rectangle
const qreal margin = option.margin;
- m_textsBoundingRect.adjust(-margin, -margin, margin, margin);
+ m_textBoundingRect.adjust(-margin, -margin, margin, margin);
}
void KFileItemListWidget::updateCompactLayoutTextCache()
y += fontHeight;
}
- m_textsBoundingRect = QRectF(x - option.margin, 0, maximumRequiredTextWidth + 2 * option.margin, widgetHeight);
+ m_textBoundingRect = QRectF(x - option.margin, 0, maximumRequiredTextWidth + 2 * option.margin, widgetHeight);
}
void KFileItemListWidget::updateDetailsLayoutTextCache()
// +------+
// | Icon | Name role Additional role 1 Additional role 2
// +------+
- m_textsBoundingRect = QRectF();
+ m_textBoundingRect = QRectF();
const KItemListStyleOption& option = styleOption();
const QHash<QByteArray, QVariant> values = data();
switch (textId) {
case Name: {
- m_textsBoundingRect = QRectF(m_textPos[textId].x() - option.margin, 0,
+ m_textBoundingRect = QRectF(m_textPos[textId].x() - option.margin, 0,
requiredWidth + 2 * option.margin, size().height());
// The column after the name should always be aligned on the same x-position independent
const KItemListStyleOption& option = styleOption();
const QPalette palette = option.palette;
- const QRect rect = m_textsBoundingRect.toRect().adjusted(0, 0, 0, -1);
+ const QRect rect = m_textBoundingRect.toRect().adjusted(0, 0, 0, -1);
QLinearGradient gradient(rect.bottomLeft(), rect.bottomRight());
gradient.setColorAt(0.0, Qt::transparent);
{
Q_UNUSED(option);
- const QRect hoverBounds = hoverBoundingRect().toRect();
+ const QRect iconBounds = iconBoundingRect().toRect();
if (m_selected) {
QStyleOptionViewItemV4 viewItemOption;
viewItemOption.initFrom(widget);
- viewItemOption.rect = hoverBounds;
+ viewItemOption.rect = iconBounds;
viewItemOption.state = QStyle::State_Enabled | QStyle::State_Selected | QStyle::State_Item;
viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne;
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
}
if (!m_hoverCache) {
- m_hoverCache = new QPixmap(hoverBounds.size());
+ m_hoverCache = new QPixmap(iconBounds.size());
m_hoverCache->fill(Qt::transparent);
QPainter pixmapPainter(m_hoverCache);
QStyleOptionViewItemV4 viewItemOption;
viewItemOption.initFrom(widget);
- viewItemOption.rect = QRect(0, 0, hoverBounds.width(), hoverBounds.height());
+ viewItemOption.rect = QRect(0, 0, iconBounds.width(), iconBounds.height());
viewItemOption.state = QStyle::State_Enabled | QStyle::State_MouseOver | QStyle::State_Item;
viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne;
const qreal opacity = painter->opacity();
painter->setOpacity(m_hoverOpacity * opacity);
- painter->drawPixmap(hoverBounds.topLeft(), *m_hoverCache);
+ painter->drawPixmap(iconBounds.topLeft(), *m_hoverCache);
painter->setOpacity(opacity);
}
bool KItemListWidget::contains(const QPointF& point) const
{
- return hoverBoundingRect().contains(point) ||
+ if (!QGraphicsWidget::contains(point)) {
+ return false;
+ }
+
+ return iconBoundingRect().contains(point) ||
+ textBoundingRect().contains(point) ||
expansionToggleRect().contains(point) ||
selectionToggleRect().contains(point);
}
-QRectF KItemListWidget::hoverBoundingRect() const
-{
- return QRectF(QPointF(0, 0), size());
-}
-
QRectF KItemListWidget::selectionToggleRect() const
{
return QRectF();
/**
* @return True if \a point is inside KItemListWidget::hoverBoundingRect(),
- * KItemListWidget::selectionToggleRect() or KItemListWidget::expansionToggleRect().
+ * KItemListWidget::textBoundingRect(), KItemListWidget::selectionToggleRect()
+ * or KItemListWidget::expansionToggleRect().
* @reimp
*/
virtual bool contains(const QPointF& point) const;
/**
- * @return Bounding rectangle for the area that acts as hovering-area. Per default
- * the bounding rectangle of the KItemListWidget is returned.
+ * @return Bounding rectangle for the area that shows the icon.
*/
- virtual QRectF hoverBoundingRect() const;
+ virtual QRectF iconBoundingRect() const = 0;
+
+ /**
+ * @return Bounding rectangle for the area that contains the text-properties.
+ */
+ virtual QRectF textBoundingRect() const = 0;
/**
* @return Rectangle for the selection-toggle that is used to select or deselect an item.