X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FQtx%2FQtxTreeView.cxx;h=e9c9f2409d7c04f853289d3ad5a574ff913cf94e;hb=b6e35aa42d3c67a529d7f9339718dfaed6891323;hp=4da1f00adff15d29e71346bf315682e3c7d97fd2;hpb=91cc8846bfa36302f7ade6cb8aa380f03e90423e;p=modules%2Fgui.git diff --git a/src/Qtx/QtxTreeView.cxx b/src/Qtx/QtxTreeView.cxx index 4da1f00ad..e9c9f2409 100644 --- a/src/Qtx/QtxTreeView.cxx +++ b/src/Qtx/QtxTreeView.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,7 @@ #include #include #include +#include /*! \class QtxTreeView::Header @@ -107,17 +108,10 @@ void QtxTreeView::Header::contextMenuEvent( QContextMenuEvent* e ) QVariant appropriate = model()->headerData( i, orientation(), Qtx::AppropriateRole ); QIcon icon; if ( iconData.isValid() ) { -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - if ( iconData.canConvert( QVariant::Icon ) ) - icon = iconData.value(); - else if ( iconData.canConvert( QVariant::Pixmap ) ) - icon = iconData.value(); -#else if ( iconData.canConvert( QMetaType::QIcon ) ) icon = iconData.value(); else if ( iconData.canConvert( QMetaType::QPixmap ) ) icon = iconData.value(); -#endif } if( ( !lab.isEmpty() || !icon.isNull() ) && appropriate.isValid() ? appropriate.toInt()==Qtx::Toggled : true ) @@ -143,11 +137,7 @@ void QtxTreeView::Header::contextMenuEvent( QContextMenuEvent* e ) } else if ( a && a == sortAction ) { setSortIndicatorShown( a->isChecked() ); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - setClickable( a->isChecked() ); -#else setSectionsClickable( a->isChecked() ); -#endif QtxTreeView* view = qobject_cast( parent() ); if ( view ) { view->emitSortingEnabled( a->isChecked() ); @@ -192,11 +182,7 @@ QtxTreeView::QtxTreeView( QWidget* parent ) : QTreeView( parent ) { setHeader( new Header( false, this ) ); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - header()->setMovable( true ); -#else header()->setSectionsMovable( true ); -#endif } /*! @@ -208,11 +194,7 @@ QtxTreeView::QtxTreeView( const bool enableSortMenu, QWidget* parent ) : QTreeView( parent ) { setHeader( new Header( enableSortMenu, this ) ); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - header()->setMovable( true ); -#else header()->setSectionsMovable( true ); -#endif } /*! @@ -409,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 )