#3738 Active correct item when clicking in Summary Plot Editor

This commit is contained in:
Gaute Lindkvist 2018-11-23 15:07:55 +01:00
parent 4f46a9b3cb
commit 2cf5357a47
3 changed files with 26 additions and 26 deletions

View File

@ -243,9 +243,6 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_treeView->setModel(m_proxyModel);
connect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
this, SLOT(slotCurrentChanged(QModelIndex, QModelIndex)));
}
bool optionsOnly = true;
@ -291,7 +288,7 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
m_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
}
connect(m_treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(slotClicked(QModelIndex)));
connect(m_treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(slotClicked(QModelIndex)), Qt::UniqueConnection);
if (!m_attributes.showTextFilter)
{
@ -574,7 +571,27 @@ void PdmUiTreeSelectionEditor::slotTextFilterChanged()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeSelectionEditor::slotCurrentChanged(const QModelIndex& current, const QModelIndex& previous)
void PdmUiTreeSelectionEditor::slotClicked(const QModelIndex& index)
{
if (m_attributes.setCurrentIndexWhenItemIsChecked && index.isValid())
{
QModelIndexList selectedIndexes = m_treeView->selectionModel()->selectedIndexes();
if (selectedIndexes.size() < 2)
{
QVariant v = m_proxyModel->data(index, Qt::CheckStateRole);
if (v == Qt::Checked)
{
m_treeView->setCurrentIndex(index);
}
}
}
currentChanged(index);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeSelectionEditor::currentChanged(const QModelIndex& current)
{
if (m_attributes.singleSelectionMode)
{
@ -593,25 +610,6 @@ void PdmUiTreeSelectionEditor::slotCurrentChanged(const QModelIndex& current, co
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeSelectionEditor::slotClicked(const QModelIndex& index)
{
if (m_attributes.setCurrentIndexWhenItemIsChecked && index.isValid())
{
QModelIndexList selectedIndexes = m_treeView->selectionModel()->selectedIndexes();
if (selectedIndexes.size() < 2)
{
QVariant v = m_proxyModel->data(index, Qt::CheckStateRole);
if (v == Qt::Checked)
{
m_treeView->setCurrentIndex(index);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -112,10 +112,11 @@ private slots:
void slotTextFilterChanged();
void slotCurrentChanged(const QModelIndex& current, const QModelIndex& previous);
void slotClicked(const QModelIndex& index);
private:
void currentChanged(const QModelIndex& current);
void setCheckedStateOfSelected(bool checked);
void setCheckedStateForSubItemsOfSelected(bool checked);
void checkAllItems();

View File

@ -46,6 +46,7 @@
#include <algorithm>
#include <QDebug>
//--------------------------------------------------------------------------------------------------
///
@ -485,7 +486,7 @@ bool caf::PdmUiTreeSelectionQModel::setData(const QModelIndex &index, const QVar
}
PdmUiCommandSystemProxy::instance()->setUiValueToField(m_uiFieldHandle->uiField(), fieldValueSelection);
emit dataChanged(index, index);
return true;
}
}