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/views/dolphinitemlistcontainer.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/views/dolphinitemlistcontainer.cpp')
| -rw-r--r-- | src/views/dolphinitemlistcontainer.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/views/dolphinitemlistcontainer.cpp b/src/views/dolphinitemlistcontainer.cpp index e8c373492..88e10d8a3 100644 --- a/src/views/dolphinitemlistcontainer.cpp +++ b/src/views/dolphinitemlistcontainer.cpp @@ -222,6 +222,8 @@ void DolphinItemListContainer::updateGridSize() // Calculate the item-width and item-height int itemWidth; int itemHeight; + QSize maxTextSize; + switch (itemLayout()) { case KFileItemListView::IconsLayout: { const int minItemWidth = 48; @@ -238,7 +240,15 @@ void DolphinItemListContainer::updateGridSize() if (itemWidth < iconSize + padding * 2) { itemWidth = iconSize + padding * 2; } - itemHeight = padding * 3 + iconSize + styleOption.fontMetrics.height(); + + itemHeight = padding * 3 + iconSize + styleOption.fontMetrics.lineSpacing(); + if (IconsModeSettings::maximumTextLines() > 0) { + // A restriction is given for the maximum number of textlines (0 means + // having no restriction) + const int additionalInfoCount = m_fileItemListView->visibleRoles().count() - 1; + const int maxAdditionalLines = additionalInfoCount + IconsModeSettings::maximumTextLines(); + maxTextSize.rheight() = styleOption.fontMetrics.lineSpacing() * maxAdditionalLines; + } horizontalMargin = 4; verticalMargin = 8; @@ -247,14 +257,21 @@ void DolphinItemListContainer::updateGridSize() case KFileItemListView::CompactLayout: { itemWidth = padding * 4 + iconSize + styleOption.fontMetrics.height() * 5; const int textLinesCount = m_fileItemListView->visibleRoles().count(); - itemHeight = padding * 2 + qMax(iconSize, textLinesCount * styleOption.fontMetrics.height()); + itemHeight = padding * 2 + qMax(iconSize, textLinesCount * styleOption.fontMetrics.lineSpacing()); + + if (CompactModeSettings::maximumTextWidthIndex() > 0) { + // A restriction is given for the maximum width of the text (0 means + // having no restriction) + maxTextSize.rwidth() = styleOption.fontMetrics.height() * 10 * + CompactModeSettings::maximumTextWidthIndex(); + } horizontalMargin = 8; break; } case KFileItemListView::DetailsLayout: { itemWidth = -1; - itemHeight = padding * 2 + qMax(iconSize, styleOption.fontMetrics.height()); + itemHeight = padding * 2 + qMax(iconSize, styleOption.fontMetrics.lineSpacing()); break; } default: @@ -269,6 +286,7 @@ void DolphinItemListContainer::updateGridSize() styleOption.horizontalMargin = horizontalMargin; styleOption.verticalMargin = verticalMargin; styleOption.iconSize = iconSize; + styleOption.maxTextSize = maxTextSize; m_fileItemListView->beginTransaction(); m_fileItemListView->setStyleOption(styleOption); m_fileItemListView->setItemSize(QSizeF(itemWidth, itemHeight)); |
