Skip to content

Commit 8653bb4

Browse files
committed
Merge pull request #2493 from SebDieBln/AttrTableHideSortIndicator
Hide the sort indicator in the attribute table until first sort (fixes #6705)
2 parents 7d600bd + caab4c1 commit 8653bb4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/gui/attributetable/qgsattributetableview.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ QgsAttributeTableView::QgsAttributeTableView( QWidget *parent )
5353

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

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

6061
connect( verticalHeader(), SIGNAL( sectionPressed( int ) ), this, SLOT( selectRow( int ) ) );
6162
connect( verticalHeader(), SIGNAL( sectionEntered( int ) ), this, SLOT( _q_selectRow( int ) ) );
63+
connect( horizontalHeader(), SIGNAL( sortIndicatorChanged( int, Qt::SortOrder ) ), this, SLOT( showHorizontalSortIndicator() ) );
6264
}
6365

6466
QgsAttributeTableView::~QgsAttributeTableView()
@@ -282,3 +284,8 @@ void QgsAttributeTableView::selectRow( int row, bool anchor )
282284
mFeatureSelectionModel->selectFeatures( QItemSelection( tl, br ), command );
283285
}
284286
}
287+
288+
void QgsAttributeTableView::showHorizontalSortIndicator()
289+
{
290+
horizontalHeader()->setSortIndicatorShown( true );
291+
}

src/gui/attributetable/qgsattributetableview.h

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class GUI_EXPORT QgsAttributeTableView : public QTableView
139139

140140
private slots:
141141
void modelDeleted();
142+
void showHorizontalSortIndicator();
142143

143144
private:
144145
void selectRow( int row, bool anchor );

0 commit comments

Comments
 (0)