diff --git a/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp index 78d3c1eec8..43cc7ab083 100644 --- a/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp @@ -421,8 +421,6 @@ void RiuPlotMainWindow::createDockPanels() m_pdmUiPropertyView = new caf::PdmUiPropertyView(dockWidget); dockWidget->setWidget(m_pdmUiPropertyView); - m_pdmUiPropertyView->layout()->setContentsMargins(5, 0, 0, 0); - addDockWidget(Qt::LeftDockWidgetArea, dockWidget); } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.cpp index 6aae177baf..f994daf052 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.cpp @@ -122,6 +122,14 @@ QMargins PdmUiFieldEditorHandle::labelContentMargins() const return calculateLabelContentMargins(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int PdmUiFieldEditorHandle::rowStretchFactor() const +{ + return isMultiRowEditor() ? 1 : 0; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -165,6 +173,14 @@ QMargins PdmUiFieldEditorHandle::calculateLabelContentMargins() const return m_labelWidget->contentsMargins(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiFieldEditorHandle::isMultiRowEditor() const +{ + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h index b2c220f794..b42af7eeca 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h @@ -98,7 +98,7 @@ public: QWidget* editorWidget() { return m_editorWidget; } QWidget* labelWidget() { return m_labelWidget; } QMargins labelContentMargins() const; - + int rowStretchFactor() const; 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 /// 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; virtual QMargins calculateLabelContentMargins() const; + virtual bool isMultiRowEditor() const; private slots: void customMenuRequested(QPoint pos); diff --git a/Fwk/AppFwk/cafUserInterface/QMinimizePanel.cpp b/Fwk/AppFwk/cafUserInterface/QMinimizePanel.cpp index ca69397c82..bf3855a614 100644 --- a/Fwk/AppFwk/cafUserInterface/QMinimizePanel.cpp +++ b/Fwk/AppFwk/cafUserInterface/QMinimizePanel.cpp @@ -39,6 +39,7 @@ #include "QMinimizePanel.h" #include +#include #include #include #include @@ -123,7 +124,7 @@ static const QIcon& expandUpIcon() /// //-------------------------------------------------------------------------------------------------- QMinimizePanel::QMinimizePanel(QWidget* parent/*=0*/) - : QWidget(parent) + : QFrame(parent) { this->initialize(""); } @@ -132,7 +133,7 @@ QMinimizePanel::QMinimizePanel(QWidget* parent/*=0*/) /// //-------------------------------------------------------------------------------------------------- QMinimizePanel::QMinimizePanel(const QString &title, QWidget* parent/*=0*/) - : QWidget(parent) + : QFrame(parent) { this->initialize(title); } @@ -176,42 +177,20 @@ void QMinimizePanel::enableFrame(bool showFrame) { if (showFrame) { + this->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); m_titleFrame->show(); m_titleLabel->show(); m_collapseButton->show(); - m_contentFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); - m_contentFrame->setPalette(m_contentPalette); - m_contentFrame->setAttribute(Qt::WA_SetPalette, true); + m_contentFrame->setObjectName("FramedGroupContent"); } else { + this->setFrameStyle(QFrame::NoFrame); m_titleFrame->hide(); m_titleLabel->hide(); m_collapseButton->hide(); - m_contentFrame->setFrameStyle(QFrame::NoFrame); - if (parentWidget()) - { - m_contentFrame->setPalette(parentWidget()->palette()); - } - m_contentFrame->setAttribute(Qt::WA_SetPalette, false); + m_contentFrame->setObjectName("UnframedGroupContent"); } - 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()); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -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) { - m_titleFrame = new QFrame(this); - m_titleFrame->setFrameStyle(QFrame::Box | QFrame::Plain); - m_titleFrame->setAutoFillBackground(true); + this->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + QVBoxLayout* fullLayout = new QVBoxLayout(this); - m_titleLabel = new QLabel(title, m_titleFrame); - QPalette titleLabelPalette = m_titleLabel->palette(); - titleLabelPalette.setBrush(QPalette::Foreground, titleLabelPalette.windowText()); + fullLayout->setContentsMargins(0, 0, 0, 0); + fullLayout->setSpacing(0); + { // Title + m_titleFrame = new QFrame(); + fullLayout->addWidget(m_titleFrame, 0); + fullLayout->setStretch(0, 0); + m_titleFrame->setObjectName("GroupTitleFrame"); + m_titleFrame->setStyleSheet(titleFrameStyleSheet()); - { - QLinearGradient titleGrad(QPointF(0, 0), QPointF(0, 1)); - titleGrad.setCoordinateMode(QGradient::StretchToDeviceMode); - titleGrad.setColorAt(0, QColor(255, 255, 255, 20)); - titleGrad.setColorAt(1, QColor(0, 0, 0, 30)); + QHBoxLayout* titleLayout = new QHBoxLayout(); + titleLayout->setContentsMargins(4, 2, 0, 2); + m_titleFrame->setLayout(titleLayout); - QPalette titleFramePalette = m_titleFrame->palette(); - titleFramePalette.setBrush(QPalette::Window, titleGrad); - titleFramePalette.setBrush(QPalette::Foreground, titleFramePalette.dark()); - m_titleFrame->setPalette(titleFramePalette); + { + m_titleLabel = new QLabel(title); + QPalette titleLabelPalette = m_titleLabel->palette(); + titleLabelPalette.setBrush(QPalette::Foreground, titleLabelPalette.windowText()); + m_titleLabel->setPalette(titleLabelPalette); + titleLayout->addWidget(m_titleLabel, 1, Qt::AlignLeft); + } + { + m_collapseButton = new QPushButton(); + m_collapseButton->setFlat(true); + m_collapseButton->setIcon(expandUpIcon()); + m_collapseButton->setDefault(false); + m_collapseButton->setAutoDefault(false); + m_collapseButton->setIconSize(QSize(16, 16)); + m_collapseButton->setMaximumSize(QSize(16, 16)); + titleLayout->addWidget(m_collapseButton, 0, Qt::AlignRight); + } + } + { + m_contentFrame = new QFrame(); + m_contentFrame->setStyleSheet(contentFrameStyleSheet()); + m_contentFrame->setObjectName("GroupContentFrame"); + fullLayout->addWidget(m_contentFrame, 1); + fullLayout->setStretch(1, 1); } - - m_titleLabel->setPalette(titleLabelPalette); - - m_collapseButton = new QPushButton(m_titleFrame); - m_collapseButton->setFlat(true); - m_collapseButton->setIcon(expandUpIcon()); - m_collapseButton->setDefault(false); - m_collapseButton->setAutoDefault(false); - - m_contentFrame = new QFrame(this); - m_contentFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); - m_contentFrame->setAutoFillBackground(true); - - m_contentPalette = m_contentFrame->palette(); - m_contentPalette.setBrush(QPalette::Window, QColor(255, 250, 250, 85)); - m_contentFrame->setPalette(m_contentPalette); 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(); - QSize titleBarHint = labelSize + QSize(4 + labelSize.height() + 8 - 2 + 1, 8); - if (!m_contentFrame->isHidden()) - { - int titleHeight = 0; - if (!m_titleFrame->isHidden()) - { - titleHeight = labelSize.height() + 8; - } - - QSize titleBarMin(0, titleHeight); - QSize contentsMin(minimumSizeHint ? m_contentFrame->minimumSizeHint() : m_contentFrame->sizeHint()); - QSize total = contentsMin.expandedTo(titleBarMin); - total.rheight() += titleBarMin.height(); - - return total; - } - else - { - // Retain width when collapsing the field - QSize contentsMin(minimumSizeHint ? m_contentFrame->minimumSizeHint() : m_contentFrame->sizeHint()); - titleBarHint.rwidth() = std::max(titleBarHint.width(), contentsMin.width()); - return titleBarHint; - } + return QString("QFrame#GroupTitleFrame " + "{" + " border-top: none; border-left: none; border-right: none; border-bottom: none;" + " background: qlineargradient(spread:pad, x1:0 y1:0, x2:0 y2:1," + " stop:0 rgba(150, 150, 150, 20), stop:1 rgba(0, 0, 0, 50));" + "}"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString QMinimizePanel::contentFrameStyleSheet() +{ + return QString + ( + "QFrame#FramedGroupContent" + "{" + " border-top: 1px solid darkgray; border-left: none; border-right: none; border-bottom: none; " + " background: rgba(255, 250, 250, 85)" + "}" + "QFrame#UnframedGroupContent" + "{" + " border-top: none; border-left: none; border-right: none; border-bottom: none; " + "}" + ); } diff --git a/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h b/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h index 697e9b9008..65456b760f 100644 --- a/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h +++ b/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h @@ -36,11 +36,9 @@ #pragma once -#include +#include -class QFrame; class QLabel; -class QPalette; class QPushButton; //================================================================================================== @@ -48,7 +46,7 @@ class QPushButton; // // //================================================================================================== -class QMinimizePanel : public QWidget +class QMinimizePanel : public QFrame { Q_OBJECT public: @@ -61,9 +59,6 @@ public: QString title() const; void enableFrame(bool showFrame); - QSize minimumSizeHint() const override; - QSize sizeHint() const override; - public slots: void setExpanded(bool isExpanded); void toggleExpanded(); @@ -71,20 +66,18 @@ public slots: signals: void expandedChanged(bool isExpanded); -public: - protected: QFrame* m_titleFrame; QLabel* m_titleLabel; QPushButton* m_collapseButton; QFrame* m_contentFrame; - QPalette m_contentPalette; - - void resizeEvent(QResizeEvent *) override; - bool event(QEvent* event) override; // To catch QEvent::LayoutRequest private: void initialize(const QString &title); + + QString titleFrameStyleSheet(); + QString contentFrameStyleSheet(); QSize calculateSizeHint(bool minimumSizeHint) const; + }; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp index 620856af61..cc6b88a52e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp @@ -90,7 +90,7 @@ PdmUiDefaultObjectEditor::~PdmUiDefaultObjectEditor() 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); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp index 8522db61e6..6f8ad34030 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp @@ -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, QWidget* containerWidgetWithGridLayout, const QString& uiConfigName) { + int maxRowStretch = 0; CAF_ASSERT(containerWidgetWithGridLayout); QWidget* previousTabOrderWidget = nullptr; @@ -141,14 +143,17 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn if (currentItem->isUiGroup()) { - recursivelyAddGroupToGridLayout(currentItem, - containerWidgetWithGridLayout, - uiConfigName, - parentLayout, - currentRowIndex, - currentColumn, - itemColumnSpan); + bool stretchGroup = recursivelyAddGroupToGridLayout(currentItem, + containerWidgetWithGridLayout, + uiConfigName, + parentLayout, + currentRowIndex, + currentColumn, + itemColumnSpan); + int groupStretchFactor = stretchGroup ? 1 : 0; + parentLayout->setRowStretch(currentRowIndex, groupStretchFactor); currentColumn += itemColumnSpan; + maxRowStretch = std::max(maxRowStretch, groupStretchFactor); } else { @@ -168,13 +173,15 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn 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 { QWidget* fieldEditorWidget = fieldEditor->editorWidget(); if (!fieldEditorWidget) continue; + int fieldColumnSpan = minimumFieldColumnSpan; QWidget* fieldLabelWidget = fieldEditor->labelWidget(); @@ -242,20 +249,25 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn QWidget::setTabOrder(previousTabOrderWidget, fieldEditorWidget); } previousTabOrderWidget = fieldEditorWidget; + + parentLayout->setRowStretch(currentRowIndex, fieldEditor->rowStretchFactor()); + maxRowStretch = std::max(maxRowStretch, fieldEditor->rowStretchFactor()); } 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, const QString& uiConfigName, QGridLayout* parentLayout, @@ -267,10 +279,12 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyAddGroupToGridLayout(PdmUiItem 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 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->setObjectName(group->keyword()); groupBoxLayout = new QGridLayout(); + if (!group->enableFrame()) { groupBoxLayout->setContentsMargins(0, 0, 0, 0); @@ -344,7 +359,7 @@ QMinimizePanel* // Update the title to be able to support dynamic group names groupBox->setTitle(group->uiName(uiConfigName)); - + groupBox->updateGeometry(); return groupBox; } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h index 48cf8bdda1..df46e17d91 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h @@ -75,11 +75,11 @@ protected: virtual void recursivelyConfigureAndUpdateTopLevelUiOrdering(const PdmUiOrdering& topLevelUiOrdering, const QString& uiConfigName) = 0; - void recursivelyConfigureAndUpdateUiOrderingInGridLayoutColumn(const PdmUiOrdering& uiOrdering, + bool recursivelyConfigureAndUpdateUiOrderingInGridLayoutColumn(const PdmUiOrdering& uiOrdering, QWidget* containerWidgetWithGridLayout, const QString& uiConfigName); - void recursivelyAddGroupToGridLayout(PdmUiItem* currentItem, + bool recursivelyAddGroupToGridLayout(PdmUiItem* currentItem, QWidget* containerWidget, const QString& uiConfigName, QGridLayout* parentLayout, diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp index 6ff4d93fea..e1d92aeb70 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp @@ -520,4 +520,12 @@ bool PdmUiListEditor::eventFilter(QObject* object, QEvent * event) return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiListEditor::isMultiRowEditor() const +{ + return true; +} + } // end namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.h index 45586151c1..c1cdce5774 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.h @@ -88,6 +88,7 @@ protected: QWidget* createLabelWidget(QWidget * parent) override; void configureAndUpdateUi(const QString& uiConfigName) override; bool eventFilter ( QObject * listView, QEvent * event ) override; // To catch delete key press in list view. + bool isMultiRowEditor() const override; protected slots: void slotSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected ); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp index b7ce27b4b6..c3b57ebf47 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -58,21 +59,6 @@ QVerticalScrollArea::QVerticalScrollArea(QWidget* parent) : 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 { @@ -83,12 +69,12 @@ namespace caf PdmUiPropertyView::PdmUiPropertyView(QWidget* parent, Qt::WindowFlags f) : QWidget (parent, f) { - QVerticalScrollArea* scrollArea = new QVerticalScrollArea(this); - scrollArea->setFrameStyle(QFrame::NoFrame); - scrollArea->setWidgetResizable(true); + m_scrollArea = new QVerticalScrollArea(this); + m_scrollArea->setFrameStyle(QFrame::NoFrame); + m_scrollArea->setWidgetResizable(true); m_placeholder = new QWidget(); - scrollArea->setWidget(m_placeholder); + m_scrollArea->setWidget(m_placeholder); m_placeHolderLayout = new QVBoxLayout(); m_placeHolderLayout->setContentsMargins(5,5,5,0); @@ -96,7 +82,7 @@ PdmUiPropertyView::PdmUiPropertyView(QWidget* parent, Qt::WindowFlags f) QVBoxLayout* dummy = new QVBoxLayout(this); dummy->setContentsMargins(0,0,0,0); - dummy->addWidget(scrollArea); + dummy->addWidget(m_scrollArea); m_defaultObjectEditor = nullptr; } @@ -180,6 +166,10 @@ 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); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h index f775574f51..c7f9128cac 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h @@ -54,7 +54,6 @@ class QVerticalScrollArea : public QScrollArea Q_OBJECT public: explicit QVerticalScrollArea(QWidget* parent = nullptr); - bool eventFilter(QObject* object, QEvent* event) override; }; @@ -85,10 +84,11 @@ public slots: void slotScheduleScrollToSelectedItemsInFieldEditors(); private: - PdmUiDefaultObjectEditor* m_defaultObjectEditor; - QString m_uiConfigName; - QPointer m_placeHolderLayout; - QPointer m_placeholder; + PdmUiDefaultObjectEditor* m_defaultObjectEditor; + QString m_uiConfigName; + QPointer m_placeHolderLayout; + QPointer m_placeholder; + QPointer m_scrollArea; }; } // End of namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp index 7f5832924d..0c1e327aab 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp @@ -321,6 +321,13 @@ void PdmUiTableViewEditor::onSelectionManagerSelectionChanged( const std::set& changedSelectionLevels ) override; + bool isMultiRowEditor() const override; private: void selectedUiItems(const QModelIndexList& modelIndexList, std::vector& objects); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp index 785bdb2837..97179e45fd 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.cpp @@ -155,6 +155,14 @@ void PdmUiTextEditor::configureAndUpdateUi(const QString& uiConfigName) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiTextEditor::isMultiRowEditor() const +{ + return true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h index 5b0efa0279..ef8f81f848 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h @@ -124,6 +124,7 @@ protected: QWidget* createEditorWidget(QWidget * parent) override; QWidget* createLabelWidget(QWidget * parent) override; void configureAndUpdateUi(const QString& uiConfigName) override; + bool isMultiRowEditor() const override; protected slots: void slotSetValueToField(); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp index 01e6d18d32..a227c04153 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp @@ -427,6 +427,14 @@ QMargins PdmUiTreeSelectionEditor::calculateLabelContentMargins() const return contentMargins; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiTreeSelectionEditor::isMultiRowEditor() const +{ + return true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h index 8d53f83ed6..df47d17cf6 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.h @@ -99,6 +99,7 @@ protected: QWidget* createEditorWidget(QWidget* parent) override; QWidget* createLabelWidget(QWidget* parent) override; QMargins calculateLabelContentMargins() const override; + bool isMultiRowEditor() const override; private slots: void customMenuRequested(const QPoint& pos);