Skip to content

Commit

Permalink
[composer] Small fixes to attribute table column model
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 16, 2014
1 parent eb5627c commit bae196b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/core/composer/qgscomposerattributetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposerattributetablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit bae196b

Please sign in to comment.