From c486a7b85501c504b18e3bb10c6497a4527a774d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 10 Nov 2016 11:10:20 +0100 Subject: [PATCH] #879 AppFwk : Workaround for navigation with arrow keys in selection lists seen on Linux --- .../cafUserInterface/cafPdmUiListEditor.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp index 3e0a52dd53..c3d8174534 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp @@ -265,12 +265,21 @@ void PdmUiListEditor::slotSelectionChanged(const QItemSelection & selected, cons { if (m_options.isEmpty()) return; - //QModelIndexList idxList = selected.indexes(); - QModelIndexList idxList = m_listView->selectionModel()->selectedIndexes(); - QVariant fieldValue = field()->uiValue(); if (fieldValue.type() == QVariant::Int || fieldValue.type() == QVariant::UInt) { + // NOTE : Workaround for update issue seen on RHEL6 with Qt 4.6.2 + // An invalid call to setSelection() from QAbstractItemView::keyPressEvent() causes the stepping using arrow keys + // in a single selection list to not work as expected. + // + // NOTE: Multi select in selection lists do still have issues similar to the above description. + // + // See also https://github.com/OPM/ResInsight/issues/879 + // + // WORKAROUND : The list view is in single selection mode, and the selection is set based on current index + m_listView->selectionModel()->select(m_listView->currentIndex(), QItemSelectionModel::SelectCurrent); + + QModelIndexList idxList = m_listView->selectionModel()->selectedIndexes(); if (idxList.size() >= 1) { if (idxList[0].row() < m_options.size()) @@ -283,6 +292,7 @@ void PdmUiListEditor::slotSelectionChanged(const QItemSelection & selected, cons { QList valuesToSetInField; + QModelIndexList idxList = m_listView->selectionModel()->selectedIndexes(); for (int i = 0; i < idxList.size(); ++i) { if (idxList[i].row() < m_options.size())