mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 07:03:25 -06:00
#4083 Summary : Do not change selected summary type when unticking a checkbox
This commit is contained in:
parent
6bdd4b8178
commit
b15f58b560
@ -589,6 +589,16 @@ void PdmUiTreeSelectionEditor::slotTextFilterChanged()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTreeSelectionEditor::slotClicked(const QModelIndex& index)
|
||||
{
|
||||
QModelIndex lastUncheckedIndex = m_model->indexForLastUncheckedItem();
|
||||
m_model->clearIndexForLastUncheckedItem();
|
||||
|
||||
QModelIndex proxyModelIndex = m_proxyModel->mapFromSource(lastUncheckedIndex);
|
||||
if (proxyModelIndex == index)
|
||||
{
|
||||
// Early return to avoid changing the current item if an item was unchecked
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_attributes.setCurrentIndexWhenItemIsChecked && index.isValid())
|
||||
{
|
||||
QModelIndexList selectedIndexes = m_treeView->selectionModel()->selectedIndexes();
|
||||
|
@ -51,13 +51,14 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmUiTreeSelectionQModel::PdmUiTreeSelectionQModel(QObject *parent /*= 0*/)
|
||||
: QAbstractItemModel(parent),
|
||||
m_uiValueCache(nullptr)
|
||||
caf::PdmUiTreeSelectionQModel::PdmUiTreeSelectionQModel(QObject* parent /*= 0*/)
|
||||
: QAbstractItemModel(parent)
|
||||
, m_uiFieldHandle(nullptr)
|
||||
, m_uiValueCache(nullptr)
|
||||
, m_tree(nullptr)
|
||||
, m_singleSelectionMode(false)
|
||||
, m_indexForLastUncheckedItem(QModelIndex())
|
||||
{
|
||||
m_uiFieldHandle = nullptr;
|
||||
m_tree = nullptr;
|
||||
m_singleSelectionMode = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -476,6 +477,8 @@ bool caf::PdmUiTreeSelectionQModel::setData(const QModelIndex &index, const QVar
|
||||
}
|
||||
else
|
||||
{
|
||||
m_indexForLastUncheckedItem = index;
|
||||
|
||||
selectedIndices.erase(std::remove(selectedIndices.begin(), selectedIndices.end(), opIndex), selectedIndices.end());
|
||||
}
|
||||
|
||||
@ -494,6 +497,22 @@ bool caf::PdmUiTreeSelectionQModel::setData(const QModelIndex &index, const QVar
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QModelIndex caf::PdmUiTreeSelectionQModel::indexForLastUncheckedItem() const
|
||||
{
|
||||
return m_indexForLastUncheckedItem;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::PdmUiTreeSelectionQModel::clearIndexForLastUncheckedItem()
|
||||
{
|
||||
m_indexForLastUncheckedItem = QModelIndex();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -84,6 +84,9 @@ public:
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
|
||||
QModelIndex indexForLastUncheckedItem() const;
|
||||
void clearIndexForLastUncheckedItem();
|
||||
|
||||
// Consider moving these functions to PdmUiFieldHandle
|
||||
static bool isSingleValueField(const QVariant& fieldValue);
|
||||
static bool isMultipleValueField(const QVariant& fieldValue);
|
||||
@ -107,6 +110,7 @@ private:
|
||||
TreeItemType* m_tree;
|
||||
|
||||
bool m_singleSelectionMode;
|
||||
QModelIndex m_indexForLastUncheckedItem;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user