]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.cpp
Do not skip rows in when clicking the empty area of the scroll bar
[dolphin.git] / src / kitemviews / kitemlistview.cpp
index ef6dfc833ab7edfbe14391d385a90474b72b0ed8..9ebad7f8bda0a99a43256c6c529bed4027d689e8 100644 (file)
@@ -23,6 +23,7 @@
 #include "kitemlistview.h"
 
 #include <KDebug>
+#include "kitemlistcontainer.h"
 #include "kitemlistcontroller.h"
 #include "kitemlistheader.h"
 #include "kitemlistselectionmanager.h"
@@ -43,6 +44,8 @@
 #include <QStyleOptionRubberBand>
 #include <QTimer>
 
+#include "kitemlistviewaccessible.h"
+
 namespace {
     // Time in ms until reaching the autoscroll margin triggers
     // an initial autoscrolling
@@ -52,6 +55,21 @@ namespace {
     const int RepeatingAutoScrollDelay = 1000 / 60;
 }
 
+#ifndef QT_NO_ACCESSIBILITY
+QAccessibleInterface* accessibleInterfaceFactory(const QString &key, QObject *object)
+{
+    Q_UNUSED(key)
+
+    if (KItemListContainer* container = qobject_cast<KItemListContainer*>(object)) {
+        return new KItemListContainerAccessible(container);
+    } else 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 +128,11 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
     m_headerWidget->setVisible(false);
 
     m_header = new KItemListHeader(this);
+
+#ifndef QT_NO_ACCESSIBILITY
+    QAccessible::installFactory(accessibleInterfaceFactory);
+#endif
+
 }
 
 KItemListView::~KItemListView()
@@ -365,6 +388,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);
@@ -1189,6 +1221,7 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
             doLayout(NoAnimation);
         }
     }
+    QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged);
 }
 
 void KItemListView::slotGroupedSortingChanged(bool current)
@@ -1251,6 +1284,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)
@@ -1413,9 +1447,9 @@ void KItemListView::triggerAutoScrolling()
     const qreal newScrollOffset = qMin(scrollOffset() + m_autoScrollIncrement, maxVisibleOffset);
     setScrollOffset(newScrollOffset);
 
-   // Trigger the autoscroll timer which will periodically call
-   // triggerAutoScrolling()
-   m_autoScrollTimer->start(RepeatingAutoScrollDelay);
+    // Trigger the autoscroll timer which will periodically call
+    // triggerAutoScrolling()
+    m_autoScrollTimer->start(RepeatingAutoScrollDelay);
 }
 
 void KItemListView::slotGeometryOfGroupHeaderParentChanged()