mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2266 AppFwk : Add editor attribute setCurrentIndexWhenItemIsChecked
Fix bug when a selection is active
This commit is contained in:
parent
3b9e7d0106
commit
81129302f3
@ -573,14 +573,18 @@ void PdmUiTreeSelectionEditor::slotCurrentChanged(const QModelIndex& current, co
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTreeSelectionEditor::slotClicked(const QModelIndex& current)
|
||||
void PdmUiTreeSelectionEditor::slotClicked(const QModelIndex& index)
|
||||
{
|
||||
if (current.isValid())
|
||||
if (m_attributes.setCurrentIndexWhenItemIsChecked && index.isValid())
|
||||
{
|
||||
QVariant v = m_proxyModel->data(current, Qt::CheckStateRole);
|
||||
if (v == Qt::Checked)
|
||||
QModelIndexList selectedIndexes = m_treeView->selectionModel()->selectedIndexes();
|
||||
if (selectedIndexes.size() < 2)
|
||||
{
|
||||
m_treeView->setCurrentIndex(current);
|
||||
QVariant v = m_proxyModel->data(index, Qt::CheckStateRole);
|
||||
if (v == Qt::Checked)
|
||||
{
|
||||
m_treeView->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
bool showTextFilter;
|
||||
bool showToggleAllCheckbox;
|
||||
bool singleSelectionMode;
|
||||
bool setCurrentIndexWhenItemIsChecked;
|
||||
|
||||
/// fieldToReceiveCurrentFieldValue is used to communicate the value of current item in the tree view
|
||||
/// This is useful when displaying a list of appEnums, and a dependent view is displaying content based on
|
||||
@ -75,6 +76,7 @@ public:
|
||||
showTextFilter = true;
|
||||
showToggleAllCheckbox = true;
|
||||
singleSelectionMode = false;
|
||||
setCurrentIndexWhenItemIsChecked = false;
|
||||
|
||||
fieldToReceiveCurrentItemValue = nullptr;
|
||||
}
|
||||
@ -110,7 +112,7 @@ private slots:
|
||||
void slotTextFilterChanged();
|
||||
|
||||
void slotCurrentChanged(const QModelIndex& current, const QModelIndex& previous);
|
||||
void slotClicked(const QModelIndex& current);
|
||||
void slotClicked(const QModelIndex& index);
|
||||
|
||||
private:
|
||||
void setCheckedStateOfSelected(bool checked);
|
||||
|
Loading…
Reference in New Issue
Block a user