Skip to content

Commit

Permalink
Handle item flags for action column
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 2, 2016
1 parent e57edc3 commit c5d00f0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/gui/attributetable/qgsattributetablefiltermodel.cpp
Expand Up @@ -468,3 +468,13 @@ QModelIndex QgsAttributeTableFilterModel::mapFromSource( const QModelIndex& sour

return index( proxyIndex.row(), mColumnMapping.indexOf( proxyIndex.column() ), proxyIndex.parent() );
}

Qt::ItemFlags QgsAttributeTableFilterModel::flags( const QModelIndex& index ) const
{
// Handle the action column flags here, the master model doesn't know it
if ( mColumnMapping.at( index.column() ) == -1 )
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;

QModelIndex source_index = mapToSource( index );
return masterModel()->flags( source_index );
}
2 changes: 2 additions & 0 deletions src/gui/attributetable/qgsattributetablefiltermodel.h
Expand Up @@ -167,6 +167,8 @@ class GUI_EXPORT QgsAttributeTableFilterModel: public QSortFilterProxyModel, pub

virtual QModelIndex mapFromSource( const QModelIndex& sourceIndex ) const override;

Qt::ItemFlags flags( const QModelIndex &index ) const override;

/**
* Sort by the given column using the given order.
* Prefetches all the data from the layer to speed up sorting.
Expand Down
2 changes: 2 additions & 0 deletions src/gui/attributetable/qgsfeatureselectionmodel.cpp
Expand Up @@ -59,6 +59,8 @@ void QgsFeatureSelectionModel::selectFeatures( const QItemSelection &selection,
{
QgsFeatureIds ids;

QgsDebugMsg( QString( "Index count: %1" ).arg( selection.indexes().size() ) );

Q_FOREACH ( const QModelIndex& index, selection.indexes() )
{
QgsFeatureId id = index.model()->data( index, QgsAttributeTableModel::FeatureIdRole ).toLongLong();
Expand Down

0 comments on commit c5d00f0

Please sign in to comment.