From 97e52de521f39c0a638eb32bf3fbde2187156351 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Fri, 21 Aug 2009 23:45:25 +0200 Subject: [PATCH] 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. --- include/RecentResourceListModel.h | 2 ++ src/core/RecentResourceListModel.cpp | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/RecentResourceListModel.h b/include/RecentResourceListModel.h index 1d886c916..00cc1b639 100644 --- a/include/RecentResourceListModel.h +++ b/include/RecentResourceListModel.h @@ -50,6 +50,8 @@ public: return m_model; } + ResourceItem * item( const QModelIndex & _idx ); + protected: // compares items at two indices by date-property diff --git a/src/core/RecentResourceListModel.cpp b/src/core/RecentResourceListModel.cpp index c87095361..92cfd92ed 100644 --- a/src/core/RecentResourceListModel.cpp +++ b/src/core/RecentResourceListModel.cpp @@ -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();