┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kfileitemlistview.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-02-04 22:14:53 +0100
committerPeter Penz <[email protected]>2012-02-04 22:22:19 +0100
commit72af3125a824722d9875d202dd156cd3f7d8fc46 (patch)
treecac6d24b77d463f264d6b82478fde44b89a38081 /src/kitemviews/kfileitemlistview.cpp
parenta2a78c98fc9737fcd7a126790f88b40fdcc38ae6 (diff)
Icons view: Layout optimizations
- Assure that landscape-previews use the whole available width of the icon-area instead of only using the square width. This waste of space occured if the text-width was larger than the icon-width. - Only use one margin instead of two between the icons and the text to improve the visual appearance (thanks to Martin Zilz for the hint) BUG: 293268 FIXED-IN: 4.8.1 CCMAIL: [email protected]
Diffstat (limited to 'src/kitemviews/kfileitemlistview.cpp')
-rw-r--r--src/kitemviews/kfileitemlistview.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/kitemviews/kfileitemlistview.cpp b/src/kitemviews/kfileitemlistview.cpp
index 4762e8089..650ed454f 100644
--- a/src/kitemviews/kfileitemlistview.cpp
+++ b/src/kitemviews/kfileitemlistview.cpp
@@ -152,7 +152,7 @@ QSizeF KFileItemListView::itemSizeHint(int index) const
const qreal height = textLinesCount * option.fontMetrics.height() +
option.iconSize +
- option.margin * 4;
+ option.margin * 3;
return QSizeF(itemSize().width(), height);
}
@@ -347,8 +347,7 @@ void KFileItemListView::onModelChanged(KItemModelBase* current, KItemModelBase*
delete m_modelRolesUpdater;
m_modelRolesUpdater = new KFileItemModelRolesUpdater(static_cast<KFileItemModel*>(current), this);
- const int size = styleOption().iconSize;
- m_modelRolesUpdater->setIconSize(QSize(size, size));
+ m_modelRolesUpdater->setIconSize(availableIconSize());
applyRolesToModel();
}
@@ -462,8 +461,7 @@ void KFileItemListView::updateVisibleIndexRange()
// of the icon-size before unpausing m_modelRolesUpdater. This prevents
// an unnecessary expensive recreation of all previews afterwards.
m_updateIconSizeTimer->stop();
- const KItemListStyleOption& option = styleOption();
- m_modelRolesUpdater->setIconSize(QSize(option.iconSize, option.iconSize));
+ m_modelRolesUpdater->setIconSize(availableIconSize());
}
m_modelRolesUpdater->setPaused(isTransactionActive());
@@ -485,8 +483,7 @@ void KFileItemListView::updateIconSize()
return;
}
- const KItemListStyleOption& option = styleOption();
- m_modelRolesUpdater->setIconSize(QSize(option.iconSize, option.iconSize));
+ m_modelRolesUpdater->setIconSize(availableIconSize());
if (m_updateVisibleIndexRangeTimer->isActive()) {
// If the visibility-index-range update is pending do an immediate update
@@ -595,4 +592,16 @@ void KFileItemListView::applyRolesToModel()
m_modelRolesUpdater->setRoles(roles);
}
+QSize KFileItemListView::availableIconSize() const
+{
+ const KItemListStyleOption& option = styleOption();
+ const int iconSize = option.iconSize;
+ if (m_itemLayout == IconsLayout) {
+ const int maxIconWidth = itemSize().width() - 2 * option.margin;
+ return QSize(maxIconWidth, iconSize);
+ }
+
+ return QSize(iconSize, iconSize);
+}
+
#include "kfileitemlistview.moc"