From f03c650c499410902598708a953ab62b8a9dd173 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 14 Dec 2022 16:57:19 +0300 Subject: [PATCH] bos #32216 [CEA] GUI ergonomic: fix horizontal scrollbar position. --- src/Qtx/QtxTreeView.cxx | 16 ++++++++++++++++ src/Qtx/QtxTreeView.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/Qtx/QtxTreeView.cxx b/src/Qtx/QtxTreeView.cxx index b3bee2242..17e2dfab1 100644 --- a/src/Qtx/QtxTreeView.cxx +++ b/src/Qtx/QtxTreeView.cxx @@ -25,6 +25,7 @@ #include #include #include +#include /*! \class QtxTreeView::Header @@ -390,6 +391,21 @@ void QtxTreeView::setModel( QAbstractItemModel* m ) this, SLOT( onAppropriate( Qt::Orientation, int, int ) ) ); } +// This method fixes problem with Object Browser horizontal scrollbar automatic scrolling to the right +void QtxTreeView::scrollTo(const QModelIndex &index, + QAbstractItemView::ScrollHint hint) +{ + QScrollBar* aScrollBar = horizontalScrollBar(); + if (aScrollBar) { + int horPos = aScrollBar->value(); + QTreeView::scrollTo(index, hint); + aScrollBar->setValue(horPos); + } + else { + QTreeView::scrollTo(index, hint); + } +} + void QtxTreeView::onAppropriate( Qt::Orientation orient, int first, int last ) { if( orient==Qt::Horizontal ) diff --git a/src/Qtx/QtxTreeView.h b/src/Qtx/QtxTreeView.h index 7dee90869..88a6a5f04 100644 --- a/src/Qtx/QtxTreeView.h +++ b/src/Qtx/QtxTreeView.h @@ -55,6 +55,9 @@ public: virtual void setModel( QAbstractItemModel* ); + virtual void scrollTo(const QModelIndex &index, + QAbstractItemView::ScrollHint hint = QAbstractItemView::EnsureVisible); + protected slots: void onHeaderClicked( int ); void rowsAboutToBeRemoved( const QModelIndex&, int, int ); -- 2.39.2