X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/59d01e8accbfb7f31fb5ea5ef4c94e57d427994a..119f7a3f:/src/kitemviews/kitemlistview.cpp diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index 5ef1695e0..0d0304afc 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -22,7 +22,7 @@ #include "kitemlistview.h" -#include +#include #include "kitemlistcontainer.h" #include "kitemlistcontroller.h" #include "kitemlistheader.h" @@ -35,23 +35,17 @@ #include "private/kitemlistviewlayouter.h" #include "private/kitemlistviewanimation.h" -#include #include #include #include -#include #include #include #include +#include #include -#if 0 #include "kitemlistviewaccessible.h" -#else -#define QT_NO_ACCESSIBILITY 1 -#pragma message("TODO: port accessibility to Qt5") -#endif namespace { // Time in ms until reaching the autoscroll margin triggers @@ -63,7 +57,7 @@ namespace { } #ifndef QT_NO_ACCESSIBILITY -QAccessibleInterface* accessibleInterfaceFactory(const QString &key, QObject *object) +QAccessibleInterface* accessibleInterfaceFactory(const QString& key, QObject* object) { Q_UNUSED(key) @@ -464,9 +458,9 @@ int KItemListView::lastVisibleIndex() const return m_layouter->lastVisibleIndex(); } -void KItemListView::calculateItemSizeHints(QVector& sizeHints) const +void KItemListView::calculateItemSizeHints(QVector& logicalHeightHints, qreal& logicalWidthHint) const { - widgetCreator()->calculateItemSizeHints(sizeHints, this); + widgetCreator()->calculateItemSizeHints(logicalHeightHints, logicalWidthHint, this); } void KItemListView::setSupportsItemExpanding(bool supportsExpanding) @@ -549,7 +543,7 @@ void KItemListView::endTransaction() --m_activeTransactions; if (m_activeTransactions < 0) { m_activeTransactions = 0; - kWarning() << "Mismatch between beginTransaction()/endTransaction()"; + qWarning() << "Mismatch between beginTransaction()/endTransaction()"; } if (m_activeTransactions == 0) { @@ -941,7 +935,7 @@ void KItemListView::dragEnterEvent(QGraphicsSceneDragDropEvent* event) setAutoScroll(true); } -void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent *event) +void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent* event) { QGraphicsWidget::dragMoveEvent(event); @@ -951,7 +945,7 @@ void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent *event) } } -void KItemListView::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) +void KItemListView::dragLeaveEvent(QGraphicsSceneDragDropEvent* event) { QGraphicsWidget::dragLeaveEvent(event); setAutoScroll(false); @@ -1012,7 +1006,7 @@ void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges) const int index = range.index + previouslyInsertedCount; const int count = range.count; if (index < 0 || count <= 0) { - kWarning() << "Invalid item range (index:" << index << ", count:" << count << ")"; + qWarning() << "Invalid item range (index:" << index << ", count:" << count << ")"; continue; } previouslyInsertedCount += count; @@ -1120,7 +1114,7 @@ void KItemListView::slotItemsRemoved(const KItemRangeList& itemRanges) const int index = range.index; const int count = range.count; if (index < 0 || count <= 0) { - kWarning() << "Invalid item range (index:" << index << ", count:" << count << ")"; + qWarning() << "Invalid item range (index:" << index << ", count:" << count << ")"; continue; } @@ -1273,9 +1267,12 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges, updateVisibleGroupHeaders(); doLayout(NoAnimation); } + + QAccessibleTableModelChangeEvent ev(this, QAccessibleTableModelChangeEvent::DataChanged); + ev.setFirstRow(itemRange.index); + ev.setLastRow(itemRange.index + itemRange.count); + QAccessible::updateAccessibility(&ev); } -#pragma message("TODO: port accessibility otherwise the following line asserts") - //QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged); } void KItemListView::slotGroupsChanged() @@ -1338,17 +1335,23 @@ void KItemListView::slotCurrentChanged(int current, int previous) { Q_UNUSED(previous); - KItemListWidget* previousWidget = m_visibleItems.value(previous, 0); - if (previousWidget) { - previousWidget->setCurrent(false); - } + // In SingleSelection mode (e.g., in the Places Panel), the current item is + // always the selected item. It is not necessary to highlight the current item then. + if (m_controller->selectionBehavior() != KItemListController::SingleSelection) { + KItemListWidget* previousWidget = m_visibleItems.value(previous, 0); + if (previousWidget) { + previousWidget->setCurrent(false); + } - KItemListWidget* currentWidget = m_visibleItems.value(current, 0); - if (currentWidget) { - currentWidget->setCurrent(true); + KItemListWidget* currentWidget = m_visibleItems.value(current, 0); + if (currentWidget) { + currentWidget->setCurrent(true); + } } -#pragma message("TODO: port accessibility otherwise the following line asserts") - //QAccessible::updateAccessibility(this, current+1, QAccessible::Focus); + + QAccessibleEvent ev(this, QAccessible::Focus); + ev.setChild(current); + QAccessible::updateAccessibility(&ev); } void KItemListView::slotSelectionChanged(const KItemSet& current, const KItemSet& previous) @@ -1985,7 +1988,12 @@ void KItemListView::updateWidgetProperties(KItemListWidget* widget, int index) widget->setStyleOption(m_styleOption); const KItemListSelectionManager* selectionManager = m_controller->selectionManager(); - widget->setCurrent(index == selectionManager->currentItem()); + + // In SingleSelection mode (e.g., in the Places Panel), the current item is + // always the selected item. It is not necessary to highlight the current item then. + if (m_controller->selectionBehavior() != KItemListController::SingleSelection) { + widget->setCurrent(index == selectionManager->currentItem()); + } widget->setSelected(selectionManager->isSelected(index)); widget->setHovered(false); widget->setEnabledSelectionToggle(enabledSelectionToggles()); @@ -2717,4 +2725,3 @@ void KItemListGroupHeaderCreatorBase::recycle(KItemListGroupHeader* header) pushRecycleableWidget(header); } -#include "kitemlistview.moc"