]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.cpp
Making code confirm to policy
[dolphin.git] / src / kitemviews / kitemlistview.cpp
index 5f4c5460687f3efd9f423d236701f68e7df1eace..580cf5bbe007b2553bfc90acfc4d91ad0d61f2d5 100644 (file)
@@ -43,6 +43,8 @@
 #include <QStyleOptionRubberBand>
 #include <QTimer>
 
+#include "kitemlistviewaccessible.h"
+
 namespace {
     // Time in ms until reaching the autoscroll margin triggers
     // an initial autoscrolling
@@ -52,6 +54,20 @@ namespace {
     const int RepeatingAutoScrollDelay = 1000 / 60;
 }
 
+#ifndef QT_NO_ACCESSIBILITY
+QAccessibleInterface* accessibleInterfaceFactory(const QString &key, QObject *object)
+{
+    Q_UNUSED(key)
+    if (KItemListContainer*view = qobject_cast<KItemListContainer*>(object)) {
+        return new KItemListContainerAccessible(view);
+    }
+    if (KItemListView *view = qobject_cast<KItemListView*>(object)) {
+        return new KItemListViewAccessible(view);
+    }
+    return 0;
+}
+#endif
+
 KItemListView::KItemListView(QGraphicsWidget* parent) :
     QGraphicsWidget(parent),
     m_enabledSelectionToggles(false),
@@ -110,6 +126,11 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
     m_headerWidget->setVisible(false);
 
     m_header = new KItemListHeader(this);
+
+#ifndef QT_NO_ACCESSIBILITY
+    QAccessible::installFactory(accessibleInterfaceFactory);
+#endif
+
 }
 
 KItemListView::~KItemListView()
@@ -641,6 +662,11 @@ void KItemListView::paint(QPainter* painter, const QStyleOptionGraphicsItem* opt
     }
 }
 
+KItemListViewLayouter* KItemListView::layouter() const
+{
+    return m_layouter;
+}
+
 void KItemListView::setItemSize(const QSizeF& size)
 {
     const QSizeF previousSize = m_itemSize;
@@ -1251,6 +1277,7 @@ void KItemListView::slotCurrentChanged(int current, int previous)
     if (currentWidget) {
         currentWidget->setCurrent(true);
     }
+    QAccessible::updateAccessibility(this, current+1, QAccessible::Focus);
 }
 
 void KItemListView::slotSelectionChanged(const QSet<int>& current, const QSet<int>& previous)
@@ -1753,7 +1780,7 @@ bool KItemListView::moveWidget(KItemListWidget* widget,const QPointF& newPos)
 
     if (m_itemSize.isEmpty()) {
         // The items are not aligned in a grid but either as columns or rows.
-        startMovingAnim = !supportsItemExpanding();
+        startMovingAnim = true;
     } else {
         // When having a grid the moving-animation should only be started, if it is done within
         // one row in the vertical scroll-orientation or one column in the horizontal scroll-orientation.
@@ -2318,6 +2345,13 @@ int KItemListView::showDropIndicator(const QPointF& pos)
         const QPointF mappedPos = widget->mapFromItem(this, 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);
+                if (mappedPos.y() >= gap && mappedPos.y() <= rect.height() - gap) {
+                    return -1;
+                }
+            }
+
             const bool isAboveItem = (mappedPos.y () < rect.height() / 2);
             const qreal y = isAboveItem ? rect.top() : rect.bottom();