X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/894232ebda5b2cf155a4f4e5bf1287eb700faa18..509464cce954f7fc4b00a9dafc2bc6355eb99ec6:/src/kitemviews/kitemlistview.cpp diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index 1586c9d96..f2ae37556 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -23,6 +23,7 @@ #include "kitemlistview.h" #include +#include "kitemlistcontainer.h" #include "kitemlistcontroller.h" #include "kitemlistheader.h" #include "kitemlistselectionmanager.h" @@ -43,6 +44,8 @@ #include #include +#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(object)) { + return new KItemListContainerAccessible(container); + } else if (KItemListView* view = qobject_cast(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() @@ -1189,6 +1212,7 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges, doLayout(NoAnimation); } } + QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged); } void KItemListView::slotGroupedSortingChanged(bool current) @@ -1251,6 +1275,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& current, const QSet& previous) @@ -1616,6 +1641,11 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha } if (animate) { + if (m_animation->isStarted(widget, KItemListViewAnimation::MovingAnimation)) { + m_animation->start(widget, KItemListViewAnimation::MovingAnimation, newPos); + applyNewPos = false; + } + const bool itemsRemoved = (changedCount < 0); const bool itemsInserted = (changedCount > 0); if (itemsRemoved && (i >= changedIndex + changedCount + 1)) { @@ -1748,7 +1778,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. @@ -2313,19 +2343,32 @@ 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()) { - const qreal y = (mappedPos.y () < rect.height() / 2) ? - rect.top() : rect.bottom(); + 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(); const QRectF draggingInsertIndicator(rect.left(), y, rect.width(), 1); if (m_dropIndicator != draggingInsertIndicator) { m_dropIndicator = draggingInsertIndicator; update(); } - return widget->index(); + + int index = widget->index(); + if (!isAboveItem) { + ++index; + } + return index; } } - return -1; + const QRectF firstItemRect = itemRect(firstVisibleIndex()); + return (pos.y() <= firstItemRect.top()) ? 0 : -1; } void KItemListView::hideDropIndicator()