mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4282 Make minimum size work well for property view
This commit is contained in:
parent
fccb363f53
commit
cdc7a12190
@ -91,10 +91,6 @@ QWidget* PdmUiDefaultObjectEditor::createWidget(QWidget* parent)
|
||||
{
|
||||
QWidget* widget = new QWidget(parent);
|
||||
widget->setObjectName("ObjectEditor");
|
||||
QGridLayout* gridLayout = new QGridLayout();
|
||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||
widget->setLayout(gridLayout);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
@ -105,7 +101,9 @@ void PdmUiDefaultObjectEditor::recursivelyConfigureAndUpdateTopLevelUiOrdering(c
|
||||
{
|
||||
CAF_ASSERT(this->widget());
|
||||
|
||||
recursivelyConfigureAndUpdateUiOrderingInGridLayoutColumn(topLevelUiOrdering, this->widget(), uiConfigName);
|
||||
ensureEmptyGridLayout(this->widget());
|
||||
recursivelyConfigureAndUpdateUiOrderingInGridLayoutColumn(topLevelUiOrdering, this->widget(), uiConfigName);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
@ -260,6 +260,7 @@ bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
|
||||
|
||||
CAF_ASSERT(currentColumn <= totalColumns);
|
||||
}
|
||||
containerWidgetWithGridLayout->updateGeometry();
|
||||
// The magnitude of the stretch should not be sent up, only if there was stretch or not
|
||||
return maxRowStretch > 0;
|
||||
}
|
||||
@ -405,6 +406,29 @@ caf::PdmUiFieldEditorHandle* caf::PdmUiFormLayoutObjectEditor::findOrCreateField
|
||||
return fieldEditor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::PdmUiFormLayoutObjectEditor::ensureEmptyGridLayout(QWidget* containerWidget)
|
||||
{
|
||||
CAF_ASSERT(containerWidget);
|
||||
QLayout* layout = containerWidget->layout();
|
||||
if (layout != nullptr)
|
||||
{
|
||||
// Remove all items from the layout, then reparent the layout to a temporary
|
||||
// This is because you cannot remove a layout from a widget but it gets moved when reparenting.
|
||||
QLayoutItem* item;
|
||||
while ((item = layout->takeAt(0)) != 0)
|
||||
{
|
||||
}
|
||||
QWidget().setLayout(layout);
|
||||
}
|
||||
|
||||
QGridLayout* gridLayout = new QGridLayout;
|
||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||
containerWidget->setLayout(gridLayout);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -90,6 +90,8 @@ protected:
|
||||
QMinimizePanel* findOrCreateGroupBox(QWidget* parent, PdmUiGroup* group, const QString& uiConfigName);
|
||||
PdmUiFieldEditorHandle* findOrCreateFieldEditor(QWidget* parent, PdmUiFieldHandle* field, const QString& uiConfigName);
|
||||
|
||||
static void ensureEmptyGridLayout(QWidget* containerWidget);
|
||||
|
||||
private slots:
|
||||
void groupBoxExpandedStateToggled(bool isExpanded);
|
||||
|
||||
|
@ -59,6 +59,28 @@ QVerticalScrollArea::QVerticalScrollArea(QWidget* parent) :
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize QVerticalScrollArea::sizeHint() const
|
||||
{
|
||||
QSize widgetSize = widget()->sizeHint();
|
||||
QSize scrollSize = QScrollArea::sizeHint();
|
||||
scrollSize.setWidth(widgetSize.width() + verticalScrollBar()->width());
|
||||
return scrollSize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize QVerticalScrollArea::minimumSizeHint() const
|
||||
{
|
||||
QSize widgetSize = widget()->minimumSizeHint();
|
||||
QSize scrollSize = QScrollArea::minimumSizeHint();
|
||||
scrollSize.setWidth(widgetSize.width() + verticalScrollBar()->width());
|
||||
return scrollSize;
|
||||
}
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
@ -166,10 +188,6 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object)
|
||||
|
||||
// Add stretch to make sure the property widget is not stretched
|
||||
this->m_placeHolderLayout->insertStretch(-1, 1);
|
||||
|
||||
//int minimumWidth = propertyWidget->minimumSizeHint().width() + m_scrollArea->verticalScrollBar()->width();
|
||||
//m_scrollArea->setMinimumWidth(minimumWidth);
|
||||
//m_scrollArea->adjustSize();
|
||||
}
|
||||
|
||||
m_defaultObjectEditor->setPdmObject(object);
|
||||
@ -177,6 +195,7 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object)
|
||||
QObject::connect(m_defaultObjectEditor, SIGNAL(uiUpdated()), this, SLOT(slotScheduleScrollToSelectedItemsInFieldEditors()));
|
||||
|
||||
m_defaultObjectEditor->updateUi(m_uiConfigName);
|
||||
m_scrollArea->updateGeometry();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -205,12 +224,15 @@ PdmObjectHandle* PdmUiPropertyView::currentObject()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize PdmUiPropertyView::sizeHint() const
|
||||
{
|
||||
if (m_placeholder)
|
||||
{
|
||||
return m_placeholder->sizeHint();
|
||||
}
|
||||
return m_scrollArea->sizeHint();
|
||||
}
|
||||
|
||||
return QWidget::sizeHint();
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize PdmUiPropertyView::minimumSizeHint() const
|
||||
{
|
||||
return m_scrollArea->minimumSizeHint();
|
||||
}
|
||||
|
||||
} //End of namespace caf
|
||||
|
@ -54,6 +54,9 @@ class QVerticalScrollArea : public QScrollArea
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QVerticalScrollArea(QWidget* parent = nullptr);
|
||||
|
||||
virtual QSize sizeHint() const override;
|
||||
virtual QSize minimumSizeHint() const override;
|
||||
};
|
||||
|
||||
|
||||
@ -78,6 +81,7 @@ public:
|
||||
PdmObjectHandle* currentObject();
|
||||
|
||||
QSize sizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
|
||||
public slots:
|
||||
void showProperties(caf::PdmObjectHandle* object); // Signal/Slot system needs caf:: prefix in some cases
|
||||
|
Loading…
Reference in New Issue
Block a user