RecentResourceListModel: added item(QModelIndex) method

Added an item(QModelIndex) method to RecentResourceListModel which
maps given QModelIndex to source model and returns the according
ResourceItem from the source model.
This commit is contained in:
Tobias Doerffel
2009-08-21 23:45:25 +02:00
parent 0404cc760f
commit 97e52de521
2 changed files with 12 additions and 1 deletions

View File

@@ -50,6 +50,8 @@ public:
return m_model;
}
ResourceItem * item( const QModelIndex & _idx );
protected:
// compares items at two indices by date-property

View File

@@ -39,7 +39,16 @@ RecentResourceListModel::RecentResourceListModel( ResourceDB * _db,
bool RecentResourceListModel::lessThan ( const QModelIndex & _left,
ResourceItem * RecentResourceListModel::item( const QModelIndex & _idx )
{
return m_model->item( mapToSource( _idx ) );
}
bool RecentResourceListModel::lessThan( const QModelIndex & _left,
const QModelIndex & _right ) const
{
return m_model->item( _left )->lastMod() < m_model->item( _right )->lastMod();