mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3738 Active correct item when clicking in Summary Plot Editor
This commit is contained in:
parent
4f46a9b3cb
commit
2cf5357a47
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user