]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/private/kitemlistviewlayouter.cpp
Merge remote-tracking branch 'origin/release/21.08'
[dolphin.git] / src / kitemviews / private / kitemlistviewlayouter.cpp
index 9da5384d4f6e849d145db850ef94ba46c53d98ab..6de83ca87eddf91897539f3e117b5617468b533f 100644 (file)
@@ -1,28 +1,13 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "kitemlistviewlayouter.h"
-
-#include <kitemviews/kitemmodelbase.h>
+#include "dolphindebug.h"
 #include "kitemlistsizehintresolver.h"
-
-#include <KDebug>
+#include "kitemviews/kitemmodelbase.h"
 
 // #define KITEMLISTVIEWLAYOUTER_DEBUG
 
@@ -35,7 +20,7 @@ KItemListViewLayouter::KItemListViewLayouter(KItemListSizeHintResolver* sizeHint
     m_itemSize(128, 128),
     m_itemMargin(),
     m_headerHeight(0),
-    m_model(0),
+    m_model(nullptr),
     m_sizeHintResolver(sizeHintResolver),
     m_scrollOffset(0),
     m_maximumScrollOffset(0),
@@ -239,6 +224,7 @@ QRectF KItemListViewLayouter::itemRect(int index) const
         // to get the physical horizontal direction
         QPointF pos(y, x);
         pos.rx() -= m_scrollOffset;
+        sizeHint.transpose();
         return QRectF(pos, sizeHint);
     }
 
@@ -282,7 +268,9 @@ QRectF KItemListViewLayouter::groupHeaderRect(int index) const
                 break;
             }
 
-            const qreal itemWidth = m_sizeHintResolver->sizeHint(index).width();
+            const qreal itemWidth = (m_scrollOrientation == Qt::Vertical)
+                                     ? m_sizeHintResolver->sizeHint(index).width()
+                                     : m_sizeHintResolver->sizeHint(index).height();
 
             if (itemWidth > headerWidth) {
                 headerWidth = itemWidth;
@@ -461,7 +449,7 @@ void KItemListViewLayouter::doLayout()
             while (index < itemCount && column < m_columnCount) {
                 qreal requiredItemHeight = itemSize.height();
                 const QSizeF sizeHint = m_sizeHintResolver->sizeHint(index);
-                const qreal sizeHintHeight = horizontalScrolling ? sizeHint.width() : sizeHint.height();
+                const qreal sizeHintHeight = sizeHint.height();
                 if (sizeHintHeight > requiredItemHeight) {
                     requiredItemHeight = sizeHintHeight;
                 }
@@ -513,7 +501,7 @@ void KItemListViewLayouter::doLayout()
         }
 
 #ifdef KITEMLISTVIEWLAYOUTER_DEBUG
-        kDebug() << "[TIME] doLayout() for " << m_model->count() << "items:" << timer.elapsed();
+        qCDebug(DolphinDebug) << "[TIME] doLayout() for " << m_model->count() << "items:" << timer.elapsed();
 #endif
         m_dirty = false;
     }
@@ -618,4 +606,3 @@ qreal KItemListViewLayouter::minimumGroupHeaderWidth() const
     return 100;
 }
 
-#include "kitemlistviewlayouter.moc"