Set the Details View colummns width to the preferred column width, by double-clicking the header grips.

BUG: 293315
FIXED-IN: 4.13
REVIEW: 115503
This commit is contained in:
Emmanuel Pescosta 2014-02-06 13:00:28 +01:00
parent 47c8eebe96
commit 15f409de33
2 changed files with 17 additions and 0 deletions

View file

@ -327,6 +327,22 @@ void KItemListHeaderWidget::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
}
}
void KItemListHeaderWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
{
QGraphicsItem::mouseDoubleClickEvent(event);
const int roleIndex = roleIndexAt(event->pos());
if (roleIndex >= 0 && isAboveRoleGrip(event->pos(), roleIndex)) {
const QByteArray role = m_columns.at(roleIndex);
qreal previousWidth = columnWidth(role);
setColumnWidth(role, preferredColumnWidth(role));
qreal currentWidth = columnWidth(role);
emit columnWidthChanged(role, currentWidth, previousWidth);
}
}
void KItemListHeaderWidget::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
{
QGraphicsWidget::hoverEnterEvent(event);

View file

@ -100,6 +100,7 @@ protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* event);