From 3f88f79f862a570b68fe64781955cf7d14124127 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 23 Mar 2012 22:26:17 +0100 Subject: Details view: Optionally remember user changed column-widths If the user changed a column-width in the details-view, up to now the width got reset when changing a directory or when restarting Dolphin. Now the column-widths automatically get remembered for each directory in case if the user has modified the width. The automatic resizing is still turn on per default. The storing of the custom column-width can easily be reset by right clicking on the header and selecting "Automatic Column Widths" from the context-menu. Some finetuning is still necessary (e.g. the "Adjust View Properties" dialog currently is not aware about this setting) but this will be fixed during the next weeks. BUG: 264434 FIXED-IN: 4.9.0 --- src/kitemviews/kitemlistwidget.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/kitemviews/kitemlistwidget.cpp') diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp index 951fb396c..b91e87167 100644 --- a/src/kitemviews/kitemlistwidget.cpp +++ b/src/kitemviews/kitemlistwidget.cpp @@ -44,7 +44,7 @@ KItemListWidget::KItemListWidget(QGraphicsItem* parent) : m_enabledSelectionToggle(false), m_data(), m_visibleRoles(), - m_visibleRolesSizes(), + m_columnWidths(), m_styleOption(), m_siblingsInfo(), m_hoverOpacity(0), @@ -177,18 +177,20 @@ QList KItemListWidget::visibleRoles() const return m_visibleRoles; } -void KItemListWidget::setVisibleRolesSizes(const QHash rolesSizes) -{ - const QHash previousRolesSizes = m_visibleRolesSizes; - m_visibleRolesSizes = rolesSizes; - visibleRolesSizesChanged(rolesSizes, previousRolesSizes); - update(); +void KItemListWidget::setColumnWidth(const QByteArray& role, qreal width) +{ + if (m_columnWidths.value(role) != width) { + const qreal previousWidth = width; + m_columnWidths.insert(role, width); + columnWidthChanged(role, width, previousWidth); + update(); + } } -QHash KItemListWidget::visibleRolesSizes() const +qreal KItemListWidget::columnWidth(const QByteArray& role) const { - return m_visibleRolesSizes; + return m_columnWidths.value(role); } void KItemListWidget::setStyleOption(const KItemListStyleOption& option) @@ -352,9 +354,11 @@ void KItemListWidget::visibleRolesChanged(const QList& current, Q_UNUSED(previous); } -void KItemListWidget::visibleRolesSizesChanged(const QHash& current, - const QHash& previous) +void KItemListWidget::columnWidthChanged(const QByteArray& role, + qreal current, + qreal previous) { + Q_UNUSED(role); Q_UNUSED(current); Q_UNUSED(previous); } -- cgit v1.3