┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/private/kitemlistheaderwidget.cpp
diff options
context:
space:
mode:
authorEmmanuel Pescosta <[email protected]>2014-02-06 13:00:28 +0100
committerEmmanuel Pescosta <[email protected]>2014-02-06 13:00:28 +0100
commit2c20502c346d975bff854567c038bf0b78c3b857 (patch)
tree6b7c96577cb5acf6af77c26786b4fec515156312 /src/kitemviews/private/kitemlistheaderwidget.cpp
parent4d9193b85b9dacdc4cc46965596c1fc456fc273e (diff)
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
Diffstat (limited to 'src/kitemviews/private/kitemlistheaderwidget.cpp')
-rw-r--r--src/kitemviews/private/kitemlistheaderwidget.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/kitemviews/private/kitemlistheaderwidget.cpp b/src/kitemviews/private/kitemlistheaderwidget.cpp
index b55ba1eb5..1f210ab5a 100644
--- a/src/kitemviews/private/kitemlistheaderwidget.cpp
+++ b/src/kitemviews/private/kitemlistheaderwidget.cpp
@@ -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);