mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1889 Curve Creator : Add stretch to bottom field layout
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
|
||||
#include "RicSummaryCurveCreator.h"
|
||||
#include "RicSummaryCurveCreatorUiKeywords.h"
|
||||
|
||||
#include "cafPdmUiFieldEditorHandle.h"
|
||||
#include "cafPdmUiFieldHandle.h"
|
||||
#include "cafPdmUiGroup.h"
|
||||
#include "cafPdmUiTreeView.h"
|
||||
|
||||
@@ -93,8 +96,10 @@ void RicSummaryCurveCreatorSplitterUi::recursivelyConfigureAndUpdateTopLevelUiIt
|
||||
|
||||
m_secondRowLayout->insertWidget(1, getOrCreatePlotWidget());
|
||||
|
||||
// NB! Only groups at top level are handled, fields at top level are not added to layout
|
||||
|
||||
// Fields at bottom of dialog
|
||||
|
||||
configureAndUpdateFields(1, m_bottomFieldLayout, topLevelUiItems, uiConfigName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -125,6 +130,10 @@ QWidget* RicSummaryCurveCreatorSplitterUi::createWidget(QWidget* parent)
|
||||
|
||||
m_layout->addWidget(m_firstColumnSplitter);
|
||||
|
||||
m_bottomFieldLayout = new QHBoxLayout;
|
||||
m_layout->addLayout(m_bottomFieldLayout);
|
||||
m_bottomFieldLayout->insertStretch(0, 1);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
@@ -192,3 +201,72 @@ QWidget* RicSummaryCurveCreatorSplitterUi::getOrCreatePlotWidget()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveCreatorSplitterUi::configureAndUpdateFields(int widgetStartIndex,
|
||||
QBoxLayout* layout,
|
||||
const std::vector<caf::PdmUiItem *>& uiItems,
|
||||
const QString& uiConfigName)
|
||||
{
|
||||
int currentWidgetIndex = widgetStartIndex;
|
||||
|
||||
for (size_t i = 0; i < uiItems.size(); ++i)
|
||||
{
|
||||
if (uiItems[i]->isUiHidden(uiConfigName)) continue;
|
||||
if (uiItems[i]->isUiGroup()) continue;
|
||||
|
||||
{
|
||||
caf::PdmUiFieldHandle* field = dynamic_cast<caf::PdmUiFieldHandle*>(uiItems[i]);
|
||||
|
||||
caf::PdmUiFieldEditorHandle* fieldEditor = findOrCreateFieldEditor(this->widget(), field, uiConfigName);
|
||||
|
||||
if (fieldEditor)
|
||||
{
|
||||
fieldEditor->setField(field);
|
||||
|
||||
// Place the widget(s) into the correct parent and layout
|
||||
QWidget* fieldCombinedWidget = fieldEditor->combinedWidget();
|
||||
|
||||
if (fieldCombinedWidget)
|
||||
{
|
||||
fieldCombinedWidget->setParent(this->widget());
|
||||
layout->insertWidget(currentWidgetIndex++, fieldCombinedWidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
caf::PdmUiItemInfo::LabelPosType labelPos = field->uiLabelPosition(uiConfigName);
|
||||
|
||||
QWidget* fieldEditorWidget = fieldEditor->editorWidget();
|
||||
|
||||
if (labelPos != caf::PdmUiItemInfo::HIDDEN)
|
||||
{
|
||||
QWidget* fieldLabelWidget = fieldEditor->labelWidget();
|
||||
if (fieldLabelWidget)
|
||||
{
|
||||
fieldLabelWidget->setParent(this->widget());
|
||||
|
||||
layout->insertWidget(currentWidgetIndex++, fieldLabelWidget);
|
||||
|
||||
fieldLabelWidget->show();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QWidget* fieldLabelWidget = fieldEditor->labelWidget();
|
||||
if (fieldLabelWidget) fieldLabelWidget->hide();
|
||||
}
|
||||
|
||||
if (fieldEditorWidget)
|
||||
{
|
||||
fieldEditorWidget->setParent(this->widget()); // To make sure this widget has the current group box as parent.
|
||||
|
||||
layout->insertWidget(currentWidgetIndex++, fieldEditorWidget);
|
||||
}
|
||||
}
|
||||
|
||||
fieldEditor->updateUi(uiConfigName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user