mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4097 Implement stretch factors for editors
This commit is contained in:
parent
14bcfb8122
commit
038d7a7676
@ -421,8 +421,6 @@ void RiuPlotMainWindow::createDockPanels()
|
|||||||
m_pdmUiPropertyView = new caf::PdmUiPropertyView(dockWidget);
|
m_pdmUiPropertyView = new caf::PdmUiPropertyView(dockWidget);
|
||||||
dockWidget->setWidget(m_pdmUiPropertyView);
|
dockWidget->setWidget(m_pdmUiPropertyView);
|
||||||
|
|
||||||
m_pdmUiPropertyView->layout()->setContentsMargins(5, 0, 0, 0);
|
|
||||||
|
|
||||||
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
|
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +122,14 @@ QMargins PdmUiFieldEditorHandle::labelContentMargins() const
|
|||||||
return calculateLabelContentMargins();
|
return calculateLabelContentMargins();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
int PdmUiFieldEditorHandle::rowStretchFactor() const
|
||||||
|
{
|
||||||
|
return isMultiRowEditor() ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -165,6 +173,14 @@ QMargins PdmUiFieldEditorHandle::calculateLabelContentMargins() const
|
|||||||
return m_labelWidget->contentsMargins();
|
return m_labelWidget->contentsMargins();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool PdmUiFieldEditorHandle::isMultiRowEditor() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -98,7 +98,7 @@ public:
|
|||||||
QWidget* editorWidget() { return m_editorWidget; }
|
QWidget* editorWidget() { return m_editorWidget; }
|
||||||
QWidget* labelWidget() { return m_labelWidget; }
|
QWidget* labelWidget() { return m_labelWidget; }
|
||||||
QMargins labelContentMargins() const;
|
QMargins labelContentMargins() const;
|
||||||
|
int rowStretchFactor() const;
|
||||||
protected: // Virtual interface to override
|
protected: // Virtual interface to override
|
||||||
/// Implement one of these, or both editor and label. The widgets will be used in the parent layout according to
|
/// Implement one of these, or both editor and label. The widgets will be used in the parent layout according to
|
||||||
/// being "Label" Editor" or a single combined widget.
|
/// being "Label" Editor" or a single combined widget.
|
||||||
@ -111,6 +111,7 @@ protected: // Virtual interface to override
|
|||||||
|
|
||||||
void updateLabelFromField(QLabel* label, const QString& uiConfigName = "") const;
|
void updateLabelFromField(QLabel* label, const QString& uiConfigName = "") const;
|
||||||
virtual QMargins calculateLabelContentMargins() const;
|
virtual QMargins calculateLabelContentMargins() const;
|
||||||
|
virtual bool isMultiRowEditor() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void customMenuRequested(QPoint pos);
|
void customMenuRequested(QPoint pos);
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "QMinimizePanel.h"
|
#include "QMinimizePanel.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDebug>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
@ -123,7 +124,7 @@ static const QIcon& expandUpIcon()
|
|||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QMinimizePanel::QMinimizePanel(QWidget* parent/*=0*/)
|
QMinimizePanel::QMinimizePanel(QWidget* parent/*=0*/)
|
||||||
: QWidget(parent)
|
: QFrame(parent)
|
||||||
{
|
{
|
||||||
this->initialize("");
|
this->initialize("");
|
||||||
}
|
}
|
||||||
@ -132,7 +133,7 @@ QMinimizePanel::QMinimizePanel(QWidget* parent/*=0*/)
|
|||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QMinimizePanel::QMinimizePanel(const QString &title, QWidget* parent/*=0*/)
|
QMinimizePanel::QMinimizePanel(const QString &title, QWidget* parent/*=0*/)
|
||||||
: QWidget(parent)
|
: QFrame(parent)
|
||||||
{
|
{
|
||||||
this->initialize(title);
|
this->initialize(title);
|
||||||
}
|
}
|
||||||
@ -176,42 +177,20 @@ void QMinimizePanel::enableFrame(bool showFrame)
|
|||||||
{
|
{
|
||||||
if (showFrame)
|
if (showFrame)
|
||||||
{
|
{
|
||||||
|
this->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
|
||||||
m_titleFrame->show();
|
m_titleFrame->show();
|
||||||
m_titleLabel->show();
|
m_titleLabel->show();
|
||||||
m_collapseButton->show();
|
m_collapseButton->show();
|
||||||
m_contentFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
|
m_contentFrame->setObjectName("FramedGroupContent");
|
||||||
m_contentFrame->setPalette(m_contentPalette);
|
|
||||||
m_contentFrame->setAttribute(Qt::WA_SetPalette, true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
this->setFrameStyle(QFrame::NoFrame);
|
||||||
m_titleFrame->hide();
|
m_titleFrame->hide();
|
||||||
m_titleLabel->hide();
|
m_titleLabel->hide();
|
||||||
m_collapseButton->hide();
|
m_collapseButton->hide();
|
||||||
m_contentFrame->setFrameStyle(QFrame::NoFrame);
|
m_contentFrame->setObjectName("UnframedGroupContent");
|
||||||
if (parentWidget())
|
|
||||||
{
|
|
||||||
m_contentFrame->setPalette(parentWidget()->palette());
|
|
||||||
}
|
}
|
||||||
m_contentFrame->setAttribute(Qt::WA_SetPalette, false);
|
|
||||||
}
|
|
||||||
QWidget::update();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
QSize QMinimizePanel::minimumSizeHint() const
|
|
||||||
{
|
|
||||||
return calculateSizeHint(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
QSize QMinimizePanel::sizeHint() const
|
|
||||||
{
|
|
||||||
return calculateSizeHint(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -236,85 +215,52 @@ void QMinimizePanel::toggleExpanded()
|
|||||||
setExpanded(m_contentFrame->isHidden());
|
setExpanded(m_contentFrame->isHidden());
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void QMinimizePanel::resizeEvent(QResizeEvent *resizeEv )
|
|
||||||
{
|
|
||||||
QWidget::updateGeometry();
|
|
||||||
|
|
||||||
int width = resizeEv->size().width();
|
|
||||||
int heigth = resizeEv->size().height();
|
|
||||||
int labelHeight = m_titleLabel->sizeHint().height();
|
|
||||||
|
|
||||||
int titleHeight = labelHeight + 8;
|
|
||||||
int buttonSize = titleHeight - 2;
|
|
||||||
|
|
||||||
int contentHeightOffset = 0;
|
|
||||||
if (!m_titleFrame->isHidden())
|
|
||||||
{
|
|
||||||
m_titleFrame->setGeometry(0, 0, width, titleHeight);
|
|
||||||
m_titleLabel->setGeometry(4, titleHeight - labelHeight - 4, width - 4 - buttonSize - 1, labelHeight);
|
|
||||||
m_collapseButton->setGeometry(width - buttonSize - 1, 1, buttonSize, buttonSize);
|
|
||||||
contentHeightOffset = titleHeight - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_contentFrame->setGeometry(0, contentHeightOffset, width, heigth - contentHeightOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
bool QMinimizePanel::event(QEvent* event)
|
|
||||||
{
|
|
||||||
if (event->type() == QEvent::LayoutRequest)
|
|
||||||
{
|
|
||||||
this->QWidget::updateGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->QWidget::event(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void QMinimizePanel::initialize(const QString &title)
|
void QMinimizePanel::initialize(const QString &title)
|
||||||
{
|
{
|
||||||
m_titleFrame = new QFrame(this);
|
this->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
|
||||||
m_titleFrame->setFrameStyle(QFrame::Box | QFrame::Plain);
|
QVBoxLayout* fullLayout = new QVBoxLayout(this);
|
||||||
m_titleFrame->setAutoFillBackground(true);
|
|
||||||
|
|
||||||
m_titleLabel = new QLabel(title, m_titleFrame);
|
fullLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
QPalette titleLabelPalette = m_titleLabel->palette();
|
fullLayout->setSpacing(0);
|
||||||
titleLabelPalette.setBrush(QPalette::Foreground, titleLabelPalette.windowText());
|
{ // Title
|
||||||
|
m_titleFrame = new QFrame();
|
||||||
|
fullLayout->addWidget(m_titleFrame, 0);
|
||||||
|
fullLayout->setStretch(0, 0);
|
||||||
|
m_titleFrame->setObjectName("GroupTitleFrame");
|
||||||
|
m_titleFrame->setStyleSheet(titleFrameStyleSheet());
|
||||||
|
|
||||||
|
QHBoxLayout* titleLayout = new QHBoxLayout();
|
||||||
|
titleLayout->setContentsMargins(4, 2, 0, 2);
|
||||||
|
m_titleFrame->setLayout(titleLayout);
|
||||||
|
|
||||||
{
|
{
|
||||||
QLinearGradient titleGrad(QPointF(0, 0), QPointF(0, 1));
|
m_titleLabel = new QLabel(title);
|
||||||
titleGrad.setCoordinateMode(QGradient::StretchToDeviceMode);
|
QPalette titleLabelPalette = m_titleLabel->palette();
|
||||||
titleGrad.setColorAt(0, QColor(255, 255, 255, 20));
|
titleLabelPalette.setBrush(QPalette::Foreground, titleLabelPalette.windowText());
|
||||||
titleGrad.setColorAt(1, QColor(0, 0, 0, 30));
|
|
||||||
|
|
||||||
QPalette titleFramePalette = m_titleFrame->palette();
|
|
||||||
titleFramePalette.setBrush(QPalette::Window, titleGrad);
|
|
||||||
titleFramePalette.setBrush(QPalette::Foreground, titleFramePalette.dark());
|
|
||||||
m_titleFrame->setPalette(titleFramePalette);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_titleLabel->setPalette(titleLabelPalette);
|
m_titleLabel->setPalette(titleLabelPalette);
|
||||||
|
titleLayout->addWidget(m_titleLabel, 1, Qt::AlignLeft);
|
||||||
m_collapseButton = new QPushButton(m_titleFrame);
|
}
|
||||||
|
{
|
||||||
|
m_collapseButton = new QPushButton();
|
||||||
m_collapseButton->setFlat(true);
|
m_collapseButton->setFlat(true);
|
||||||
m_collapseButton->setIcon(expandUpIcon());
|
m_collapseButton->setIcon(expandUpIcon());
|
||||||
m_collapseButton->setDefault(false);
|
m_collapseButton->setDefault(false);
|
||||||
m_collapseButton->setAutoDefault(false);
|
m_collapseButton->setAutoDefault(false);
|
||||||
|
m_collapseButton->setIconSize(QSize(16, 16));
|
||||||
m_contentFrame = new QFrame(this);
|
m_collapseButton->setMaximumSize(QSize(16, 16));
|
||||||
m_contentFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
|
titleLayout->addWidget(m_collapseButton, 0, Qt::AlignRight);
|
||||||
m_contentFrame->setAutoFillBackground(true);
|
}
|
||||||
|
}
|
||||||
m_contentPalette = m_contentFrame->palette();
|
{
|
||||||
m_contentPalette.setBrush(QPalette::Window, QColor(255, 250, 250, 85));
|
m_contentFrame = new QFrame();
|
||||||
m_contentFrame->setPalette(m_contentPalette);
|
m_contentFrame->setStyleSheet(contentFrameStyleSheet());
|
||||||
|
m_contentFrame->setObjectName("GroupContentFrame");
|
||||||
|
fullLayout->addWidget(m_contentFrame, 1);
|
||||||
|
fullLayout->setStretch(1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
connect(m_collapseButton, SIGNAL(clicked()), this, SLOT(toggleExpanded()));
|
connect(m_collapseButton, SIGNAL(clicked()), this, SLOT(toggleExpanded()));
|
||||||
}
|
}
|
||||||
@ -322,30 +268,31 @@ void QMinimizePanel::initialize(const QString &title)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QSize QMinimizePanel::calculateSizeHint(bool minimumSizeHint) const
|
QString QMinimizePanel::titleFrameStyleSheet()
|
||||||
{
|
{
|
||||||
QSize labelSize = m_titleLabel->sizeHint();
|
return QString("QFrame#GroupTitleFrame "
|
||||||
QSize titleBarHint = labelSize + QSize(4 + labelSize.height() + 8 - 2 + 1, 8);
|
"{"
|
||||||
if (!m_contentFrame->isHidden())
|
" border-top: none; border-left: none; border-right: none; border-bottom: none;"
|
||||||
{
|
" background: qlineargradient(spread:pad, x1:0 y1:0, x2:0 y2:1,"
|
||||||
int titleHeight = 0;
|
" stop:0 rgba(150, 150, 150, 20), stop:1 rgba(0, 0, 0, 50));"
|
||||||
if (!m_titleFrame->isHidden())
|
"}");
|
||||||
{
|
}
|
||||||
titleHeight = labelSize.height() + 8;
|
|
||||||
}
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
QSize titleBarMin(0, titleHeight);
|
//--------------------------------------------------------------------------------------------------
|
||||||
QSize contentsMin(minimumSizeHint ? m_contentFrame->minimumSizeHint() : m_contentFrame->sizeHint());
|
QString QMinimizePanel::contentFrameStyleSheet()
|
||||||
QSize total = contentsMin.expandedTo(titleBarMin);
|
{
|
||||||
total.rheight() += titleBarMin.height();
|
return QString
|
||||||
|
(
|
||||||
return total;
|
"QFrame#FramedGroupContent"
|
||||||
}
|
"{"
|
||||||
else
|
" border-top: 1px solid darkgray; border-left: none; border-right: none; border-bottom: none; "
|
||||||
{
|
" background: rgba(255, 250, 250, 85)"
|
||||||
// Retain width when collapsing the field
|
"}"
|
||||||
QSize contentsMin(minimumSizeHint ? m_contentFrame->minimumSizeHint() : m_contentFrame->sizeHint());
|
"QFrame#UnframedGroupContent"
|
||||||
titleBarHint.rwidth() = std::max(titleBarHint.width(), contentsMin.width());
|
"{"
|
||||||
return titleBarHint;
|
" border-top: none; border-left: none; border-right: none; border-bottom: none; "
|
||||||
}
|
"}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QFrame>
|
||||||
|
|
||||||
class QFrame;
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QPalette;
|
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
@ -48,7 +46,7 @@ class QPushButton;
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
class QMinimizePanel : public QWidget
|
class QMinimizePanel : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -61,9 +59,6 @@ public:
|
|||||||
QString title() const;
|
QString title() const;
|
||||||
void enableFrame(bool showFrame);
|
void enableFrame(bool showFrame);
|
||||||
|
|
||||||
QSize minimumSizeHint() const override;
|
|
||||||
QSize sizeHint() const override;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setExpanded(bool isExpanded);
|
void setExpanded(bool isExpanded);
|
||||||
void toggleExpanded();
|
void toggleExpanded();
|
||||||
@ -71,20 +66,18 @@ public slots:
|
|||||||
signals:
|
signals:
|
||||||
void expandedChanged(bool isExpanded);
|
void expandedChanged(bool isExpanded);
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
QFrame* m_titleFrame;
|
QFrame* m_titleFrame;
|
||||||
QLabel* m_titleLabel;
|
QLabel* m_titleLabel;
|
||||||
QPushButton* m_collapseButton;
|
QPushButton* m_collapseButton;
|
||||||
QFrame* m_contentFrame;
|
QFrame* m_contentFrame;
|
||||||
QPalette m_contentPalette;
|
|
||||||
|
|
||||||
void resizeEvent(QResizeEvent *) override;
|
|
||||||
bool event(QEvent* event) override; // To catch QEvent::LayoutRequest
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize(const QString &title);
|
void initialize(const QString &title);
|
||||||
|
|
||||||
|
QString titleFrameStyleSheet();
|
||||||
|
QString contentFrameStyleSheet();
|
||||||
QSize calculateSizeHint(bool minimumSizeHint) const;
|
QSize calculateSizeHint(bool minimumSizeHint) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -90,7 +90,7 @@ PdmUiDefaultObjectEditor::~PdmUiDefaultObjectEditor()
|
|||||||
QWidget* PdmUiDefaultObjectEditor::createWidget(QWidget* parent)
|
QWidget* PdmUiDefaultObjectEditor::createWidget(QWidget* parent)
|
||||||
{
|
{
|
||||||
QWidget* widget = new QWidget(parent);
|
QWidget* widget = new QWidget(parent);
|
||||||
|
widget->setObjectName("ObjectEditor");
|
||||||
QGridLayout* gridLayout = new QGridLayout();
|
QGridLayout* gridLayout = new QGridLayout();
|
||||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
widget->setLayout(gridLayout);
|
widget->setLayout(gridLayout);
|
||||||
|
@ -84,13 +84,15 @@ void caf::PdmUiFormLayoutObjectEditor::slotScrollToSelectedItemsInFieldEditors()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Add all widgets at a recursion level in the form.
|
||||||
|
/// Returns true if the level should get a row stretch at the level above.
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInGridLayoutColumn(
|
bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInGridLayoutColumn(
|
||||||
const PdmUiOrdering& uiOrdering,
|
const PdmUiOrdering& uiOrdering,
|
||||||
QWidget* containerWidgetWithGridLayout,
|
QWidget* containerWidgetWithGridLayout,
|
||||||
const QString& uiConfigName)
|
const QString& uiConfigName)
|
||||||
{
|
{
|
||||||
|
int maxRowStretch = 0;
|
||||||
CAF_ASSERT(containerWidgetWithGridLayout);
|
CAF_ASSERT(containerWidgetWithGridLayout);
|
||||||
|
|
||||||
QWidget* previousTabOrderWidget = nullptr;
|
QWidget* previousTabOrderWidget = nullptr;
|
||||||
@ -141,14 +143,17 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
|
|||||||
|
|
||||||
if (currentItem->isUiGroup())
|
if (currentItem->isUiGroup())
|
||||||
{
|
{
|
||||||
recursivelyAddGroupToGridLayout(currentItem,
|
bool stretchGroup = recursivelyAddGroupToGridLayout(currentItem,
|
||||||
containerWidgetWithGridLayout,
|
containerWidgetWithGridLayout,
|
||||||
uiConfigName,
|
uiConfigName,
|
||||||
parentLayout,
|
parentLayout,
|
||||||
currentRowIndex,
|
currentRowIndex,
|
||||||
currentColumn,
|
currentColumn,
|
||||||
itemColumnSpan);
|
itemColumnSpan);
|
||||||
|
int groupStretchFactor = stretchGroup ? 1 : 0;
|
||||||
|
parentLayout->setRowStretch(currentRowIndex, groupStretchFactor);
|
||||||
currentColumn += itemColumnSpan;
|
currentColumn += itemColumnSpan;
|
||||||
|
maxRowStretch = std::max(maxRowStretch, groupStretchFactor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -168,13 +173,15 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
|
|||||||
|
|
||||||
if (fieldCombinedWidget)
|
if (fieldCombinedWidget)
|
||||||
{
|
{
|
||||||
fieldCombinedWidget->setParent(containerWidgetWithGridLayout);
|
|
||||||
parentLayout->addWidget(fieldCombinedWidget, currentRowIndex, currentColumn, 1, itemColumnSpan);
|
parentLayout->addWidget(fieldCombinedWidget, currentRowIndex, currentColumn, 1, itemColumnSpan);
|
||||||
|
parentLayout->setRowStretch(currentRowIndex, fieldEditor->rowStretchFactor());
|
||||||
|
maxRowStretch = std::max(maxRowStretch, fieldEditor->rowStretchFactor());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QWidget* fieldEditorWidget = fieldEditor->editorWidget();
|
QWidget* fieldEditorWidget = fieldEditor->editorWidget();
|
||||||
if (!fieldEditorWidget) continue;
|
if (!fieldEditorWidget) continue;
|
||||||
|
|
||||||
int fieldColumnSpan = minimumFieldColumnSpan;
|
int fieldColumnSpan = minimumFieldColumnSpan;
|
||||||
|
|
||||||
QWidget* fieldLabelWidget = fieldEditor->labelWidget();
|
QWidget* fieldLabelWidget = fieldEditor->labelWidget();
|
||||||
@ -242,20 +249,25 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
|
|||||||
QWidget::setTabOrder(previousTabOrderWidget, fieldEditorWidget);
|
QWidget::setTabOrder(previousTabOrderWidget, fieldEditorWidget);
|
||||||
}
|
}
|
||||||
previousTabOrderWidget = fieldEditorWidget;
|
previousTabOrderWidget = fieldEditorWidget;
|
||||||
|
|
||||||
|
parentLayout->setRowStretch(currentRowIndex, fieldEditor->rowStretchFactor());
|
||||||
|
maxRowStretch = std::max(maxRowStretch, fieldEditor->rowStretchFactor());
|
||||||
}
|
}
|
||||||
fieldEditor->updateUi(uiConfigName);
|
fieldEditor->updateUi(uiConfigName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int stretchFactor = currentRowIndex == totalRows - 1 ? 1 : 0;
|
|
||||||
parentLayout->setRowStretch(currentRowIndex, stretchFactor);
|
CAF_ASSERT(currentColumn <= totalColumns);
|
||||||
}
|
}
|
||||||
|
// The magnitude of the stretch should not be sent up, only if there was stretch or not
|
||||||
|
return maxRowStretch > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Create a group and add widgets. Return true if the containing row needs to be stretched.
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void caf::PdmUiFormLayoutObjectEditor::recursivelyAddGroupToGridLayout(PdmUiItem* currentItem,
|
bool caf::PdmUiFormLayoutObjectEditor::recursivelyAddGroupToGridLayout(PdmUiItem* currentItem,
|
||||||
QWidget* containerWidgetWithGridLayout,
|
QWidget* containerWidgetWithGridLayout,
|
||||||
const QString& uiConfigName,
|
const QString& uiConfigName,
|
||||||
QGridLayout* parentLayout,
|
QGridLayout* parentLayout,
|
||||||
@ -267,10 +279,12 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyAddGroupToGridLayout(PdmUiItem
|
|||||||
|
|
||||||
QMinimizePanel* groupBox = findOrCreateGroupBox(containerWidgetWithGridLayout, group, uiConfigName);
|
QMinimizePanel* groupBox = findOrCreateGroupBox(containerWidgetWithGridLayout, group, uiConfigName);
|
||||||
|
|
||||||
|
bool stretch = recursivelyConfigureAndUpdateUiOrderingInGridLayoutColumn(*group, groupBox->contentFrame(), uiConfigName);
|
||||||
|
|
||||||
/// 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);
|
||||||
|
|
||||||
recursivelyConfigureAndUpdateUiOrderingInGridLayoutColumn(*group, groupBox->contentFrame(), uiConfigName);
|
return stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -316,6 +330,7 @@ QMinimizePanel*
|
|||||||
groupBox->setTitle(group->uiName(uiConfigName));
|
groupBox->setTitle(group->uiName(uiConfigName));
|
||||||
groupBox->setObjectName(group->keyword());
|
groupBox->setObjectName(group->keyword());
|
||||||
groupBoxLayout = new QGridLayout();
|
groupBoxLayout = new QGridLayout();
|
||||||
|
|
||||||
if (!group->enableFrame())
|
if (!group->enableFrame())
|
||||||
{
|
{
|
||||||
groupBoxLayout->setContentsMargins(0, 0, 0, 0);
|
groupBoxLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
@ -344,7 +359,7 @@ QMinimizePanel*
|
|||||||
|
|
||||||
// Update the title to be able to support dynamic group names
|
// Update the title to be able to support dynamic group names
|
||||||
groupBox->setTitle(group->uiName(uiConfigName));
|
groupBox->setTitle(group->uiName(uiConfigName));
|
||||||
|
groupBox->updateGeometry();
|
||||||
return groupBox;
|
return groupBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,11 +75,11 @@ protected:
|
|||||||
virtual void recursivelyConfigureAndUpdateTopLevelUiOrdering(const PdmUiOrdering& topLevelUiOrdering,
|
virtual void recursivelyConfigureAndUpdateTopLevelUiOrdering(const PdmUiOrdering& topLevelUiOrdering,
|
||||||
const QString& uiConfigName) = 0;
|
const QString& uiConfigName) = 0;
|
||||||
|
|
||||||
void recursivelyConfigureAndUpdateUiOrderingInGridLayoutColumn(const PdmUiOrdering& uiOrdering,
|
bool recursivelyConfigureAndUpdateUiOrderingInGridLayoutColumn(const PdmUiOrdering& uiOrdering,
|
||||||
QWidget* containerWidgetWithGridLayout,
|
QWidget* containerWidgetWithGridLayout,
|
||||||
const QString& uiConfigName);
|
const QString& uiConfigName);
|
||||||
|
|
||||||
void recursivelyAddGroupToGridLayout(PdmUiItem* currentItem,
|
bool recursivelyAddGroupToGridLayout(PdmUiItem* currentItem,
|
||||||
QWidget* containerWidget,
|
QWidget* containerWidget,
|
||||||
const QString& uiConfigName,
|
const QString& uiConfigName,
|
||||||
QGridLayout* parentLayout,
|
QGridLayout* parentLayout,
|
||||||
|
@ -520,4 +520,12 @@ bool PdmUiListEditor::eventFilter(QObject* object, QEvent * event)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool PdmUiListEditor::isMultiRowEditor() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace caf
|
} // end namespace caf
|
||||||
|
@ -88,6 +88,7 @@ protected:
|
|||||||
QWidget* createLabelWidget(QWidget * parent) override;
|
QWidget* createLabelWidget(QWidget * parent) override;
|
||||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||||
bool eventFilter ( QObject * listView, QEvent * event ) override; // To catch delete key press in list view.
|
bool eventFilter ( QObject * listView, QEvent * event ) override; // To catch delete key press in list view.
|
||||||
|
bool isMultiRowEditor() const override;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void slotSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
|
void slotSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QResizeEvent>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -58,21 +59,6 @@ QVerticalScrollArea::QVerticalScrollArea(QWidget* parent) :
|
|||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
bool QVerticalScrollArea::eventFilter(QObject* object, QEvent* event)
|
|
||||||
{
|
|
||||||
// This works because QScrollArea::setWidget installs an eventFilter on the widget
|
|
||||||
if (object && object == widget() && event->type() == QEvent::Resize)
|
|
||||||
{
|
|
||||||
setMinimumWidth(widget()->minimumSizeHint().width() + verticalScrollBar()->width());
|
|
||||||
}
|
|
||||||
|
|
||||||
return QScrollArea::eventFilter(object, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -83,12 +69,12 @@ namespace caf
|
|||||||
PdmUiPropertyView::PdmUiPropertyView(QWidget* parent, Qt::WindowFlags f)
|
PdmUiPropertyView::PdmUiPropertyView(QWidget* parent, Qt::WindowFlags f)
|
||||||
: QWidget (parent, f)
|
: QWidget (parent, f)
|
||||||
{
|
{
|
||||||
QVerticalScrollArea* scrollArea = new QVerticalScrollArea(this);
|
m_scrollArea = new QVerticalScrollArea(this);
|
||||||
scrollArea->setFrameStyle(QFrame::NoFrame);
|
m_scrollArea->setFrameStyle(QFrame::NoFrame);
|
||||||
scrollArea->setWidgetResizable(true);
|
m_scrollArea->setWidgetResizable(true);
|
||||||
|
|
||||||
m_placeholder = new QWidget();
|
m_placeholder = new QWidget();
|
||||||
scrollArea->setWidget(m_placeholder);
|
m_scrollArea->setWidget(m_placeholder);
|
||||||
|
|
||||||
m_placeHolderLayout = new QVBoxLayout();
|
m_placeHolderLayout = new QVBoxLayout();
|
||||||
m_placeHolderLayout->setContentsMargins(5,5,5,0);
|
m_placeHolderLayout->setContentsMargins(5,5,5,0);
|
||||||
@ -96,7 +82,7 @@ PdmUiPropertyView::PdmUiPropertyView(QWidget* parent, Qt::WindowFlags f)
|
|||||||
|
|
||||||
QVBoxLayout* dummy = new QVBoxLayout(this);
|
QVBoxLayout* dummy = new QVBoxLayout(this);
|
||||||
dummy->setContentsMargins(0,0,0,0);
|
dummy->setContentsMargins(0,0,0,0);
|
||||||
dummy->addWidget(scrollArea);
|
dummy->addWidget(m_scrollArea);
|
||||||
|
|
||||||
m_defaultObjectEditor = nullptr;
|
m_defaultObjectEditor = nullptr;
|
||||||
}
|
}
|
||||||
@ -180,6 +166,10 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object)
|
|||||||
|
|
||||||
// Add stretch to make sure the property widget is not stretched
|
// Add stretch to make sure the property widget is not stretched
|
||||||
this->m_placeHolderLayout->insertStretch(-1, 1);
|
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);
|
m_defaultObjectEditor->setPdmObject(object);
|
||||||
|
@ -54,7 +54,6 @@ class QVerticalScrollArea : public QScrollArea
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit QVerticalScrollArea(QWidget* parent = nullptr);
|
explicit QVerticalScrollArea(QWidget* parent = nullptr);
|
||||||
bool eventFilter(QObject* object, QEvent* event) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -89,6 +88,7 @@ private:
|
|||||||
QString m_uiConfigName;
|
QString m_uiConfigName;
|
||||||
QPointer<QVBoxLayout> m_placeHolderLayout;
|
QPointer<QVBoxLayout> m_placeHolderLayout;
|
||||||
QPointer<QWidget> m_placeholder;
|
QPointer<QWidget> m_placeholder;
|
||||||
|
QPointer<QVerticalScrollArea> m_scrollArea;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace caf
|
} // End of namespace caf
|
||||||
|
@ -321,6 +321,13 @@ void PdmUiTableViewEditor::onSelectionManagerSelectionChanged( const std::set<in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool PdmUiTableViewEditor::isMultiRowEditor() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// NOTE: If no selection role is defined, the selection manager is not changed, the selection in the
|
/// NOTE: If no selection role is defined, the selection manager is not changed, the selection in the
|
||||||
|
@ -137,6 +137,7 @@ protected:
|
|||||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||||
|
|
||||||
void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override;
|
void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override;
|
||||||
|
bool isMultiRowEditor() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void selectedUiItems(const QModelIndexList& modelIndexList, std::vector<PdmUiItem*>& objects);
|
void selectedUiItems(const QModelIndexList& modelIndexList, std::vector<PdmUiItem*>& objects);
|
||||||
|
@ -155,6 +155,14 @@ void PdmUiTextEditor::configureAndUpdateUi(const QString& uiConfigName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool PdmUiTextEditor::isMultiRowEditor() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -124,6 +124,7 @@ protected:
|
|||||||
QWidget* createEditorWidget(QWidget * parent) override;
|
QWidget* createEditorWidget(QWidget * parent) override;
|
||||||
QWidget* createLabelWidget(QWidget * parent) override;
|
QWidget* createLabelWidget(QWidget * parent) override;
|
||||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||||
|
bool isMultiRowEditor() const override;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void slotSetValueToField();
|
void slotSetValueToField();
|
||||||
|
@ -427,6 +427,14 @@ QMargins PdmUiTreeSelectionEditor::calculateLabelContentMargins() const
|
|||||||
return contentMargins;
|
return contentMargins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool PdmUiTreeSelectionEditor::isMultiRowEditor() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -99,6 +99,7 @@ protected:
|
|||||||
QWidget* createEditorWidget(QWidget* parent) override;
|
QWidget* createEditorWidget(QWidget* parent) override;
|
||||||
QWidget* createLabelWidget(QWidget* parent) override;
|
QWidget* createLabelWidget(QWidget* parent) override;
|
||||||
QMargins calculateLabelContentMargins() const override;
|
QMargins calculateLabelContentMargins() const override;
|
||||||
|
bool isMultiRowEditor() const override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void customMenuRequested(const QPoint& pos);
|
void customMenuRequested(const QPoint& pos);
|
||||||
|
Loading…
Reference in New Issue
Block a user