┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kfileitemlistview.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-09-23 23:37:42 +0200
committerPeter Penz <[email protected]>2011-09-23 23:38:51 +0200
commit9ea4d3c70c3765c1ef417642a392465caa31997c (patch)
tree501200dfc615f61858fc96e7066b040db28123c1 /src/kitemviews/kfileitemlistview.cpp
parent56852cff392f33ee731129fd9a755544d817e590 (diff)
Increase the width of the first column automatically
Additionally it is assured that on role-changes the size-hints get updated if necessary.
Diffstat (limited to 'src/kitemviews/kfileitemlistview.cpp')
-rw-r--r--src/kitemviews/kfileitemlistview.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/kitemviews/kfileitemlistview.cpp b/src/kitemviews/kfileitemlistview.cpp
index 6ff83b793..48e7306fc 100644
--- a/src/kitemviews/kfileitemlistview.cpp
+++ b/src/kitemviews/kfileitemlistview.cpp
@@ -194,6 +194,24 @@ QHash<QByteArray, QSizeF> KFileItemListView::visibleRoleSizes() const
}
}
+ // Stretch the width of the first role so that the full visible view-width
+ // is used to show all roles.
+ const qreal availableWidth = size().width();
+
+ qreal usedWidth = 0;
+ QHashIterator<QByteArray, QSizeF> it(sizes);
+ while (it.hasNext()) {
+ it.next();
+ usedWidth += it.value().width();
+ }
+
+ if (usedWidth < availableWidth) {
+ const QByteArray role = visibleRoles().first();
+ QSizeF firstRoleSize = sizes.value(role);
+ firstRoleSize.rwidth() += availableWidth - usedWidth;
+ sizes.insert(role, firstRoleSize);
+ }
+
#ifdef KFILEITEMLISTVIEW_DEBUG
kDebug() << "[TIME] Calculated dynamic item size for " << itemCount << "items:" << timer.elapsed();
#endif
@@ -232,6 +250,21 @@ void KFileItemListView::initializeItemListWidget(KItemListWidget* item)
}
}
+bool KFileItemListView::itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const
+{
+ // Even if the icons have a different size they are always aligned within
+ // the area defined by KItemStyleOption.iconSize and hence result in no
+ // change of the item-size.
+ const bool containsIconName = changedRoles.contains("iconName");
+ const bool containsIconPixmap = changedRoles.contains("iconPixmap");
+ const int count = changedRoles.count();
+
+ const bool iconChanged = (containsIconName && containsIconPixmap && count == 2) ||
+ (containsIconName && count == 1) ||
+ (containsIconPixmap && count == 1);
+ return !iconChanged;
+}
+
void KFileItemListView::onModelChanged(KItemModelBase* current, KItemModelBase* previous)
{
Q_UNUSED(previous);
@@ -320,6 +353,7 @@ void KFileItemListView::resizeEvent(QGraphicsSceneResizeEvent* event)
{
KItemListView::resizeEvent(event);
triggerVisibleIndexRangeUpdate();
+ markVisibleRolesSizesAsDirty();
}
void KFileItemListView::slotItemsRemoved(const KItemRangeList& itemRanges)