mirror of
https://github.com/OPM/ResInsight.git
synced 2026-07-31 08:48:17 -05:00
#1896 Curve Creator : Add editor attributes to control search and toggle
This commit is contained in:
@@ -162,3 +162,19 @@ void ManyGroups::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOr
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void ManyGroups::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
||||
{
|
||||
if (field == &m_multiSelectList)
|
||||
{
|
||||
caf::PdmUiTreeSelectionEditorAttribute* myAttr = dynamic_cast<caf::PdmUiTreeSelectionEditorAttribute*>(attribute);
|
||||
if (myAttr)
|
||||
{
|
||||
//myAttr->showTextFilter = false;
|
||||
//myAttr->showToggleAllCheckbox = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,5 +40,8 @@ protected:
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -153,17 +153,37 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
m_treeView->expandAll();
|
||||
}
|
||||
|
||||
bool allItemsChecked = true;
|
||||
QModelIndexList indices = allVisibleSourceModelIndices();
|
||||
for (auto mi : indices)
|
||||
PdmUiTreeSelectionEditorAttribute attributes;
|
||||
caf::PdmUiObjectHandle* uiObject = uiObj(field()->fieldHandle()->ownerObject());
|
||||
if (uiObject)
|
||||
{
|
||||
if (m_model->data(mi, Qt::CheckStateRole).toBool() == false)
|
||||
{
|
||||
allItemsChecked = false;
|
||||
}
|
||||
uiObject->editorAttribute(field()->fieldHandle(), uiConfigName, &attributes);
|
||||
}
|
||||
|
||||
m_toggleAllCheckBox->setChecked(allItemsChecked);
|
||||
if (!attributes.showTextFilter)
|
||||
{
|
||||
m_textFilterLineEdit->hide();
|
||||
}
|
||||
|
||||
if (!attributes.showToggleAllCheckbox)
|
||||
{
|
||||
m_toggleAllCheckBox->hide();
|
||||
}
|
||||
|
||||
if (m_toggleAllCheckBox)
|
||||
{
|
||||
bool allItemsChecked = true;
|
||||
QModelIndexList indices = allVisibleSourceModelIndices();
|
||||
for (auto mi : indices)
|
||||
{
|
||||
if (m_model->data(mi, Qt::CheckStateRole).toBool() == false)
|
||||
{
|
||||
allItemsChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
m_toggleAllCheckBox->setChecked(allItemsChecked);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -179,6 +199,8 @@ QWidget* PdmUiTreeSelectionEditor::createEditorWidget(QWidget* parent)
|
||||
QHBoxLayout* headerLayout = new QHBoxLayout;
|
||||
layout->addLayout(headerLayout);
|
||||
|
||||
PdmUiTreeSelectionEditorAttribute attrib;
|
||||
|
||||
m_toggleAllCheckBox = new QCheckBox();
|
||||
headerLayout->addWidget(m_toggleAllCheckBox);
|
||||
|
||||
|
||||
@@ -59,11 +59,13 @@ class PdmUiTreeSelectionEditorAttribute : public PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
bool showTextFilter;
|
||||
bool showToggleAllCheckbox;
|
||||
|
||||
public:
|
||||
PdmUiTreeSelectionEditorAttribute()
|
||||
{
|
||||
showTextFilter = false;
|
||||
showTextFilter = true;
|
||||
showToggleAllCheckbox = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user