mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-02 09:00:14 -06:00
#14122 Allow tree selection editor to grow only when it is the last row
The tree selection editor can grow to a large height, which is useful when it is the last field editor in the property dialog. When other field editors are located below, the heightHint is now used as the maximum height instead. The form layout tracks whether an editor occupies the bottom-most row of the form and passes this to the editor. In the Analysis Plot, the time step selection is constrained to its height hint because other input fields are located below it.
This commit is contained in:
1 parent
cbae501a13
commit
98ea83146a
7 files changed
+77
-9
No files matched your search
@@ -692,6 +692,20 @@ QList<caf::PdmOptionItemInfo> RimAnalysisPlot::calculateValueOptions( const caf:
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimAnalysisPlot::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
|
||||||
|
{
|
||||||
|
if ( field == &m_selectedTimeSteps )
|
||||||
|
{
|
||||||
|
if ( auto* attrib = dynamic_cast<caf::PdmUiTreeSelectionEditorAttribute*>( attribute ) )
|
||||||
|
{
|
||||||
|
attrib->heightHint = 150;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ private:
|
|||||||
|
|
||||||
caf::PdmFieldHandle* userDescriptionField() override;
|
caf::PdmFieldHandle* userDescriptionField() override;
|
||||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||||
|
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
||||||
|
|
||||||
std::set<time_t> allAvailableTimeSteps() const;
|
std::set<time_t> allAvailableTimeSteps() const;
|
||||||
|
|
||||||
|
|||||||
@@ -182,6 +182,22 @@ int PdmUiFieldEditorHandle::rowStretchFactor() const
|
|||||||
return isMultiRowEditor() ? 1 : 0;
|
return isMultiRowEditor() ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiFieldEditorHandle::setIsInLastFormRow( bool isLast )
|
||||||
|
{
|
||||||
|
m_isInLastFormRow = isLast;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool PdmUiFieldEditorHandle::isInLastFormRow() const
|
||||||
|
{
|
||||||
|
return m_isInLastFormRow;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -102,6 +102,11 @@ public:
|
|||||||
QMargins labelContentMargins() const;
|
QMargins labelContentMargins() const;
|
||||||
int rowStretchFactor() const;
|
int rowStretchFactor() const;
|
||||||
|
|
||||||
|
/// True if this editor occupies the bottom-most row of the entire form. Editors that can grow
|
||||||
|
/// vertically may use this to fill the remaining space instead of being constrained to a height hint.
|
||||||
|
void setIsInLastFormRow( bool isLast );
|
||||||
|
bool isInLastFormRow() const;
|
||||||
|
|
||||||
void updateValidationState();
|
void updateValidationState();
|
||||||
|
|
||||||
protected: // Virtual interface to override
|
protected: // Virtual interface to override
|
||||||
@@ -132,6 +137,7 @@ private:
|
|||||||
QPointer<QWidget> m_editorWidget;
|
QPointer<QWidget> m_editorWidget;
|
||||||
QPointer<QWidget> m_labelWidget;
|
QPointer<QWidget> m_labelWidget;
|
||||||
QPointer<QAction> m_validationErrorAction;
|
QPointer<QAction> m_validationErrorAction;
|
||||||
|
bool m_isInLastFormRow = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|||||||
@@ -88,12 +88,14 @@ caf::PdmUiFormLayoutObjectEditor::~PdmUiFormLayoutObjectEditor()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInNewGridLayout( const PdmUiOrdering& uiOrdering,
|
bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInNewGridLayout( const PdmUiOrdering& uiOrdering,
|
||||||
QWidget* containerWidget,
|
QWidget* containerWidget,
|
||||||
const QString& uiConfigName )
|
const QString& uiConfigName,
|
||||||
|
bool parentRowIsLast )
|
||||||
{
|
{
|
||||||
QSize beforeSize = containerWidget->sizeHint();
|
QSize beforeSize = containerWidget->sizeHint();
|
||||||
|
|
||||||
ensureWidgetContainsEmptyGridLayout( containerWidget );
|
ensureWidgetContainsEmptyGridLayout( containerWidget );
|
||||||
int stretch = recursivelyConfigureAndUpdateUiOrderingInGridLayout( uiOrdering, containerWidget, uiConfigName );
|
int stretch =
|
||||||
|
recursivelyConfigureAndUpdateUiOrderingInGridLayout( uiOrdering, containerWidget, uiConfigName, parentRowIsLast );
|
||||||
|
|
||||||
QSize afterSize = containerWidget->sizeHint();
|
QSize afterSize = containerWidget->sizeHint();
|
||||||
if ( beforeSize != afterSize )
|
if ( beforeSize != afterSize )
|
||||||
@@ -110,7 +112,8 @@ bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
int caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInGridLayout( const PdmUiOrdering& uiOrdering,
|
int caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInGridLayout( const PdmUiOrdering& uiOrdering,
|
||||||
QWidget* containerWidgetWithGridLayout,
|
QWidget* containerWidgetWithGridLayout,
|
||||||
const QString& uiConfigName )
|
const QString& uiConfigName,
|
||||||
|
bool parentRowIsLast )
|
||||||
{
|
{
|
||||||
int sumRowStretch = 0;
|
int sumRowStretch = 0;
|
||||||
CAF_ASSERT( containerWidgetWithGridLayout );
|
CAF_ASSERT( containerWidgetWithGridLayout );
|
||||||
@@ -130,6 +133,10 @@ int caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInG
|
|||||||
{
|
{
|
||||||
int currentColumn = 0;
|
int currentColumn = 0;
|
||||||
|
|
||||||
|
// True when this row is the bottom-most row of the entire form. Editors that can grow vertically
|
||||||
|
// use this to fill the remaining space rather than being constrained to a fixed height hint.
|
||||||
|
bool rowIsLast = parentRowIsLast && ( currentRowIndex == totalRows - 1 );
|
||||||
|
|
||||||
const PdmUiOrdering::RowLayout& uiItemsInRow = tableLayout[currentRowIndex];
|
const PdmUiOrdering::RowLayout& uiItemsInRow = tableLayout[currentRowIndex];
|
||||||
|
|
||||||
int columnsRequiredForCurrentRow = uiOrdering.nrOfRequiredColumnsInRow( uiItemsInRow );
|
int columnsRequiredForCurrentRow = uiOrdering.nrOfRequiredColumnsInRow( uiItemsInRow );
|
||||||
@@ -171,7 +178,8 @@ int caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInG
|
|||||||
parentLayout,
|
parentLayout,
|
||||||
currentRowIndex,
|
currentRowIndex,
|
||||||
currentColumn,
|
currentColumn,
|
||||||
itemColumnSpan );
|
itemColumnSpan,
|
||||||
|
rowIsLast );
|
||||||
parentLayout->setRowStretch( currentRowIndex, groupStretchFactor );
|
parentLayout->setRowStretch( currentRowIndex, groupStretchFactor );
|
||||||
currentColumn += itemColumnSpan;
|
currentColumn += itemColumnSpan;
|
||||||
sumRowStretch += groupStretchFactor;
|
sumRowStretch += groupStretchFactor;
|
||||||
@@ -313,6 +321,7 @@ int caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInG
|
|||||||
parentLayout->setRowStretch( currentRowIndex, fieldEditor->rowStretchFactor() );
|
parentLayout->setRowStretch( currentRowIndex, fieldEditor->rowStretchFactor() );
|
||||||
sumRowStretch += fieldEditor->rowStretchFactor();
|
sumRowStretch += fieldEditor->rowStretchFactor();
|
||||||
}
|
}
|
||||||
|
fieldEditor->setIsInLastFormRow( rowIsLast );
|
||||||
fieldEditor->updateUi( uiConfigName );
|
fieldEditor->updateUi( uiConfigName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,13 +343,15 @@ int caf::PdmUiFormLayoutObjectEditor::recursivelyAddGroupToGridLayout( PdmUiItem
|
|||||||
QGridLayout* parentLayout,
|
QGridLayout* parentLayout,
|
||||||
int currentRowIndex,
|
int currentRowIndex,
|
||||||
int currentColumn,
|
int currentColumn,
|
||||||
int itemColumnSpan )
|
int itemColumnSpan,
|
||||||
|
bool parentRowIsLast )
|
||||||
{
|
{
|
||||||
PdmUiGroup* group = static_cast<PdmUiGroup*>( currentItem );
|
PdmUiGroup* group = static_cast<PdmUiGroup*>( currentItem );
|
||||||
|
|
||||||
QMinimizePanel* groupBox = findOrCreateGroupBox( containerWidgetWithGridLayout, group, uiConfigName );
|
QMinimizePanel* groupBox = findOrCreateGroupBox( containerWidgetWithGridLayout, group, uiConfigName );
|
||||||
|
|
||||||
int stretch = recursivelyConfigureAndUpdateUiOrderingInGridLayout( *group, groupBox->contentFrame(), uiConfigName );
|
int stretch =
|
||||||
|
recursivelyConfigureAndUpdateUiOrderingInGridLayout( *group, groupBox->contentFrame(), uiConfigName, parentRowIsLast );
|
||||||
|
|
||||||
/// Insert the group box at the correct position of the parent layout
|
/// Insert the group box at the correct position of the parent layout
|
||||||
parentLayout->addWidget( groupBox, currentRowIndex, currentColumn, 1, itemColumnSpan );
|
parentLayout->addWidget( groupBox, currentRowIndex, currentColumn, 1, itemColumnSpan );
|
||||||
|
|||||||
@@ -79,10 +79,12 @@ protected:
|
|||||||
|
|
||||||
bool recursivelyConfigureAndUpdateUiOrderingInNewGridLayout( const PdmUiOrdering& uiOrdering,
|
bool recursivelyConfigureAndUpdateUiOrderingInNewGridLayout( const PdmUiOrdering& uiOrdering,
|
||||||
QWidget* containerWidget,
|
QWidget* containerWidget,
|
||||||
const QString& uiConfigName );
|
const QString& uiConfigName,
|
||||||
|
bool parentRowIsLast = true );
|
||||||
int recursivelyConfigureAndUpdateUiOrderingInGridLayout( const PdmUiOrdering& uiOrdering,
|
int recursivelyConfigureAndUpdateUiOrderingInGridLayout( const PdmUiOrdering& uiOrdering,
|
||||||
QWidget* containerWidgetWithGridLayout,
|
QWidget* containerWidgetWithGridLayout,
|
||||||
const QString& uiConfigName );
|
const QString& uiConfigName,
|
||||||
|
bool parentRowIsLast = true );
|
||||||
|
|
||||||
int recursivelyAddGroupToGridLayout( PdmUiItem* currentItem,
|
int recursivelyAddGroupToGridLayout( PdmUiItem* currentItem,
|
||||||
QWidget* containerWidget,
|
QWidget* containerWidget,
|
||||||
@@ -90,7 +92,8 @@ protected:
|
|||||||
QGridLayout* parentLayout,
|
QGridLayout* parentLayout,
|
||||||
int currentRowIndex,
|
int currentRowIndex,
|
||||||
int currentColumn,
|
int currentColumn,
|
||||||
int itemColumnSpan );
|
int itemColumnSpan,
|
||||||
|
bool parentRowIsLast = true );
|
||||||
|
|
||||||
QMinimizePanel* findOrCreateGroupBox( QWidget* parent, PdmUiGroup* group, const QString& uiConfigName );
|
QMinimizePanel* findOrCreateGroupBox( QWidget* parent, PdmUiGroup* group, const QString& uiConfigName );
|
||||||
PdmUiFieldEditorHandle* findOrCreateFieldEditor( QWidget* parent, PdmUiFieldHandle* field, const QString& uiConfigName );
|
PdmUiFieldEditorHandle* findOrCreateFieldEditor( QWidget* parent, PdmUiFieldHandle* field, const QString& uiConfigName );
|
||||||
|
|||||||
@@ -309,6 +309,23 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi( const QString& uiConfigName
|
|||||||
if ( m_attributes.heightHint > 0 )
|
if ( m_attributes.heightHint > 0 )
|
||||||
{
|
{
|
||||||
m_treeView->setHeightHint( m_attributes.heightHint );
|
m_treeView->setHeightHint( m_attributes.heightHint );
|
||||||
|
|
||||||
|
// The tree selection editor is a multi-row editor, so its row is given a stretch factor in the
|
||||||
|
// property layout. Without an upper bound the tree view would expand to fill all available vertical
|
||||||
|
// space, ignoring the height hint. Cap the height so the hint is respected - unless this editor is
|
||||||
|
// the bottom-most widget in the form, in which case let it grow to fill the remaining space.
|
||||||
|
if ( isInLastFormRow() )
|
||||||
|
{
|
||||||
|
m_treeView->setMaximumHeight( QWIDGETSIZE_MAX );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_treeView->setMaximumHeight( m_attributes.heightHint );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_treeView->setMaximumHeight( QWIDGETSIZE_MAX );
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the tree doesn't have grand children we treat this as a straight list
|
// If the tree doesn't have grand children we treat this as a straight list
|
||||||
|
|||||||
Reference in new issue
Block a user