return new KItemListWidgetCreator<KFileItemListWidget>();
}
+void KFileItemListView::initializeItemListWidget(KItemListWidget* item)
+{
+ KStandardItemListView::initializeItemListWidget(item);
+
+ // Make sure that the item has an icon.
+ QHash<QByteArray, QVariant> data = item->data();
+ if (!data.contains("iconName") && data["iconPixmap"].value<QPixmap>().isNull()) {
+ Q_ASSERT(qobject_cast<KFileItemModel*>(model()));
+ KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(model());
+
+ const KFileItem fileItem = fileItemModel->fileItem(item->index());
+ data.insert("iconName", fileItem.iconName());
+ item->setData(data, QSet<QByteArray>() << "iconName");
+ }
+}
+
void KFileItemListView::onPreviewsShownChanged(bool shown)
{
Q_UNUSED(shown);
void KFileItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous)
{
- if (previous == DetailsLayout || current == DetailsLayout) {
- // The details-layout requires some invisible roles that
- // must be added to the model if the new layout is "details".
- // If the old layout was "details" the roles will get removed.
- applyRolesToModel();
- }
KStandardItemListView::onItemLayoutChanged(current, previous);
triggerVisibleIndexRangeUpdate();
}
const int index = firstVisibleIndex();
const int count = lastVisibleIndex() - index + 1;
+ m_modelRolesUpdater->setMaximumVisibleItems(maximumVisibleItems());
m_modelRolesUpdater->setVisibleIndexRange(index, count);
if (m_updateIconSizeTimer->isActive()) {