Skip to content

Commit

Permalink
hide the sort indicator in the attribute table until first sort
Browse files Browse the repository at this point in the history
  • Loading branch information
SebDieBln committed Nov 22, 2015
1 parent 504c252 commit caab4c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/gui/attributetable/qgsattributetableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ QgsAttributeTableView::QgsAttributeTableView( QWidget *parent )

setSelectionBehavior( QAbstractItemView::SelectRows );
setSelectionMode( QAbstractItemView::ExtendedSelection );
setSortingEnabled( true );
setSortingEnabled( true ); // At this point no data is in the model yet, so actually nothing is sorted.
horizontalHeader()->setSortIndicatorShown( false ); // So hide the indicator to avoid confusion.

verticalHeader()->viewport()->installEventFilter( this );

connect( verticalHeader(), SIGNAL( sectionPressed( int ) ), this, SLOT( selectRow( int ) ) );
connect( verticalHeader(), SIGNAL( sectionEntered( int ) ), this, SLOT( _q_selectRow( int ) ) );
connect( horizontalHeader(), SIGNAL( sortIndicatorChanged( int, Qt::SortOrder ) ), this, SLOT( showHorizontalSortIndicator() ) );
}

QgsAttributeTableView::~QgsAttributeTableView()
Expand Down Expand Up @@ -282,3 +284,8 @@ void QgsAttributeTableView::selectRow( int row, bool anchor )
mFeatureSelectionModel->selectFeatures( QItemSelection( tl, br ), command );
}
}

void QgsAttributeTableView::showHorizontalSortIndicator()
{
horizontalHeader()->setSortIndicatorShown( true );
}
1 change: 1 addition & 0 deletions src/gui/attributetable/qgsattributetableview.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class GUI_EXPORT QgsAttributeTableView : public QTableView

private slots:
void modelDeleted();
void showHorizontalSortIndicator();

private:
void selectRow( int row, bool anchor );
Expand Down

0 comments on commit caab4c1

Please sign in to comment.