PartitionModel: Add getter for Partition

This commit is contained in:
Aurélien Gâteau 2014-06-30 15:03:45 +02:00
parent 4429a8fd63
commit 2000553a10
2 changed files with 13 additions and 0 deletions

View File

@ -82,3 +82,14 @@ PartitionModel::fillPartitionList( PartitionNode* parent )
fillPartitionList( partition );
}
}
Partition*
PartitionModel::partitionForIndex( const QModelIndex& index ) const
{
int row = index.row();
if ( row < 0 || row >= m_partitionList.count() )
{
return nullptr;
}
return m_partitionList.at( row );
}

View File

@ -33,6 +33,8 @@ public:
int rowCount( const QModelIndex& parent = QModelIndex() ) const Q_DECL_OVERRIDE;
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE;
Partition* partitionForIndex( const QModelIndex& index ) const;
private:
Device* m_device;
QList< Partition* > m_partitionList;