Skip to content

Commit

Permalink
OPM#12075 When activating an item, also select the item
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Jan 19, 2025
1 parent d17ecc4 commit 5338852
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1290,10 +1290,9 @@ void RiuSummaryVectorSelectionUi::defineEditorAttribute( const caf::PdmFieldHand
{
if ( &m_selectedSummaryCategories == field )
{
attrib->currentIndexFieldHandle = &m_currentSummaryCategory;
attrib->showTextFilter = false;
attrib->showToggleAllCheckbox = false;
attrib->setCurrentIndexWhenItemIsChecked = true;
attrib->currentIndexFieldHandle = &m_currentSummaryCategory;
attrib->showTextFilter = false;
attrib->showToggleAllCheckbox = false;
}

// All tree selection editors are set in specified selection mode
Expand Down
5 changes: 2 additions & 3 deletions Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,6 @@ QWidget* PdmUiTreeSelectionEditor::createEditorWidget( QWidget* parent )
headerLayout->setContentsMargins( 0, 0, 0, 0 );
layout->addLayout( headerLayout );

PdmUiTreeSelectionEditorAttribute attrib;

m_toggleAllCheckBox = new QCheckBox();
headerLayout->addWidget( m_toggleAllCheckBox );

Expand Down Expand Up @@ -715,14 +713,15 @@ void PdmUiTreeSelectionEditor::slotClicked( const QModelIndex& index )
return;
}

if ( m_attributes.setCurrentIndexWhenItemIsChecked && index.isValid() )
if ( index.isValid() )
{
QModelIndexList selectedIndexes = m_treeView->selectionModel()->selectedIndexes();
if ( selectedIndexes.size() < 2 )
{
QVariant v = m_proxyModel->data( index, Qt::CheckStateRole );
if ( v == Qt::Checked )
{
// Make sure the activated item also is selected in the tree view
m_treeView->setCurrentIndex( index );
}
}
Expand Down
14 changes: 6 additions & 8 deletions Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class PdmUiTreeSelectionEditorAttribute : public PdmUiEditorAttribute
bool showTextFilter;
bool showToggleAllCheckbox;
bool singleSelectionMode;
bool setCurrentIndexWhenItemIsChecked;
bool showCheckBoxes;
bool showContextMenu;
int heightHint;
Expand All @@ -77,13 +76,12 @@ class PdmUiTreeSelectionEditorAttribute : public PdmUiEditorAttribute
public:
PdmUiTreeSelectionEditorAttribute()
{
showTextFilter = true;
showToggleAllCheckbox = true;
singleSelectionMode = false;
setCurrentIndexWhenItemIsChecked = false;
showCheckBoxes = true;
showContextMenu = true;
heightHint = -1;
showTextFilter = true;
showToggleAllCheckbox = true;
singleSelectionMode = false;
showCheckBoxes = true;
showContextMenu = true;
heightHint = -1;

currentIndexFieldHandle = nullptr;
}
Expand Down

0 comments on commit 5338852

Please sign in to comment.