diff options
| author | Peter Penz <[email protected]> | 2012-04-14 00:22:08 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-04-14 00:28:24 +0200 |
| commit | 60b868108151463a702e8c10933b0ceb99f11bbe (patch) | |
| tree | 97b5a6aeca8df6b121674d38b11ea69b11b7878a /src/kitemviews/kitemlistview.cpp | |
| parent | 31ee4085c2b2c374158fb956ac376399ff375b5a (diff) | |
Allow to optionally limit the maximum number of text lines
Showing the whole filename unclipped seems to be a good default,
however for users with a lot of files that have extremely long names
this might get a problem especially in the icons-view.
- Allow to limit the maximum number of lines in the icons-view
- Allow to specify a maximum width in the compact-view
(No limit is required for the details-view, as the name is shortened
automatically to show other columns)
BUG: 288596
FIXED-IN: 4.9.0
Diffstat (limited to 'src/kitemviews/kitemlistview.cpp')
| -rw-r--r-- | src/kitemviews/kitemlistview.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index 732ed24e4..c62523410 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -148,10 +148,10 @@ Qt::Orientation KItemListView::scrollOrientation() const return m_layouter->scrollOrientation(); } -void KItemListView::setItemSize(const QSizeF& itemSize) +void KItemListView::setItemSize(const QSizeF& size) { const QSizeF previousSize = m_itemSize; - if (itemSize == previousSize) { + if (size == previousSize) { return; } @@ -159,14 +159,14 @@ void KItemListView::setItemSize(const QSizeF& itemSize) // are changed in the grid layout. Although the animation // engine can handle this usecase, it looks obtrusive. const bool animate = !changesItemGridLayout(m_layouter->size(), - itemSize, + size, m_layouter->itemMargin()); const bool alternateBackgroundsChanged = (m_visibleRoles.count() > 1) && - (( m_itemSize.isEmpty() && !itemSize.isEmpty()) || - (!m_itemSize.isEmpty() && itemSize.isEmpty())); + (( m_itemSize.isEmpty() && !size.isEmpty()) || + (!m_itemSize.isEmpty() && size.isEmpty())); - m_itemSize = itemSize; + m_itemSize = size; if (alternateBackgroundsChanged) { // For an empty item size alternate backgrounds are drawn if more than @@ -175,23 +175,23 @@ void KItemListView::setItemSize(const QSizeF& itemSize) updateAlternateBackgrounds(); } - if (itemSize.isEmpty()) { + if (size.isEmpty()) { if (m_headerWidget->automaticColumnResizing()) { updatePreferredColumnWidths(); } else { // Only apply the changed height and respect the header widths // set by the user const qreal currentWidth = m_layouter->itemSize().width(); - const QSizeF newSize(currentWidth, itemSize.height()); + const QSizeF newSize(currentWidth, size.height()); m_layouter->setItemSize(newSize); } } else { - m_layouter->setItemSize(itemSize); + m_layouter->setItemSize(size); } m_sizeHintResolver->clearCache(); doLayout(animate ? Animation : NoAnimation); - onItemSizeChanged(itemSize, previousSize); + onItemSizeChanged(size, previousSize); } QSizeF KItemListView::itemSize() const @@ -392,6 +392,12 @@ void KItemListView::setStyleOption(const KItemListStyleOption& option) updateGroupHeaderHeight(); } + if (animate && previousOption.maxTextSize != option.maxTextSize) { + // Animating a change of the maximum text size just results in expensive + // temporary eliding and clipping operations and does not look good visually. + animate = false; + } + QHashIterator<int, KItemListWidget*> it(m_visibleItems); while (it.hasNext()) { it.next(); @@ -399,6 +405,7 @@ void KItemListView::setStyleOption(const KItemListStyleOption& option) } m_sizeHintResolver->clearCache(); + m_layouter->markAsDirty(); doLayout(animate ? Animation : NoAnimation); onStyleOptionChanged(option, previousOption); |
