+ KCategorizedSortFilterProxyModel* proxyModel = dynamic_cast<KCategorizedSortFilterProxyModel*>(model());
+ if (leftToRightFlow && !proxyModel->isCategorizedModel()) {
+ // TODO: This workaround bypasses a layout issue in QListView::visualRect(), where
+ // the horizontal position of items might get calculated in a wrong manner when the item
+ // name is too long. I'll try create a patch for Qt but as Dolphin must also work with
+ // Qt 4.3.0 this workaround must get applied at least for KDE 4.0.
+ const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+ const int margin = settings->gridSpacing() / 2;
+ const int gridWidth = gridSize().width();
+ int left = itemRect.left();
+ left = ((left - margin + 1) / gridWidth) * gridWidth + margin;
+ itemRect.moveLeft(left);
+ }
+