Apply SelectionFilter in Partition{Labels,Bars}View.

This commit is contained in:
Teo Mrnjavac 2016-01-15 16:55:23 +01:00
parent f7f19eb617
commit ddf4878ec7
4 changed files with 31 additions and 2 deletions

View file

@ -53,6 +53,7 @@ buildUnknownDisklabelTexts( Device* dev )
PartitionLabelsView::PartitionLabelsView( QWidget* parent )
: QAbstractItemView( parent )
, canBeSelected( []( const QModelIndex& ) { return true; } )
{
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
setFrameStyle( QFrame::NoFrame );
@ -523,7 +524,9 @@ PartitionLabelsView::isIndexHidden( const QModelIndex& index ) const
void
PartitionLabelsView::setSelection( const QRect& rect, QItemSelectionModel::SelectionFlags flags )
{
selectionModel()->select( indexAt( rect.topLeft() ), flags );
QModelIndex eventIndex = indexAt( rect.topLeft() );
if ( canBeSelected( eventIndex ) )
selectionModel()->select( eventIndex, flags );
}