+ KCategorizedSortFilterProxyModel* proxyModel = dynamic_cast<KCategorizedSortFilterProxyModel*>(model());
+ if (leftToRightFlow && !proxyModel->isCategorizedModel()) {
+ // TODO: QListView::visualRect() calculates a wrong position of the items under
+ // certain circumstances (e. g. if the text is too long). This issue is bypassed
+ // by the following code (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();
+ const int gridWidth = gridSize().width();
+ const int gridIndex = (itemRect.left() - margin + 1) / gridWidth;
+ const int centerInc = (maxWidth - itemRect.width()) / 2;
+ itemRect.moveLeft((gridIndex * gridWidth) + margin + centerInc);
+ }
+