Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't show scrollbars when embedding a feature form
  • Loading branch information
m-kuhn committed Jun 6, 2016
1 parent bad0d3e commit c61daf8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
16 changes: 12 additions & 4 deletions src/gui/attributetable/qgsdualview.cpp
Expand Up @@ -47,6 +47,7 @@ QgsDualView::QgsDualView( QWidget* parent )
, mLayerCache( nullptr )
, mProgressDlg( nullptr )
, mFeatureSelectionManager( nullptr )
, mAttributeEditorScrollArea( nullptr )
{
setupUi( this );

Expand Down Expand Up @@ -83,10 +84,17 @@ void QgsDualView::init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const Qg
mTableView->setModel( mFilterModel );
mFeatureList->setModel( mFeatureListModel );
mAttributeForm = new QgsAttributeForm( layer, QgsFeature(), mEditorContext );
if ( !mAttributeEditorScrollArea->layout() )
mAttributeEditorScrollArea->setLayout( new QGridLayout() );
mAttributeEditorScrollArea->layout()->addWidget( mAttributeForm );
mAttributeEditorScrollArea->setWidget( mAttributeForm );
if ( !context.parentContext() )
{
mAttributeEditorScrollArea = new QScrollArea();
mAttributeEditorScrollArea->setWidgetResizable( true );
mAttributeEditor->layout()->addWidget( mAttributeEditorScrollArea );
mAttributeEditorScrollArea->setWidget( mAttributeForm );
}
else
{
mAttributeEditor->layout()->addWidget( mAttributeForm );
}

mAttributeForm->hideButtonBox();

Expand Down
2 changes: 2 additions & 0 deletions src/gui/attributetable/qgsdualview.h
Expand Up @@ -31,6 +31,7 @@ class QgsAttributeForm;
class QgsFeatureRequest;
class QSignalMapper;
class QgsMapLayerAction;
class QScrollArea;

/**
* This widget is used to show the attributes of a set of features of a {@link QgsVectorLayer}.
Expand Down Expand Up @@ -333,6 +334,7 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas
QgsDistanceArea mDistanceArea;
QString mDisplayExpression;
QgsAttributeTableConfig mConfig;
QScrollArea* mAttributeEditorScrollArea;

friend class TestQgsDualView;
};
Expand Down
24 changes: 15 additions & 9 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -1137,15 +1137,21 @@ void QgsAttributeForm::init()
QGridLayout* gridLayout = new QGridLayout( formWidget );
formWidget->setLayout( gridLayout );

// put the form into a scroll area to nicely handle cases with lots of attributes

QScrollArea* scrollArea = new QScrollArea( this );
scrollArea->setWidget( formWidget );
scrollArea->setWidgetResizable( true );
scrollArea->setFrameShape( QFrame::NoFrame );
scrollArea->setFrameShadow( QFrame::Plain );
scrollArea->setFocusProxy( this );
layout->addWidget( scrollArea );
if ( mContext.formMode() != QgsAttributeEditorContext::Embed )
{
// put the form into a scroll area to nicely handle cases with lots of attributes
QScrollArea* scrollArea = new QScrollArea( this );
scrollArea->setWidget( formWidget );
scrollArea->setWidgetResizable( true );
scrollArea->setFrameShape( QFrame::NoFrame );
scrollArea->setFrameShadow( QFrame::Plain );
scrollArea->setFocusProxy( this );
layout->addWidget( scrollArea );
}
else
{
layout->addWidget( formWidget );
}

int row = 0;
Q_FOREACH ( const QgsField& field, mLayer->fields().toList() )
Expand Down
18 changes: 0 additions & 18 deletions src/ui/qgsdualviewbase.ui
Expand Up @@ -148,24 +148,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QScrollArea" name="mAttributeEditorScrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="mAttributeEditorLayout">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>229</width>
<height>503</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4"/>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
Expand Down

3 comments on commit c61daf8

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-kuhn what's the rationale behind this change? Having it in a scroll area worked nicely for the new search mode

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-kuhn I think it's also caused a regression with long forms in the identify results pop ups in that the form now can be taller than the screen

@m-kuhn
Copy link
Member Author

@m-kuhn m-kuhn commented on c61daf8 Jun 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that the scrollbar should always be on the topmost widget and not having many embedded scrollbars.
E.g. relation editors were always the same size with scrollbars and often too small.

Please sign in to comment.