Skip to content

Commit

Permalink
[Geometry checker] Introduce vertical-only scroll-areas
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Oct 23, 2017
1 parent aa27b66 commit e0caef9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/plugins/geometry_checker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_BINARY_DIR}/src/gui

${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
INCLUDE_DIRECTORIES(SYSTEM
${GEOS_INCLUDE_DIR}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,9 @@ void QgsGeometryCheckerResultTab::setDefaultResolutionMethods()

QVBoxLayout *layout = new QVBoxLayout( &dialog );

QgsScrollArea *scrollArea = new QgsScrollArea( &dialog );
scrollArea->setFrameShape( QFrame::NoFrame );
layout->setContentsMargins( 0, 0, 0, 0 );
QgsGeometryCheckerUtils::VScrollArea *scrollArea = new QgsGeometryCheckerUtils::VScrollArea( &dialog );
layout->addWidget( scrollArea );

QWidget *scrollAreaContents = new QWidget( scrollArea );
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/geometry_checker/ui/qgsgeometrycheckersetuptab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QgsScrollArea" name="scrollArea">
<widget class="QgsGeometryCheckerUtils::VScrollArea" name="scrollArea">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
Expand Down Expand Up @@ -800,9 +800,9 @@
</widget>
<customwidgets>
<customwidget>
<class>QgsScrollArea</class>
<class>QgsGeometryCheckerUtils::VScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<header>utils/qgsgeometrycheckerutils.h</header>
<container>1</container>
</customwidget>
</customwidgets>
Expand Down
22 changes: 22 additions & 0 deletions src/plugins/geometry_checker/utils/qgsgeometrycheckerutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,34 @@
#include "qgsvectorlayer.h"
#include "geometry/qgsabstractgeometry.h"
#include "geometry/qgspoint.h"
#include <qmath.h>
#include <QScrollArea>
#include <QScrollBar>

class QgsGeometryEngine;
class QgsFeaturePool;

namespace QgsGeometryCheckerUtils
{
class VScrollArea : public QScrollArea
{
public:
explicit VScrollArea( QWidget *parent = 0 )
: QScrollArea( parent )
{
setWidgetResizable( true );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
}
virtual bool eventFilter( QObject *o, QEvent *e )
{
// This works because QScrollArea::setWidget installs an eventFilter on the widget
if ( o && o == widget() && e->type() == QEvent::Resize )
setMinimumWidth( widget()->minimumSizeHint().width() + verticalScrollBar()->width() );
return QScrollArea::eventFilter( o, e );
}
};

class LayerFeature
{
public:
Expand Down

0 comments on commit e0caef9

Please sign in to comment.