17 #include <QMouseEvent>
25 : QScrollArea( parent )
26 , mFilter( new ScrollAreaFilter( this, viewport() ) )
28 viewport()->installEventFilter( mFilter );
35 QScrollArea::wheelEvent( e );
40 if ( mVerticalOnly && widget() )
41 widget()->setFixedWidth( event->size().width() );
42 QScrollArea::resizeEvent( event );
47 mTimer.setSingleShot(
true );
53 return mTimer.isActive();
58 mVerticalOnly = verticalOnly;
60 setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
62 if ( mVerticalOnly && widget() )
63 widget()->setFixedWidth( size().width() );
68 ScrollAreaFilter::ScrollAreaFilter(
QgsScrollArea *parent, QWidget *viewPort )
70 , mScrollAreaWidget( parent )
71 , mViewPort( viewPort )
74 bool ScrollAreaFilter::eventFilter( QObject *obj, QEvent *event )
76 switch ( event->type() )
78 case QEvent::ChildAdded:
81 QChildEvent *ce =
static_cast<QChildEvent *
>( event );
82 addChild( ce->child() );
86 case QEvent::ChildRemoved:
88 QChildEvent *ce =
static_cast<QChildEvent *
>( event );
89 removeChild( ce->child() );
95 if ( obj == mViewPort )
98 mScrollAreaWidget->scrollOccurred();
102 if ( mScrollAreaWidget->hasScrolled() )
114 return QObject::eventFilter( obj, event );
117 void ScrollAreaFilter::addChild( QObject *child )
119 if ( child && child->isWidgetType() )
121 child->installEventFilter(
this );
124 const auto constChildren = child->children();
125 for ( QObject *
c : constChildren )
132 void ScrollAreaFilter::removeChild( QObject *child )
134 if ( child && child->isWidgetType() )
136 child->removeEventFilter(
this );
139 const auto constChildren = child->children();
140 for ( QObject *
c : constChildren )