+void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount)
+{
+ const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+ Q_ASSERT(settings != 0);
+
+ int itemWidth = settings->itemWidth();
+ int itemHeight = settings->itemHeight();
+ int size = settings->iconSize();
+
+ if (showPreview) {
+ const int previewSize = settings->previewSize();
+ const int diff = previewSize - size;
+ Q_ASSERT(diff >= 0);
+ itemWidth += diff;
+ itemHeight += diff;
+
+ size = previewSize;
+ }
+
+ Q_ASSERT(additionalInfoCount >= 0);
+ itemHeight += additionalInfoCount * m_viewOptions.font.pointSize() * 2;
+
+ if (settings->arrangement() == QListView::TopToBottom) {
+ // The decoration width indirectly defines the maximum
+ // width for the text wrapping. To use the maximum item width
+ // for text wrapping, it is used as decoration width.
+ m_viewOptions.decorationSize = QSize(itemWidth, size);
+ } else {
+ m_viewOptions.decorationSize = QSize(size, size);
+ }
+
+ const int spacing = settings->gridSpacing();
+ setGridSize(QSize(itemWidth + spacing * 2, itemHeight + spacing));
+
+ m_itemSize = QSize(itemWidth, itemHeight);
+
+ m_controller->setZoomInPossible(isZoomInPossible());
+ m_controller->setZoomOutPossible(isZoomOutPossible());
+}
+
+KFileItem DolphinIconsView::itemForIndex(const QModelIndex& index) const
+{
+ QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(model());
+ KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
+ const QModelIndex dirIndex = proxyModel->mapToSource(index);
+ return dirModel->itemForIndex(dirIndex);
+}
+