Skip to content
Permalink
Browse files
[composer] Small fixes to attribute table column model
  • Loading branch information
nyalldawson committed May 16, 2014
1 parent eb5627c commit bae196ba7dd59edd8b9520f1c584b2726765922b
Showing with 20 additions and 3 deletions.
  1. +19 −3 src/core/composer/qgscomposerattributetablemodel.cpp
  2. +1 −0 src/core/composer/qgscomposerattributetablemodel.h
@@ -37,18 +37,34 @@ QgsComposerAttributeTableColumnModel::~QgsComposerAttributeTableColumnModel()
QModelIndex QgsComposerAttributeTableColumnModel::index( int row, int column, const QModelIndex &parent ) const
{
Q_UNUSED( parent );
if ( row < 0 || row >= mComposerTable->columns()->length() )
if ( row < 0 || row >= rowCount()
|| column < 0 || column >= columnCount() )
{
//invalid row
return QModelIndex();
}

return createIndex( row, column, ( *mComposerTable->columns() )[row] );
if ( hasIndex( row, column, parent ) )
{
if (( *mComposerTable->columns() )[row] )
{
return createIndex( row, column, ( *mComposerTable->columns() )[row] );
}
}
return QModelIndex();
}

QModelIndex QgsComposerAttributeTableColumnModel::parent( const QModelIndex &child ) const
{
Q_UNUSED( child );
return QModelIndex();
}

int QgsComposerAttributeTableColumnModel::rowCount( const QModelIndex &parent ) const
{
Q_UNUSED( parent );
if ( parent.isValid() )
return 0;

return mComposerTable->columns()->length();
}

@@ -57,6 +57,7 @@ class CORE_EXPORT QgsComposerAttributeTableColumnModel: public QAbstractTableMod
bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );
bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() );
QModelIndex index( int row, int column, const QModelIndex &parent ) const;
QModelIndex parent( const QModelIndex &child ) const;

/**Moves the specified row up or down in the model. Used for rearranging the attribute tables
* columns.

0 comments on commit bae196b

Please sign in to comment.