]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphiniconsview.cpp
use "Sort by" instead of "Sort By"
[dolphin.git] / src / dolphiniconsview.cpp
index 237a319c835e181609db9fb341aa27cf4324879f..37f0bf1727cb27a95db7b370e29784281ad94cf4 100644 (file)
@@ -35,7 +35,9 @@
 DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
     KCategorizedView(parent),
     m_controller(controller),
-    m_dragging(false)
+    m_itemSize(),
+    m_dragging(false),
+    m_dropRect()
 {
     Q_ASSERT(controller != 0);
     setViewMode(QListView::IconMode);
@@ -93,6 +95,35 @@ DolphinIconsView::~DolphinIconsView()
 {
 }
 
+QRect DolphinIconsView::visualRect(const QModelIndex& index) const
+{
+    const bool leftToRightFlow = (flow() == QListView::LeftToRight);
+
+    QRect itemRect = KCategorizedView::visualRect(index);
+    const int maxWidth  = m_itemSize.width();
+    const int maxHeight = m_itemSize.height();
+
+    if (itemRect.width() > maxWidth) {
+        // assure that the maximum item width is not exceeded
+        if (leftToRightFlow) {
+            const int left = itemRect.left() + (itemRect.width() - maxWidth) / 2;
+            itemRect.setLeft(left);
+        }
+        itemRect.setWidth(maxWidth);
+    }
+
+    if (itemRect.height() > maxHeight) {
+        // assure that the maximum item height is not exceeded
+        if (!leftToRightFlow) {
+            const int top = itemRect.top() + (itemRect.height() - maxHeight) / 2;
+            itemRect.setTop(top);
+        }
+        itemRect.setHeight(maxHeight);
+    }
+
+    return itemRect;
+}
+
 QStyleOptionViewItem DolphinIconsView::viewOptions() const
 {
     return m_viewOptions;
@@ -321,6 +352,8 @@ void DolphinIconsView::updateGridSize(bool showPreview, bool showAdditionalInfo)
     const int spacing = settings->gridSpacing();
     setGridSize(QSize(itemWidth + spacing, itemHeight + spacing));
 
+    m_itemSize = QSize(itemWidth, itemHeight);
+
     m_controller->setZoomInPossible(isZoomInPossible());
     m_controller->setZoomOutPossible(isZoomOutPossible());
 }