#3564 System : Recreate QGridLayout for each property editor

If the layout is reused, the rows grow over time. This causes the Cell Result to not fill all available space.
This commit is contained in:
Magne Sjaastad 2018-10-26 11:39:58 +02:00
parent 7febeba433
commit f6c92a15a6
2 changed files with 29 additions and 28 deletions

View File

@ -50,7 +50,6 @@
namespace caf
{
// Register default field editor for selected types
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiCheckBoxEditor, bool);
@ -68,43 +67,50 @@ CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiListEditor, std::vector<float>);
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiFilePathEditor, FilePath);
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiDefaultObjectEditor::PdmUiDefaultObjectEditor() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
PdmUiDefaultObjectEditor::PdmUiDefaultObjectEditor()
{
}
PdmUiDefaultObjectEditor::~PdmUiDefaultObjectEditor() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiDefaultObjectEditor::~PdmUiDefaultObjectEditor()
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiDefaultObjectEditor::createWidget(QWidget* parent)
{
QWidget* widget = new QWidget(parent);
QGridLayout* gridLayout = new QGridLayout();
gridLayout->setContentsMargins(0, 0, 0, 0);
widget->setLayout(gridLayout);
return widget;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void PdmUiDefaultObjectEditor::recursivelyConfigureAndUpdateTopLevelUiOrdering(const PdmUiOrdering& topLevelUiOrdering, const QString& uiConfigName)
void PdmUiDefaultObjectEditor::recursivelyConfigureAndUpdateTopLevelUiOrdering(const PdmUiOrdering& topLevelUiOrdering,
const QString& uiConfigName)
{
CAF_ASSERT(this->widget());
// Recreate layout object, as the content of the grid layout grows. This causes Cell Result to have a lot of space at the
// bottom and no other solution has been found. Similar issues might also be the case for the grid layout inside group boxes
{
auto currentLayout = this->widget()->layout();
if (currentLayout)
{
delete currentLayout;
}
}
CAF_ASSERT(this->widget()->layout() == nullptr);
QGridLayout* gridLayout = new QGridLayout();
gridLayout->setContentsMargins(0, 0, 0, 0);
this->widget()->setLayout(gridLayout);
recursivelyConfigureAndUpdateUiOrderingInGridLayoutColumn(topLevelUiOrdering, this->widget(), uiConfigName);
}

View File

@ -34,7 +34,6 @@
//
//##################################################################################################
#pragma once
#include "cafPdmUiFormLayoutObjectEditor.h"
@ -44,14 +43,12 @@
class QGridLayout;
class QString;
namespace caf
namespace caf
{
class PdmUiFieldEditorHandle;
class PdmUiItem;
class PdmUiGroup;
//==================================================================================================
/// The default editor for PdmObjects. Manages the field editors in a grid layout vertically
//==================================================================================================
@ -65,9 +62,7 @@ public:
private:
QWidget* createWidget(QWidget* parent) override;
void recursivelyConfigureAndUpdateTopLevelUiOrdering(const PdmUiOrdering& topLevelUiItems,
const QString& uiConfigName) override;
const QString& uiConfigName) override;
};
} // end namespace caf