]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.cpp
Merge remote-tracking branch 'origin/KDE/4.10'
[dolphin.git] / src / kitemviews / kitemlistview.cpp
index 6a68ae79899e18c1f3127f992ab8b9276221b3ff..b5e105843375c7c3fb54829408d986a10de31e10 100644 (file)
@@ -208,6 +208,11 @@ qreal KItemListView::maximumItemOffset() const
     return m_layouter->maximumItemOffset();
 }
 
+int KItemListView::maximumVisibleItems() const
+{
+    return m_layouter->maximumVisibleItems();
+}
+
 void KItemListView::setVisibleRoles(const QList<QByteArray>& roles)
 {
     const QList<QByteArray> previousRoles = m_visibleRoles;
@@ -388,6 +393,15 @@ void KItemListView::setGeometry(const QRectF& rect)
     }
 }
 
+qreal KItemListView::verticalPageStep() const
+{
+    qreal headerHeight = 0;
+    if (m_headerWidget->isVisible()) {
+        headerHeight = m_headerWidget->size().height();
+    }
+    return size().height() - headerHeight;
+}
+
 int KItemListView::itemAt(const QPointF& pos) const
 {
     QHashIterator<int, KItemListWidget*> it(m_visibleItems);
@@ -664,6 +678,16 @@ void KItemListView::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt
     }
 }
 
+QVariant KItemListView::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+    if (change == QGraphicsItem::ItemSceneHasChanged && scene()) {
+        if (!scene()->views().isEmpty()) {
+            m_styleOption.palette = scene()->views().at(0)->palette();
+        }
+    }
+    return QGraphicsItem::itemChange(change, value);
+}
+
 void KItemListView::setItemSize(const QSizeF& size)
 {
     const QSizeF previousSize = m_itemSize;
@@ -1133,7 +1157,10 @@ void KItemListView::slotItemsRemoved(const KItemRangeList& itemRanges)
         // Important: Don't read any m_layouter-property inside the for-loop in case if
         // multiple ranges are given! m_layouter accesses m_sizeHintResolver which is
         // updated in each loop-cycle and has only a consistent state after the loop.
-        Q_ASSERT(m_layouter->isDirty());
+        // TODO: This assert can be hit when filtering in Icons and Compact view,
+        // see https://bugs.kde.org/show_bug.cgi?id=317827 comments 2 and 3.
+        // We should try to figure out if the assert is wrong or if there is a bug in the code.
+        //Q_ASSERT(m_layouter->isDirty());
 #endif
         m_endTransactionAnimationHint = NoAnimation;
         endTransaction();
@@ -2348,7 +2375,8 @@ int KItemListView::showDropIndicator(const QPointF& pos)
         const QRectF rect = itemRect(widget->index());
         if (mappedPos.y() >= 0 && mappedPos.y() <= rect.height()) {
             if (m_model->supportsDropping(widget->index())) {
-                const int gap = qMax(4, m_styleOption.padding);
+                // Keep 30% of the rectangle as the gap instead of always having a fixed gap
+                const int gap = qMax(4.0, 0.3 * rect.height());
                 if (mappedPos.y() >= gap && mappedPos.y() <= rect.height() - gap) {
                     return -1;
                 }