diff options
| author | Frank Reininghaus <[email protected]> | 2014-02-24 21:05:09 +0100 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2014-02-24 21:05:09 +0100 |
| commit | 342822e83de4508a7e32bf9c23ee074c2d584d48 (patch) | |
| tree | 888ec0bf9a09db0d8adb2e23c8e5caf958ff04dc /src/views/dolphinitemlistview.cpp | |
| parent | 0d37038b407944a9b7ec05127b5b6d41dc1a496f (diff) | |
Make the handling of the "maximum text lines" setting more robust
If the user sets a maximum number of text lines in the settings, this
number was translated into a maximum height in pixels using
QFontMetrics::lineSpacing() before this commit.
In KStandardItemListWidgetInformant::itemSizeHint(), this maximum height
limited the size that is reserved for the item.
However, in KStandardItemListWidget::updateIconsLayoutTextCache(), the
maximum height was translated back into a maximum number of lines,
which limits the number of lines that are created using the QTextLayout.
This approach could lead to problems if the real height of the layouted
text is 1 pixel more or less than QFontMetrics::lineSpacing() times
"number of lines".
Now we do not store a "maximum height" inside the "maximum size"
explicitly, but store a maximum number of lines and a maximum with (for
Compact View) separately, and then use the number of lines also to
calculate the required size in
KStandardItemListWidgetInformant::itemSizeHint(). This should make sure
that the correct height is reserved for each item.
Thanks to Christoph Feck and Emmanuel Pescosta for helping to debug this
problem and testing the patch.
BUG: 323841
FIXED-IN: 4.13
REVIEW: 113871
Diffstat (limited to 'src/views/dolphinitemlistview.cpp')
| -rw-r--r-- | src/views/dolphinitemlistview.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/views/dolphinitemlistview.cpp b/src/views/dolphinitemlistview.cpp index eb61ccb21..db4dadf2f 100644 --- a/src/views/dolphinitemlistview.cpp +++ b/src/views/dolphinitemlistview.cpp @@ -180,7 +180,8 @@ void DolphinItemListView::updateGridSize() // Calculate the item-width and item-height int itemWidth; int itemHeight; - QSize maxTextSize; + int maxTextLines = 0; + int maxTextWidth = 0; switch (itemLayout()) { case KFileItemListView::IconsLayout: { @@ -200,16 +201,10 @@ void DolphinItemListView::updateGridSize() } itemHeight = padding * 3 + iconSize + option.fontMetrics.lineSpacing(); - if (IconsModeSettings::maximumTextLines() > 0) { - // A restriction is given for the maximum number of textlines (0 means - // having no restriction) - const int additionalInfoCount = visibleRoles().count() - 1; - const int maxAdditionalLines = additionalInfoCount + IconsModeSettings::maximumTextLines(); - maxTextSize.rheight() = option.fontMetrics.lineSpacing() * maxAdditionalLines; - } horizontalMargin = 4; verticalMargin = 8; + maxTextLines = IconsModeSettings::maximumTextLines(); break; } case KFileItemListView::CompactLayout: { @@ -220,8 +215,7 @@ void DolphinItemListView::updateGridSize() if (CompactModeSettings::maximumTextWidthIndex() > 0) { // A restriction is given for the maximum width of the text (0 means // having no restriction) - maxTextSize.rwidth() = option.fontMetrics.height() * 10 * - CompactModeSettings::maximumTextWidthIndex(); + maxTextWidth = option.fontMetrics.height() * 10 * CompactModeSettings::maximumTextWidthIndex(); } horizontalMargin = 8; @@ -244,7 +238,8 @@ void DolphinItemListView::updateGridSize() option.horizontalMargin = horizontalMargin; option.verticalMargin = verticalMargin; option.iconSize = iconSize; - option.maxTextSize = maxTextSize; + option.maxTextLines = maxTextLines; + option.maxTextWidth = maxTextWidth; beginTransaction(); setStyleOption(option); setItemSize(QSizeF(itemWidth, itemHeight)); |
