Skip to content
Permalink
Browse files

Merge pull request #484 from matthias-kuhn/attribute-table-sort

Fix #7459: Sorting of attribute table takes type into account
  • Loading branch information
jef-n committed Mar 27, 2013
2 parents aa6d22a + f28f13c commit dd9bf7ef70b2680319d36b9539301d4fa84ff5d5
@@ -36,6 +36,7 @@ QgsAttributeTableFilterModel::QgsAttributeTableFilterModel( QgsMapCanvas* canvas
mMasterSelection = new QItemSelectionModel( this, this );
setSourceModel( sourceModel );
setDynamicSortFilter( true );
setSortRole( QgsAttributeTableModel::SortRole );
connect( layer(), SIGNAL( selectionChanged() ), SLOT( selectionChanged() ) );
}

@@ -422,7 +422,7 @@ QVariant QgsAttributeTableModel::headerData( int section, Qt::Orientation orient

QVariant QgsAttributeTableModel::data( const QModelIndex &index, int role ) const
{
if ( !index.isValid() || ( role != Qt::TextAlignmentRole && role != Qt::DisplayRole && role != Qt::EditRole ) )
if ( !index.isValid() || ( role != Qt::TextAlignmentRole && role != Qt::DisplayRole && role != Qt::EditRole && role != SortRole ) )
return QVariant();

QgsFeatureId rowId = rowToId( index.row() );
@@ -483,6 +483,11 @@ QVariant QgsAttributeTableModel::data( const QModelIndex &index, int role ) cons
}
}

if ( role == SortRole )
{
return val;
}

return field.displayString( val );
}

@@ -42,6 +42,12 @@ class GUI_EXPORT QgsAttributeTableModel: public QAbstractTableModel
{
Q_OBJECT

public:
enum Role
{
SortRole = Qt::UserRole + 1
};

public:
/**
* Constructor

0 comments on commit dd9bf7e

Please sign in to comment.
You can’t perform that action at this time.