-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <QHeaderView>
#include <QMenu>
#include <QMouseEvent>
+#include <QScrollBar>
/*!
\class QtxTreeView::Header
QVariant appropriate = model()->headerData( i, orientation(), Qtx::AppropriateRole );
QIcon icon;
if ( iconData.isValid() ) {
- if ( qVariantCanConvert<QIcon>( iconData ) )
- icon = qVariantValue<QIcon>( iconData );
- else if ( qVariantCanConvert<QPixmap>( iconData ) )
- icon = qVariantValue<QPixmap>( iconData );
+ if ( iconData.canConvert( QMetaType::QIcon ) )
+ icon = iconData.value<QIcon>();
+ else if ( iconData.canConvert( QMetaType::QPixmap ) )
+ icon = iconData.value<QPixmap>();
}
if( ( !lab.isEmpty() || !icon.isNull() ) &&
appropriate.isValid() ? appropriate.toInt()==Qtx::Toggled : true )
}
else if ( a && a == sortAction ) {
setSortIndicatorShown( a->isChecked() );
- setClickable( a->isChecked() );
+ setSectionsClickable( a->isChecked() );
QtxTreeView* view = qobject_cast<QtxTreeView*>( parent() );
if ( view ) {
view->emitSortingEnabled( a->isChecked() );
: QTreeView( parent )
{
setHeader( new Header( false, this ) );
- header()->setMovable( true );
+ header()->setSectionsMovable( true );
}
/*!
: QTreeView( parent )
{
setHeader( new Header( enableSortMenu, this ) );
- header()->setMovable( true );
+ header()->setSectionsMovable( true );
}
/*!
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 )