X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/6770e617cb8154ba0c8acd4229c4c0f9b8d65da9..7f381a34cb37ff4aeb215a8fe91448e5ea27aca0:/src/kitemviews/kitemlistview.cpp diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index fe62e7a36..a2629c565 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" @@ -54,13 +55,20 @@ namespace { const int RepeatingAutoScrollDelay = 1000 / 60; } -QAccessibleInterface* accessibleViewFactory(const QString &key, QObject *object) +#ifndef QT_NO_ACCESSIBILITY +QAccessibleInterface* accessibleInterfaceFactory(const QString &key, QObject *object) { Q_UNUSED(key) - if (KItemListView *view = qobject_cast(object)) + + 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), @@ -120,9 +128,11 @@ KItemListView::KItemListView(QGraphicsWidget* parent) : m_headerWidget->setVisible(false); m_header = new KItemListHeader(this); + #ifndef QT_NO_ACCESSIBILITY - QAccessible::installFactory(accessibleViewFactory); + QAccessible::installFactory(accessibleInterfaceFactory); #endif + } KItemListView::~KItemListView() @@ -138,9 +148,6 @@ KItemListView::~KItemListView() delete m_sizeHintResolver; m_sizeHintResolver = 0; -#ifndef QT_NO_ACCESSIBILITY - QAccessible::removeFactory(accessibleViewFactory); -#endif } void KItemListView::setScrollOffset(qreal offset) @@ -201,6 +208,11 @@ qreal KItemListView::maximumItemOffset() const return m_layouter->maximumItemOffset(); } +int KItemListView::maximumVisibleItems() const +{ + return m_layouter->maximumVisibleItems(); +} + void KItemListView::setVisibleRoles(const QList& roles) { const QList previousRoles = m_visibleRoles; @@ -381,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 it(m_visibleItems); @@ -1126,7 +1147,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(); @@ -1205,6 +1229,7 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges, doLayout(NoAnimation); } } + QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged); } void KItemListView::slotGroupedSortingChanged(bool current) @@ -1267,6 +1292,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) @@ -1429,9 +1455,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() @@ -1445,12 +1471,16 @@ void KItemListView::slotGeometryOfGroupHeaderParentChanged() void KItemListView::slotRoleEditingCanceled(int index, const QByteArray& role, const QVariant& value) { + disconnectRoleEditingSignals(index); + emit roleEditingCanceled(index, role, value); m_editingRole = false; } void KItemListView::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value) { + disconnectRoleEditingSignals(index); + emit roleEditingFinished(index, role, value); m_editingRole = false; } @@ -2521,6 +2551,17 @@ bool KItemListView::hasSiblingSuccessor(int index) const return hasSuccessor; } +void KItemListView::disconnectRoleEditingSignals(int index) +{ + KItemListWidget* widget = m_visibleItems.value(index); + if (!widget) { + return; + } + + widget->disconnect(SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)), this); + widget->disconnect(SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), this); +} + int KItemListView::calculateAutoScrollingIncrement(int pos, int range, int oldInc) { int inc = 0;